yuantianjiao 6 년 전
부모
커밋
9f35b0ea04
7개의 변경된 파일27개의 추가작업 그리고 20개의 파일을 삭제
  1. 7
    0
      src/config/index.js
  2. 1
    9
      src/pages/user/App.vue
  3. 3
    8
      src/pages/user/mainPage/userCenter/index.vue
  4. 1
    0
      src/store/userCenter/userCenter.js
  5. 10
    2
      src/util/ajax.js
  6. 1
    0
      src/util/util.js
  7. 4
    1
      vue.config.js

+ 7
- 0
src/config/index.js 파일 보기

@@ -0,0 +1,7 @@
1
+export default {
2
+  appid: 'wx7320287e057bbeee',
3
+  redirect_uri: encodeURIComponent(window.location.href),
4
+  response_type: 'code',
5
+  scope: 'snsapi_userinfo',
6
+  state: '12313'
7
+}

+ 1
- 9
src/pages/user/App.vue 파일 보기

@@ -23,15 +23,7 @@ export default {
23 23
     } else {
24 24
       this.code = null
25 25
     }
26
-    this.getUserInfo({ org: this.org, code: this.code }).then((res) => {
27
-      if (typeof (res) === 'string') {
28
-        if (res.indexOf('401-') > -1) {
29
-          this.toolClass.getCode(res.substring(4, res.length))
30
-        }
31
-      }
32
-    }).catch((err) => {
33
-      console.log(err)
34
-    })
26
+    this.getUserInfo({ org: this.org, code: this.code })
35 27
   },
36 28
   methods: {
37 29
     ...actions(['getUserInfo'])

+ 3
- 8
src/pages/user/mainPage/userCenter/index.vue 파일 보기

@@ -1,7 +1,6 @@
1 1
 <template>
2 2
   <div class="mainPage">
3 3
     <div class="loading" v-if="isLoading">
4
-      <!-- <img :src='loading' alt=""> -->
5 4
       <div @click="bindMobile">请绑定手机号</div>
6 5
     </div>
7 6
     <div v-else>
@@ -61,7 +60,6 @@
61 60
 </template>
62 61
 
63 62
 <script>
64
-import loading from '../../../../common/icon/loading.gif'
65 63
 import { mapState, createNamespacedHelpers } from 'vuex'
66 64
 const { mapActions: actions } = createNamespacedHelpers('userCenter')
67 65
 export default {
@@ -69,7 +67,6 @@ export default {
69 67
   data () {
70 68
     return {
71 69
       user: {},
72
-      loading,
73 70
       isLoading: true
74 71
     }
75 72
   },
@@ -83,14 +80,12 @@ export default {
83 80
 
84 81
   },
85 82
   created () {
86
-    this.getUserInfo({ org: this.org }).then((res) => {
83
+    if (this.userInfo != 406) {
87 84
       this.user = this.userInfo.customer
88 85
       this.AccountInfo = JSON.parse(this.user.AccountInfo)
89 86
       this.headimgurl = this.AccountInfo.headimgurl
90 87
       this.isLoading = false
91
-    }).catch((err) => {
92
-      console.log(err)
93
-    })
88
+    }
94 89
   },
95 90
   methods: {
96 91
     ...actions(['getUserInfo']),
@@ -115,5 +110,5 @@ export default {
115 110
 
116 111
 <!-- Add "scoped" attribute to limit CSS to this component only -->
117 112
 <style lang="scss" scoped>
118
-@import "page.scss";
113
+@import 'page.scss';
119 114
 </style>

+ 1
- 0
src/store/userCenter/userCenter.js 파일 보기

@@ -17,6 +17,7 @@ http.getUserInfo = (data) => { // 获取用户信息
17 17
       method: api.user.info.method,
18 18
       queryData: queryData
19 19
     }).then(res => {
20
+      console.log(res)
20 21
       resolve(res)
21 22
     }).catch((err) => {
22 23
       reject(err)

+ 10
- 2
src/util/ajax.js 파일 보기

@@ -1,6 +1,7 @@
1 1
 import axios from 'axios'
2 2
 import qs from 'qs'
3 3
 import toolClass from './util'
4
+import router from '../pages/user/router'
4 5
 import { Toast } from '../../node_modules/vant';
5 6
 
6 7
 const Axios = axios.create({
@@ -48,13 +49,20 @@ Axios.interceptors.request.use((config) => {
48 49
 const ajax = (...args) => {
49 50
   return new Promise((resolve, reject) => {
50 51
     Axios(...args).then(({ data }) => {
51
-      // console.log(111)
52
+      console.log(111)
52 53
       const { code, message, result } = data
53 54
       if (code === 200) {
54 55
         resolve(result)
55 56
       } else if (code === 401) {
57
+        console.log(result)
56 58
         // reject(code)
57
-        toolClass.getCode()
59
+        toolClass.getCode(result.appid)
60
+      } else if (code === 406) {
61
+        console.log(message)
62
+        // if (router.history.current.name == 'bindMobile'){
63
+        //   router.push({ name:'bindMobile' })
64
+        // }
65
+        resolve(code)
58 66
       } else {
59 67
         Toast({
60 68
           message: message,

+ 1
- 0
src/util/util.js 파일 보기

@@ -1,3 +1,4 @@
1
+import wechatConfig from '../config/index'
1 2
 const toolClass = {
2 3
   dateFormat: (timestamp, fmt) => {
3 4
     if (!fmt) {

+ 4
- 1
vue.config.js 파일 보기

@@ -20,6 +20,7 @@ module.exports = {
20 20
   productionSourceMap: true,
21 21
   chainWebpack: config => config.plugins.delete('named-chunks'),
22 22
   devServer: {
23
+    publicPath: '/c-v2/',
23 24
     proxy: {
24 25
       '/api-v2': {
25 26
         // target: 'https://dp.huiju360.com.cn/hj_operations',
@@ -31,6 +32,8 @@ module.exports = {
31 32
         //   '^/api': '/api-v2/api'
32 33
         // },
33 34
       },
34
-    }
35
+    },
36
+    // compress: true,
37
+    disableHostCheck: true,   // That solved it
35 38
   }
36 39
 }