xiaohaizhao 1 rok pred
rodič
commit
e1dc71a6b1
1 zmenil súbory, kde vykonal 53 pridanie a 53 odobranie
  1. 53 53
      pages/index/index.vue

+ 53 - 53
pages/index/index.vue

@@ -31,64 +31,20 @@ export default {
 	data() {
 		return {
 			swiperItemID: 'index',
-			page: '首页'
+			page: '首页',
+			user: {
+				wechatBindUserid: 0,
+				userName: ""
+			}
 		}
 	},
 	onLoad(options) {
-		let user = {
-			wechatBindUserid: 0,
-			userName: ""
-		},
-			that = this;
 		if (options.wechatBindUserid) {
-			user.wechatBindUserid = options.wechatBindUserid;
-			user.userName = options.userName;
-		}
-		if (options.q) {
-			let params = this.getUrlParams(options.q);
-			user.wechatBindUserid = params.wechatBindUserid;
-			user.userName = params.userName;
-		}
-		if (user.wechatBindUserid) {
-			console.log("被邀请绑定账号", user);
-			uni.showModal({
-				title: '提醒',
-				content: `"${user.userName}"是否与当前微信号绑定`,
-				confirmText: '确定绑定',
-				success: function ({ confirm }) {
-					if (confirm) uni.login({
-						success(res) {
-							that.$Http.basic({
-								"id": 20240516090402,
-								"content": {
-									"wechat_code": res.code,
-									"isbinging": 1,
-									"wechatuserinfo": "",
-									"userid": user.wechatBindUserid
-								}
-							}).then(res => {
-								console.log("绑定账号", res)
-								uni.showModal({
-									title: '提示',
-									content: res.msg == '成功' ? '绑定成功' : res.msg,
-									showCancel: false,
-									success: function ({ confirm }) {
-										if (confirm) {
-											if (res.msg == '成功') that.$Login.wechatLogin().then(s => {
-												uni.reLaunch({
-													url: '/pages/index/index'
-												})
-											})
-										}
-									}
-								});
-								if (that.cutoff(res.msg, '绑定成功')) return;
-							})
-						}
-					})
-				}
-			});
+			this.user.wechatBindUserid = options.wechatBindUserid;
+			this.user.userName = options.userName;
 		}
+		if (options.q) this.user = this.getUrlParams(options.q);
+
 	},
 	onShow() {
 		const systemInitIsComplete = this.$Http.systemInitIsComplete;
@@ -104,6 +60,50 @@ export default {
 			// #ifdef MP-WEIXIN
 			that.updatePageData(that.swiperItemID, that.page)
 			// #endif
+			if (that.user.wechatBindUserid) {
+				console.log("被邀请绑定账号", that.user);
+				uni.showModal({
+					title: '提醒',
+					content: `"${that.user.userName}"是否与当前微信号绑定`,
+					confirmText: '确定绑定',
+					success: function ({ confirm }) {
+						if (confirm) uni.login({
+							success(res) {
+								that.$Http.basic({
+									"id": 20240516090402,
+									"content": {
+										"wechat_code": res.code,
+										"isbinging": 1,
+										"wechatuserinfo": "",
+										"userid": that.user.wechatBindUserid
+									}
+								}).then(s => {
+									console.log("绑定账号", s)
+									uni.showModal({
+										title: '提示',
+										content: s.msg == '成功' ? '绑定成功' : s.msg,
+										showCancel: false,
+										success: function ({ confirm }) {
+											if (confirm) {
+												if (s.msg == '成功') that.$Login.wechatLogin().then(() => {
+													uni.reLaunch({
+														url: '/pages/index/index'
+													})
+													that.user = {
+														wechatBindUserid: 0,
+														userName: ""
+													}
+												})
+											}
+										}
+									});
+									if (that.cutoff(res.msg, '绑定成功')) return;
+								})
+							}
+						})
+					}
+				});
+			}
 		}
 	},
 	methods: {