|
|
<template></template>
<script> export default { data() { return { order_id: 0, timesIndex: 0, userInfo: {}, payErr: {}, paySuccecc: {} } }, onShow(e) { // this.order_id = uni.getStorageSync('order_id')
let that = this uni.$on('order_id',function(data){ that.order_id = data.msg if (that.order_id) { that.getUserProfile() } else { that.$msg('获取订单失败'); } }) }, methods: { // 获取用户信息
getUserProfile() { let that = this uni.login({ complete: result => { if (result.errMsg == 'login:ok') { let code = result.code; that.$http(that.API.API_WXLOGIN, { code }).then(res => { uni.setStorageSync('userinfo', res.data); that.userInfo = JSON.stringify(res.data) if(res.data) { uni.showModal({ title: '支付提示', content: '确认支付吗?', confirmColor: '#1998FE', showCancel: false, success(res2) { if (res2.confirm) { that.payOnce(); } } }); } }) } } })
}, payOnce() { let that = this; that.$http(that.API.API_LF_PAY, { id: that.order_id }).then(res => { uni.requestPayment({ orderInfo: res.data.order_num, timeStamp: res.data.timeStamp, nonceStr: res.data.nonceStr, package: res.data.package, signType: res.data.signType, paySign: res.data.paySign, success: (res) => { wx.navigateBackMiniProgram({ extraData: { backPayState: true, payorder_id: that.order_id }, success(res) {} }) }, fail: (err) => { wx.navigateBackMiniProgram({ extraData: { backPayState: false, payorder_id: that.order_id }, success(res) {} }) }, }) }).catch(err => { uni.showModal({ title: '提示', content: '支付获取订单失败', showCancel: false, success(res2) { if (res2.confirm) { wx.navigateBackMiniProgram({ extraData: { backPayState: false, payorder_id: that.order_id }, success(res) {} }) } } }); }) } } }</script>
<style> .btn { margin: 0; padding: 0; width: 212rpx; height: 82rpx; background-color: #1998FE; color: #FFFFFF; line-height: 80rpx; font-size: 32rpx; border-radius: 41rpx; }
.bref-box { text-overflow: -o-ellipsis-lastline; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }</style>
|