read.js
1.22 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 = {
goodInfo: {}
}
const mutations = {
INIT: (state, goodInfo) => {
state.goodInfo = goodInfo
}
}
const actions = {
fetch({ commit }, param) {
// 由于购物车和用户推荐的价格要根据sk_id来获取
const arg=Object.assign({},param)
delete param.sk_id
return new Promise((resolve, reject) => request({
url: read,
data: param,
success: (res) => {
console.log('readParm====>',arg)
console.log('read====>',res.data.data)
// 用一个新的对象来接收sk_id找的值
const Res=Object.assign({},res.data.data)
if(arg.sk_id!=undefined){
for (let i = 0; i < res.data.data.skuList.length; i++) {
if(res.data.data.skuList[i].sk_id==arg.sk_id){
Res.p_sale_price= res.data.data.skuList[i].real_price
console.log('陈工了')
}
}
}
console.log(Res)
commit('INIT', Res)
resolve()
},
fail: (res) => {
console.log('fail status === > ', res)
},
complete: (res) => {
console.log('complete status === > ', res)
}
}))
}
}
export default {
namespaced: true,
state,
mutations,
actions
}