11wqe1 3 hafta önce
ebeveyn
işleme
d363cb2c26
2 değiştirilmiş dosya ile 20 ekleme ve 15 silme
  1. 16 11
      src/components/userInfoA.vue
  2. 4 4
      src/views/login/loginPage.vue

+ 16 - 11
src/components/userInfoA.vue

@@ -647,17 +647,17 @@ export default {
 			let params = {
 				openid: openid,
 			};
-			
+			let _this = this
 			this.openid = openid;
 			axios.defaults.withCredentials = true;
 			axios
 				.post(`https://beta.api.cocorobo.cn/api/user`, qs.stringify(params))
 				.then(async (res) => {
 					let _data = res.data[0][0];
-					this.$message.error('该微信已绑定'+_data.username+'账号');
-					this.wechatDialogVisible = false;
-					if (this.$refs.QRcode && this.$refs.QRcode.innerHTML) {
-						this.$refs.QRcode.innerHTML = "";
+					_this.$message.error('该微信已绑定'+_data.username+'账号');
+					_this.wechatDialogVisible = false;
+					if (_this.$refs.QRcode && _this.$refs.QRcode.innerHTML) {
+						_this.$refs.QRcode.innerHTML = "";
 					}
 				})
 				.catch((err) => {
@@ -666,20 +666,25 @@ export default {
 					let params = [
 						{
 							functionName: API_CONFIG.ajax_UpdateOpenId.functionName, // 调用存储过程的名称
-							uid: this.userid,
+							uid: _this.userid,
 							openid: openid,
 						},
 					];
-					this.$ajax
+					_this.$ajax
 						.post(API_CONFIG.baseUrl, params)
 						.then(() => {
-							this.$message.success("绑定成功");
-							this.wechatDialogVisible = false;
-							this.getData();
+							_this.$message.success("绑定成功");
+							_this.wechatDialogVisible = false;
+							_this.getData();
 						})
 						.catch((err) => {
-							this.$message.error("绑定失败请重新扫码");
+							_this.$message.error("绑定失败请重新扫码");
 							console.error(err);
+							setTimeout(() => {
+								_this.wechatDialogVisible = true;
+								_this.wechatLogin();
+							}, 1000);
+
 						});
 					});
 		},

+ 4 - 4
src/views/login/loginPage.vue

@@ -1093,7 +1093,7 @@ export default {
 		// });
 		this.messageHandler = function (e) {
 			// 监听 message 事件
-			console.log('userinfo', e);
+			console.log('login', e);
 			if (e.data && e.data.method === "getOpenId") {
 				console.log('e', e);
 				console.log('e.data.code', e.data.code);
@@ -1116,9 +1116,9 @@ export default {
 		this.getLoading();
 		this.getOrdOidData();
 	},
-	// beforeDestroy() {
-	// 	window.removeEventListener("message", this.messageHandler);
-	// }
+	beforeDestroy() {
+		window.removeEventListener("message", this.messageHandler);
+	}
 };
 </script>
 <style scoped>