xueyihao 4 месяцев назад
Родитель
Сommit
fb9bc9f0cd
2 измененных файлов с 25 добавлено и 11 удалено
  1. 11 2
      src/api/index.js
  2. 14 9
      src/setting/myNew/phone.vue

+ 11 - 2
src/api/index.js

@@ -45,7 +45,7 @@ export function videoUpload(data) {
     });
 }
 
-// 获取token  
+// 获取token
 export function getAccessToken(data) {
     return request({
         method: 'get',
@@ -54,7 +54,7 @@ export function getAccessToken(data) {
     });
 }
 
-// 轮播图  
+// 轮播图
 export function getBannerList(data) {
     return request({
         method: 'get',
@@ -547,3 +547,12 @@ export function withDraw(data) {
 		data
 	})
 }
+
+// 绑定手机号
+export function bindPhone(data) {
+    return request({
+        method: 'post',
+        url: '/weChat/bindPhone',
+        data
+    })
+}

+ 14 - 9
src/setting/myNew/phone.vue

@@ -1,4 +1,5 @@
 <script>
+import {bindPhone} from '@/api/index.js'
 export default {
   data() {
     return {
@@ -91,16 +92,20 @@ export default {
       }
 
       this.isBinding = true
-
-      uni.showToast({
-        title: '绑定成功',
-        icon: 'success'
+      bindPhone({
+        openId:uni.getStorageSync('wx_copenid'),
+        phone:this.phone,
+        code:this.code
+      }).then(res =>{
+        if (res.data.code == 200) {
+          uni.showToast({
+            title: '绑定成功',
+            icon: 'success'
+          })
+          uni.setStorageSync('wx_phone', this.phone)
+          uni.navigateBack()
+        }
       })
-
-      setTimeout(() => {
-        uni.setStorageSync('wx_phone', this.phone)
-        uni.navigateBack()
-      }, 1500)
     }
   },
   beforeDestroy() {