rk
2026-04-28 908b9876dde97acbb09c53dc6debe3eecbb9d1b4
small-program/pages/payment-success/payment-success.vue
@@ -16,33 +16,87 @@
         </view>
         <view class="pickup-card">
            <text class="pickup-title">自提码</text>
            <text class="pickup-title">核销码</text>
            <view class="qrcode-box">
               <image class="qrcode-image" src="" mode="aspectFit"></image>
               <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">38389</text>
            <text class="pickup-tip" @tap="copyCode">点击复制自提码</text>
            <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.switchTab({
               url: '/pages/itinerary/itinerary'
            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: '38389',
               data: this.orderDetail.memberVerifyCode,
               success: () => {
                  uni.showToast({
                     title: '已复制自提码',
@@ -50,7 +104,7 @@
                  })
               }
            })
         }
         }
      }
   }
</script>
@@ -155,12 +209,18 @@
      height: 360rpx;
      border-radius: 8rpx;
      box-sizing: border-box;
      position: relative;
      canvas {
         position: absolute;
         top: 0;
         left: 0;
         opacity: 0;
      }
   }
   .qrcode-image {
      width: 100%;
      height: 100%;
      background: #f4f6fa;
   }
   .pickup-code {