From b44e169dd8a6e0f15d3788970176922e96aec6e1 Mon Sep 17 00:00:00 2001
From: zhao_js <349234519@qq.com>
Date: 星期三, 15 十一月 2023 09:55:33 +0800
Subject: [PATCH] no message

---
 uniapp/App.vue |  193 ++++++++++++++++++++++++++++++++++--------------
 1 files changed, 137 insertions(+), 56 deletions(-)

diff --git a/uniapp/App.vue b/uniapp/App.vue
index 5cb1d20..d385ab8 100644
--- a/uniapp/App.vue
+++ b/uniapp/App.vue
@@ -11,12 +11,14 @@
 	// #endif
 	export default {
 		onLaunch: function() {
+
 			// #ifdef APP-PLUS
 			//鎺ㄩ�佸紑濮�
-			var info = plus.push.getClientInfo()
+			/* var info = plus.push.getClientInfo()
 			console.log(info);
 			// 鑾峰彇褰撳墠璁惧鐨勫鎴风id,浼犵粰鍚庡彴,瀹炵幇鎸囧畾鐢ㄦ埛
-			info && uni.setStorageSync('clientInfo', info)
+			info && uni.setStorageSync('clientInfo', info) */
+			this.getPushCid();
 			// 浣跨敤5+App鐨勬柟寮忚繘琛岀洃鍚秷鎭帹閫�
 			//娑堟伅鐐瑰嚮浜嬩欢  
 			//銆怉PP鍦ㄧ嚎銆戯紝鏀跺埌閫忎紶娑堟伅閫氳繃锛屼笉浼氭彁閱掕嚦閫氱煡鏍忕洰锛岄渶瑕佸彂閫佹湰鍦版秷鎭紝鍐嶈繘琛岀偣鍑昏Е鍙戠殑鐐瑰嚮浜嬩欢銆�  
@@ -31,10 +33,12 @@
 					} else { //APP鍦ㄧ嚎锛屾敹鍒版秷鎭笉浼氬寘鍚玹ype灞炴��,杩欐椂鐨刾ayload鏄疛SON瀛楃涓诧紝闇�瑕佽浆涓篔SON瀵硅薄  
 						payload = JSON.parse(msg.payload);
 					}
+
 					if (payload != null || payload != undefined) {
 						// var messageType = payload.messageType; 
 						// onLaunch 鐢熷懡鍛ㄦ湡閲岋紝椤甸潰璺宠浆鏈夐棶棰�,璺充笉杩囧幓
 						// 搴旇鏄〉闈㈣繕娌″姞杞斤紝鍔犱笂瀹氭椂鍚庯紝灏卞彲浠ヤ簡锛�
+						console.log(payload);
 						setTimeout(() => {
 							uni.navigateTo({
 								url: payload
@@ -43,6 +47,7 @@
 					}
 				} else { // Android
 					var payload = msg.payload;
+					console.log(payload);
 					if (payload != null || payload != undefined) {
 						// onLaunch 鐢熷懡鍛ㄦ湡閲岋紝椤甸潰璺宠浆鏈夐棶棰�,璺充笉杩囧幓
 						// 搴旇鏄〉闈㈣繕娌″姞杞斤紝鍔犱笂瀹氭椂鍚庯紝灏卞彲浠ヤ簡锛� 
@@ -57,6 +62,7 @@
 			//鏀跺埌閫忎紶娑堟伅  
 			//鍙湁APP鍦ㄧ嚎鏃讹紝鎵嶄細瑙﹀彂receive浜嬩欢锛岄�忎紶娑堟伅涓嶄細瑙﹀彂绯荤粺娑堟伅,闇�瑕佸垱寤烘湰鍦版秷鎭�  
 			plus.push.addEventListener("receive", function(msg) {
+				console.log('receive', JSON.stringify(msg))
 				//涓氬姟浠g爜
 				// IOS
 				if (uni.getSystemInfoSync().platform == 'ios') {
@@ -70,12 +76,18 @@
 						});
 					}
 				} else { // Android
-					var payload = JSON.parse(msg.content);
+					console.log(msg.content);
+					plus.push.createMessage(msg.content, msg.payload, {
+						title: messageTitle
+						//icon:'/static/images/app/pushlogo.png'
+					});
+					/* var payload = JSON.parse(msg.content);
+					
 					var messageTitle = payload.title;
 					var messageContent = payload.content;
 					plus.push.createMessage(messageContent, payload, {
 						title: messageTitle
-					})
+					}) */
 				}
 			}, false);
 			//娑堟伅鎺ㄩ�佺粨鏉�
@@ -126,9 +138,11 @@
 						this.globalData.systemLevel = e.system;
 						this.globalData.equipmentNumber = idfa.value()
 					};
+					this.getArgument(true);
 					// #endif
 				}
 			})
