Blame view
src/store/modules/cart.js
2.73 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 22 23 24 25 26 27 28 |
MODI: (state, args) => { console.log('the num', state.cartList[args.index].num) console.log('mutations====>isadd', args) if (args.isadd) { state.cartList[args.index].num = args.num } else { state.cartList[args.index].num = args.num } console.log('the num', state.cartList[args.index].num) } |
7d2bdf29e 修改镜片选购逻辑 添加购物车和用户... |
29 |
|
058f060df 冲突修改 |
30 |
} |
7d2bdf29e 修改镜片选购逻辑 添加购物车和用户... |
31 32 |
const actions = { |
7d2bdf29e 修改镜片选购逻辑 添加购物车和用户... |
33 34 35 |
getCartList({ commit }, param) { request({ url: cartList, |
058f060df 冲突修改 |
36 |
data: param, |
7d2bdf29e 修改镜片选购逻辑 添加购物车和用户... |
37 |
success: (res) => { |
058f060df 冲突修改 |
38 39 40 41 42 |
console.log('cart===>接口数据', res.data.data) // const resData = { // ...res, // data, // } |
7d2bdf29e 修改镜片选购逻辑 添加购物车和用户... |
43 44 45 |
commit('INIT', res.data.data) }, fail: (res) => { |
058f060df 冲突修改 |
46 |
console.log('fail status === > ', res) |
7d2bdf29e 修改镜片选购逻辑 添加购物车和用户... |
47 48 |
}, complete: (res) => { |
058f060df 冲突修改 |
49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
console.log('complete status === > ', res) } }) }, modiCart({ commit }, param) { const args = Object.assign({ num: param.num }, param.args) delete param.args request({ url: cartModi, data: param, success: (res) => { console.log('modi-parm', param) commit('MODI', args) |
7d2bdf29e 修改镜片选购逻辑 添加购物车和用户... |
63 |
}, |
058f060df 冲突修改 |
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 108 109 110 |
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 修改镜片选购逻辑 添加购物车和用户... |
111 112 |
}) } |
058f060df 冲突修改 |
113 |
|
7d2bdf29e 修改镜片选购逻辑 添加购物车和用户... |
114 115 116 117 118 119 |
} export default { namespaced: true, state, mutations, |
058f060df 冲突修改 |
120 121 |
actions } |