import urlAlias from '../url' import request from '../request' const { editAddress, addressList, getAddress } = urlAlias const state = { list: [], detail: {} } const mutations = { LIST: (state, list) => { state.list = list }, DETAILS: (state, details) => { state.details = details } } const actions = { edit(mutations, param, success) { request({ url: editAddress, data: param, success, fail: () => { uni.showModal({ content: '编辑失败', showCancel: false }) }, complete: (res) => { console.log('complete status === > ', res) } }) }, list({ commit }) { request({ url: addressList, success: (res) => { commit('LIST', res.data.data) }, fail: () => { uni.showModal({ content: '获取地址列表失败', showCancel: false }) } }) }, details({ commit }, param, execute) { return new Promise((resolve, reject) => request({ url: getAddress, data: param, success: (res) => { commit('DETAILS', res.data.data) resolve() }, fail: () => { uni.showModal({ content: '获取地址信息失败', showCancel: false }) } })) } } export default { namespaced: true, state, mutations, actions }