Files
kangyuan-mobile/pages/order/pickUpVerify.vue
T

424 lines
11 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<template>
<view class="order-details">
<!-- 自提商品核销 -->
<view v-if="orderInfo.deliveryType === 2 && orderInfo.payStatus" class="writeOff borRadius14">
<view class="title-row">
<view class="title">核销信息</view>
<view class="progress-btn" @tap.stop="goStockProgress">备货进度</view>
</view>
<view class="grayBg flex-center">
<view class="pictrue">
<image
v-if="!!painterImageUrl"
:src="painterImageUrl"
:style="{ width: `${state.qrcodeSize}px`, height: `${state.qrcodeSize}px` }"
:show-menu-by-longpress="true"
/>
</view>
</view>
<view class="gear">
<image :src="sheep.$url.static('/static/img/shop/writeOff.png')"></image>
</view>
<view class="num-wrap" @tap="copyVerifyCode">
<view class="num">{{ orderInfo.pickUpVerifyCode }}</view>
</view>
<view class="rules">
<view class="item">
<view class="rulesTitle flex flex-wrap align-center"> 核销时间 </view>
<view class="info">
每日:
<text class="time">{{ openingTimeText }} - {{ closingTimeText }}</text>
</view>
</view>
<view class="item">
<view class="rulesTitle flex flex-wrap align-center">
<text class="iconfont icon-shuoming1"></text>
使用说明
</view>
<view class="info">可将二维码出示给店员扫描或提供数字核销码</view>
</view>
</view>
</view>
<view
v-if="orderInfo.deliveryType === 2"
class="pickup-card borRadius14"
>
<image v-if="coverImageUrl" class="pickup-cover" :src="coverImageUrl" mode="aspectFill" />
<view class="pickup-hd">
<view class="pickup-title">{{ systemStore.name || '自提门店' }}</view>
<view v-if="distanceText" class="pickup-distance">{{ distanceText }}</view>
</view>
<view class="pickup-address">{{ pickupAddressText || '--' }}</view>
<view class="pickup-hours">
<uni-icons type="clock" size="14" color="#8c8c8c" />
<view class="pickup-hours__text">营业时间:{{ openingTimeText }} - {{ closingTimeText }}</view>
</view>
<view class="pickup-btn" @tap="showMaoLocation">查看位置导航</view>
</view>
<!-- 海报画板:默认隐藏只用来生成海报。生成方式为主动调用 -->
<l-painter
v-if="showPainter"
isCanvasToTempFilePath
pathType="url"
@success="setPainterImageUrl"
hidden
ref="painterRef"
/>
</view>
</template>
<script setup>
import sheep from '@/sheep';
import { computed, reactive, ref } from 'vue';
const props = defineProps({
orderInfo: {
type: Object,
default() {},
},
systemStore: {
type: Object,
default() {},
},
});
const state = reactive({
qrcodeSize: 145,
});
const goStockProgress = () => {
const id = props.orderInfo?.id || props.orderInfo?.orderId;
const pickUpStoreId = Number(
props.orderInfo?.pickUpStoreId ||
props.orderInfo?.pickUpStore?.id ||
props.orderInfo?.pickUpStore?.storeId ||
props.systemStore?.id ||
props.systemStore?.storeId ||
props.orderInfo?.storeId ||
0,
);
if (!id) return;
uni.navigateTo({
url: `/pages/order/stockProgress?id=${id}${
pickUpStoreId > 0 ? `&pickUpStoreId=${pickUpStoreId}` : ''
}`,
});
};
const copyVerifyCode = () => {
const code = String(props.orderInfo?.pickUpVerifyCode || '').trim();
if (!code) {
sheep.$helper.toast('暂无核销码');
return;
}
uni.setClipboardData({
data: code,
success: () => {
sheep.$helper.toast('核销码已复制');
},
});
};
/**
* 打开地图
*/
const formatHm = (hm) => {
if (!Array.isArray(hm) || hm.length < 2) return '';
const h = String(hm[0]).padStart(2, '0');
const m = String(hm[1]).padStart(2, '0');
return `${h}:${m}`;
};
const openingTimeText = computed(() => {
return props.systemStore?.openingTime || formatHm(props.systemStore?.businessHoursStart) || '--';
});
const closingTimeText = computed(() => {
return props.systemStore?.closingTime || formatHm(props.systemStore?.businessHoursEnd) || '--';
});
const pickupAddressText = computed(() => {
const s = props.systemStore || {};
const province = s.province || '';
const city = s.city || '';
const district = s.district || '';
const address = s.address || '';
const legacy = `${s.areaName || ''}${s.detailAddress || ''}`;
return `${province}${city}${district}${address}` || legacy || s.description || '';
});
const distanceText = computed(() => {
const d = Number(props.systemStore?.distance);
if (!(d > 0)) return '';
const t = d >= 1000 ? `${(d / 1000).toFixed(1)}km` : `${Math.round(d)}m`;
return `距离${t}`;
});
const sanitizeUrl = (value) => String(value || '').replace(/[`"'\s]/g, '');
const coverImageUrl = computed(() => {
const raw = sanitizeUrl(props.systemStore?.coverImage);
if (!raw) return '';
if (/^https?:\/\//i.test(raw)) return raw;
return sheep.$url.cdn(raw);
});
const addressText = computed(() => {
const s = props.systemStore || {};
const province = s.province || '';
const city = s.city || '';
const district = s.district || '';
const description = s.description || '';
const legacy = `${s.areaName || ''}${s.detailAddress || ''}`;
return `${province}${city}${district}${description}` || legacy || s.address || '';
});
const showMaoLocation = () => {
const latitude = Number(props.systemStore?.latitude);
const longitude = Number(props.systemStore?.longitude);
if (!(latitude && longitude)) {
sheep.$helper.toast('缺少经纬度信息无法查看地图!');
return;
}
uni.openLocation({
latitude,
longitude,
scale: 8,
name: props.systemStore?.name,
address: addressText.value,
});
};
const painterRef = ref(); // 海报画板
const painterImageUrl = ref(); // 海报 url
const showPainter = ref(true);
// 渲染海报
const renderPoster = async (poster) => {
await painterRef.value.render(poster);
};
// 获得生成的图片
const setPainterImageUrl = (path) => {
painterImageUrl.value = path;
showPainter.value = false;
};
/**
* 生成核销二维码
*/
const markCode = (text) => {
renderPoster({
css: {
width: `${state.qrcodeSize}px`,
height: `${state.qrcodeSize}px`,
},
views: [
{
type: 'qrcode',
text: text,
css: {
width: `${state.qrcodeSize}px`,
height: `${state.qrcodeSize}px`,
},
},
],
});
};
defineExpose({
markCode,
});
</script>
<style scoped lang="scss">
.borRadius14 {
border-radius: 14rpx !important;
}
.cart-color {
color: #e93323 !important;
border: 1px solid #e93323 !important;
}
.order-details {
border-radius: 10rpx;
margin: 0 20rpx 20rpx 20rpx;
}
.order-details .writeOff {
background-color: #fff;
margin-top: 15rpx;
padding-bottom: 50rpx;
}
.order-details .writeOff .title-row {
display: flex;
align-items: center;
justify-content: space-between;
font-size: 30rpx;
color: #282828;
height: 87rpx;
border-bottom: 1px solid #f0f0f0;
padding: 0 24rpx;
line-height: 87rpx;
box-sizing: border-box;
}
.order-details .writeOff .title {
font-size: 30rpx;
color: #282828;
height: 87rpx;
line-height: 87rpx;
}
.order-details .writeOff .progress-btn {
height: 52rpx;
line-height: 52rpx;
padding: 0 16rpx;
border-radius: 26rpx;
font-size: 24rpx;
color: #5b4eff;
background: rgba(91, 78, 255, 0.12);
}
.order-details .writeOff .grayBg {
background-color: #f2f5f7;
width: 590rpx;
height: 384rpx;
border-radius: 20rpx 20rpx 0 0;
margin: 50rpx auto 0 auto;
padding-top: 55rpx;
}
.order-details .writeOff .grayBg .pictrue {
width: 290rpx;
height: 290rpx;
}
.order-details .writeOff .grayBg .pictrue image {
width: 100%;
height: 100%;
}
.order-details .writeOff .gear {
width: 590rpx;
height: 30rpx;
margin: 0 auto;
}
.order-details .writeOff .gear image {
width: 100%;
height: 100%;
}
.order-details .writeOff .num-wrap {
width: 590rpx;
margin: 0 auto;
}
.order-details .writeOff .num {
background-color: #f0c34c;
width: 100%;
height: 84rpx;
color: #282828;
font-size: 48rpx;
border-radius: 0 0 20rpx 20rpx;
text-align: center;
padding-top: 4rpx;
}
.order-details .writeOff .rules {
margin: 46rpx 30rpx 0 30rpx;
border-top: 1px solid #f0f0f0;
padding-top: 10rpx;
}
.order-details .writeOff .rules .item {
margin-top: 20rpx;
}
.order-details .writeOff .rules .item .rulesTitle {
font-size: 28rpx;
color: #282828;
}
.order-details .writeOff .rules .item .rulesTitle .iconfont {
font-size: 30rpx;
color: #333;
margin-right: 8rpx;
margin-top: 5rpx;
}
.order-details .writeOff .rules .item .info {
font-size: 28rpx;
color: #999;
margin-top: 7rpx;
}
.order-details .writeOff .rules .item .info .time {
margin-left: 20rpx;
}
.order-details .pickup-card {
margin-top: 15rpx;
background-color: #fff;
padding: 22rpx 24rpx 24rpx;
box-sizing: border-box;
}
.order-details .pickup-hd {
display: flex;
align-items: center;
justify-content: space-between;
}
.order-details .pickup-title {
font-size: 30rpx;
color: #282828;
font-weight: 700;
}
.order-details .pickup-distance {
padding: 4rpx 12rpx;
border-radius: 999rpx;
font-size: 22rpx;
color: #2556ec;
background: rgba(37, 86, 236, 0.12);
}
.order-details .pickup-address {
margin-top: 10rpx;
font-size: 26rpx;
color: #666;
line-height: 36rpx;
}
.order-details .pickup-cover {
width: 100%;
height: 168rpx;
border-radius: 16rpx;
display: block;
margin-bottom: 14rpx;
background: #f2f4f7;
}
.order-details .pickup-hours {
margin-top: 10rpx;
display: flex;
align-items: center;
gap: 10rpx;
}
.order-details .pickup-hours__text {
font-size: 24rpx;
color: #8c8c8c;
}
.order-details .pickup-btn {
margin-top: 16rpx;
height: 76rpx;
border-radius: 16rpx;
border: 2rpx solid rgba(37, 86, 236, 0.35);
background: #fff;
color: #2556ec;
font-size: 28rpx;
display: flex;
align-items: center;
justify-content: center;
box-sizing: border-box;
}
</style>