Ver código fonte

静态页面

1002884655 4 anos atrás
pai
commit
8866c1b01e

+ 23
- 4
package-lock.json Ver arquivo

@@ -2178,6 +2178,12 @@
2178 2178
           "requires": {
2179 2179
             "safer-buffer": ">= 2.1.2 < 3"
2180 2180
           }
2181
+        },
2182
+        "qs": {
2183
+          "version": "6.5.2",
2184
+          "resolved": "https://registry.npm.taobao.org/qs/download/qs-6.5.2.tgz",
2185
+          "integrity": "sha1-yzroBuh0BERYTvFUzo7pjUA/PjY=",
2186
+          "dev": true
2181 2187
         }
2182 2188
       }
2183 2189
     },
@@ -4983,6 +4989,12 @@
4983 4989
         "vary": "~1.1.2"
4984 4990
       },
4985 4991
       "dependencies": {
4992
+        "qs": {
4993
+          "version": "6.5.2",
4994
+          "resolved": "https://registry.npm.taobao.org/qs/download/qs-6.5.2.tgz",
4995
+          "integrity": "sha1-yzroBuh0BERYTvFUzo7pjUA/PjY=",
4996
+          "dev": true
4997
+        },
4986 4998
         "statuses": {
4987 4999
           "version": "1.4.0",
4988 5000
           "resolved": "https://registry.npmjs.org/statuses/-/statuses-1.4.0.tgz",
@@ -12023,10 +12035,9 @@
12023 12035
       "dev": true
12024 12036
     },
12025 12037
     "qs": {
12026
-      "version": "6.5.2",
12027
-      "resolved": "https://registry.npmjs.org/qs/-/qs-6.5.2.tgz",
12028
-      "integrity": "sha512-N5ZAX4/LxJmF+7wN74pUD6qAh9/wnvdQcjq9TZjevvXzSUo7bfmw91saqMjzGS2xq91/odN2dW/WOl7qQHNDGA==",
12029
-      "dev": true
12038
+      "version": "6.9.4",
12039
+      "resolved": "https://registry.npm.taobao.org/qs/download/qs-6.9.4.tgz",
12040
+      "integrity": "sha1-kJCykNH5FyjTwi5UhDykSupatoc="
12030 12041
     },
12031 12042
     "query-string": {
12032 12043
       "version": "4.3.4",
@@ -12705,6 +12716,14 @@
12705 12716
         "tough-cookie": "~2.4.3",
12706 12717
         "tunnel-agent": "^0.6.0",
12707 12718
         "uuid": "^3.3.2"
12719
+      },
12720
+      "dependencies": {
12721
+        "qs": {
12722
+          "version": "6.5.2",
12723
+          "resolved": "https://registry.npm.taobao.org/qs/download/qs-6.5.2.tgz",
12724
+          "integrity": "sha1-yzroBuh0BERYTvFUzo7pjUA/PjY=",
12725
+          "dev": true
12726
+        }
12708 12727
       }
12709 12728
     },
12710 12729
     "request-promise-core": {

+ 1
- 0
package.json Ver arquivo

@@ -18,6 +18,7 @@
18 18
     "exports-loader": "^0.7.0",
19 19
     "js-md5": "^0.7.3",
20 20
     "md5": "^2.3.0",
21
+    "qs": "^6.9.4",
21 22
     "script-loader": "^0.7.2",
22 23
     "vant": "^2.10.3",
23 24
     "vue": "^2.5.2",

+ 5
- 1
src/components/common/MainPageContainer/index.vue Ver arquivo

@@ -138,7 +138,8 @@ export default {
138 138
       ''
139 139
     ]),
140 140
     ...mapUserActions([
141
-      'SignIn'
141
+      'SignIn',
142
+      'GetCurrentShopInfo'
142 143
     ]),
