<template> <view class="orderVerification"> <!-- 输入核销码 --> <view class="verification"> <view class="num">1</view> <view class="verification-title">核销券码</view> <u-input v-model="writeCode" inputAlign="center" :customStyle="{'border-color':'#38BE41 !important'}" placeholder="请输入核销券码"></u-input> <view class="verification-btn" :style="{opacity:writeCode?1:'.6'}" @click="onConfirmProduct">确认核销</view> </view> <!-- 二维码 --> <view class="verification"> <view class="num">2</view> <view class="verification-title" style="margin-bottom: 48rpx;">二维码核销</view> <view class="scan"> <view class="scan1" @click="onScanToWrite"> <u-image width="84rpx" height="84rpx" src="../images/scan.png"></u-image> </view> </view> </view> <!-- 弹框 1-1717497530223296 --> <u-popup :show="show" @close="close" @open="open" mode="center" v-if="shopDetail != null"> <view class="popup"> <view class="popup-wrap"> <view class="popup-title">请确认核销订单</view> <view class="popup-order_num">订单编号:{{shopDetail.order_id}}</view> <view class="popup-goods-wrap"> <view class="popup-goods" v-for="item in shopDetail.goods_list" :key="item.id"> <view class="popup-goods-left"> <u-image width="100rpx" height="100rpx" radius="8rpx" :src="item.image" /> </view> <view class="popup-goods-right"> <view class="popup-goods-right-info"> <text class='goods_name'>{{item.store_name}}</text> <text class="goods_price">¥{{item.price}}</text> </view> <view class="popup-goods-num">x{{item.cart_num}}</view> </view> </view> <view class="popup-goods-total"> <text class="popup-goods-total-num">共{{shopDetail.total_num}}件商品,总金额</text> <text class="popup-goods-total-price">¥{{shopDetail.total_price}}</text> </view> </view> <view class="verification-btn" @click="onConfirmWrite">确认核销</view> </view> </view> </u-popup> </view> </template> <script setup> import { ref } from "vue"; import { writeOrderApi, writeCodeApi } from "@/api/order.js"; const show = ref(true); const writeCode = ref(''); // 确认核销 const onConfirmWrite = () => { if (!writeCode) return; writeOrderApi({ verify_code: writeCode.value }).then(res => { writeCode.value = ''; //清空 if (res.code == 1) { uni.showToast({ title: '核销成功', icon: 'none', success() { uni.$u.sleep(1500).then(rrr => { uni.navigateBack(); }) } }) } else { uni.showToast({ title: '核销失败', icon: 'none', success() { writeCode.value = ''; } }) } }) } const shopDetail = ref(null); // 根据核销码获取商品 const onConfirmProduct = () => { writeCodeApi({ code: writeCode.value }).then(res => { shopDetail.value = res.data; }) } // 二维码 const onScanToWrite = () => { uni.scanCode({ success(resp) { writeCode.value = resp.result; onConfirmProduct(); } }) } </script> <style lang="scss" scoped> .orderVerification { padding-top: 68rpx; .verification { position: relative; width: 710rpx; height: 390rpx; background-image: url(../images/circle_bg.png); background-size: 100%; background-repeat: no-repeat; margin: 0 auto 66rpx; padding: 70rpx 30rpx 0 30rpx; box-sizing: border-box; .num { position: absolute; left: 50%; top: -36rpx; transform: translateX(-50%); width: 72rpx; height: 72rpx; line-height: 72rpx; border-radius: 50%; background: #20B128; font-size: 36rpx; color: #FFFFFF; text-align: center; } .verification-title { margin-bottom: 24rpx; font-weight: 600; font-size: 32rpx; color: #333333; text-align: center; } .scan { display: flex; align-items: center; justify-content: center; box-shadow: 0 0 4rpx 16rpx rgba(32, 177, 40, .1); width: 160rpx; height: 160rpx; border-radius: 50%; margin: 0 auto; } .scan1 { display: flex; align-items: center; justify-content: center; width: 152rpx; height: 152rpx; background-color: #20B128; border-radius: 50%; box-shadow: 0 0 0 8rpx rgba(32, 177, 40, .3); } } .verification-btn { width: 648rpx; height: 94rpx; line-height: 94rpx; background: #38BE41; border-radius: 48rpx; margin-top: 40rpx; font-weight: 600; font-size: 32rpx; color: #FFFFFF; text-align: center; transition: opacity .3; } ::v-deep .u-popup__content { background-color: transparent; } .popup { .popup-wrap { width: 710rpx; border-radius: 12rpx; padding: 40rpx; box-sizing: border-box; background-color: #fff; .popup-title { margin-bottom: 60rpx; font-weight: 600; font-size: 32rpx; color: #333333; text-align: center; } .popup-order_num { margin-bottom: 36rpx; font-weight: bold; font-size: 24rpx; color: #333333; } .popup-goods { display: flex; justify-content: space-between; width: 630rpx; height: 150rpx; background: #F7F7F7; border-radius: 16rpx; padding: 24rpx 24rpx 0; box-sizing: border-box; margin-bottom: 20rpx; .popup-goods-left { margin-right: 24rpx; } .popup-goods-right { flex-grow: 1; .popup-goods-right-info { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20rpx; .goods_name { font-size: 24rpx; color: #333333; } .goods_price { font-weight: bold; font-size: 24rpx; color: #060606; } } .popup-goods-num { margin-bottom: 20rpx; font-size: 24rpx; color: #777777; text-align: right; } } } .popup-goods-total { text-align: right; .popup-goods-total-num { font-size: 24rpx; color: #666666; } .popup-goods-total-price { font-size: 24rpx; color: #F55726; } } } } } </style>