Sfoglia il codice sorgente

H5:request.js代码优化

panyong 3 anni fa
parent
commit
d73f3a4231

+ 6 - 0
htmldev/dashboard/README.md

@@ -22,3 +22,9 @@ npm run lint
 
 ### Customize configuration
 See [Configuration Reference](https://cli.vuejs.org/config/).
+
+# todo list
+- [ ] 我订单状态整理
+- [ ] 新增个人中心(菜单配置)
+- [ ] 订座下单测试
+- [ ] api接口配置loading

+ 7 - 7
htmldev/dashboard/src/api/request.js

@@ -63,16 +63,16 @@ request.interceptors.request.use(request => {
   request.headers.token = getCookieValue('afhousetoken')
   request.headers.tingbangSource = tingbangSource
   if (platform.isWeixin) {
-    request.headers.wechatToken = getCookieValue('afhousewechatToken')
+    // 因为微信开发者工具重复授权,本地开发时写死
+    if (/^(0|192|10|localhost)/.test(domain)) {
+      // request.url += '&owner_open_id=0c540a8d284b38f84d2f8ad262ab5d2c'
+      request.headers.wechatToken = '0c540a8d284b38f84d2f8ad262ab5d2c'
+    } else {
+      request.headers.wechatToken = getCookieValue('afhousewechatToken')
+    }
   }
   request.url = requestUrl + (requestUrl.indexOf('?') > -1 ? '&' : '?') + 'nextUrl=' + encodeURIComponent(location.href)
 
-  // 因为微信开发者工具重复授权,本地开发时写死
-  if (/^(0|192|10|localhost)|(test$)/.test(domain)) {
-    // request.url += '&owner_open_id=0c540a8d284b38f84d2f8ad262ab5d2c'
-    request.headers.wechatToken = '0c540a8d284b38f84d2f8ad262ab5d2c'
-  }
-
   // 判断当前请求是否设置了不显示Loading
   if (request.showLoading) {
     showLoading()

+ 25 - 27
htmldev/dashboard/src/router/index.js

@@ -99,6 +99,28 @@ const routes = [
       wxpayHref: route.query.wxpayHref
     })
   },
+  {
+    path: '/sell/goods',
+    name: 'SellGoods',
+    component: _import('views/sell/goods/index'),
+    meta: {
+      title: '点单',
+      isUseCache: false,
+      keepAlive: false,
+      isUseVanTabbar: false
+    }
+  },
+  {
+    path: '/sell/pay',
+    name: 'SellPay',
+    component: _import('views/sell/pay/index'),
+    meta: {
+      title: '订单',
+      isUseCache: false,
+      keepAlive: false,
+      isUseVanTabbar: false
+    }
+  },
   {
     path: '/order',
     component: _import('views/order/index'),
@@ -110,13 +132,11 @@ const routes = [
         meta: {
           title: '订单',
           isUseCache: false,
-          keepAlive: false
+          keepAlive: false,
+          isUseVanTabbar: false
         }
       }
-    ],
-    meta: {
-      isUseVanTabbar: false
-    }
+    ]
   },
   {
     path: '/orderDetail',
@@ -137,28 +157,6 @@ const routes = [
       isUseCache: false,
       keepAlive: false
     }
-  },
-  {
-    path: '/sell/goods',
-    name: 'SellGoods',
-    component: _import('views/sell/goods/index'),
-    meta: {
-      title: '点单',
-      isUseCache: false,
-      keepAlive: false,
-      isUseVanTabbar: false
-    }
-  },
-  {
-    path: '/sell/pay',
-    name: 'SellPay',
-    component: _import('views/sell/pay/index'),
-    meta: {
-      title: '订单',
-      isUseCache: false,
-      keepAlive: false,
-      isUseVanTabbar: false
-    }
   }
 ]