提交 af7814e2 编写于 作者: W WOSHIMAHAIFENG

补充支付示例

上级 029b61cc
...@@ -16,26 +16,42 @@ ...@@ -16,26 +16,42 @@
}, },
methods: { methods: {
pay() { pay() {
uni.requestPayment({ uni.showLoading({
provider: "alipay", title: "请求中..."
orderInfo: this.orderInfo, })
fail: (res : RequestPaymentFail) => { uni.request({
console.log(JSON.stringify(res)) url: 'https://demo.dcloud.net.cn/payment/alipay/?total=0.01',
const error = res as UniError method: 'GET',
this.errorCode = error.errCode timeout: 6000,
uni.showToast({ success: (res) => {
icon: 'error', this.orderInfo = JSON.stringify(res.data);
title: 'errorCode:' + this.errorCode console.log("====" + this.orderInfo)
}); uni.hideLoading()
uni.requestPayment({
provider: "alipay",
orderInfo: res.data as string,
fail: (res : RequestPaymentFail) => {
console.log(JSON.stringify(res))
const error = res as UniError
this.errorCode = error.errCode
uni.showToast({
icon: 'error',
title: 'errorCode:' + this.errorCode
});
},
success: (res : RequestPaymentSuccess) => {
console.log(JSON.stringify(res))
uni.showToast({
icon: 'success',
title: '支付成功'
});
}
} as RequestPaymentOptions)
}, },
success: (res : RequestPaymentSuccess) => { fail: () => {
console.log(JSON.stringify(res)) uni.hideLoading()
uni.showToast({ },
icon: 'success', });
title: '支付成功'
});
}
} as RequestPaymentOptions)
} }
} }
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册