feat: 添加商户端页面

This commit is contained in:
2026-07-07 10:42:09 +08:00
parent baf82cec86
commit 948957d805
9 changed files with 1026 additions and 1 deletions
+250
View File
@@ -0,0 +1,250 @@
<template>
<s-layout
title="扫码核销"
:showLeftButton="false"
tabbar="/pages/merchant/scanVerify"
navPreset="light"
>
<template #navRight>
<modeSwitch />
</template>
<view class="page">
<view class="seg bg24">
<view class="seg-item" :class="{ segActive: tab === 'scan' }" @tap="tab = 'scan'">
扫码核销
</view>
<view class="seg-item" :class="{ segActive: tab === 'input' }" @tap="tab = 'input'">
输入取货码
</view>
</view>
<view class="panel bg24" v-if="tab === 'scan'">
<view class="scan-box">
<view class="scan-box__inner">
<uni-icons type="scan" size="42" color="#2556EC" />
<view class="scan-title">请将用户订单二维码对准扫码框</view>
<view class="scan-tip c_999 size24">或点击下方按钮开始扫码</view>
</view>
</view>
<view class="btnScan" @tap="startScan">开始扫码</view>
</view>
<view class="panel bg24" v-else>
<view class="input-row">
<uni-easyinput
class="code-input"
v-model="manualCode"
placeholder="请输入取货码"
:inputBorder="false"
:styles="{ fontSize: '34rpx' }"
/>
</view>
<view class="btnScan" @tap="confirmManual">确认核销</view>
</view>
<view class="records bg24">
<view class="records-hd flex-center ju-between">
<view class="records-title">近期核销记录</view>
<view class="records-link" @tap="clear">清空</view>
</view>
<view v-for="row in records" :key="row.id" class="record flex-center ju-between">
<view class="record-left">
<view class="record-code">取货码:{{ row.code }}</view>
<view class="record-time c_999 size24">{{ row.time }}</view>
</view>
<view class="record-right c_999 size24">{{ row.operator }}</view>
</view>
<view v-if="records.length === 0" class="empty c_999">暂无记录</view>
</view>
</view>
</s-layout>
</template>
<script setup>
import { ref } from 'vue';
import modeSwitch from '@/components/mode_switch/mode_switch.vue';
const tab = ref('scan');
const manualCode = ref('');
const STORAGE_KEY = 'merchant.verify.records';
const records = ref(uni.getStorageSync(STORAGE_KEY) || []);
const pushRecord = (code) => {
const next = [
{
id: `${Date.now()}-${Math.random()}`,
code,
time: new Date().toLocaleString(),
operator: '当前账号',
},
...records.value,
].slice(0, 20);
records.value = next;
uni.setStorageSync(STORAGE_KEY, next);
};
const startScan = () => {
uni.scanCode({
scanType: ['qrCode', 'barCode'],
success: (res) => {
const code = String(res.result || '').trim();
if (!code) {
uni.showToast({ title: '未识别到内容', icon: 'none' });
return;
}
pushRecord(code);
uni.showToast({ title: '核销成功', icon: 'success' });
},
fail: () => {
uni.showToast({ title: '扫码失败', icon: 'none' });
},
});
};
const confirmManual = () => {
const code = String(manualCode.value || '').trim();
if (!code) {
uni.showToast({ title: '请输入取货码', icon: 'none' });
return;
}
pushRecord(code);
manualCode.value = '';
uni.showToast({ title: '核销成功', icon: 'success' });
};
const clear = () => {
records.value = [];
uni.setStorageSync(STORAGE_KEY, []);
};
</script>
<style scoped lang="scss">
.page {
padding: 24rpx 24rpx 170rpx;
box-sizing: border-box;
}
.seg {
border-radius: 24rpx;
padding: 10rpx;
box-sizing: border-box;
display: flex;
margin-bottom: 18rpx;
background: rgba(255, 255, 255, 0.98);
}
.seg-item {
flex: 1;
height: 76rpx;
display: flex;
align-items: center;
justify-content: center;
border-radius: 18rpx;
font-size: 28rpx;
color: #333;
}
.segActive {
background: rgba(37, 86, 236, 0.12);
color: #2556ec;
font-weight: 700;
}
.panel {
border-radius: 24rpx;
padding: 24rpx;
box-sizing: border-box;
margin-bottom: 18rpx;
}
.scan-box {
border-radius: 24rpx;
border: 2rpx dashed rgba(37, 86, 236, 0.35);
height: 360rpx;
display: flex;
align-items: center;
justify-content: center;
margin-bottom: 20rpx;
background: rgba(37, 86, 236, 0.04);
}
.scan-box__inner {
display: flex;
flex-direction: column;
align-items: center;
}
.scan-title {
margin-top: 18rpx;
font-size: 28rpx;
color: #333;
font-weight: 600;
}
.scan-tip {
margin-top: 10rpx;
}
.btnScan {
height: 92rpx;
border-radius: 24rpx;
background: #2556ec;
color: #fff;
display: flex;
align-items: center;
justify-content: center;
font-size: 30rpx;
font-weight: 700;
}
.input-row {
border-radius: 24rpx;
background: #f6f7fb;
padding: 18rpx 20rpx;
box-sizing: border-box;
margin-bottom: 20rpx;
}
:deep(.code-input .uni-easyinput__content) {
background: transparent !important;
}
.records {
border-radius: 24rpx;
padding: 18rpx;
box-sizing: border-box;
}
.records-hd {
padding-bottom: 12rpx;
border-bottom: 2rpx solid #f1f2f6;
}
.records-title {
font-size: 28rpx;
color: #222;
font-weight: 700;
}
.records-link {
font-size: 24rpx;
color: #2556ec;
}
.record {
padding: 16rpx 0;
border-bottom: 2rpx solid #f6f7fb;
}
.record-code {
font-size: 26rpx;
color: #333;
font-weight: 600;
}
.empty {
text-align: center;
padding: 70rpx 0;
}
</style>