zhaojs
2023-06-09 bef3a652349b7b79c914afcc013d7229706a2b3b
uniapp/App.vue
@@ -135,7 +135,10 @@
         userInfo: {},
         canlisten: true,
         appinfo: {},
         ifwt: 0
         ifwt: 0,
         hasinit:false,
         hasbcinit:false,
      },
      onShow: function() {
         var that = this;
@@ -147,10 +150,20 @@
                     content: '检测到网络权限可能设置为关闭,您可以在“设置”中检查无线数据及蜂窝移动网络'
                  })
               }else{
                  let appInfo = utils.getCacheSync('appInfo')
                  if(appInfo == "" || appInfo == undefined){
                  console.log("是否请求过:"+that.globalData.hasinit)
                  if(!that.globalData.hasinit)
                  {
                     that.getAppInfo();
                  }
                  if(!that.globalData.hasbcinit)
                  {
                     that.bcInit();
                  }
                  /* let appInfo = utils.getCacheSync('appInfo')
                  if(appInfo == "" || appInfo == undefined){
                     console.log("获取方法")
                     that.getAppInfo();
                  } */
               }
            }
         })
@@ -169,10 +182,29 @@
      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(result);   // code等于0就是初始化成功
                  if(result.code==0)
                  {
                     that.globalData.hasbcinit=true;
                  }
               });
            }
         },
         getAppInfo: function() {
            var that = this;
            this.$u.api.comminInt({}).then(e => {
               console.log(e)
               if (e.code != 0) return that.$alert(e.msg)
               that.globalData.hasinit=true;
               that.globalData.appinfo = e.data.basic
               utils.setCache('appInfo', e.data.basic)
               utils.setCache('baseUrl', this.$u.http.config.baseUrl)
@@ -206,6 +238,22 @@
            }).catch(function(err) {})
            
         },
          watch:function(method,istr){
                         var obj=this.globalData
                         console.log(obj)
                         Object.defineProperty(obj,istr,{
                         configurable:true,
                         enumerable:true,
                         set:function(value){
                             this._consumerGoodsStatus=value
                             method(value)
                         },
                         get:function(value){
                                     return this._consumerGoodsStatus
                                 }
                             })
                         },
      },
   }
</script>