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