Blame view

src/store/modules/index.js 2.08 KB
c300654f9   范牧   首页部分功能
1
2
3
4
   import urlAlias from '../url';
   import request from '../request';
  
   const {
83e446d4d   Adam   修正订单数据
5
6
7
     category,
     shopList,
     search,
c300654f9   范牧   首页部分功能
8
   } = urlAlias;
83e446d4d   Adam   修正订单数据
9
10
11
12
   const state = {
     categoryList: [],
     list: []
   };
c300654f9   范牧   首页部分功能
13

83e446d4d   Adam   修正订单数据
14
15
16
17
18
19
20
21
   const mutations = {
     LIST: (state, list) => {
       state.list = list;
     },
     CATEGORY: (state, categoryList) => {
       state.categoryList = categoryList;
     }
   };
c300654f9   范牧   首页部分功能
22

83e446d4d   Adam   修正订单数据
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
   const actions = {
     category({
       commit
     }, param) {
       request({
         url: category,
         success: (res) => {
           console.log('category', res);
           let data = res.data.data;
           for (let i = 0; i <= data.length; i++) {
             if (data[i] && data[i].type !== 'filter') {
               data[i].type = 'hierarchy';
             }
           }
           data.unshift({
             type: "hierarchy",
             name: "全部",
             value: "all",
             isNoPull: true,
c300654f9   范牧   首页部分功能
42

83e446d4d   Adam   修正订单数据
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
           });
           commit('CATEGORY', data);
         },
         fail: (res) => {
           console.log("fail status === > ", res);
         },
         complete: (res) => {
           console.log("complete status === > ", res);
         },
       })
     },
     list({
       commit
     }, param) {
  
       request({
         url: shopList,
         success: (res) => {
           commit('LIST', res.data.data)
         },
         fail: (res) => {
           console.log("fail status === > ", res);
         },
         complete: (res) => {
           console.log("complete status === > ", res);
           state.isLoading = false;
         },
       })
     },
     search({
       commit
     }, {
       params,
       keyword
     }) {
       const uid = uni.getStorageSync('uid');
       console.log("params", params, keyword);
       request({
         url: search,
         data: {
           params: JSON.stringify(params),
           uid,
           way: 1,
           keyword,
         },
         success: (res) => {
           commit('LIST', res.data.data);
         },
         fail: (res) => {
           console.log("fail status === > ", res);
         },
         complete: (res) => {
           console.log("complete status === > ", res);
         },
       })
     },
   };
  
   export default {
     namespaced: true,
     state,
     mutations,
     actions,
   };