pay.js
1.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
import {pay,lotteryOrder} from "@/api/pay/index.js"
const state = {
// 订单id
orderId:"",
// 支付状态
payStatus:"",
// 获得的商品
commoditys:[],
// 订单号
orderSn:"",
//回收需要的id
returnOrderId:""
};
const mutations = {
// 存储订单 id
PAYMENT(state,data){
state.orderId = data.order.id
state.orderSn = data.payResponse.aliPayRes
},
// 存储订单数据 存储支付状态
GAINORDER(state,data){
state.payStatus=data.payStatus
state.commoditys=data.orderItemList
state.returnOrderId = data.id
}
};
const actions = {
//支付宝支付
async payment({commit},data){
let result = await pay(data)
console.log(result);
if (result.code == 200) {
commit("PAYMENT", result.data)
}
},
// 抽奖后订单
async gainOrder({commit},data){
let result = await lotteryOrder(data)
console.log(result);
if (result.code == 200) {
commit("GAINORDER", result.data)
}
}
};
const getters = {
}
export default {
state,
mutations,
actions,
getters
}