You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
175 lines
3.7 KiB
175 lines
3.7 KiB
<template>
|
|
<view></view>
|
|
</template>
|
|
|
|
<script>
|
|
export default {
|
|
data() {
|
|
return {
|
|
order_id: 0,
|
|
timesIndex: 0
|
|
}
|
|
},
|
|
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
|
|
return new Promise((resolve, rejecj) => {
|
|
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);
|
|
resolve(res.data);
|
|
if(res.data) {
|
|
that.payOnce();
|
|
}
|
|
// uni.showModal({
|
|
// title: '用户信息',
|
|
// content: JSON.stringify(res.data),
|
|
// confirmColor: '#1998FE',
|
|
// showCancel: false,
|
|
// success(res2) {
|
|
// if (res2.confirm) {
|
|
// that.payOnce();
|
|
// }
|
|
// }
|
|
// });
|
|
})
|
|
}
|
|
}
|
|
})
|
|
})
|
|
|
|
},
|
|
payOnce() {
|
|
let that = this
|
|
uni.showModal({
|
|
title: '订单id提示',
|
|
content: JSON.stringify(that.order_id),
|
|
showCancel: false,
|
|
});
|
|
that.$http(that.API.API_LF_PAY, {
|
|
id: that.order_id
|
|
}).then(res => {
|
|
uni.showModal({
|
|
title: '进入支付接口',
|
|
content: '',
|
|
showCancel: false,
|
|
});
|
|
|
|
uni.showModal({
|
|
title: '接口返回信息',
|
|
content: JSON.stringify(res),
|
|
showCancel: false,
|
|
});
|
|
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) => {
|
|
uni.showModal({
|
|
title: '支付成功提示',
|
|
content: JSON.stringify(res),
|
|
showCancel: false,
|
|
});
|
|
wx.navigateBackMiniProgram({
|
|
extraData: {
|
|
backPayState: true
|
|
},
|
|
success(res) {}
|
|
})
|
|
},
|
|
fail: (err) => {
|
|
uni.showModal({
|
|
title: '支付失败提示',
|
|
content: JSON.stringify(err),
|
|
showCancel: false,
|
|
});
|
|
wx.navigateBackMiniProgram({
|
|
extraData: {
|
|
backPayState: false
|
|
},
|
|
success(res) {}
|
|
})
|
|
},
|
|
})
|
|
}).catch(err => {
|
|
uni.showModal({
|
|
title: '接口报错',
|
|
content: JSON.stringify(err),
|
|
showCancel: false,
|
|
success(res2) {
|
|
if (res2.confirm) {
|
|
wx.navigateBackMiniProgram({
|
|
extraData: {
|
|
backPayState: false
|
|
},
|
|
success(res) {}
|
|
})
|
|
}
|
|
}
|
|
});
|
|
// uni.showModal({
|
|
// title: '提示',
|
|
// content: '支付获取订单失败',
|
|
// confirmColor: '#1998FE',
|
|
// showCancel: false,
|
|
// success(res2) {
|
|
// if (res2.confirm) {
|
|
// wx.navigateBackMiniProgram({
|
|
// extraData: {
|
|
// backPayState: false
|
|
// },
|
|
// 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>
|