|
@@ -5,4 +5,35 @@ Page({
|
|
title: '内容会员',
|
|
title: '内容会员',
|
|
},
|
|
},
|
|
},
|
|
},
|
|
|
|
+
|
|
|
|
+ toBuy() {
|
|
|
|
+ wx.request({
|
|
|
|
+ url: 'https://yourdomain.com/get-payment-params',
|
|
|
|
+ method: 'POST',
|
|
|
|
+ data: {
|
|
|
|
+ // 传递需要的参数,比如订单号等
|
|
|
|
+ },
|
|
|
|
+ success: (res) => {
|
|
|
|
+ if (res.data && res.data.success) {
|
|
|
|
+ const paymentParams = res.data.paymentParams;
|
|
|
|
+ wx.requestPayment({
|
|
|
|
+ ...paymentParams,
|
|
|
|
+ success: (res) => {
|
|
|
|
+ console.log('支付成功', res);
|
|
|
|
+ // 支付成功后的处理
|
|
|
|
+ },
|
|
|
|
+ fail: (err) => {
|
|
|
|
+ console.error('支付失败', err);
|
|
|
|
+ // 支付失败后的处理
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ } else {
|
|
|
|
+ console.error('获取支付参数失败', res);
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+ fail: (err) => {
|
|
|
|
+ console.error('请求支付参数失败', err);
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ }
|
|
});
|
|
});
|