143 144
     Init () { // 初始化
144 145
       if (this.UserInfo === null) {
@@ -148,6 +149,9 @@ export default {
148 149
               // this.$router.push({ name: 'SignIn' })
149 150
             } else {
150 151
               this.$emit('UserInfoChange')
152
+              this.GetCurrentShopInfo().then(() => { // 获取当前店铺信息
153
+                this.$emit('ShopInfoChange')
154
+              })
151 155
             }
152 156
           }).catch(() => {
153 157
             // this.$router.push({ name: 'SignIn' })

+ 56
- 7
src/pages/CaiMinGuanLi/CaiMinLieBiao/index.vue Ver arquivo

@@ -2,20 +2,20 @@
2 2
   <div class="Page">
3 3
     <MainPageContainer :ShowMainHeader="true" :MainHeaderTitle="`全部彩民`" :ShowMainHeaderBack="true">
4 4
       <div class="Content">
5
-        <scroller :on-refresh="Refresh">
5
+        <scroller :on-refresh="Refresh" :on-infinite="Infinite" ref="MyScroller">
6 6
           <div class="Container">
7 7
             <ul>
8
-              <li v-for="(item, index) in 15" :key="index" class="flex-h">
8
+              <li v-for="(item, index) in CurrentShopAllCustomer" :key="index" class="flex-h">
9 9
                 <div class="Icon">
10 10
                   <img src="" class="centerLabel cover" alt="">
11 11
                 </div>
12 12
                 <div class="flex-item">
13 13
                   <div>
14
-                    <span>叭叭叭</span>
15
-                    <span>2天前,下单2元未出票</span>
14
+                    <span>{{item.name}}</span>
15
+                    <span>{{ToolClass.DateFormat(item.createDate)}}</span>
16 16
                   </div>
17 17
                 </div>
18
-                <span>2.00</span>
18
+                <!-- <span>2.00</span> -->
19 19
               </li>
20 20
             </ul>
21 21
           </div>
@@ -27,28 +27,77 @@
27 27
 
28 28
 <script>
29 29
 import MainPageContainer from '../../../components/common/MainPageContainer'
30
+import { createNamespacedHelpers } from 'vuex'
31
+const { mapState: mapUserState, mapActions: mapUserActions, mapMutations: mapUserMutations } = createNamespacedHelpers('user')
30 32
 export default {
31 33
   name: 'index',
32 34
   data () {
33 35
     return {
36
+      PageData: {
37
+        pageNum: 0,
38
+        pageSize: 10
39
+      },
40
+      Timer: null,
41
+      HasNextPage: true,
42
+      DataLock: false
34 43
     }
35 44
   },
36 45
   computed: {
46
+    ...mapUserState({
47
+      UserInfo: x => x.UserInfo,
48
+      CurrentShopAllCustomer: x => x.CurrentShopAllCustomer
49
+    })
37 50
   },
38 51
   components: {
39 52
     MainPageContainer
40 53
   },
41 54
   created () {
55
+    this.EmptyCurrentShopAllCustomer()
42 56
   },
43 57
   mounted () {
44 58
     this.$nextTick(() => {
45 59
     })
46 60
   },
47 61
   methods: {
62
+    ...mapUserMutations([
63
+      'EmptyCurrentShopAllCustomer'
64
+    ]),
65
+    ...mapUserActions([
66
+      'GetShopAllCustomer'
67
+    ]),
68
+    Init (done = () => { }) { // 初始化
69
+      this.EmptyCurrentShopAllCustomer()
70
+      this.PageData.pageNum = 1
71
+      this.HasNextPage = true
72
+      this.DataLock = false
73
+      this.ToGetPageList(done)
74
+    },
75
+    ToGetPageList (done = () => { }) { // 获取页面列表
76
+      if (this.HasNextPage) {
77
+        this.GetShopAllCustomer({ queryData: { ...this.PageData, from: 'all' } }).then((res) => {
78
+          this.HasNextPage = res.data.data.total > this.CurrentShopAllCustomer.length
79
+          done()
80
+        }).catch(() => {
81
+          done()
82
+        })
83
+      }
84
+    },
85
+    Infinite (done) { // 上拉加载
86
+      this.Timer = window.setTimeout(() => {
87
+        if (this.HasNextPage) {
88
+          this.PageData.pageNum += 1
89
+          this.ToGetPageList(done)
90
+        } else {
91
+          this.$refs.MyScroller.finishInfinite(true)
92
+        }
93
+      }, 1000)
94
+    },
48 95
     Refresh (done) { // 页面下拉刷新
49
-      window.setTimeout(() => {
96
+      if (!this.DataLock) {
97
+        this.Init(done)
98
+      } else {
50 99
         done()
51
-      }, 1000)
100
+      }
52 101
     }
53 102
   }
54 103
 }

+ 57
- 8
src/pages/CaiMinGuanLi/ShouYe/index.vue Ver arquivo

@@ -14,20 +14,20 @@
14 14
         <div class="flex-item">
15 15
           <div>
16 16
             <div class="Content">
17
-              <scroller :on-refresh="Refresh">
17
+              <scroller :on-refresh="Refresh" :on-infinite="Infinite" ref="MyScroller">
18 18
                 <div class="Container">
19 19
                   <ul>
20
-                    <li v-for="(item, index) in 15" :key="index" class="flex-h">
20
+                    <li v-for="(item, index) in CurrentShopCustomer" :key="index" class="flex-h">
21 21
                       <div class="Icon">
22
-                        <img src="" class="centerLabel cover" alt="">
22
+                        <img :src="item.avatar" class="centerLabel cover" alt="">
23 23
                       </div>
24 24
                       <div class="flex-item">
25 25
                         <div>
26
-                          <span>叭叭叭</span>
27
-                          <span>2天前,下单2元未出票</span>
26
+                          <span>{{item.name}}</span>
27
+                          <span>{{ToolClass.DateFormat(item.createDate)}}</span>
28 28
                         </div>
29 29
                       </div>
30
-                      <span>2.00</span>
30
+                      <!-- <span>2.00</span> -->
31 31
                     </li>
32 32
                   </ul>
33 33
                 </div>
@@ -42,28 +42,77 @@
42 42
 
43 43
 <script>
44 44
 import MainPageContainer from '../../../components/common/MainPageContainer'
45
+import { createNamespacedHelpers } from 'vuex'
46
+const { mapState: mapUserState, mapActions: mapUserActions, mapMutations: mapUserMutations } = createNamespacedHelpers('user')
45 47
 export default {
46 48
   name: 'index',
47 49
   data () {
48 50
     return {
51
+      PageData: {
52
+        pageNum: 0,
53
+        pageSize: 10
54
+      },
55
+      Timer: null,
56
+      HasNextPage: true,
57
+      DataLock: false
49 58
     }
50 59
   },
51 60
   computed: {
61
+    ...mapUserState({
62
+      UserInfo: x => x.UserInfo,
63
+      CurrentShopCustomer: x => x.CurrentShopCustomer
64
+    })
52 65
   },
53 66
   components: {
54 67
     MainPageContainer
55 68
   },
56 69
   created () {
70
+    this.EmptyCurrentShopCustomer()
57 71
   },
58 72
   mounted () {
59 73
     this.$nextTick(() => {
60 74
     })
61 75
   },
62 76
   methods: {
77
+    ...mapUserMutations([
78
+      'EmptyCurrentShopCustomer'
79
+    ]),
80
+    ...mapUserActions([
81
+      'GetShopCustomer'
82
+    ]),
83
+    Init (done = () => { }) { // 初始化
84
+      this.EmptyCurrentShopCustomer()
85
+      this.PageData.pageNum = 1
86
+      this.HasNextPage = true
87
+      this.DataLock = false
88
+      this.ToGetPageList(done)
89
+    },
90
+    ToGetPageList (done = () => { }) { // 获取页面列表
91
+      if (this.HasNextPage) {
92
+        this.GetShopCustomer({ queryData: { ...this.PageData, from: 'order' } }).then((res) => {
93
+          this.HasNextPage = res.data.data.total > this.CurrentShopCustomer.length
94
+          done()
95
+        }).catch(() => {
96
+          done()
97
+        })
98
+      }
99
+    },
100
+    Infinite (done) { // 上拉加载
101
+      this.Timer = window.setTimeout(() => {
102
+        if (this.HasNextPage) {
103
+          this.PageData.pageNum += 1
104
+          this.ToGetPageList(done)
105
+        } else {
106
+          this.$refs.MyScroller.finishInfinite(true)
107
+        }
108
+      }, 1000)
109
+    },
63 110
     Refresh (done) { // 页面下拉刷新
64
-      window.setTimeout(() => {
111
+      if (!this.DataLock) {
112
+        this.Init(done)
113
+      } else {
65 114
         done()
66
-      }, 1000)
115
+      }
67 116
     }
68 117
   }
69 118
 }

+ 73
- 12
src/pages/index/ShouYe/index.vue Ver arquivo

@@ -1,6 +1,6 @@
1 1
 <template>
2 2
   <div class="Page">
3
-    <MainPageContainer :MainHeaderTitle="`订单管理`" :MainTabBarActiveId="1" :ShowMainHeader="true" :ShowMainTabBar="true" :ShowMainHeaderMore="true" :MainHeaderMoreIcon="`icondaojishi`" :MainHeaderMoreText="`全部彩种`" :MainHeaderMoreClick="() => { $router.push({ name: 'DingDanChaXun' }) }">
3
+    <MainPageContainer :MainHeaderTitle="`订单管理`" :MainTabBarActiveId="1" :ShowMainHeader="true" :ShowMainTabBar="true">
4 4
       <div class="PageContainer flex-v">
5 5
         <a class="flex-h">
6 6
           <i class="iconfont icontongzhi"></i>
@@ -11,19 +11,29 @@
11 11
         <!-- 内容 -->
12 12
         <div class="flex-item">
13 13
           <div>
14
-            <div class="Content">
15
-              <scroller :on-refresh="Refresh">
14
+            <div class="Content" v-if="UserInfo !== null">
15
+              <scroller :on-refresh="Refresh" :on-infinite="Infinite" ref="MyScroller">
16 16
                 <div class="Container">
17 17
                   <ul>
18
-                    <li v-for="(item, index) in 15" :key="index">
18
+                    <li v-for="(item, index) in CurrentShopOrderList" :key="index">
19 19
                       <div class="Res">
20 20
                         <div class="Num flex-h">
21 21
                           <div class="Icon">
22
-                            <img src="../../../assets/img/icon5.png" class="centerLabel contain" alt="">
22
+                            <img v-if="item.customerBetting.lotteryId === 'double-color'" src="../../../assets/img/icon5.png" class="centerLabel contain" alt="">
23
+                            <img v-if="item.customerBetting.lotteryId === 'lottery'" src="../../../assets/img/icon4.png" class="centerLabel contain" alt="">
24
+                            <img v-if="item.customerBetting.lotteryId === 'p5'" src="../../../assets/img/icon2.png" class="centerLabel contain" alt="">
25
+                            <img v-if="item.customerBetting.lotteryId === 'p3'" src="../../../assets/img/icon7.png" class="centerLabel contain" alt="">
26
+                            <img v-if="item.customerBetting.lotteryId === 'football'" src="../../../assets/img/icon3.png" class="centerLabel contain" alt="">
27
+                            <img v-if="item.customerBetting.lotteryId === 'basketball'" src="../../../assets/img/icon6.png" class="centerLabel contain" alt="">
23 28
                           </div>
24
-                          <span>双色球</span>
29
+                          <span v-if="item.customerBetting.lotteryId === 'double-color'">双色球</span>
30
+                          <span v-if="item.customerBetting.lotteryId === 'lottery'">大乐透</span>
31
+                          <span v-if="item.customerBetting.lotteryId === 'p5'">排列5</span>
32
+                          <span v-if="item.customerBetting.lotteryId === 'p3'">排列3</span>
33
+                          <span v-if="item.customerBetting.lotteryId === 'football'">足球</span>
34
+                          <span v-if="item.customerBetting.lotteryId === 'basketball'">篮球</span>
25 35
                           <div class="flex-item">
26
-                            <ul>
36
+                            <ul v-if="item.customerBetting.lotteryId === 'lottery' || item.customerBetting.lotteryId === 'double-color'">
27 37
                               <li>01</li>
28 38
                               <li>01</li>
29 39
                               <li>01</li>
@@ -32,12 +42,14 @@
32 42
                               <li class="active">01</li>
33 43
                               <li class="active">01</li>
34 44
                             </ul>
45
+                            <span v-if="item.customerBetting.lotteryId === 'football' || item.customerBetting.lotteryId === 'basketball'">{{item.customerBetting.planName}} 预计奖金:{{item.customerBetting.expectedEarning}}</span>
35 46
                           </div>
36 47
                         </div>
37 48
                         <div class="Count flex-h">
38
-                          <span class="flex-item"><em>1</em>注<em>1</em>倍<em>2.00</em>元</span>
39
-                          <span>第202076期</span>
40
-                          <span>2020-08-14 18:43:22</span>
49
+                          <span class="flex-item" v-if="item.customerBetting.lotteryId !== 'football' && item.customerBetting.lotteryId !== 'basketball'"><em>1</em>注<em>1</em>倍<em>2.00</em>元</span>
50
+                          <span class="flex-item" v-else>{{item.customerBetting.notesNum}}注{{item.customerBetting.totalPrice}}元</span>
51
+                          <span v-if="item.customerBetting.lotteryId !== 'football' && item.customerBetting.lotteryId !== 'basketball'">第202076期</span>
52
+                          <span>{{ToolClass.DateFormat(item.customerBetting.createDate)}}</span>
41 53
                         </div>
42 54
                       </div>
43 55
                       <div class="Time flex-h">
@@ -58,28 +70,77 @@
58 70
 
59 71
 <script>
60 72
 import MainPageContainer from '../../../components/common/MainPageContainer'
73
+import { createNamespacedHelpers } from 'vuex'
74
+const { mapState: mapUserState, mapActions: mapUserActions, mapMutations: mapUserMutations } = createNamespacedHelpers('user')
61 75
 export default {
62 76
   name: 'index',
63 77
   data () {
64 78
     return {
79
+      PageData: {
80
+        pageNum: 0,
81
+        pageSize: 10
82
+      },
83
+      Timer: null,
84
+      HasNextPage: true,
85
+      DataLock: false
65 86
     }
66 87
   },
67 88
   computed: {
89
+    ...mapUserState({
90
+      UserInfo: x => x.UserInfo,
91
+      CurrentShopOrderList: x => x.CurrentShopOrderList
92
+    })
68 93
   },
69 94
   components: {
70 95
     MainPageContainer
71 96
   },
72 97
   created () {
98
+    this.EmptyCurrentShopOrderList()
73 99
   },
74 100
   mounted () {
75 101
     this.$nextTick(() => {
76 102
     })
77 103
   },
78 104
   methods: {
105
+    ...mapUserMutations([
106
+      'EmptyCurrentShopOrderList'
107
+    ]),
108
+    ...mapUserActions([
109
+      'GetCurrentShopOrderList'
110
+    ]),
111
+    Init (done = () => { }) { // 初始化
112
+      this.EmptyCurrentShopOrderList()
113
+      this.PageData.pageNum = 1
114
+      this.HasNextPage = true
115
+      this.DataLock = false
116
+      this.ToGetPageList(done)
117
+    },
118
+    ToGetPageList (done = () => { }) { // 获取页面列表
119
+      if (this.HasNextPage) {
120
+        this.GetCurrentShopOrderList({ queryData: { ...this.PageData } }).then((res) => {
121
+          this.HasNextPage = res.data.data.total > this.CurrentShopOrderList.length
122
+          done()
123
+        }).catch(() => {
124
+          done()
125
+        })
126
+      }
127
+    },
128
+    Infinite (done) { // 上拉加载
129
+      this.Timer = window.setTimeout(() => {
130
+        if (this.HasNextPage) {
131
+          this.PageData.pageNum += 1
132
+          this.ToGetPageList(done)
133
+        } else {
134
+          this.$refs.MyScroller.finishInfinite(true)
135
+        }
136
+      }, 1000)
137
+    },
79 138
     Refresh (done) { // 页面下拉刷新
80
-      window.setTimeout(() => {
139
+      if (!this.DataLock) {
140
+        this.Init(done)
141
+      } else {
81 142
         done()
82
-      }, 1000)
143
+      }
83 144
     }
84 145
   }
85 146
 }

+ 8
- 0
src/pages/index/ShouYe/page.scss Ver arquivo

@@ -72,6 +72,14 @@
72 72
                       margin-right: 0.1rem;
73 73
                     }
74 74
                     > .flex-item {
75
+                      > span {
76
+                        display: block;
77
+                        font-size: 0.1rem;
78
+                        line-height: 0.2rem;
79
+                        white-space: nowrap;
80
+                        overflow: hidden;
81
+                        text-overflow: ellipsis;
82
+                      }
75 83
                       > ul {
76 84
                         width: 100%;
77 85
                         font-size: 0;

+ 45
- 0
src/store/user/index.js Ver arquivo

@@ -4,6 +4,10 @@ import ToolClass from '../../util/PublicMethod'
4 4
 export default {
5 5
   namespaced: true,
6 6
   state: {
7
+    CurrentShopCustomer: [], // 当前店铺顾客列表
8
+    CurrentShopAllCustomer: [], // 当前店铺所有顾客列表
9
+    CurrentShopOrderList: [], // 当前店铺订单列表
10
+    CurrentShopInfo: null, // 当前店铺信息
7 11
     UserInfo: null, // 用户信息
8 12
     UserOrderList: [ // 用户订单
9 13
       { createDate: '2020-08-14  15:10:20', dateNum: '202076期', type: '超级大乐透', amount: 2, id: 1, orderNum: 'TE202008140000146179970', status: '已撤单' },
@@ -41,6 +45,27 @@ export default {
41 45
     },
42 46
     EmptyUserInfo (state) { // 清空用户信息
43 47
       state.UserInfo = null
48
+    },
49
+    UpdateCurrentShopInfo (state, data) { // 更新当前店铺信息
50
+      state.CurrentShopInfo = data || null
51
+    },
52
+    UpdateCurrentShopOrderList (state, data) { // 更新当前店铺订单列表
53
+      state.CurrentShopOrderList = state.CurrentShopOrderList.concat(data.records || [])
54
+    },
55
+    EmptyCurrentShopOrderList (state) { // 清空当前店铺订单列表
56
+      state.CurrentShopOrderList = []
57
+    },
58
+    UpdateCurrentShopCustomer (state, data) { // 更新当前店铺顾客列表
59
+      state.CurrentShopCustomer = state.CurrentShopCustomer.concat(data.records || [])
60
+    },
61
+    EmptyCurrentShopCustomer (state) { // 清空当前店铺顾客列表
62
+      state.CurrentShopCustomer = []
63
+    },
64
+    UpdateCurrentShopAllCustomer (state, data) { // 更新当前店铺所有顾客列表
65
+      state.CurrentShopAllCustomer = state.CurrentShopAllCustomer.concat(data.records || [])
66
+    },
67
+    EmptyCurrentShopAllCustomer (state) { // 清空当前店铺所有顾客列表
68
+      state.CurrentShopAllCustomer = []
44 69
     }
45 70
   },
46 71
   actions: {
@@ -48,6 +73,26 @@ export default {
48 73
       return new Promise((resolve, reject) => {
49 74
         ToolClass.Axios(resolve, reject, Api.SignIn, context, payload, 1000, 'UpdateUserInfo')
50 75
       })
76
+    },
77
+    GetCurrentShopInfo (context, payload) { // 获取当前店铺信息
78
+      return new Promise((resolve, reject) => {
79
+        ToolClass.Axios(resolve, reject, Api.GetCurrentShopInfo, context, payload, 1000, 'UpdateCurrentShopInfo')
80
+      })
81
+    },
82
+    GetCurrentShopOrderList (context, payload) { // 获取当前店铺订单列表
83
+      return new Promise((resolve, reject) => {
84
+        ToolClass.Axios(resolve, reject, Api.GetCurrentShopOrderList, context, payload, 1000, 'UpdateCurrentShopOrderList')
85
+      })
86
+    },
87
+    GetShopCustomer (context, payload) { // 获取当前店铺用户列表
88
+      return new Promise((resolve, reject) => {
89
+        ToolClass.Axios(resolve, reject, Api.GetShopCustomer, context, payload, 1000, 'UpdateCurrentShopCustomer')
90
+      })
91
+    },
92
+    GetShopAllCustomer (context, payload) { // 获取当前店铺所有用户列表
93
+      return new Promise((resolve, reject) => {
94
+        ToolClass.Axios(resolve, reject, Api.GetShopCustomer, context, payload, 1000, 'UpdateCurrentShopAllCustomer')
95
+      })
51 96
     }
52 97
   }
53 98
 }

+ 12
- 0
src/util/Api.js Ver arquivo

@@ -5,6 +5,18 @@ const $api = {
5 5
   SignIn: { // 登录
6 6
     method: 'post',
7 7
     url: `${prefix}/shop/login`
8
+  },
9
+  GetCurrentShopInfo: { // 获取当前店铺信息
10
+    method: 'get',
11
+    url: `${prefix}/shop/current`
12
+  },
13
+  GetCurrentShopOrderList: { // 获取当前店铺订单列表
14
+    method: 'get',
15
+    url: `${prefix}/shop/order`
16
+  },
17
+  GetShopCustomer: { // 获取店铺用户列表
18
+    method: 'get',
19
+    url: `${prefix}/shop/customer`
8 20
   }
9 21
 }
10 22
 

+ 31
- 7
src/util/PublicMethod.js Ver arquivo

@@ -1,12 +1,36 @@
1 1
 /* eslint-disable */
2 2
 import Axios from 'axios'
3
+import qs from 'qs'
3 4
 const ToolClass = {
4 5
   Axios (resolve, reject, target, context, payload = {}, code = 0, commit = null, params = null, hasdata = false) { // Axios
6
+    let Data = null
7
+    let Url = null
8
+    if (payload.urlData !== undefined) {
9
+      Url = this.ReplaceURLParams(target.url, payload.urlData)
10
+    } else {
11
+      Url = target.url
12
+    }
13
+    if (payload.queryData !== undefined) {
14
+      Url += '?' + qs.stringify(payload.queryData)
15
+    }
16
+    if (payload.data !== undefined) {
17
+      Data = payload.data
18
+    }
19
+    let Header = {}
20
+    if (window.localStorage.Jwt !== undefined && window.localStorage.JwtTime !== undefined && window.localStorage.JwtTime + 24 * 60 * 60 * 1000 >= Date.now()) { // 本地获取token
21
+      Header['x-authorization-jwt'] = window.localStorage.Jwt
22
+    }
5 23
     Axios({
6 24
       method: target.method,
7
-      url: target.url,
8
-      ...payload
25
+      url: Url,
26
+      data: { ...Data },
27
+      headers: { ...Header }
9 28
     }).then(res => {
29
+      const token = res.headers['x-authorization-jwt']
30
+      if (token) { // 更新本地存储token
31
+        window.localStorage.Jwt = token
32
+        window.localStorage.JwtTime = Date.now()
33
+      }
10 34
       if (res.data.code - 0 === code - 0) {
11 35
         if (commit !== null) {
12 36
           context.commit(commit, params === null ? res.data.data : hasdata ? { ...params, data: res.data.data } : params)
@@ -47,14 +71,14 @@ const ToolClass = {
47 71
     return false
48 72
   },
49 73
   DateFormat (timestamp) { // 格式化时间
50
-    let Date = new Date(timestamp - 0)
74
+    let aDate = new Date(timestamp)
51 75
     let yy = new Date(timestamp).getFullYear()
52 76
     let mm = new Date(timestamp).getMonth() + 1
53 77
     let dd = new Date(timestamp).getDate()
54
-    let hh = Date.getHours()
55
-    let min = Date.getMinutes()
56
-    let ss = Date.getSeconds()
57
-    return `${yy}-${mm}-${dd} ${hh}:${min}:${ss}`
78
+    let hh = aDate.getHours()
79
+    let min = aDate.getMinutes()
80
+    let ss = aDate.getSeconds()
81
+    return `${yy}-${mm > 9 ? mm : `0${mm}`}-${dd > 9 ? dd : `0${dd}`} ${hh > 9 ? hh : `0${hh}`}:${min > 9 ? min : `0${min}`}:${ss > 9 ? ss : `0${ss}`}`
58 82
   },
59 83
   WindowClick (callback) { // window点击事件
60 84
     let WindowClickFn = window.onclick