Blame view
src/store/modules/address.js
2.03 KB
7d6833f2c 地址列表 |
1 2 |
import urlAlias from '../url' import request from '../request' |
323398550 若干功能添加 |
3 |
const { editAddress, addressList, getAddress, getDefaultAddress } = urlAlias |
7d6833f2c 地址列表 |
4 |
|
323398550 若干功能添加 |
5 |
const state = { list: [], detail: {}, defaultInfo: {} } |
7d6833f2c 地址列表 |
6 7 8 9 10 11 12 |
const mutations = { LIST: (state, list) => { state.list = list }, DETAILS: (state, details) => { state.details = details |
323398550 若干功能添加 |
13 14 15 |
}, DEFAULT: (state, data) => { state.defaultInfo = data |
b38a27f3e 详情页样式修改 |
16 |
}, |
7d6833f2c 地址列表 |
17 18 19 20 |
} const actions = { edit(mutations, param, success) { |
4e9d88ff7 新建地址修改 |
21 |
return new Promise((resolve) => request({ |
7d6833f2c 地址列表 |
22 23 |
url: editAddress, data: param, |
4e9d88ff7 新建地址修改 |
24 25 26 |
success: () => { resolve() }, |
7d6833f2c 地址列表 |
27 28 29 |
fail: () => { uni.showModal({ content: '编辑失败', |
b38a27f3e 详情页样式修改 |
30 |
showCancel: false, |
7d6833f2c 地址列表 |
31 32 33 34 |
}) }, complete: (res) => { console.log('complete status === > ', res) |
b38a27f3e 详情页样式修改 |
35 |
}, |
4e9d88ff7 新建地址修改 |
36 |
})) |
7d6833f2c 地址列表 |
37 |
}, |
1b4b4938a auto commit the c... |
38 |
list({ commit },param) { |
7d6833f2c 地址列表 |
39 40 |
request({ url: addressList, |
1b4b4938a auto commit the c... |
41 |
data: param, |
7d6833f2c 地址列表 |
42 |
success: (res) => { |
1b4b4938a auto commit the c... |
43 |
commit('LIST', res.data.data.list) |
7d6833f2c 地址列表 |
44 45 46 47 |
}, fail: () => { uni.showModal({ content: '获取地址列表失败', |
b38a27f3e 详情页样式修改 |
48 |
showCancel: false, |
7d6833f2c 地址列表 |
49 |
}) |
b38a27f3e 详情页样式修改 |
50 |
}, |
7d6833f2c 地址列表 |
51 52 |
}) }, |
323398550 若干功能添加 |
53 |
details({ commit }, param) { |
7d6833f2c 地址列表 |
54 55 56 57 58 |
return new Promise((resolve, reject) => request({ url: getAddress, data: param, success: (res) => { commit('DETAILS', res.data.data) |
323398550 若干功能添加 |
59 60 |
resolve({ code: res.data.code, |
b38a27f3e 详情页样式修改 |
61 |
data: res.data.data, |
323398550 若干功能添加 |
62 |
}) |
7d6833f2c 地址列表 |
63 64 65 66 |
}, fail: () => { uni.showModal({ content: '获取地址信息失败', |
b38a27f3e 详情页样式修改 |
67 |
showCancel: false, |
7d6833f2c 地址列表 |
68 |
}) |
b38a27f3e 详情页样式修改 |
69 |
}, |
7d6833f2c 地址列表 |
70 |
})) |
323398550 若干功能添加 |
71 72 73 74 75 76 77 78 |
}, default({ commit }, param) { return new Promise((resolve, reject) => request({ url: getDefaultAddress, data: param, success: (res) => { resolve({ code: res.data.code, |
b38a27f3e 详情页样式修改 |
79 |
data: res.data.data, |
323398550 若干功能添加 |
80 81 82 83 84 |
}) }, fail: () => { uni.showModal({ content: '获取默认地址信息失败', |
b38a27f3e 详情页样式修改 |
85 |
showCancel: false, |
323398550 若干功能添加 |
86 |
}) |
b38a27f3e 详情页样式修改 |
87 |
}, |
323398550 若干功能添加 |
88 |
})) |
b38a27f3e 详情页样式修改 |
89 |
}, |
7d6833f2c 地址列表 |
90 91 92 93 94 95 |
} export default { namespaced: true, state, mutations, |
b38a27f3e 详情页样式修改 |
96 |
actions, |
7d6833f2c 地址列表 |
97 |
} |