Commit ea133e80 authored by Facius's avatar Facius

feat: 题库详情页面

parent 305eebad
...@@ -62,7 +62,10 @@ ...@@ -62,7 +62,10 @@
"path": "detail", "path": "detail",
"name": "learnDetail", "name": "learnDetail",
"style": { "style": {
"navigationBarTitleText": "题库详情" "navigationBarTitleText": "", // 题库详情
"navigationStyle": "custom",
"enablePullDownRefresh": false,
"disableScroll": true
} }
}, },
{ {
......
<template>
<view>
<u-button type="primary" @click="payOrder">微信支付测试</u-button>
</view>
</template>
<script>
import md5 from '@/common/md5.js'
export default {
components: {},
data() {
return {
lists: [
{
questionWarehouseId: 1,
amount: 0.01,
count: 1,
},
],
}
},
methods: {
payOrder() {
const data = {
instrtutionId: 1,
orders: JSON.stringify(this.lists),
openId: this.openId,
}
this.$u.api.payOrder(data).then((res) => {
this.pay(res)
})
},
pay(data) {
const timeStamp = String(Date.now())
const paySign = md5
.hexMD5(
`appId=wxd1d6eede324b0465&nonceStr=${data.nonce_str}&package=prepay_id=${data.prepay_id}&signType=MD5&timeStamp=${timeStamp}&key=weixiuhui20151a2b3c4d5e6f7g8h9ij`
)
.toUpperCase()
uni.requestPayment({
provider: 'wxpay',
timeStamp: timeStamp,
nonceStr: data.nonce_str,
package: `prepay_id=${data.prepay_id}`,
signType: 'MD5',
paySign: paySign,
success: (res) => {
console.log('success:' + JSON.stringify(res))
this.checkPayStatus(data.out_trade_no)
},
fail: (err) => {
console.log('fail:' + JSON.stringify(err))
if (err.errMsg === 'requestPayment:fail cancel') {
this.$u.toast('取消支付')
} else {
this.checkPayStatus(data.out_trade_no)
}
},
})
},
checkPayStatus(no) {
const params = {
outTradeNo: no
}
this.$u.api.payQuery(params).then(res => {
if (res.trade_state === 'SUCCESS') {
this.$u.toast('支付成功')
} else if (res.trade_state === 'NOTPAY') {
this.$u.toast('请稍后核实订单状态,不要重复发起支付')
} else if (res.trade_state === 'PAYERROR') {
this.$u.toast('支付失败')
} else {
this.$u.toast(res.trade_state_desc)
}
})
}
},
}
</script>
<style lang="scss" scoped></style>
This diff is collapsed.
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