|
@@ -9,7 +9,7 @@ import OrderMolded from "@/components/OrderMolded";
|
9
|
9
|
import Popup from "@/components/Popup";
|
10
|
10
|
import "./style.less";
|
11
|
11
|
import Taro, { useDidShow } from "@tarojs/taro";
|
12
|
|
-import { getShopPackageDetail } from "@/services/home";
|
|
12
|
+import { getPackageDetail } from "@/services/home";
|
13
|
13
|
import { saveOrder, getOrderSub, payOrder } from "@/services/payOrder";
|
14
|
14
|
import formatTime from "@/utils/formatTime";
|
15
|
15
|
|
|
@@ -17,7 +17,7 @@ export default withLayout((props) => {
|
17
|
17
|
const { router, person } = props;
|
18
|
18
|
const { packageId, orderId } = props.router.params;
|
19
|
19
|
|
20
|
|
- const [payInfo, setPayInfo] = useState()
|
|
20
|
+ const [payInfo, setPayInfo] = useState();
|
21
|
21
|
|
22
|
22
|
const [showDialog, setShowDialog] = useState(false);
|
23
|
23
|
// 是否已阅读协议
|
|
@@ -67,13 +67,16 @@ export default withLayout((props) => {
|
67
|
67
|
};
|
68
|
68
|
|
69
|
69
|
const requestPayment = (params) => {
|
70
|
|
- console.log(params, 'requestPayment')
|
|
70
|
+ console.log(params, "requestPayment");
|
|
71
|
+ Taro.hideLoading()
|
71
|
72
|
Taro.requestPayment({
|
72
|
73
|
...params,
|
73
|
74
|
package: params.packageValue,
|
74
|
75
|
success: () => {
|
75
|
|
- console.log("success");
|
76
|
|
- setPayInfo()
|
|
76
|
+ setPayInfo();
|
|
77
|
+ Taro.redirectTo({
|
|
78
|
+ url: "/pages/MineUserAll/AllOrder/index",
|
|
79
|
+ });
|
77
|
80
|
Taro.showToast({
|
78
|
81
|
title: "支付成功",
|
79
|
82
|
icon: "none",
|
|
@@ -89,14 +92,18 @@ export default withLayout((props) => {
|
89
|
92
|
});
|
90
|
93
|
},
|
91
|
94
|
});
|
92
|
|
- }
|
|
95
|
+ };
|
93
|
96
|
|
94
|
97
|
const onShowPay = (e) => {
|
95
|
98
|
if (agreement) {
|
96
|
99
|
if (payInfo) {
|
97
|
|
- requestPayment(payInfo)
|
98
|
|
- return
|
|
100
|
+ requestPayment(payInfo);
|
|
101
|
+ return;
|
99
|
102
|
}
|
|
103
|
+ Taro.showLoading({
|
|
104
|
+ title: '支付中',
|
|
105
|
+ })
|
|
106
|
+
|
100
|
107
|
if (packageId) {
|
101
|
108
|
saveOrder(
|
102
|
109
|
list.map((x) => {
|
|
@@ -107,14 +114,28 @@ export default withLayout((props) => {
|
107
|
114
|
};
|
108
|
115
|
})
|
109
|
116
|
).then((res) => {
|
110
|
|
- setPayInfo(res)
|
111
|
|
- requestPayment(res)
|
|
117
|
+ setPayInfo(res);
|
|
118
|
+ requestPayment(res);
|
|
119
|
+ }).catch(()=>{
|
|
120
|
+ Taro.hideLoading()
|
|
121
|
+ Taro.showToast({
|
|
122
|
+ title: "支付失败",
|
|
123
|
+ icon: "none",
|
|
124
|
+ duration: 2000,
|
|
125
|
+ });
|
112
|
126
|
});
|
113
|
127
|
}
|
114
|
128
|
if (orderId) {
|
115
|
129
|
payOrder(orderId).then((res) => {
|
116
|
|
- setPayInfo(res)
|
117
|
|
- requestPayment(res)
|
|
130
|
+ setPayInfo(res);
|
|
131
|
+ requestPayment(res);
|
|
132
|
+ }).catch(()=>{
|
|
133
|
+ Taro.hideLoading()
|
|
134
|
+ Taro.showToast({
|
|
135
|
+ title: "支付失败",
|
|
136
|
+ icon: "none",
|
|
137
|
+ duration: 2000,
|
|
138
|
+ });
|
118
|
139
|
});
|
119
|
140
|
}
|
120
|
141
|
} else {
|
|
@@ -128,7 +149,7 @@ export default withLayout((props) => {
|
128
|
149
|
|
129
|
150
|
useEffect(() => {
|
130
|
151
|
if (packageId) {
|
131
|
|
- getShopPackageDetail(packageId).then((res) => {
|
|
152
|
+ getPackageDetail(packageId).then((res) => {
|
132
|
153
|
setList([res]);
|
133
|
154
|
});
|
134
|
155
|
}
|