details.js
1.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
import urlAlias from '../url'
import request from '../request'
const {
read,
} = urlAlias
const state = {
// 轮播图
carousel: [
'/static/img/detail/d9.png',
],
// 商品基本信息
goodsInfo: {
name: '暂无名称',
price: '暂无价格',
discountPrice: undefined,
tradeNumber: undefined,
},
}
const mutations = {
INIT: (state, { carousel, goodsInfo }) => {
state.carousel = carousel
state.goodsInfo = goodsInfo
},
}
const actions = {
details({ commit }, param) {
return new Promise((resolve, reject) => request({
url: read,
data: param,
success: ({ data: { data } }) => {
commit('INIT', {
carousel: data.pics,
goodsInfo: {
name: data.p_name,
price: data.priceArea.Min_Price,
discountPrice: data.priceArea.Min_Price - Number(data.priceArea.discount),
tradeNumber: data.trade_num,
},
})
resolve(data)
},
fail: (res) => {
console.log('fail status ===>', res)
},
}))
},
}
export default {
namespaced: true,
state,
mutations,
actions,
}