123456789101112131415161718192021222324252627282930313233343536373839 |
- Page({
- data: {
- navbarData: {
- showCapsule: 1,
- 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);
- }
- });
- }
- });
|