Browse Source

Merge branch 'dev' of http://git.ycjcjy.com/SpaceOfCheng/wechat into dev

许成详 6 years ago
parent
commit
b133918198
3 changed files with 32 additions and 6 deletions
  1. 17
    1
      src/pages/sales/salesGiveOutDetail/index.vue
  2. 1
    1
      src/store/forbid/index.js
  3. 14
    4
      src/util/ajax.js

+ 17
- 1
src/pages/sales/salesGiveOutDetail/index.vue View File

61
 
61
 
62
 <script>
62
 <script>
63
 import topCaseInfo from '../../../components/topCaseInfo/index'
63
 import topCaseInfo from '../../../components/topCaseInfo/index'
64
+import { createNamespacedHelpers } from 'vuex'
65
+const { mapState: mapForbidState, mapActions: mapForbidActions } = createNamespacedHelpers('forbid')
64
 
66
 
65
 export default {
67
 export default {
66
   name: '',
68
   name: '',
73
         showSelect: false,
75
         showSelect: false,
74
         userName: 'xxx'
76
         userName: 'xxx'
75
       },
77
       },
78
+      data: [
79
+        [
80
+          {}
81
+        ],
82
+        [
83
+
84
+        ]
85
+      ]
76
     }
86
     }
77
   },
87
   },
88
+  computed: {
89
+    ...mapForbidState({
90
+      salesCardList: x => x.salesCardList
91
+    })
92
+  },
78
   components: {
93
   components: {
79
     topCaseInfo,
94
     topCaseInfo,
80
   },
95
   },
81
   created () {
96
   created () {
82
-
97
+    this.getSalesCardList({ id: this.$route.query.id })
83
   },
98
   },
84
   methods: {
99
   methods: {
100
+    ...mapForbidActions(['getSalesCardList']),
85
     cutNav (index) {
101
     cutNav (index) {
86
       this.activeIndex = index
102
       this.activeIndex = index
87
     },
103
     },

+ 1
- 1
src/store/forbid/index.js View File

84
             ...data
84
             ...data
85
           }
85
           }
86
         }).then(res => {
86
         }).then(res => {
87
-          context.commit('setForbidList', res)
87
+          context.commit('setSalesCardList', res)
88
           resolve(res)
88
           resolve(res)
89
         }).catch((err) => {
89
         }).catch((err) => {
90
           reject(err)
90
           reject(err)

+ 14
- 4
src/util/ajax.js View File

3
 import toolClass from './util'
3
 import toolClass from './util'
4
 import router from '../pages/user/router'
4
 import router from '../pages/user/router'
5
 import { Toast } from '../../node_modules/vant';
5
 import { Toast } from '../../node_modules/vant';
6
-var JWT = localStorage.getItem('JWT')
6
+
7
+const token = function (headers) {
8
+  let JWT
9
+  if (headers){
10
+    localStorage.setItem('JWT', headers.authorization)
11
+    JWT = headers.authorization
12
+  }
13
+  console.log(JWT)
14
+  return JWT ? JWT : localStorage.getItem('JWT')
15
+}
16
+
7
 const Axios = axios.create({
17
 const Axios = axios.create({
8
   timeout: 60000,
18
   timeout: 60000,
9
   responseType: 'json',
19
   responseType: 'json',
12
   urlData: {},
22
   urlData: {},
13
   headers: {
23
   headers: {
14
     'Content-Type': 'multipart/form-data',
24
     'Content-Type': 'multipart/form-data',
15
-    'authorization': JWT
25
+    'authorization': token()
16
   }
26
   }
17
 })
27
 })
18
 
28
 
19
 Axios.interceptors.request.use((config) => {
29
 Axios.interceptors.request.use((config) => {
30
+  config.headers.authorization = token()
20
   // 处理请求data,若为get请求,拼到url后面,若为post请求,直接添加到body中
31
   // 处理请求data,若为get请求,拼到url后面,若为post请求,直接添加到body中
21
   config.urlData = { ...config.urlData, org: 'MQ' }
32
   config.urlData = { ...config.urlData, org: 'MQ' }
22
   let urlData = qs.stringify(config.urlData)
33
   let urlData = qs.stringify(config.urlData)
51
   return new Promise((resolve, reject) => {
62
   return new Promise((resolve, reject) => {
52
     Axios(...args).then(({ data, headers }) => {
63
     Axios(...args).then(({ data, headers }) => {
53
       if (headers.authorization) {
64
       if (headers.authorization) {
54
-        localStorage.setItem('JWT', headers.authorization)
55
-        JWT = headers.authorization
65
+        token(headers)
56
       }
66
       }
57
       const { code, message, result } = data
67
       const { code, message, result } = data
58
       if (code === 200) {
68
       if (code === 200) {