This commit is contained in:
lcj
2026-09-04 16:20:56 +08:00
parent 08e2f6888b
commit 4ed72056a9
6 changed files with 304 additions and 68 deletions
+4 -4
View File
@@ -69,20 +69,20 @@ export function checkFaceFlag(cardNo: string): Promise<boolean> {
}
/** 上传图片到 OSS */
export function uploadImage(filePath: string): Promise<string> {
export function uploadImage(filePath: string, endpoint = '/open-api/oss/upload'): Promise<string> {
return new Promise((resolve, reject) => {
uni.uploadFile({
url: `${BASE_URL}/open-api/oss/upload`,
url: `${BASE_URL}${endpoint}`,
filePath,
name: 'file',
success: (res) => {
if (res.statusCode === 200) {
try {
const data = JSON.parse(res.data as string)
if (data.errcode === 0 && data.data?.fileUrl) {
if ((data.errcode === 0 || data.code === 200) && data.data?.fileUrl) {
resolve(data.data.fileUrl)
} else {
reject(new Error(data.errmsg || '上传失败'))
reject(new Error(data.errmsg || data.msg || '上传失败'))
}
} catch { reject(new Error('解析响应失败')) }
} else {
+85 -5
View File
@@ -115,6 +115,35 @@
</button>
</view>
<!-- 5. 照片拍摄要求提示 -->
<view class="photo-tips">
<text class="photo-tips__title">照片拍摄要求</text>
<view class="photo-tips__item">
<view class="photo-tips__dot" />
<text class="photo-tips__text">图片仅允许1张人脸,多人脸直接驳回</text>
</view>
<view class="photo-tips__item">
<view class="photo-tips__dot" />
<text class="photo-tips__text">图片不能无人脸、侧脸过大、遮挡严重(口罩/帽子遮大半脸)</text>
</view>
<view class="photo-tips__item">
<view class="photo-tips__dot" />
<text class="photo-tips__text">不允许全身、远景、远距离人像照片</text>
</view>
<view class="photo-tips__item">
<view class="photo-tips__dot" />
<text class="photo-tips__text">不允许脸部极致特写、贴脸拍摄无留白</text>
</view>
<view class="photo-tips__item">
<view class="photo-tips__dot" />
<text class="photo-tips__text">图片清晰,无严重模糊、逆光、黑影、反光</text>
</view>
<view class="photo-tips__item">
<view class="photo-tips__dot" />
<text class="photo-tips__text">不允许翻拍屏幕、截图、证件复印件照片</text>
</view>
</view>
<!-- 弹窗:证件类型选择 -->
<uni-popup ref="idTypePopup" type="bottom" :mask-click="true" mask-background="transparent" @change="(e: any) => showIdTypePicker = e.show">
<view class="popup-sheet">
@@ -237,11 +266,16 @@ async function handleImage(filePath: string) {
try {
const compressedPath = await compressImage(filePath)
uni.showLoading({ title: '上传中...' })
const url = await uploadImage(compressedPath)
const url = await uploadImage(compressedPath, '/open-api/oss/uploadWithFaceCheck')
photoUrl.value = url
uni.showToast({ title: '上传成功', icon: 'success' })
} catch {
uni.showToast({ title: '上传失败', icon: 'none' })
} catch (e) {
uni.showModal({
title: '上传失败',
content: (e as Error).message || '上传失败',
showCancel: false,
confirmText: '确定',
})
} finally {
uploading.value = false
uni.hideLoading()
@@ -362,8 +396,8 @@ function handleCancel() {
/* ===== Page ===== */
.page {
height: 100vh;
overflow: hidden;
min-height: 100vh;
overflow-y: auto;
background: $color-card;
font-family: $font-family-body;
}
@@ -714,6 +748,52 @@ function handleCancel() {
color: $uv-tips-color;
}
/* ===== 5. Photo Tips ===== */
.photo-tips {
margin: 32rpx 24rpx;
padding: 28rpx;
background: #f7f8fa;
border-radius: 16rpx;
}
.photo-tips__title {
display: block;
font-family: $font-family-body;
font-size: $font-size-sm;
font-weight: $font-weight-medium;
color: $uv-main-color;
margin-bottom: 16rpx;
}
.photo-tips__item {
display: flex;
align-items: flex-start;
margin-bottom: 12rpx;
&:last-child {
margin-bottom: 0;
}
}
.photo-tips__dot {
width: 8rpx;
height: 8rpx;
border-radius: 50%;
background: $uv-primary;
flex-shrink: 0;
margin-top: 14rpx;
margin-right: 12rpx;
}
.photo-tips__text {
flex: 1;
font-family: $font-family-body;
font-size: $font-size-xs;
font-weight: 400;
color: $uv-tips-color;
line-height: 36rpx;
}
/* ===== Popup Sheet ===== */
.popup-sheet {
background: $color-card;
+9 -4
View File
@@ -500,7 +500,7 @@ async function doActivate() {
url: `${BASE_URL}/open-api/card/sendAndBind`,
method: 'POST',
data: {
orderNo: selectedVoucher.value?.id || '',
orderNo: `${selectedVoucher.value?.code || ''}-${selectedVoucher.value?.id || ''}`,
typeId: '820093438328133',
userName: form.userName.trim(),
mobile: phone.value,
@@ -578,10 +578,15 @@ async function handleImage(filePath: string) {
try {
const compressed = await compressImage(filePath)
uni.showLoading({ title: '上传中...' })
faceImg.value = await uploadImage(compressed)
faceImg.value = await uploadImage(compressed, '/open-api/oss/uploadWithFaceCheck')
uni.showToast({ title: '上传成功', icon: 'success' })
} catch {
uni.showToast({ title: '上传失败', icon: 'none' })
} catch (e) {
uni.showModal({
title: '上传失败',
content: (e as Error).message || '上传失败',
showCancel: false,
confirmText: '确定',
})
} finally {
uploading.value = false
uni.hideLoading()
+27 -19
View File
@@ -58,7 +58,7 @@
</view>
<!-- 预约入园日期 -->
<view class="record-info">
<text class="record-date">预约入园日期:{{ r.date }}</text>
<text class="record-date">预约入园日期:<text class="record-date--value">{{ formatDateOnly(r.date) }}</text></text>
</view>
<!-- 操作 -->
<view class="record-actions">
@@ -124,7 +124,7 @@
</uni-popup>
<!-- 详情弹窗 -->
<uni-popup ref="detailPopup" type="bottom" :mask-click="true">
<uni-popup ref="detailPopup" type="center" :mask-click="true">
<view class="detail-sheet">
<view class="sheet-header">
<text class="sheet-title">使用详情</text>
@@ -137,17 +137,9 @@
<text class="sheet-label">预约景区</text>
<text class="sheet-value">{{ detailRecord?.scenicName }}</text>
</view>
<view class="sheet-row">
<text class="sheet-label">卡种</text>
<text class="sheet-value">{{ detailRecord?.cardType }}</text>
</view>
<view class="sheet-row">
<text class="sheet-label">卡号</text>
<text class="sheet-value">{{ detailRecord?.cardNo }}</text>
</view>
<view class="sheet-row">
<text class="sheet-label">预约入园日期</text>
<text class="sheet-value">{{ detailRecord?.date }}</text>
<text class="sheet-value sheet-value--date">{{ formatDateOnly(detailRecord?.date) }}</text>
</view>
<view v-if="detailRecord?.session" class="sheet-row">
<text class="sheet-label">预约场次</text>
@@ -157,10 +149,6 @@
<text class="sheet-label">预约人</text>
<text class="sheet-value">{{ detailRecord?.userName }}</text>
</view>
<view class="sheet-row">
<text class="sheet-label">证件号</text>
<text class="sheet-value">{{ detailRecord?.maskedId }}</text>
</view>
<view class="sheet-row">
<text class="sheet-label">预约状态</text>
<text class="sheet-value">{{ detailStatusLabel(detailRecord?.status || '') }}</text>
@@ -177,6 +165,11 @@
<text class="sheet-label">取消时间</text>
<text class="sheet-value">{{ detailRecord.cancelTime }}</text>
</view>
<!-- 人脸图片 -->
<view v-if="detailRecord?.photo" class="sheet-photo">
<text class="sheet-label">人脸图片</text>
<image class="sheet-photo-avatar" :src="detailRecord.photo" mode="aspectFill" @tap="previewPhoto(detailRecord.photo)" />
</view>
<!-- 核销人脸照片 -->
<view v-if="detailRecord?.verifyPhoto" class="sheet-photo">
<text class="sheet-label">核销照片</text>
@@ -213,6 +206,7 @@ interface ReserveRecord {
cancelTime?: string
verifyTime?: string
verifyPhoto?: string
photo?: string
cardInstruction?: string
cardModelId?: string
canCancel?: boolean
@@ -288,6 +282,7 @@ async function fetchRecords(append = false) {
cancelTime: item.cancelTime || '',
verifyTime: item.verifyTime || '',
verifyPhoto: item.verifyPhoto || '',
photo: item.photo || '',
cardInstruction: item.cardInstruction || '',
cardModelId: item.cardModelId || item.thirdId || '',
canCancel: !!item.canCancel,
@@ -332,6 +327,12 @@ function formatReserveDate(date?: string): string {
return `${m[1]} 年 ${Number(m[2])} 月 ${Number(m[3])} 日`
}
/** 日期去除时分秒(如 2026-08-05 10:00:00 → 2026-08-05) */
function formatDateOnly(date?: string): string {
if (!date) return ''
return date.split(' ')[0]
}
function showCancelModal(r: ReserveRecord) {
cancelRecord.value = r
cancelPopup.value?.open()
@@ -449,6 +450,7 @@ async function viewDetail(r: ReserveRecord) {
cancelTime: res.cancelTime || r.cancelTime,
verifyTime: res.verifyTime || r.verifyTime,
verifyPhoto: res.verifyPhoto || r.verifyPhoto,
photo: res.photo || r.photo,
cardInstruction: res.cardInstruction || r.cardInstruction || '',
cardModelId: res.cardModelId || r.cardModelId || '',
}
@@ -622,6 +624,11 @@ function previewPhoto(url: string) {
color: $uv-tips-color;
}
.record-date--value {
color: $uv-error;
font-weight: $font-weight-medium;
}
.record-actions {
display: flex;
justify-content: flex-end;
@@ -743,7 +750,7 @@ function previewPhoto(url: string) {
/* ===== Detail Sheet ===== */
.detail-sheet {
background: $color-card; border-radius: $radius-lg $radius-lg 0 0; max-height: 75vh;
width: 640rpx; background: $color-card; border-radius: $radius-lg; max-height: 75vh;
display: flex; flex-direction: column;
}
@@ -778,6 +785,7 @@ function previewPhoto(url: string) {
.sheet-label { font-family: $font-family-body; font-size: $font-size-sm; color: $uv-main-color; }
.sheet-value { font-family: $font-family-body; font-size: $font-size-sm; color: $uv-content-color; text-align: right; }
.sheet-value--date { color: $uv-error; font-weight: $font-weight-medium; }
.sheet-photo {
display: flex;
@@ -788,9 +796,9 @@ function previewPhoto(url: string) {
}
.sheet-photo-avatar {
width: 100rpx;
height: 100rpx;
border-radius: 50%;
width: 200rpx;
height: 200rpx;
border-radius: 8rpx;
}
.sheet-tip {
+18 -4
View File
@@ -182,19 +182,33 @@ async function fetchCardPrice() {
}
}
onMounted(async () => {
onMounted(() => {
fetchCardPrice()
fetchSpots()
fetchBannersAndNotices()
})
/** 获取 banner 与公告(与景区加载互相独立) */
async function fetchBannersAndNotices() {
try {
const [bannerData, noticeData, spotsData] = await Promise.all([
const [bannerData, noticeData] = await Promise.all([
post<BannerItem[]>('/mp-api/mpContent/queryList', { channel: 'pingxiang', type: 'BANNER' }),
post<BannerItem[]>('/mp-api/mpContent/queryList', { channel: 'pingxiang', type: 'NOTICE' }),
post<any>('/mp-api/mpScenic/queryScenicList', { channel: 'pingxiang', pageNo: 1, pageSize: 8, phone: uni.getStorageSync('phone') || '' }),
])
banners.value = bannerData || []
announcements.value = (noticeData || []).map(n => ({
...n,
typeLabel: '公告',
}))
} catch {
// 静默失败
}
}
/** 获取热门景点(独立加载,不阻塞 banner/公告渲染) */
async function fetchSpots() {
try {
const spotsData = await post<any>('/mp-api/mpScenic/queryScenicList', { channel: 'pingxiang', pageNo: 1, pageSize: 8, phone: uni.getStorageSync('phone') || '' })
const list = spotsData?.list || spotsData || []
hotSpots.value = (Array.isArray(list) ? list : []).slice(0, 8).map((s: any) => ({
id: s.id || s.scenicId,
@@ -208,7 +222,7 @@ onMounted(async () => {
} catch {
// 静默失败
}
})
}
onShareAppMessage(() => ({
title: '爱上萍乡旅游年卡',
+161 -32
View File
@@ -106,13 +106,13 @@
<view class="detail-row">
<text class="detail-label">卡号:</text>
<view class="detail-value-wrap">
<text class="detail-value">{{ currentCard.cardNo }}</text>
<text class="detail-value">{{ currentCard?.cardNo }}</text>
<text class="copy-btn" @click="copyCardNo">复制</text>
</view>
</view>
<view class="detail-row">
<text class="detail-label">有效期至:</text>
<text class="detail-value">{{ formatDateOnly(currentCard.validityTime) }}</text>
<text class="detail-value">{{ formatDateOnly(currentCard?.validityTime) }}</text>
</view>
<view class="detail-row">
<text class="detail-label">{{ userInfoData?.idType || '证件' }}:</text>
@@ -124,30 +124,59 @@
<!-- 入园提示(持卡人信息下方) -->
<view class="qrcode-section" v-if="!showFaceModal && !isLeaving">
<text class="qrcode-title">入园提示</text>
<view>为确保信息安全,现入园核销只能使用人脸核销。</view>
<view v-if="!entryNotice" class="qrcode-fallback">为确保信息安全,现入园核销只能使用人脸核销。</view>
<view v-else class="qrcode-content">
<rich-text :nodes="entryNotice" />
</view>
</view>
<!-- 底部占位(滑到底时与tabBar的间隔) -->
<view style="height: 48rpx;"/>
</scroll-view>
<!-- 人脸绑定提醒弹窗 -->
<ConfirmModal
v-model="showFaceModal"
:title="faceModalTitle"
:content="faceModalContent"
confirmText="前往人脸绑定"
@confirm="onFaceModalConfirm"
/>
<uni-popup
ref="faceModalPopup"
type="center"
:mask-click="false"
@change="(e: any) => showFaceModal = e.show"
>
<view class="face-modal">
<view class="face-modal__title">人脸核销升级通知</view>
<view class="face-modal__row face-modal__row--spec">
<image class="face-modal__icon" src="https://aliyunoss.hn12301.net/sd/ticket_icon1.png" mode="aspectFit" />
<view class="face-modal__col">
<text class="face-modal__sub-title">拍照规范</text>
<view class="face-modal__desc">仅可现场真人实拍正面头像,禁止艺术写真、美颜修图、远景全身、特写大头照;人脸要求完整。</view>
</view>
</view>
<view class="face-modal__row">
<image class="face-modal__icon" src="https://aliyunoss.hn12301.net/sd/ticket_icon3.png" mode="aspectFit" />
<view class="face-modal__col">
<text class="face-modal__sub-title">隐私说明</text>
<view class="face-modal__desc">采集人脸仅用于本人入园身份核验,信息加密严格保密,不会挪作其他用途。</view>
</view>
</view>
<view class="face-modal__tip">
<image class="face-modal__tip-icon" src="https://aliyunoss.hn12301.net/sd/ticket_icon2.png" mode="aspectFit" />
<view class="face-modal__tip-text">完成人脸重新绑定后,才可正常使用旅游卡</br>全部入园权益功能</view>
</view>
<view class="face-modal__btn" @click="onFaceModalConfirm">立即重新绑定</view>
<view class="face-modal__hint">请使用本人实拍照片</view>
</view>
</uni-popup>
</view>
</template>
<script setup lang="ts">
import { ref, computed, onUnmounted } from 'vue'
import { ref, computed, watch, onUnmounted } from 'vue'
import { onShow, onHide } from '@dcloudio/uni-app'
import { useUserStore } from '../../store/user'
import { getUserCardList, getQrAndUserInfo } from '../../api/card'
import type { UserCardListItem, QrAndUserInfoResult } from '../../api/types'
import ConfirmModal from '../../components/confirm-modal.vue'
import type { UserCardListItem, QrAndUserInfoResult, BannerItem } from '../../api/types'
import { post } from '../../api/request'
const userStore = useUserStore()
@@ -158,9 +187,14 @@ const loaded = ref(false)
const userCards = ref<UserCardListItem[]>([])
const userInfoData = ref<QrAndUserInfoResult | null>(null)
const showFaceModal = ref(false)
const faceModalTitle = ref('系统安全升级提醒')
const faceModalContent = ref('为保障您的旅游卡信息安全、规范入园使用,平台已启动人脸核验升级。\n根据规则要求,使用旅游卡前需完成人脸绑定,核验仅用于身份核实,人脸信息严格保密,不会挪作他用。\n请立即完成人脸绑定,方可继续使用全部功能。')
const faceModalPopup = ref<any>(null)
watch(showFaceModal, (v) => {
if (v) faceModalPopup.value?.open()
else faceModalPopup.value?.close()
})
const isLeaving = ref(false)
const entryNotice = ref('')
const entryNoticeLoaded = ref(false)
const hasCard = computed(() => userCards.value.length > 0)
const currentCardIndex = ref(0)
@@ -170,22 +204,17 @@ let timer: ReturnType<typeof setInterval> | null = null
/** 获取用户年卡列表 */
async function fetchCards() {
const mobile = uni.getStorageSync('phone') as string
if (!mobile) {
loaded.value = true
loading.value = false
return
}
const mobile = (uni.getStorageSync('phone') as string) || userStore.userInfo?.phone || ''
loading.value = true
fetchEntryNotice()
try {
const list = (await getUserCardList({ mobile, saleChannel: 'xgh' })) || []
const allowedIds = ['820093340659013', '820093438328133']
userCards.value = list.filter((c: any) => allowedIds.includes(String(c.cardModelId)))
currentCardIndex.value = 0
const firstCard = userCards.value[0]
if (firstCard?.needFaceImgFlag) {
faceModalTitle.value = '系统安全升级提醒'
faceModalContent.value = '为保障您的旅游卡信息安全、规范入园使用,平台已启动人脸核验升级。\n根据规则要求,使用旅游卡前需完成人脸绑定,核验仅用于身份核实,人脸信息严格保密,不会挪作他用。\n请立即完成人脸绑定,方可继续使用全部功能。'
showFaceModal.value = true
}
@@ -200,21 +229,32 @@ async function fetchCards() {
}
}
/** 获取入园提示内容(ENTRY_NOTICE 公告) */
async function fetchEntryNotice() {
if (entryNoticeLoaded.value) return
try {
const list = await post<BannerItem[]>('/mp-api/mpContent/queryList', { channel: 'pingxiang', type: 'ENTRY_NOTICE' })
entryNotice.value = list?.[0]?.content || ''
} catch {
entryNotice.value = ''
} finally {
entryNoticeLoaded.value = true
}
}
/** 刷新当前卡的人脸绑定状态(从接口获取最新数据) */
async function refreshNeedFace() {
const mobile = uni.getStorageSync('phone') as string
if (!mobile) return
const mobile = (uni.getStorageSync('phone') as string) || userStore.userInfo?.phone || ''
try {
const list = (await getUserCardList({ mobile, saleChannel: 'xgh' })) || []
const allowedIds = ['820093340659013', '820093438328133']
userCards.value = list.filter((c: any) => allowedIds.includes(String(c.cardModelId)))
currentCardIndex.value = 0
const current = userCards.value[currentCardIndex.value]
if (current) {
fetchUserInfo(current)
if (current.needFaceImgFlag) {
faceModalTitle.value = '系统安全升级提醒'
faceModalContent.value = '为保障您的旅游卡信息安全、规范入园使用,平台已启动人脸核验升级。\n根据规则要求,使用旅游卡前需完成人脸绑定,核验仅用于身份核实,人脸信息严格保密,不会挪作他用。\n请立即完成人脸绑定,方可继续使用全部功能。'
showFaceModal.value = true
}
}
@@ -248,8 +288,6 @@ function onCardChange(e: any) {
if (card) {
fetchUserInfo(card)
if (card.needFaceImgFlag) {
faceModalTitle.value = '系统安全升级提醒'
faceModalContent.value = '为保障您的旅游卡信息安全、规范入园使用,平台已启动人脸核验升级。\n根据规则要求,使用旅游卡前需完成人脸绑定,核验仅用于身份核实,人脸信息严格保密,不会挪作他用。\n请立即完成人脸绑定,方可继续使用全部功能。'
showFaceModal.value = true
}
}
@@ -293,8 +331,10 @@ function goBuyCard() {
}
function copyCardNo() {
const card = currentCard.value
if (!card) return
uni.setClipboardData({
data: currentCard.value.cardNo,
data: card.cardNo,
success: () => { uni.showToast({ title: '已复制', icon: 'success' }) },
})
}
@@ -349,8 +389,6 @@ function onFeatureClick(item: { label: string }) {
post<any>('/mp-api/mpCard/checkFaceBind', { cardModelId: card.cardModelId, cardNumber: card.cardNo })
.then((res) => {
if (res?.needBindFace) {
faceModalTitle.value = '系统安全升级提醒'
faceModalContent.value = '为保障您的旅游卡信息安全、规范入园使用,平台已启动人脸核验升级。\n根据规则要求,使用旅游卡前需完成人脸绑定,核验仅用于身份核实,人脸信息严格保密,不会挪作他用。\n请立即完成人脸绑定,方可继续使用全部功能。'
showFaceModal.value = true
} else {
const url = card.thirdId
@@ -400,6 +438,89 @@ onUnmounted(() => { if (timer) clearInterval(timer) })
.page { min-height: 100vh; background: $color-background; font-family: $font-family-body; }
.scroll-content { }
/* === 人脸绑定提醒弹窗 === */
.face-modal {
width: 600rpx;
padding: 24rpx;
position: relative;
box-sizing: border-box;
background: #ffffff;
border-radius: 24rpx;
}
.face-modal__title {
color: #000;
font-size: 36rpx;
font-weight: bold;
text-align: center;
}
.face-modal__row {
width: 552rpx;
display: flex;
padding-bottom: 24rpx;
margin-top: 24rpx;
}
.face-modal__row--spec {
border-bottom: 2rpx solid #f2f2f7;
margin-top: 36rpx;
}
.face-modal__icon {
width: 50rpx;
height: 50rpx;
}
.face-modal__col {
display: flex;
flex-direction: column;
margin-left: 12rpx;
}
.face-modal__sub-title {
font-size: 32rpx;
font-weight: bold;
}
.face-modal__desc {
width: 490rpx;
line-height: 44rpx;
margin-top: 24rpx;
}
.face-modal__tip {
width: 552rpx;
display: flex;
margin-top: 24rpx;
padding: 7rpx;
background: #f6f9fe;
box-sizing: border-box;
}
.face-modal__tip-icon {
width: 36rpx;
height: 36rpx;
}
.face-modal__tip-text {
display: flex;
flex-direction: column;
margin-left: 16rpx;
font-size: 24rpx;
line-height: 36rpx;
}
.face-modal__btn {
width: 552rpx;
height: 80rpx;
display: flex;
align-items: center;
justify-content: center;
font-size: 32rpx;
border-radius: 40rpx;
color: #fff;
margin-top: 32rpx;
background: #0088ff;
}
.face-modal__hint {
width: 552rpx;
display: flex;
align-items: center;
justify-content: center;
margin-top: 24rpx;
color: #404040;
}
/* === 加载中 === */
.loading-state {
display: flex; flex-direction: column; align-items: center;
@@ -540,6 +661,14 @@ onUnmounted(() => { if (timer) clearInterval(timer) })
font-size: $font-size-lg; font-weight: $font-weight-medium; color: $uv-main-color;
display: block; margin-bottom: 20rpx; align-self: flex-start;
}
.qrcode-content {
font-size: $font-size-base; color: $uv-content-color;
line-height: 1.7; word-break: break-all; align-self: flex-start;
}
.qrcode-fallback {
font-size: $font-size-base; color: $uv-content-color;
line-height: 1.7; word-break: break-all; align-self: flex-start;
}
.qrcode-box {
width: 360rpx; height: 360rpx; background: #f8fafc;
border-radius: 16rpx; display: flex; align-items: center;