| | |
| | | // #ifdef APP-PLUS |
| | | //推送开始 |
| | | /* var info = plus.push.getClientInfo() |
| | | console.log(info); |
| | | // 获取当前设备的客户端id,传给后台,实现指定用户 |
| | | info && uni.setStorageSync('clientInfo', info) |
| | | info && uni.setStorageSync('clientInfo', info) */ |
| | | this.getPushCid(); |
| | | // 使用5+App的方式进行监听消息推送 |
| | | //消息点击事件 |
| | | //【APP在线】,收到透传消息通过,不会提醒至通知栏目,需要发送本地消息,再进行点击触发的点击事件。 |
| | |
| | | //收到透传消息 |
| | | //只有APP在线时,才会触发receive事件,透传消息不会触发系统消息,需要创建本地消息 |
| | | plus.push.addEventListener("receive", function(msg) { |
| | | console.log('receive', JSON.stringify(msg)) |
| | | //业务代码 |
| | | // IOS |
| | | if (uni.getSystemInfoSync().platform == 'ios') { |
| | |
| | | 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 |
| | |
| | | //消息推送结束 |
| | | 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) |
| | |
| | | userInfo: {}, |
| | | canlisten: true, |
| | | appinfo: {}, |
| | | ifwt: 0 |
| | | ifwt: 0, |
| | | hasinit:false, |
| | | hasbcinit:false, |
| | | isLaunch:false |
| | | |
| | | }, |
| | | onShow: function() { |
| | | var that = this; |
| | |
| | | content: '检测到网络权限可能设置为关闭,您可以在“设置”中检查无线数据及蜂窝移动网络' |
| | | }) |
| | | }else{ |
| | | let appInfo = utils.getCacheSync('appInfo') |
| | | if(appInfo == "" || appInfo == undefined){ |
| | | 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("获取方法") |
| | | that.getAppInfo(); |
| | | } */ |
| | | } |
| | | } |
| | | }) |
| | |
| | | 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() |
| | | } |
| | |
| | | onHide: function() {}, |
| | | methods: { |
| | | ...mapMutations(['login']), |
| | | bcInit:function() |
| | | { |
| | | var that = this; |
| | | if (uni.getSystemInfoSync().platform == 'ios') |
| | | { |
| | | const plug = uni.requireNativePlugin('xiguazhu-baichuan'); |
| | | plug.init({}, result => { |
| | | //console.log('1111111111111111111'); |
| | | console.log(result); // code等于0就是初始化成功 |
| | | if(result.code==0) |
| | | { |
| | | that.globalData.hasbcinit=true; |
| | | } |
| | | }); |
| | | } |
| | | else{ |
| | | that.globalData.hasbcinit=true; |
| | | } |
| | | }, |
| | | getPushCid:function() |
| | | { |
| | | // #ifdef APP-PLUS |
| | | var info = plus.push.getClientInfo() |
| | | if(info&&info.clientid!='null') |
| | | {// 获取当前设备的客户端id,传给后台,实现指定用户 |
| | | uni.setStorageSync('clientInfo', info); |
| | | this.updatePushCid(); |
| | | } |
| | | else{ |
| | | console.log('没有获取到'); |
| | | setTimeout(() => { |
| | | this.getPushCid(); |
| | | }, 1000) |
| | | } |
| | | // #endif |
| | | }, |
| | | updatePushCid:function() |
| | | { |
| | | let clientInfo = uni.getStorageSync('clientInfo'); |
| | | if(clientInfo&&clientInfo!='null'&&clientInfo.clientid) |
| | | { |
| | | console.log('开始更新'); |
| | | this.$u.api.updateCid({ |
| | | pushcid:clientInfo.clientid |
| | | }).then(e => { |
| | | }).catch(function (err) { |
| | | }) |
| | | } |
| | | else{ |
| | | this.getPushCid(); |
| | | } |
| | | |
| | | }, |
| | | getAppInfo: function() { |
| | | var that = this; |
| | | that.globalData.hasinit=true; |
| | | this.$u.api.comminInt({}).then(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) |
| | | // #ifdef APP-PLUS |
| | | if (plus.os.name == 'iOS') { |
| | | if (plus.os.name == 'iOS') { |
| | | if (that.globalData.appinfo.iosExamine && plus.runtime.version == e.data.basic.IosExamineV) { |
| | | that.globalData.ifwt = 0 |
| | | } else { |
| | |
| | | } |
| | | } |
| | | // #endif |
| | | }).catch(function(err) {}) |
| | | |
| | | }).catch(function(err) {that.globalData.hasinit=false;}) |
| | | |
| | | }, |
| | | |
| | | 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> |