Blame view
src/store/modules/cart.js
2.69 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 = { |
058f060df 冲突修改 |
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 24 |
console.log('the num', state.cartList[args.index].num) } |
7d2bdf29e 修改镜片选购逻辑 添加购物车和用户... |
25 |
|
058f060df 冲突修改 |
26 |
} |
7d2bdf29e 修改镜片选购逻辑 添加购物车和用户... |
27 28 |
const actions = { |
7d2bdf29e 修改镜片选购逻辑 添加购物车和用户... |
29 30 31 |
getCartList({ commit }, param) { request({ url: cartList, |
058f060df 冲突修改 |
32 |
data: param, |
7d2bdf29e 修改镜片选购逻辑 添加购物车和用户... |
33 |
success: (res) => { |
058f060df 冲突修改 |
34 35 36 37 38 |
console.log('cart===>接口数据', res.data.data) // const resData = { // ...res, // data, // } |
7d2bdf29e 修改镜片选购逻辑 添加购物车和用户... |
39 40 41 |
commit('INIT', res.data.data) }, fail: (res) => { |
058f060df 冲突修改 |
42 |
console.log('fail status === > ', res) |
7d2bdf29e 修改镜片选购逻辑 添加购物车和用户... |
43 44 |
}, complete: (res) => { |
058f060df 冲突修改 |
45 46 47 48 49 50 |
console.log('complete status === > ', res) } }) }, modiCart({ commit }, param) { |
acc7ee230 购物车,用户推荐,新增验光逻辑修改 |
51 |
const arg = Object.assign({ num: param.num }, param.args) |
058f060df 冲突修改 |
52 53 54 55 56 |
delete param.args request({ url: cartModi, data: param, success: (res) => { |
637a02b07 添加购物车 |
57 |
console.log('modiCart-res=====>', res.data) |
058f060df 冲突修改 |
58 |
console.log('modi-parm', param) |
acc7ee230 购物车,用户推荐,新增验光逻辑修改 |
59 |
commit('MODI', arg) |
7d2bdf29e 修改镜片选购逻辑 添加购物车和用户... |
60 |
}, |
058f060df 冲突修改 |
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 |
fail: (res) => { console.log('fail status === > ', res) }, complete: (res) => { console.log('complete status === > ', res) } }) }, 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) // console.log('deacart====>cartList',this.$store.state.cart.cartList) commit('DEL', arg) }, fail: (res) => { console.log('fail status === > ', res) }, complete: (res) => { console.log('complete status === > ', res) } }) }, 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) } |
7d2bdf29e 修改镜片选购逻辑 添加购物车和用户... |
108 109 |
}) } |
058f060df 冲突修改 |
110 |
|
7d2bdf29e 修改镜片选购逻辑 添加购物车和用户... |
111 112 113 114 115 116 |
} export default { namespaced: true, state, mutations, |
058f060df 冲突修改 |
117 118 |
actions } |