+
 
 		},
 		globalData: {
@@ -139,28 +153,31 @@
 			canlisten: true,
 			appinfo: {},
 			ifwt: 0,
-			hasinit:false,
-			hasbcinit:false,
-			isLaunch:false
-			
+			hasinit: false,
+			hasbcinit: false,
+			isLaunch: false,
+			argumentStr: ''
+
+		},
+		data() {
+			return {
+
+			}
 		},
 		onShow: function() {
 			var that = this;
 			uni.getNetworkType({
-				success:function(res){
+				success: function(res) {
 					if (res.networkType == 'none') {
 						uni.showModal({
 							title: '缃戠粶閾炬帴澶辫触',
 							content: '妫�娴嬪埌缃戠粶鏉冮檺鍙兘璁剧疆涓哄叧闂紝鎮ㄥ彲浠ュ湪鈥滆缃�濅腑妫�鏌ユ棤绾挎暟鎹強铚傜獫绉诲姩缃戠粶'
 						})
-					}else{
-						console.log("鏄惁璇锋眰杩囷細"+that.globalData.hasinit)
-						if(!that.globalData.hasinit)
-						{
+					} else {
+						if (!that.globalData.hasinit) {
 							that.getAppInfo();
 						}
-						if(!that.globalData.hasbcinit)
-						{
+						if (!that.globalData.hasbcinit) {
 							console.log("鍒濆鍖栫櫨宸濇彃浠�")
 							that.bcInit();
 						}
@@ -177,51 +194,112 @@
 				var route = routes[routes.length - 1].route
 			}
 			// #ifdef APP-PLUS
-			if (this.globalData.canlisten && route != 'pages/mine/tools/turnChain') {
+			if (this.globalData.canlisten && route != 'pages/mine/tools/turnChain' && route !=
+				'pages/rankinglist/compareprice') {
 				getClipboard()
 			}
-
+			that.getArgument();
 			// #endif
 		},
 		onHide: function() {},
 		methods: {
 			...mapMutations(['login']),
-			 bcInit:function()
-			{
+			bcInit: function() {
 				var that = this;
-				console.log(uni.getSystemInfoSync().platform);
-				if (uni.getSystemInfoSync().platform == 'ios')
-				{
+				//uni.getSystemInfoSync().platform == 'ios'
+				if (true) {
 					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;
+						console.log(result); // code绛変簬0灏辨槸鍒濆鍖栨垚鍔�
+						if (result.code == 0) {
+							that.globalData.hasbcinit = true;
 						}
 					});
+				} else {
+					that.globalData.hasbcinit = true;
 				}
-				else{
-					that.globalData.hasbcinit=true;
+			},
+			targetArgument(args) {
+				var toarg = args.replace('dafanguan://', '');
+				uni.navigateTo({
+					url: toarg
+				});
+				/* var argObj = JSON.parse(decodeURIComponent(toarg));
+				switch (argObj.totype) {
+					case "0": //鍐呴摼
+						if (argObj.url) {
+							uni.navigateTo({
+								url: argObj.url
+							});
+						}
+						break;
+					default:
+						break;
+				} */
+			},
+			getArgument(isload = false) {
+				if (this.globalData.argumentStr && this.globalData.argumentStr.length > 0) {
+					return;
 				}
+				try {
+					var args = plus.runtime.arguments;
+					console.log(args);
+					if (args) {
+						if (isload) {
+							this.globalData.argumentStr = args;
+							return;
+						}
+						plus.runtime.arguments = "";
+						plus.runtime.arguments = null;
+						this.targetArgument(args);
+					}
+				} catch (es) {
+					console.log(es)
+				}
+
+			},
+			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('寮�濮嬫洿鏂�:' + clientInfo.clientid);
+					this.$u.api.updateCid({
+						pushcid: clientInfo.clientid
+					}).then(e => {}).catch(function(err) {})
+				} else {
+					this.getPushCid();
+				}
+
 			},
 			getAppInfo: function() {
 				var that = this;
-				that.globalData.hasinit=true;
+				that.globalData.hasinit = true;
 				this.$u.api.comminInt({}).then(e => {
-					if (e.code != 0) 
-					{
-						that.globalData.hasinit=false;
+					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 (that.globalData.appinfo.iosExamine && plus.runtime.version == e.data.basic.IosExamineV) {
+					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({
@@ -235,36 +313,39 @@
 							}
 						}
 					} else {
-						if (plus.runtime.isApplicationExist({pname:'com.tencent.mm',
+						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) {that.globalData.hasinit=false;})
-				
+				}).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
-			                        }
-			                    })
-			                },
+
+			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>
@@ -286,4 +367,4 @@
 	}
 
 	/* #endif */
-</style>
+</style>
\ No newline at end of file

--
Gitblit v1.9.3