Explorar o código

improve: 个人中心手机号获取优化

From-wh %!s(int64=2) %!d(string=hai) anos
pai
achega
a296d76eda
Modificáronse 1 ficheiros con 25 adicións e 23 borrados
  1. 25 23
      template/uni-app/pages/users/user_info/index.vue

+ 25 - 23
template/uni-app/pages/users/user_info/index.vue

@@ -170,7 +170,7 @@
 		userEdit,
 		getLogout,
 		getLangList,
-		getLangJson,
+		getLangJson,
 		mpBindingPhone
 	} from '@/api/user.js';
 	import {
@@ -257,29 +257,31 @@
 				});
 			},
 			getphonenumber(e) {
-				Routine.getCode()
-					.then(code => {
-						let data = {
-							code,
-							iv: e.detail.iv,
-							encryptedData: e.detail.encryptedData,
-						}
-						mpBindingPhone(data).then(res => {
-							this.getUserInfo()
-							this.$util.Tips({
-								title: res.msg,
-								icon: 'success'
-							});
-						}).catch(err => {
-							return this.$util.Tips({
-								title: err
-							});
+				console.log(e)
+				if (e.detail.errMsg == 'getPhoneNumber:ok') {
+					Routine.getCode()
+						.then(code => {
+							let data = {
+								code,
+								iv: e.detail.iv,
+								encryptedData: e.detail.encryptedData,
+							}
+							mpBindingPhone(data).then(res => {
+								this.getUserInfo()
+								this.$util.Tips({
+									title: res.msg,
+									icon: 'success'
+								});
+							}).catch(err => {
+								return this.$util.Tips({
+									title: err
+								});
+							})
 						})
-					})
-					.catch(error => {
-						uni.hideLoading();
-					});
-
+						.catch(error => {
+							uni.hideLoading();
+						});
+				}
 			},
 			setLang() {
 				this.array.map((item, i) => {