Commit 9f48015c authored by liwei's avatar liwei

对接了支付接口(暂定,缺参数)

parent 80fab316
......@@ -26,3 +26,15 @@ export function addApplication(data) {
})
}
// 支付
export function pay(data) {
return request({
url: '/app/wxPay/pay',
method: 'post',
data,
headers: {
'Content-Type': 'application/json;charset=UTF-8',
isToken: true
}
})
}
......@@ -50,7 +50,7 @@
</template>
<script>
import {activityDetail,addApplication} from "../api/activity/index.js"
import {activityDetail, addApplication, pay} from "../api/activity/index.js"
export default {
data() {
return {
......@@ -109,11 +109,75 @@
// 添加订单(报名)
addApplication(params).then(res => {
if (res.data.code === 200) {
this.show = false
uni.showToast({
title: '报名成功',
icon: 'success'
})
const activityId = this.activityId
const orderId = res.data.data.businessId
// 如果支付总金额大于0,则进行支付,反之则不进行支付
// if(this.totalprice > 0){
// 支付
const payquery = {
orderId: orderId,
activityId: this.activityId
}
pay(payquery).then(res => {
console.log("支付参数", res)
console.log("测试支付", res.data.errMsg)
if (res.data.errMsg === 'OK') {
if (!res.data.data.nonceStr) {
uni.showToast({
title: '下单失败,请稍后重试',
icon: 'none'
})
} else {
// 调取微信支付窗口
uni.requestPayment({
provider: "wxpay",
appId: res.data.appid, // 微信小程序appid
timeStamp: res.data.timeStamp, // 时间戳
nonceStr: res.data.nonceStr, // 随机字符串
package: res.data.package,
signType: "MD5", // 签名算法
paySign: res.data.paySign, // 签名
success(res) {
uni.showToast({
title: '支付成功',
icon: 'success'
})
this.show = false
uni.navigateTo({
url:'/my/myorder/index'
})
},
fail(e) {
console.log("支付失败", e)
uni.showToast({
title: '支付已取消',
icon: 'none'
})
const orderStatus = {
orderId: orderId,
activityId: activityId
}
// 修改订单状态为待支付
// updateorderstatus(orderStatus).then(res=>{
// console.log('修改订单状态',res)
// })
}
});
}
} else {
uni.showToast({
title: '下单失败',
icon: 'none'
})
}
})
// }else{
// uni.showToast({
// title: '支付成功',
// icon: 'success'
// })
// }
} else if(res.data.code !== 200){
uni.showToast({
title: res.data.message,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment