zhaojs
2023-07-07 55803b1a7b478aade9b6e59ca6675777375e2a92
uniapp/App.vue
@@ -13,7 +13,8 @@
      onLaunch: function() {
         // #ifdef APP-PLUS
         //推送开始
         /* var info = plus.push.getClientInfo()
         var info = plus.push.getClientInfo()
         console.log(info);
         // 获取当前设备的客户端id,传给后台,实现指定用户
         info && uni.setStorageSync('clientInfo', info)
         // 使用5+App的方式进行监听消息推送
@@ -64,7 +65,8 @@
               if (msg.type == "receive") {
                  //创建本地消息,发送的本地消息也会被receive方法接收到,但没有type属性,且aps是null  
                  plus.push.createMessage(msg.content, JSON.stringify(msg), {
                     title: messageTitle
                     title: messageTitle,
                     //icon:'/static/images/app/pushlogo.png'
                  });
               }
            } else { // Android
@@ -79,10 +81,11 @@
         //消息推送结束
         plus.push.addEventListener('click', res => {
            console.log(res);
         }); */
         });
         APPUpdate();
         // #endif
         this.getAppInfo()
         this.getAppInfo();
         //this.that.bcInit();
         let userInfo = uni.getStorageSync('userInfo')
         if (userInfo.id) {
            this.login(userInfo)
@@ -136,6 +139,9 @@
         canlisten: true,
         appinfo: {},
         ifwt: 0,
         hasinit:false,
         hasbcinit:false,
         isLaunch:false
         
      },
      onShow: function() {
@@ -148,7 +154,16 @@
                     content: '检测到网络权限可能设置为关闭,您可以在“设置”中检查无线数据及蜂窝移动网络'
                  })
               }else{
                  that.getAppInfo();
                  console.log("是否请求过:"+that.globalData.hasinit)
                  if(!that.globalData.hasinit)
                  {
                     that.getAppInfo();
                  }
                  if(!that.globalData.hasbcinit)
                  {
                     console.log("初始化百川插件")
                     that.bcInit();
                  }
                  /* let appInfo = utils.getCacheSync('appInfo')
                  if(appInfo == "" || appInfo == undefined){
                     console.log("获取方法")
@@ -162,7 +177,6 @@
            var route = routes[routes.length - 1].route
         }
         // #ifdef APP-PLUS
         console.log(this.globalData.canlisten)
         if (this.globalData.canlisten && route != 'pages/mine/tools/turnChain') {
            getClipboard()
         }
@@ -172,11 +186,36 @@
      onHide: function() {},
      methods: {
         ...mapMutations(['login']),
          bcInit:function()
         {
            var that = this;
            console.log(uni.getSystemInfoSync().platform);
            if (uni.getSystemInfoSync().platform == 'ios')
            {
               const plug = uni.requireNativePlugin('xiguazhu-baichuan');
               console.log(plug)
               plug.init({}, result => {
                  //console.log('1111111111111111111');
                  console.log(result);   // code等于0就是初始化成功
                  if(result.code==0)
                  {
                     that.globalData.hasbcinit=true;
                  }
               });
            }
            else{
               that.globalData.hasbcinit=true;
            }
         },
         getAppInfo: function() {
            var that = this;
            that.globalData.hasinit=true;
            this.$u.api.comminInt({}).then(e => {
               console.log(e)
               if (e.code != 0) return that.$alert(e.msg)
               if (e.code != 0)
               {
                  that.globalData.hasinit=false;
                  return that.$alert(e.msg)
               }
               that.globalData.appinfo = e.data.basic
               utils.setCache('appInfo', e.data.basic)
               utils.setCache('baseUrl', this.$u.http.config.baseUrl)
@@ -207,9 +246,10 @@
                  }
               }
               // #endif
            }).catch(function(err) {})
            }).catch(function(err) {that.globalData.hasinit=false;})
            
         },
          watch:function(method,istr){
                         var obj=this.globalData
                         console.log(obj)