pay.js
1.79 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
54
55
56
57
58
59
60
61
62
63
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
import { pair, payList, payWX, payResult } from "../api/pay/index"
// 支付
// 状态
const state = {
// 配对信息
pairData: {},
// 付款人列表
paylist: [],
// 微信跳转链接
WXurl: "",
// 结果数据
resultDate:"",
}
// 改变
const mutations = {
// 配对信息
GAINPAIR(state, data) {
state.pairData = data
},
// 付款人列表
GAINPAYLIST(state, data) {
state.paylist = data
},
// 微信支付
GAINPAYWX(state, data) {
state.WXurl = data
},
// 支付后结果
GAINPAYRESULT(state, data) {
state.resultDate = data
}
}
// 行动
const actions = {
// 配对成功获取数据
async gainPair({ commit }, data) {
let result = await pair(data)
console.log(result);
if (result.code == 200) {
commit("GAINPAIR", result.data)
} else {
return Promise.reject(result.message)
}
},
// 付款人列表
async gainPayList({ commit }, data) {
let result = await payList(data)
console.log(result);
if (result.code == 200) {
commit("GAINPAYLIST", result.data)
console.log(result.data);
}
},
// 微信支付
async gainPayWX({ commit }, data) {
let result = await payWX(data)
console.log(result);
if (result.code == 200) {
commit("GAINPAYWX", result.data)
}
},
// 支付后结果
async gainPayResult({ commit }, data) {
let result = await payResult(data)
console.log(result);
if (result.code == 200) {
commit("GAINPAYRESULT", result.data)
}
},
}
// 简化
const getters = {
}
// 导出
export default {
state,
mutations,
actions,
getters
}