Blame view
src/store/modules/index.js
2.43 KB
c300654f9 首页部分功能 |
1 2 3 4 |
import urlAlias from '../url'; import request from '../request'; const { |
83e446d4d 修正订单数据 |
5 6 7 |
category, shopList, search, |
c300654f9 首页部分功能 |
8 |
} = urlAlias; |
53bcba4f8 文件分包,首页添加骨架屏幕 |
9 10 11 12 13 14 15 16 17 18 |
let initData = {"name":"志平防蓝光-防辐射电脑网课眼镜","id":"9","imgurl":"", "price":0,"trade_num":"102","rsSon":{"pic":"9_FDB33D.jpg","model_pic":null,"in_price":"6000","sku_value":"80_83", "discount":"45","kc":"0","sku_name":"1.56非球面防蓝光_黑透+蓝纹","Max_Price":158,"Min_Price":99}} var initArr = [1,2,3,4,5,6,7,8] let list = [] initArr.forEach(function (value) { list.push(initData) }); //初始化数据是为了显示默认骨架 |
83e446d4d 修正订单数据 |
19 20 |
const state = { categoryList: [], |
53bcba4f8 文件分包,首页添加骨架屏幕 |
21 |
list: list |
83e446d4d 修正订单数据 |
22 |
}; |
53bcba4f8 文件分包,首页添加骨架屏幕 |
23 |
|
83e446d4d 修正订单数据 |
24 25 26 27 28 29 30 31 |
const mutations = { LIST: (state, list) => { state.list = list; }, CATEGORY: (state, categoryList) => { state.categoryList = categoryList; } }; |
c300654f9 首页部分功能 |
32 |
|
83e446d4d 修正订单数据 |
33 34 35 36 |
const actions = { category({ commit }, param) { |
53bcba4f8 文件分包,首页添加骨架屏幕 |
37 |
return new Promise((resolve) => request({ |
83e446d4d 修正订单数据 |
38 39 |
url: category, success: (res) => { |
83e446d4d 修正订单数据 |
40 41 42 43 44 45 46 47 48 49 50 |
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, |
83e446d4d 修正订单数据 |
51 52 |
}); commit('CATEGORY', data); |
53bcba4f8 文件分包,首页添加骨架屏幕 |
53 54 |
resolve(data) console.log('3333') |
83e446d4d 修正订单数据 |
55 56 57 |
}, fail: (res) => { console.log("fail status === > ", res); |
53bcba4f8 文件分包,首页添加骨架屏幕 |
58 59 60 |
} })) |
83e446d4d 修正订单数据 |
61 62 63 64 |
}, list({ commit }, param) { |
53bcba4f8 文件分包,首页添加骨架屏幕 |
65 |
return new Promise((resolve) => request({ |
83e446d4d 修正订单数据 |
66 67 68 |
url: shopList, success: (res) => { commit('LIST', res.data.data) |
53bcba4f8 文件分包,首页添加骨架屏幕 |
69 70 |
resolve(res.data) console.log('3333') |
83e446d4d 修正订单数据 |
71 72 73 74 75 |
}, fail: (res) => { console.log("fail status === > ", res); }, complete: (res) => { |
83e446d4d 修正订单数据 |
76 77 |
state.isLoading = false; }, |
53bcba4f8 文件分包,首页添加骨架屏幕 |
78 |
})) |
83e446d4d 修正订单数据 |
79 80 81 82 83 84 85 |
}, search({ commit }, { params, keyword }) { |
53bcba4f8 文件分包,首页添加骨架屏幕 |
86 87 |
const uid = uni.getStorageSync('uid'); return new Promise((resolve) => request({ |
83e446d4d 修正订单数据 |
88 89 90 91 92 93 94 95 96 |
url: search, data: { params: JSON.stringify(params), uid, way: 1, keyword, }, success: (res) => { commit('LIST', res.data.data); |
53bcba4f8 文件分包,首页添加骨架屏幕 |
97 |
resolve(res.data) |
83e446d4d 修正订单数据 |
98 99 100 |
}, fail: (res) => { console.log("fail status === > ", res); |
53bcba4f8 文件分包,首页添加骨架屏幕 |
101 102 103 |
} })) |
83e446d4d 修正订单数据 |
104 105 106 107 108 109 110 111 112 |
}, }; export default { namespaced: true, state, mutations, actions, }; |