Blame view
src/store/modules/order.js
1.51 KB
323398550 若干功能添加 |
1 2 |
import urlAlias from '../url' import request from '../request' |
089dce19d 支付修改 |
3 |
const { orderBuild, buyNow, pay } = urlAlias |
323398550 若干功能添加 |
4 |
|
87eade409 验光数据填充检测 |
5 |
const state = { list: [], param: {} } |
323398550 若干功能添加 |
6 7 8 9 10 11 12 |
const mutations = { LIST: (state, list) => { state.list = list }, SAVE: (state, param) => { state.param = param |
089dce19d 支付修改 |
13 |
}, |
323398550 若干功能添加 |
14 15 16 |
} const actions = { |
089dce19d 支付修改 |
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
// 立即购买->创建订单 buyNow({ commit }, param) { return new Promise((resolve) => request({ url: buyNow, data: param, success: (res) => { resolve(res) }, fail: () => { uni.showModal({ content: '创建订单失败', showCancel: false, }) }, })) }, // 购物车->创建订单 |
323398550 若干功能添加 |
34 35 36 37 38 |
build({ commit }, param) { return new Promise((resolve, reject) => request({ url: orderBuild, data: param, success: (res) => { |
089dce19d 支付修改 |
39 |
resolve(res.data) |
323398550 若干功能添加 |
40 41 42 43 |
}, fail: () => { uni.showModal({ content: '订单生成失败', |
089dce19d 支付修改 |
44 |
showCancel: false, |
323398550 若干功能添加 |
45 |
}) |
089dce19d 支付修改 |
46 |
}, |
323398550 若干功能添加 |
47 48 |
})) }, |
089dce19d 支付修改 |
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
// 支付 pay({ commit }, param) { return new Promise((resolve, reject) => request({ url: pay, data: param, success: (res) => { resolve(res.data) }, fail: () => { uni.showModal({ content: '订单生成失败', showCancel: false, }) }, })) }, // 储存创建订单参数 |
323398550 若干功能添加 |
66 67 68 |
saveParams({ commit }, param) { console.log('save', param) commit('SAVE', param) |
089dce19d 支付修改 |
69 |
}, |
323398550 若干功能添加 |
70 71 72 73 74 75 |
} export default { namespaced: true, state, mutations, |
089dce19d 支付修改 |
76 |
actions, |
323398550 若干功能添加 |
77 |
} |