Blame view
src/store/modules/cart.js
2.44 KB
058f060df 冲突修改 |
1 2 |
import urlAlias from '../url' import request from '../request' |
7d2bdf29e 修改镜片选购逻辑 添加购物车和用户... |
3 |
|
058f060df 冲突修改 |
4 |
const { cartList, cartModi, cartDel, cartAdd } = urlAlias |
7d2bdf29e 修改镜片选购逻辑 添加购物车和用户... |
5 6 |
const state = { |
b38a27f3e 详情页样式修改 |
7 |
cartList: [], |
cc196c33c 购物车和用户推荐接口渲染 |
8 |
} |
7d2bdf29e 修改镜片选购逻辑 添加购物车和用户... |
9 10 |
const mutations = { INIT: (state, cartList) => { |
058f060df 冲突修改 |
11 |
state.cartList = cartList |
7d2bdf29e 修改镜片选购逻辑 添加购物车和用户... |
12 |
}, |
058f060df 冲突修改 |
13 14 15 16 17 |
DEL: (state, index) => { console.log('mutations====>', state.cartList) state.cartList.splice(index, 1) console.log('mutations====>index', index) // state.cartList=delList |
cc196c33c 购物车和用户推荐接口渲染 |
18 |
}, |
058f060df 冲突修改 |
19 |
MODI: (state, args) => { |
637a02b07 添加购物车 |
20 |
state.cartList[args.index].num = args.num |
b38a27f3e 详情页样式修改 |
21 |
}, |
7d2bdf29e 修改镜片选购逻辑 添加购物车和用户... |
22 |
|
058f060df 冲突修改 |
23 |
} |
7d2bdf29e 修改镜片选购逻辑 添加购物车和用户... |
24 25 |
const actions = { |
b38a27f3e 详情页样式修改 |
26 |
// 获取购物车列表 |
0bda9efec 购物车功能修改 |
27 28 |
getCartList({ commit }, param) { return new Promise((resolve) => request({ |
7d2bdf29e 修改镜片选购逻辑 添加购物车和用户... |
29 |
url: cartList, |
058f060df 冲突修改 |
30 |
data: param, |
7d2bdf29e 修改镜片选购逻辑 添加购物车和用户... |
31 |
success: (res) => { |
058f060df 冲突修改 |
32 |
console.log('cart===>接口数据', res.data.data) |
0bda9efec 购物车功能修改 |
33 34 |
commit('INIT', res.data.data) resolve(res.data.data) |
7d2bdf29e 修改镜片选购逻辑 添加购物车和用户... |
35 |
}, |
0bda9efec 购物车功能修改 |
36 |
})) |
058f060df 冲突修改 |
37 |
}, |
b38a27f3e 详情页样式修改 |
38 |
// 修改购物车数量 |
058f060df 冲突修改 |
39 |
modiCart({ commit }, param) { |
acc7ee230 购物车,用户推荐,新增验光逻辑修改 |
40 |
const arg = Object.assign({ num: param.num }, param.args) |
058f060df 冲突修改 |
41 |
delete param.args |
22e1420fa 弹窗组件修改 |
42 |
return new Promise((resolve) => request({ |
058f060df 冲突修改 |
43 44 45 46 |
url: cartModi, data: param, success: (res) => { console.log('modi-parm', param) |
acc7ee230 购物车,用户推荐,新增验光逻辑修改 |
47 |
commit('MODI', arg) |
7d2bdf29e 修改镜片选购逻辑 添加购物车和用户... |
48 |
}, |
058f060df 冲突修改 |
49 50 51 52 53 |
fail: (res) => { console.log('fail status === > ', res) }, complete: (res) => { console.log('complete status === > ', res) |
b38a27f3e 详情页样式修改 |
54 |
}, |
22e1420fa 弹窗组件修改 |
55 |
})) |
058f060df 冲突修改 |
56 |
}, |
b38a27f3e 详情页样式修改 |
57 |
// 删除购物车商品 |
058f060df 冲突修改 |
58 59 60 61 62 63 64 65 66 |
delCart({ commit }, param) { const arg = param.arg delete param.arg request({ url: cartDel, data: param, success: (res) => { console.log('del-parm', param) console.log('del-myparms==>', arg) |
058f060df 冲突修改 |
67 68 69 70 71 72 73 |
commit('DEL', arg) }, fail: (res) => { console.log('fail status === > ', res) }, complete: (res) => { console.log('complete status === > ', res) |
b38a27f3e 详情页样式修改 |
74 |
}, |
058f060df 冲突修改 |
75 76 |
}) }, |
b38a27f3e 详情页样式修改 |
77 |
// 添加到购物车 |
058f060df 冲突修改 |
78 79 |
addCart({ commit }, param) { console.log('请求接口开始') |
0bda9efec 购物车功能修改 |
80 |
return new Promise((resolve) => request({ |
058f060df 冲突修改 |
81 82 83 84 85 |
url: cartAdd, data: param, success: (res) => { console.log('add-parm', param) console.log('addcart===>res.data===>', res.data) |
0bda9efec 购物车功能修改 |
86 87 |
// commit('INIT', res.data.data) resolve(res.data) |
058f060df 冲突修改 |
88 89 |
}, fail: (res) => { |
0bda9efec 购物车功能修改 |
90 |
console.log('添加购物车失败 === > ', res) |
058f060df 冲突修改 |
91 92 |
}, complete: (res) => { |
0bda9efec 购物车功能修改 |
93 |
console.log('添加购物车完成 === > ', res) |
b38a27f3e 详情页样式修改 |
94 |
}, |
0bda9efec 购物车功能修改 |
95 |
})) |
b38a27f3e 详情页样式修改 |
96 |
}, |
7d2bdf29e 修改镜片选购逻辑 添加购物车和用户... |
97 98 99 100 101 102 |
} export default { namespaced: true, state, mutations, |
b38a27f3e 详情页样式修改 |
103 |
actions, |
058f060df 冲突修改 |
104 |
} |