From 5f5179811a778b6bd996ed64cae2a96f5ccc437f Mon Sep 17 00:00:00 2001 From: zhaojs <349234519@qq.com> Date: 星期四, 13 七月 2023 17:02:20 +0800 Subject: [PATCH] no message --- uniapp/App.vue | 141 ++++++++++++++++++++++++++++++++++------------- 1 files changed, 102 insertions(+), 39 deletions(-) diff --git a/uniapp/App.vue b/uniapp/App.vue index 360af37..ecd99d1 100644 --- a/uniapp/App.vue +++ b/uniapp/App.vue @@ -14,8 +14,10 @@ // #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鐨勬柟寮忚繘琛岀洃鍚秷鎭帹閫� //娑堟伅鐐瑰嚮浜嬩欢 //銆怉PP鍦ㄧ嚎銆戯紝鏀跺埌閫忎紶娑堟伅閫氳繃锛屼笉浼氭彁閱掕嚦閫氱煡鏍忕洰锛岄渶瑕佸彂閫佹湰鍦版秷鎭紝鍐嶈繘琛岀偣鍑昏Е鍙戠殑鐐瑰嚮浜嬩欢銆� @@ -56,6 +58,7 @@ //鏀跺埌閫忎紶娑堟伅 //鍙湁APP鍦ㄧ嚎鏃讹紝鎵嶄細瑙﹀彂receive浜嬩欢锛岄�忎紶娑堟伅涓嶄細瑙﹀彂绯荤粺娑堟伅,闇�瑕佸垱寤烘湰鍦版秷鎭� plus.push.addEventListener("receive", function(msg) { + console.log('receive', JSON.stringify(msg)) //涓氬姟浠g爜 // IOS if (uni.getSystemInfoSync().platform == 'ios') { @@ -64,7 +67,8 @@ if (msg.type == "receive") { //鍒涘缓鏈湴娑堟伅,鍙戦�佺殑鏈湴娑堟伅涔熶細琚玶eceive鏂规硶鎺ユ敹鍒帮紝浣嗘病鏈塼ype灞炴�э紝涓攁ps鏄痭ull plus.push.createMessage(msg.content, JSON.stringify(msg), { - title: messageTitle + title: messageTitle, + //icon:'/static/images/app/pushlogo.png' }); } } else { // Android @@ -79,10 +83,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) @@ -135,7 +140,11 @@ userInfo: {}, canlisten: true, appinfo: {}, - ifwt: 0 + ifwt: 0, + hasinit:false, + hasbcinit:false, + isLaunch:false + }, onShow: function() { var that = this; @@ -147,10 +156,20 @@ 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(); + } */ } } }) @@ -159,8 +178,7 @@ var route = routes[routes.length - 1].route } // #ifdef APP-PLUS - console.log(this.globalData.canlisten) - if (this.globalData.canlisten && route != 'pages/mine/tools/turnChain') { + if (this.globalData.canlisten && route != 'pages/mine/tools/turnChain'&&route!='pages/rankinglist/compareprice') { getClipboard() } @@ -169,43 +187,73 @@ onHide: function() {}, methods: { ...mapMutations(['login']), - getAppInfo: function() { + bcInit:function() + { var that = this; - // #ifdef APP-PLUS - if (plus.os.name == 'iOS') { - if (that.globalData.appinfo.iosExamine && plus.runtime.version == e.data.basic.IosExamineV) { - that.globalData.ifwt = 0 - } else { - if (plus.runtime.isApplicationExist({ - action: 'weixin://' - }) && plus.runtime.isApplicationExist({ - action: 'taobao://' - })) { - that.globalData.ifwt = 1 //鏄惁瀹夎寰俊鍜屾窐瀹� 1浠h〃瀹夎 - } else { - that.globalData.ifwt = 0 + 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 { - if (plus.runtime.isApplicationExist({pname:'com.tencent.mm', - action: 'weixin://' - })) { - console.log("瀹夊崜绔凡瀹夎寰俊") - that.globalData.ifwt = 1 //鏄惁瀹夎寰俊 1浠h〃瀹夎 - } else { - console.log("瀹夊崜绔湭瀹夎寰俊") - that.globalData.ifwt = 0 - } + }); + } + 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 { @@ -223,17 +271,32 @@ if (plus.runtime.isApplicationExist({pname:'com.tencent.mm', action: 'weixin://' })) { - console.log("瀹夊崜绔凡瀹夎寰俊") that.globalData.ifwt = 1 //鏄惁瀹夎寰俊 1浠h〃瀹夎 } else { console.log("瀹夊崜绔湭瀹夎寰俊") that.globalData.ifwt = 0 } - } */ + } // #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> -- Gitblit v1.9.3