aXin-0810 vor 9 Monaten
Ursprung
Commit
0f3161aac2
1 geänderte Dateien mit 21 neuen und 10 gelöschten Zeilen
  1. 21 10
      src/common/http/index.js

+ 21 - 10
src/common/http/index.js

@@ -18,8 +18,8 @@ const whiteCodes = [200, 201, 4444]
 export const $http = (url, method, data, json, loadingBool = false, isExecute = true, isForm = false) => {
   //设置请求前拦截器
   http.interceptor.request = config => {
-    return new Promise((r) => {
-      mini_env((bool) => {
+    return new Promise(r => {
+      mini_env(bool => {
         if (loadingBool && url !== '/homepage/study') {
           uni.showLoading({
             title: '加载中...'
@@ -32,7 +32,7 @@ export const $http = (url, method, data, json, loadingBool = false, isExecute =
           'x-token': store.getters.token,
           APPID: store.getters.appId,
           Program: program[platform()],
-          source: bool ? "A" : "B",
+          source: bool ? 'A' : 'B',
           miniOpenId: store.getters.miniOpenId,
           sharerOpenId: store.getters.sharerOpenId
         }
@@ -54,10 +54,22 @@ export const $http = (url, method, data, json, loadingBool = false, isExecute =
       if (res.code === 1001) {
         webLogin(true)
         return {}
-      }
-
-      // if (res.message || res.code) {
-      else {
+      } else if (res.code === 4001) {
+        uni.showModal({
+          title: '提示',
+          content: '你尚未绑定手机号,无法下单!',
+          confirmText: '立即绑定',
+          success: function (res) {
+            if (res.confirm) {
+              uni.navigateTo({
+                url: '/packageMine/pages/phone'
+              })
+            } else if (res.cancel) {
+              console.log('用户点击取消')
+            }
+          }
+        })
+      } else {
         if (isForm) {
           uni.showModal({
             title: '温馨提示',
@@ -77,7 +89,6 @@ export const $http = (url, method, data, json, loadingBool = false, isExecute =
           })
         }
       }
-
       return Promise.reject(new Error(res.message || 'Error'))
     } else {
       return res
@@ -91,7 +102,7 @@ export const $http = (url, method, data, json, loadingBool = false, isExecute =
       dataType: 'json',
       data
     })
-  } else if (!!~['/user/auth2', "/goods/detail"].indexOf(url)) {
+  } else if (!!~['/user/auth2', '/goods/detail'].indexOf(url)) {
     return http.request({
       method: method,
       url: url,
@@ -133,7 +144,7 @@ async function login() {
       success(loginRes) {
         resolve(loginRes.code)
       },
-      fail() { }
+      fail() {}
     })
   })
 }