<template>
|
<view class="pay-success-page">
|
<view class="page-body">
|
<view class="success-block">
|
<view class="success-line">
|
<view class="success-icon">
|
<image src="/static/icon/diancan_ic_success@2x.png" mode="widthFix"></image>
|
</view>
|
<text class="success-title">支付成功</text>
|
</view>
|
<text class="success-desc">可在个人中心“我的订单”页面查看</text>
|
<view class="action-row">
|
<view class="ghost-btn" @tap="goHome">回到首页</view>
|
<view class="outline-btn" @tap="viewOrder">查看订单</view>
|
</view>
|
</view>
|
|
<view class="pickup-card">
|
<text class="pickup-title">核销码</text>
|
<view class="qrcode-box">
|
<canvas canvas-id="qrcodeCanvas" id="qrcodeCanvas" :style="'width: '+width+'px; height:'+height+'px;'"></canvas>
|
<image class="qrcode-image" :src="qrcodeImage" mode="widthFix"></image>
|
</view>
|
<text class="pickup-code">{{ orderDetail.memberVerifyCode }}</text>
|
<text class="pickup-tip" @tap="copyCode">点击复制核销码</text>
|
</view>
|
</view>
|
</view>
|
</template>
|
|
<script>
|
import drawQrcode from 'weapp-qrcode'
|
|
export default {
|
data() {
|
|
return {
|
height:100,
|
width:100,
|
orderId: '',
|
orderDetail: null,
|
qrcodeImage: ''
|
}
|
},
|
onLoad(options) {
|
this.orderId = options.orderId
|
uni.setNavigationBarTitle({
|
title: '支付成功'
|
})
|
this.getOrderDetail()
|
this.width = this.rpxToPx(200)
|
this.height = this.rpxToPx(200)
|
},
|
methods: {
|
async getOrderDetail() {
|
const res = await this.$u.api.getOrderDetail(this.orderId)
|
if (res.code === 200) {
|
this.orderDetail = res.data
|
if (this.orderDetail.memberVerifyCode) {
|
this.generateQrcode(this.orderDetail.memberVerifyCode)
|
}
|
}
|
},
|
rpxToPx(rpx) {
|
return rpx * wx.getSystemInfoSync().windowWidth / 750
|
},
|
generateQrcode(code) {
|
drawQrcode({
|
canvasId: 'qrcodeCanvas',
|
text: code,
|
width: this.width,
|
height: this.height,
|
correctLevel: 2
|
})
|
setTimeout(() => {
|
uni.canvasToTempFilePath({
|
canvasId: 'qrcodeCanvas',
|
success: (res) => {
|
this.qrcodeImage = res.tempFilePath
|
}
|
}, this)
|
}, 100)
|
},
|
goHome() {
|
uni.switchTab({
|
url: '/pages/index/index'
|
})
|
},
|
viewOrder() {
|
uni.navigateTo({
|
url:'/pages/delivery-order-detail/delivery-order-detail?userType=0&id='+this.orderId
|
})
|
},
|
copyCode() {
|
if (!this.orderDetail || !this.orderDetail.memberVerifyCode) {
|
return
|
}
|
uni.setClipboardData({
|
data: this.orderDetail.memberVerifyCode,
|
success: () => {
|
uni.showToast({
|
title: '已复制自提码',
|
icon: 'none'
|
})
|
}
|
})
|
}
|
}
|
}
|
</script>
|
|
<style lang="scss" scoped>
|
.pay-success-page {
|
min-height: 100vh;
|
background: #ffffff;
|
}
|
|
.page-body {
|
padding: 62rpx 40rpx;
|
box-sizing: border-box;
|
}
|
|
.success-block {
|
display: flex;
|
flex-direction: column;
|
align-items: center;
|
}
|
|
.success-line {
|
display: flex;
|
align-items: center;
|
}
|
|
.success-icon {
|
width: 40rpx;
|
height: 40rpx;
|
margin-right: 14rpx;
|
display: flex;
|
align-items: center;
|
justify-content: center;
|
image {
|
width: 100%;
|
}
|
}
|
|
.success-title {
|
font-weight: 500;
|
font-size: 30rpx;
|
color: #333333;
|
}
|
|
.success-desc {
|
font-weight: 400;
|
font-size: 24rpx;
|
color: #999999;
|
margin-top: 40rpx;
|
}
|
|
.action-row {
|
margin-top: 60rpx;
|
display: flex;
|
justify-content: center;
|
gap: 24rpx;
|
}
|
|
.ghost-btn,
|
.outline-btn {
|
width: 260rpx;
|
height: 88rpx;
|
border-radius: 50rpx;
|
display: flex;
|
align-items: center;
|
justify-content: center;
|
font-size: 28rpx;
|
box-sizing: border-box;
|
}
|
|
.ghost-btn {
|
border: 1rpx solid #CCCCCC;
|
color: #666666;
|
background: #ffffff;
|
}
|
|
.outline-btn {
|
border: 1rpx solid #10B2FA;
|
color: #10B2FA;
|
background: #ffffff;
|
}
|
|
.pickup-card {
|
margin-top: 72rpx;
|
padding: 46rpx 36rpx 42rpx;
|
border-radius: 24rpx;
|
background: #f7f9fc;
|
display: flex;
|
flex-direction: column;
|
align-items: center;
|
}
|
|
.pickup-title {
|
font-weight: 500;
|
font-size: 34rpx;
|
color: #222222;
|
}
|
|
.qrcode-box {
|
margin-top: 40rpx;
|
width: 360rpx;
|
height: 360rpx;
|
border-radius: 8rpx;
|
box-sizing: border-box;
|
canvas {
|
position: fixed;
|
top: -100%;
|
left: -100%;
|
opacity: 0;
|
}
|
}
|
|
.qrcode-image {
|
width: 100%;
|
height: 100%;
|
}
|
|
.pickup-code {
|
margin-top: 32rpx;
|
font-weight: 600;
|
font-size: 36rpx;
|
color: #222222;
|
}
|
|
.pickup-tip {
|
font-weight: 400;
|
font-size: 24rpx;
|
color: #999999;
|
margin-top: 24rpx;
|
}
|
</style>
|