一、apicloud 各种坑

一、窗口的打开

    function relogin()
    {
      var uid=$api.getStorage('userid');
      //alert(s);
      //console.log($api.getStorage('userid'));
      if(uid)
      {
        //  console.log(uid);
        //还有一个要注意的就是,你打开一个win不能立马关闭一个win
        //都是要延迟500
          setTimeout(function() { // 这里不知道 为什么必须放在setTimeout里面
                                  // 意思就是你 打开一个win的时候不能立马打开另外一个win
              api.openWin({
                            name : 'mais',
                            url : './main.html'
                        });
              api.toast({
                msg : '加载失败,请检查网络',
                duration : 500,
                location : 'bottom'
              });
            }, 500)
        }
    }

二、函数的加载
1、函数加载调用的callback(ret, err)
注意:不然 报错,即使不执行,也会检查报错

三、$api.getStorage(‘token’)); 中 setStorage 是有延迟的,如果上一行用setStorage 下一行就getStorage 就会报错

四、消息的监听

页面A在载入监听事件ConversationList()的时候,负责监听,跳转B页面的在重写监听方法的时候,回到页面A的监听事件则失效

    function ConversationList(){ //获取会话列表
      var rong = api.require('rongCloud2');
      // 之前调用 init 和 connect 的代码省略
      /* rong.getConversationListByCount(function(ret, err) {   //这个方法安卓无效
              console.log("count"+JSON.stringify(ret));
          })
      */
      rong.getConversationList(function(ret, err) {   
          //console.log("list"+JSON.stringify(ret));
          if(ret.status=='success')
          {
                initlist(ret.result);
          }
      })
      /*
       rong.clearConversations({
            conversationTypes: ['PRIVATE', 'GROUP']
        }, function(ret, err) {
            console.log(JSON.stringify( ret.status ));
        })
      /* */

    }

猜你喜欢

转载自blog.csdn.net/weixin_36792339/article/details/81119136