提交 af7814e2 编写于 作者: W WOSHIMAHAIFENG

补充支付示例

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