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