合并:中奖名单公示页搜索修复(feature/venue-discount-rights-filter → xuchao)
冲突解决:venue 列表灰底间距与卡片内边距取 feature 侧设计修正;card-address 保留 min-width:0;index 页面取页级滚动方案。 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
@@ -13,12 +13,19 @@
|
||||
<view class="search-btn" @click="onSearch">搜索</view>
|
||||
</view>
|
||||
</view>
|
||||
<!-- xuchao: 所属县区 + 所属类型筛选,选项与联动条数由列表接口一并返回 -->
|
||||
<hhrs-filter-bar :districts="filters.districts" :categories="filters.categories"
|
||||
:district-id="districtId" :category="category" @change="onFilterChange" />
|
||||
</view>
|
||||
|
||||
<!-- 商户列表 -->
|
||||
<view class="list-area">
|
||||
<view class="venue-card" v-for="item in list" :key="item.shopId" @click="goDetail(item)">
|
||||
<image class="card-img" :src="item.image" mode="aspectFill" />
|
||||
<view class="card-thumb">
|
||||
<image class="card-img" :src="item.image" mode="aspectFill" />
|
||||
<!-- xuchao: 左上角所属地区角标(districtName 来自商铺「所在地区」,未录入则不显示) -->
|
||||
<text class="card-area" v-if="item.districtName">{{ shortDistrict(item.districtName) }}</text>
|
||||
</view>
|
||||
<view class="card-info">
|
||||
<text class="card-name">{{ item.name }}</text>
|
||||
<text class="card-category">{{ item.category }}</text>
|
||||
@@ -40,7 +47,13 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
// xuchao: 角标区县简称(后端返回的是行政区划全称)
|
||||
import { shortDistrict } from '@/common/district.js'
|
||||
// xuchao: 县区 + 类型筛选条,三个列表页共用(pages.json 的 easycom 只给 u- 前缀配了规则,这里显式引入)
|
||||
import HhrsFilterBar from '@/components/hhrs-filter-bar/hhrs-filter-bar.vue'
|
||||
|
||||
export default {
|
||||
components: { HhrsFilterBar },
|
||||
data() {
|
||||
return {
|
||||
keyword: '',
|
||||
@@ -53,7 +66,11 @@ export default {
|
||||
lat: '',
|
||||
loadStatus: 'loadmore',
|
||||
hasScrolled: false,
|
||||
reqSeq: 0
|
||||
reqSeq: 0,
|
||||
// xuchao: 筛选条件与面板选项(选项由列表响应带回)
|
||||
districtId: '',
|
||||
category: '',
|
||||
filters: { districts: [], categories: [] }
|
||||
}
|
||||
},
|
||||
onLoad() {
|
||||
@@ -78,6 +95,7 @@ export default {
|
||||
this.loadMore()
|
||||
},
|
||||
methods: {
|
||||
shortDistrict,
|
||||
loadList() {
|
||||
// xuchao: 请求序号 —— 新请求直接取代在途请求,过期响应整体丢弃(修复搜索竞态,故不再用 loading 提前 return)
|
||||
const seq = ++this.reqSeq
|
||||
@@ -91,9 +109,16 @@ export default {
|
||||
}
|
||||
if (this.lng) params.lng = this.lng
|
||||
if (this.lat) params.lat = this.lat
|
||||
if (this.districtId) params.districtId = this.districtId
|
||||
if (this.category) params.category = this.category
|
||||
this.$u.api.getStoreList(params).then(res => {
|
||||
if (seq !== this.reqSeq) return
|
||||
if (res.errcode === 0 && res.data) {
|
||||
// xuchao: 面板选项随列表一起回来(后端已按关键词与另一维度算好条数)
|
||||
this.filters = {
|
||||
districts: res.data.districts || [],
|
||||
categories: res.data.categories || []
|
||||
}
|
||||
const list = res.data.list || []
|
||||
if (this.pageNo === 1) {
|
||||
this.list = list
|
||||
@@ -133,12 +158,19 @@ export default {
|
||||
}
|
||||
},
|
||||
goDetail(item) {
|
||||
uni.navigateTo({ url: '/pages/venue/detail?id=' + item.shopId })
|
||||
// xuchao: type=2 标记商户折扣入口,详情页据此展示商品信息+商户优惠模块
|
||||
uni.navigateTo({ url: '/pages/venue/detail?id=' + item.shopId + '&type=2' })
|
||||
},
|
||||
onSearch() {
|
||||
this.pageNo = 1
|
||||
this.list = []
|
||||
this.loadList()
|
||||
},
|
||||
// xuchao: 换筛选条件即回第 1 页重查(关键词保持不变,两者为 AND)
|
||||
onFilterChange(e) {
|
||||
this.districtId = e.districtId
|
||||
this.category = e.category
|
||||
this.onSearch()
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -153,7 +185,11 @@ export default {
|
||||
|
||||
.search-area {
|
||||
background-color: #ffffff;
|
||||
padding: 6px 12px;
|
||||
padding: 6px 12px 0;
|
||||
// xuchao: 滚动时固定在页面顶部;z-index 高于筛选遮罩(90),保证面板与选中态不被压住
|
||||
position: sticky;
|
||||
top: 0;
|
||||
z-index: 100;
|
||||
}
|
||||
|
||||
.nav-row {
|
||||
@@ -204,6 +240,7 @@ export default {
|
||||
}
|
||||
|
||||
.list-area {
|
||||
// xuchao: 顶部 12px 必须是页面灰底(不能放进头部的白底里),否则与白色卡片连成一片看不出间隔
|
||||
padding: 12px;
|
||||
// xuchao: border-box 防止 padding 撑出页面横向滚动
|
||||
box-sizing: border-box;
|
||||
@@ -223,13 +260,39 @@ export default {
|
||||
margin-bottom: 12px;
|
||||
}
|
||||
|
||||
.card-img {
|
||||
.card-thumb {
|
||||
width: 75px;
|
||||
height: 75px;
|
||||
border-radius: 6px;
|
||||
overflow: hidden;
|
||||
position: relative;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
/* xuchao: image 由 thumb 裁圆角,自身不再设圆角 */
|
||||
.card-img {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
display: block;
|
||||
}
|
||||
|
||||
.card-area {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
display: block;
|
||||
max-width: 100%;
|
||||
padding: 1px 5px;
|
||||
border-radius: 0 0 6px 0;
|
||||
background: rgba(0, 0, 0, 0.45);
|
||||
color: #ffffff;
|
||||
font-size: 10px;
|
||||
line-height: 14px;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.card-info {
|
||||
flex: 1;
|
||||
// xuchao: min-width:0 允许 flex 子项收缩到内容宽度以下,配合 nowrap 文本出省略号
|
||||
@@ -253,6 +316,9 @@ export default {
|
||||
font-size: 14px;
|
||||
color: #727272;
|
||||
margin-top: 8px;
|
||||
// xuchao: 分类为空也预留一行高度,防止卡片内容底部对齐时名称上下跳动
|
||||
min-height: 20px;
|
||||
line-height: 20px;
|
||||
}
|
||||
|
||||
.card-address-row {
|
||||
|
||||
+23
-10
@@ -1,7 +1,9 @@
|
||||
<template>
|
||||
<view class="page">
|
||||
<view class="content">
|
||||
<text>参加指南</text>
|
||||
<!-- xuchao: 参加指南改为整图展示,与使用指南一致;图片资源尚未上传 OSS,加载失败时给文字兜底避免白屏 -->
|
||||
<image v-if="!imgFailed" class="join-img" :src="imgUrl" mode="widthFix" @error="imgFailed = true"></image>
|
||||
<view class="empty-tip" v-else>
|
||||
<text class="empty-text">参加指南内容整理中,请稍后再来查看</text>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
@@ -9,7 +11,11 @@
|
||||
<script>
|
||||
export default {
|
||||
data() {
|
||||
return {}
|
||||
return {
|
||||
// 运营指定图片地址(OSS 上传后可与全站统一为 aliyunoss.hn12301.net/hhrs)
|
||||
imgUrl: 'https://zhihuiyou.oss-cn-shenzhen.aliyuncs.com/hhrs/hhrs_zhinan.jpg',
|
||||
imgFailed: false
|
||||
}
|
||||
},
|
||||
onLoad() {},
|
||||
methods: {}
|
||||
@@ -18,14 +24,21 @@
|
||||
|
||||
<style scoped>
|
||||
.page {
|
||||
height: 100vh;
|
||||
min-height: 100vh;
|
||||
background-color: #f5f5f5;
|
||||
overflow: hidden;
|
||||
}
|
||||
.content {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
height: 100vh;
|
||||
/* xuchao: 整图展示,widthFix 随页面向下滚动 */
|
||||
.join-img {
|
||||
display: block;
|
||||
width: 100%;
|
||||
}
|
||||
.empty-tip {
|
||||
padding: 80px 24px 0;
|
||||
text-align: center;
|
||||
}
|
||||
.empty-text {
|
||||
font-size: 14px;
|
||||
color: #999999;
|
||||
line-height: 1.6;
|
||||
}
|
||||
</style>
|
||||
|
||||
+6
-10
@@ -1,8 +1,6 @@
|
||||
<template>
|
||||
<view class="page">
|
||||
<view class="content">
|
||||
<text>使用指南</text>
|
||||
</view>
|
||||
<image class="use-img" src="https://aliyunoss.hn12301.net/hhrs/hhrs_use.jpg" mode="widthFix"></image>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
@@ -18,14 +16,12 @@
|
||||
|
||||
<style scoped>
|
||||
.page {
|
||||
height: 100vh;
|
||||
min-height: 100vh;
|
||||
background-color: #f5f5f5;
|
||||
overflow: hidden;
|
||||
}
|
||||
.content {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
height: 100vh;
|
||||
/* xuchao: 使用指南整图展示,widthFix 随页面向下滚动 */
|
||||
.use-img {
|
||||
display: block;
|
||||
width: 100%;
|
||||
}
|
||||
</style>
|
||||
|
||||
+50
-57
@@ -19,14 +19,10 @@
|
||||
<view class="title-line"></view>
|
||||
<text class="title-text">活动指南</text>
|
||||
</view>
|
||||
<!-- xuchao: 图内已带标题/副标题/官方指南角标,不再叠加文字层,只保留图片 -->
|
||||
<view class="guide-list">
|
||||
<view class="guide-card" v-for="(item, index) in guideList" :key="index" @click="goPage(item.url)">
|
||||
<image class="guide-bg" :src="item.bg" mode="scaleToFill"></image>
|
||||
<view class="guide-info">
|
||||
<text class="guide-title">{{ item.title }}</text>
|
||||
<text class="guide-sub">{{ item.sub }}</text>
|
||||
<view class="guide-tag">官方指南</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
@@ -34,6 +30,8 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import account from '@/common/account.js'
|
||||
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
@@ -45,32 +43,54 @@
|
||||
],
|
||||
guideList: [
|
||||
{
|
||||
title: '怀化社保卡惠民活动参加指南',
|
||||
sub: '本地文旅场馆、商户惠民福利',
|
||||
bg: 'https://aliyunoss.hn12301.net/hhrs/hhrs_cjzn.png',
|
||||
// xuchao: ?v= 为图片版本参数,运营换图必须同步更新日期,否则各平台 WebView/CDN 会继续命中旧缓存
|
||||
bg: 'https://aliyunoss.hn12301.net/hhrs/hhrs_cjzn.png?v=20260928',
|
||||
url: '/pages/guide/join'
|
||||
},
|
||||
{
|
||||
title: '社保卡领取及使用指南',
|
||||
sub: '全流程办理及激活指引',
|
||||
bg: 'https://aliyunoss.hn12301.net/hhrs/hhrs_syzn.png',
|
||||
bg: 'https://aliyunoss.hn12301.net/hhrs/hhrs_syzn.png?v=20260928',
|
||||
url: '/pages/guide/use'
|
||||
}
|
||||
]
|
||||
],
|
||||
// xuchao: 云闪付免密登录是否仍在进行中 —— 返回前不放行任何依赖身份的跳转
|
||||
tokenLoginPending: false,
|
||||
tokenLoginTimer: null
|
||||
}
|
||||
},
|
||||
onLoad(options) {
|
||||
// xuchao: 云闪付入口带 token 进来 —— 直接免密换取会话,不经过手机号验证码
|
||||
if (options.token) {
|
||||
this.handleTokenLogin(options.token)
|
||||
}
|
||||
this.getLocation()
|
||||
},
|
||||
// xuchao: 离开首页时收尾,避免看门狗与遮罩残留
|
||||
onUnload() {
|
||||
this.finishTokenLogin()
|
||||
},
|
||||
methods: {
|
||||
// xuchao: 云闪付入口 token 自动登录
|
||||
// xuchao: 云闪付入口 token 自动登录(免密换人)
|
||||
handleTokenLogin(token) {
|
||||
// xuchao: 云闪付入口是"免密换人",本机上一个账号的会话与权益缓存必须先丢弃:
|
||||
// 一是请求不能再带旧 accessToken(后端"会话优先"会把旧账号数据返给新用户),
|
||||
// 二是权益页只在 onLoad 取一次账号快照、不会自我纠正,所以清缓存必须赶在
|
||||
// 发请求之前 —— 解码返回前的窗口期里最多读到"未登录",绝不会读到别人的数据
|
||||
account.clearAccountCache()
|
||||
this.tokenLoginPending = true
|
||||
uni.showLoading({ title: '登录中', mask: true })
|
||||
// xuchao: 兜底看门狗,网络异常时不让遮罩卡死(只收遮罩,不改变登录结果)
|
||||
this.tokenLoginTimer = setTimeout(() => {
|
||||
this.finishTokenLogin()
|
||||
}, 10000)
|
||||
this.$u.api.tokenDecode({ token }).then(res => {
|
||||
this.finishTokenLogin()
|
||||
if (res.errcode === 0 && res.data && res.data.mobile) {
|
||||
uni.setStorageSync('phone', res.data.mobile)
|
||||
// xuchao: 后端已为云闪付入口签发会员会话,存下 accessToken,后续接口才认得这个用户。
|
||||
// 只认"非空字符串":后端字段缺失/为 null 时会被序列化成 {},直接存进缓存
|
||||
// 就会变成 Bearer [object Object],把所有鉴权接口全打挂
|
||||
const issued = typeof res.data.accessToken === 'string' ? res.data.accessToken : ''
|
||||
if (issued) uni.setStorageSync('token', issued)
|
||||
this.$u.api.getEligibility({ phone: res.data.mobile, identityNo: res.data.idNo || '', name: res.data.name || '' }).then(eRes => {
|
||||
if (eRes.errcode === 0) {
|
||||
uni.setStorageSync('isAuth', eRes.data.isAuth)
|
||||
@@ -85,9 +105,18 @@
|
||||
this.degradeToPhoneLogin()
|
||||
}
|
||||
}).catch(() => {
|
||||
this.finishTokenLogin()
|
||||
this.degradeToPhoneLogin()
|
||||
})
|
||||
},
|
||||
// xuchao: 免密登录收尾(收起遮罩、撤看门狗),成功/失败/超时/离开页面都会走到
|
||||
finishTokenLogin() {
|
||||
if (!this.tokenLoginPending) return
|
||||
this.tokenLoginPending = false
|
||||
clearTimeout(this.tokenLoginTimer)
|
||||
this.tokenLoginTimer = null
|
||||
uni.hideLoading()
|
||||
},
|
||||
// xuchao: 解码失败兜底,提示并跳手机号登录
|
||||
degradeToPhoneLogin() {
|
||||
uni.showToast({ title: '登录凭证已失效,请使用手机号登录', icon: 'none' })
|
||||
@@ -122,6 +151,11 @@
|
||||
uni.navigateTo({ url })
|
||||
},
|
||||
goRights() {
|
||||
// xuchao: 免密登录还没返回时不放行,避免带着空/旧身份进权益页
|
||||
if (this.tokenLoginPending) {
|
||||
uni.showToast({ title: '正在登录,请稍候', icon: 'none' })
|
||||
return
|
||||
}
|
||||
const phone = uni.getStorageSync('phone')
|
||||
if (!phone) {
|
||||
uni.navigateTo({ url: '/pages/index/login?redirect=rights' })
|
||||
@@ -142,15 +176,11 @@
|
||||
</script>
|
||||
|
||||
<style>
|
||||
page {
|
||||
height: 100%;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
/* xuchao: 原 page/.page 固定 100vh + overflow:hidden,小屏下活动指南第二张卡片会被裁掉且无法滚动;
|
||||
改为 min-height 撑满、超出可滚动,视觉在正常屏上保持不变 */
|
||||
.page {
|
||||
height: 100vh;
|
||||
min-height: 100vh;
|
||||
background-color: #f5f5f5;
|
||||
overflow-y: auto;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
@@ -202,7 +232,6 @@
|
||||
flex: 1;
|
||||
background-color: #ffffff;
|
||||
margin-top: 10rpx;
|
||||
overflow: hidden;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
@@ -236,7 +265,6 @@
|
||||
}
|
||||
|
||||
.guide-card {
|
||||
position: relative;
|
||||
width: 100%;
|
||||
height: 252rpx;
|
||||
border-radius: 16rpx;
|
||||
@@ -249,40 +277,5 @@
|
||||
border-radius: 16rpx;
|
||||
}
|
||||
|
||||
.guide-info {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
padding: 0 30rpx;
|
||||
}
|
||||
|
||||
.guide-title {
|
||||
font-size: 16px;
|
||||
font-weight: 600;
|
||||
color: #0088FF;
|
||||
margin-bottom: 10rpx;
|
||||
}
|
||||
|
||||
.guide-sub {
|
||||
font-size: 12px;
|
||||
color: #949AA0;
|
||||
margin-bottom: 16rpx;
|
||||
}
|
||||
|
||||
.guide-tag {
|
||||
display: inline-block;
|
||||
width: fit-content;
|
||||
padding: 4px 10px;
|
||||
background-color: #e6f2ff;
|
||||
color: #0088FF;
|
||||
font-size: 12px;
|
||||
border-radius: 6rpx;
|
||||
}
|
||||
|
||||
|
||||
</style>
|
||||
|
||||
+43
-14
@@ -43,6 +43,8 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import config from '@/common/config.js'
|
||||
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
@@ -63,6 +65,24 @@ export default {
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
// xuchao: open-api/hhService/login、sendLoginVerifyCode 返回 OpenapiResponse{code,msg,data},
|
||||
// 被网关再包一层后外层 errcode 恒为 0,真正的业务码在 data.code 里。
|
||||
// 只判 errcode 会把「验证码错误/过期、短信被限流」全部当成成功。
|
||||
// 宽松兜底:后端若改成不返回 data.code,仍按 errcode 判定,不会把成功误判为失败。
|
||||
isBizOk(res) {
|
||||
if (!res || res.errcode !== 0) return false
|
||||
const d = res.data
|
||||
if (!d || d.code === undefined || d.code === null) {
|
||||
// xuchao: 没有业务码时,还要排除“网关把 404/错误页包成 HTTP 200”的情况
|
||||
// (实测未部署的新地址会返回 {data:{timestamp,status:404,error:'Not Found'}} 且 errcode=0)
|
||||
return !d || (d.status === undefined && d.error === undefined)
|
||||
}
|
||||
return d.code === 200
|
||||
},
|
||||
// xuchao: 失败原因优先取业务 msg,其次取网关 errmsg
|
||||
bizMsg(res) {
|
||||
return (res && res.data && res.data.msg) || (res && res.errmsg) || ''
|
||||
},
|
||||
sendCode() {
|
||||
if (this.countdown > 0) return
|
||||
if (!this.phone || !/^1\d{10}$/.test(this.phone)) {
|
||||
@@ -70,22 +90,24 @@ export default {
|
||||
return
|
||||
}
|
||||
this.$u.api.sendLoginVerifyCode({ smsType: 'CIB_LOGIN', mobile: this.phone }).then(res => {
|
||||
if (res.errcode === 0) {
|
||||
if (this.isBizOk(res)) {
|
||||
uni.showToast({ title: '验证码已发送', icon: 'success' })
|
||||
// xuchao: 倒计时移到发送成功之后(原来无条件启动,发送失败也会被白锁 60 秒无法重试)
|
||||
this.countdown = 60
|
||||
this.timer = setInterval(() => {
|
||||
this.countdown--
|
||||
if (this.countdown <= 0) {
|
||||
clearInterval(this.timer)
|
||||
this.timer = null
|
||||
}
|
||||
}, 1000)
|
||||
} else {
|
||||
uni.showToast({ title: res.errmsg || '发送失败', icon: 'none' })
|
||||
// xuchao: 透出后端真实原因,如「操作频繁,请稍后再试」
|
||||
uni.showToast({ title: this.bizMsg(res) || '发送失败', icon: 'none' })
|
||||
}
|
||||
}).catch(() => {
|
||||
uni.showToast({ title: '发送失败', icon: 'none' })
|
||||
})
|
||||
this.countdown = 60
|
||||
this.timer = setInterval(() => {
|
||||
this.countdown--
|
||||
if (this.countdown <= 0) {
|
||||
clearInterval(this.timer)
|
||||
this.timer = null
|
||||
}
|
||||
}, 1000)
|
||||
},
|
||||
onLogin() {
|
||||
if (!this.phone || !/^1\d{10}$/.test(this.phone)) {
|
||||
@@ -100,9 +122,14 @@ export default {
|
||||
uni.showToast({ title: '请同意用户协议和隐私协议', icon: 'none' })
|
||||
return
|
||||
}
|
||||
this.$u.api.checkerLogin({ password: '1232321', mobile: this.phone, verifyCode: this.code }).then(res => {
|
||||
if (res.errcode === 0) {
|
||||
uni.setStorageSync('token', res.data.token)
|
||||
// xuchao: password 为后端要求的固定旁路口令,集中取自 config.loginFixedPassword
|
||||
this.$u.api.checkerLogin({ password: config.loginFixedPassword, mobile: this.phone, verifyCode: this.code }).then(res => {
|
||||
if (this.isBizOk(res)) {
|
||||
// xuchao: 只认"非空字符串"凭证。后端若把 null 序列化成 {}(实测 tokenDecode 就是这个形状),
|
||||
// 用 || 兜底会把对象存进缓存,之后每个请求都变成 Bearer [object Object]
|
||||
const payload = (res.data && res.data.data) || {}
|
||||
const issued = [payload.accessToken, payload.token].find(v => typeof v === 'string' && v.length > 0)
|
||||
uni.setStorageSync('token', issued || '')
|
||||
uni.setStorageSync('phone', this.phone)
|
||||
this.$u.api.getEligibility({ phone: this.phone, identityNo: '', name: '' }).then(eRes => {
|
||||
if (eRes.errcode === 0) {
|
||||
@@ -125,7 +152,9 @@ export default {
|
||||
}
|
||||
})
|
||||
} else {
|
||||
uni.showToast({ title: res.errmsg || '登录失败', icon: 'none' })
|
||||
// xuchao: 透出后端真实原因,如「验证码错误」「验证码已过期,请重新获取」;
|
||||
// 失败时绝不写 phone,避免留下“假登录态”让后续页面以为已登录
|
||||
uni.showToast({ title: this.bizMsg(res) || '登录失败', icon: 'none' })
|
||||
}
|
||||
}).catch(() => {
|
||||
uni.showToast({ title: '登录失败', icon: 'none' })
|
||||
|
||||
+12
-7
@@ -38,16 +38,14 @@
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 底部 TabBar -->
|
||||
<!-- <tab-bar :current="1" /> -->
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import tabBar from '@/components/TabBar/TabBar.vue'
|
||||
import config from '@/common/config.js'
|
||||
import account from '@/common/account.js'
|
||||
|
||||
export default {
|
||||
components: { tabBar },
|
||||
data() {
|
||||
return {
|
||||
isLogin: false,
|
||||
@@ -74,8 +72,9 @@ export default {
|
||||
content: '确定要退出登录吗?',
|
||||
success: (res) => {
|
||||
if (res.confirm) {
|
||||
uni.removeStorageSync('token')
|
||||
uni.removeStorageSync('phone')
|
||||
// xuchao: 原来只清 token/phone,权益缓存(isAuth/hasWin/cardNumber/expiresTime/
|
||||
// rightsCount 等)残留会被下一个账号当成自己的数据展示
|
||||
account.clearAccountCache()
|
||||
this.isLogin = false
|
||||
this.phone = ''
|
||||
uni.showToast({ title: '已退出登录', icon: 'success' })
|
||||
@@ -90,7 +89,13 @@ export default {
|
||||
uni.navigateTo({ url: '/pages/guide/use' })
|
||||
},
|
||||
goService() {
|
||||
// TODO: 联系客服
|
||||
// xuchao: 唤起拨号,号码与协议页公示的统一客服电话同源(common/config.js)
|
||||
uni.makePhoneCall({
|
||||
phoneNumber: config.servicePhone,
|
||||
fail: () => {
|
||||
uni.showToast({ title: '拨号失败,客服电话 ' + config.servicePhone, icon: 'none' })
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,241 @@
|
||||
<template>
|
||||
<view class="page">
|
||||
<view class="nav-bar">
|
||||
<view class="nav-back" @click="goBack">
|
||||
<u-icon name="arrow-left" color="#1a1818" size="40"></u-icon>
|
||||
</view>
|
||||
<text class="nav-title">确认订单</text>
|
||||
</view>
|
||||
|
||||
<!-- 券面 -->
|
||||
<view class="ticket">
|
||||
<view class="ticket-amt">200元 <text class="ticket-amt-sub">汽油电子券</text></view>
|
||||
<view class="ticket-dsc">{{ voucherName }} | 收银台扫码核销</view>
|
||||
<text class="ticket-wm">90天</text>
|
||||
</view>
|
||||
|
||||
<!-- 订单要素 -->
|
||||
<view class="card">
|
||||
<view class="kv"><text class="k">券名称</text><text class="v">{{ voucherName }}</text></view>
|
||||
<view class="kv"><text class="k">有效期</text><text class="v">购买日起 90 天</text></view>
|
||||
<view class="kv"><text class="k">购买数量</text><text class="v">1 张</text></view>
|
||||
<view class="kv"><text class="k">售价</text><text class="v">¥{{ priceText }}</text></view>
|
||||
<view class="kv"><text class="k">购买账户</text><text class="v">{{ maskedPhone }}</text></view>
|
||||
</view>
|
||||
|
||||
<!-- 支付方式 -->
|
||||
<view class="card">
|
||||
<view class="card-title">支付方式</view>
|
||||
<view class="payrow">
|
||||
<image class="pay-logo" src="https://zhihuiyou.oss-cn-shenzhen.aliyuncs.com/hhrs/hhrs_ysf_logo.png" mode="aspectFit" />
|
||||
<text class="pay-name">云闪付 App 安全支付</text>
|
||||
<view class="pay-radio"></view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="foot-note">券数量有限,售完即止;兑换后不可退换。</view>
|
||||
|
||||
<view class="footbar">
|
||||
<view class="foot-price"><text class="foot-price-label">合计 </text>¥{{ priceText }}</view>
|
||||
<view class="foot-btn" :class="{ disabled: submitting }" @click="onConfirmPay">{{ submitting ? '支付中…' : '确认支付' }}</view>
|
||||
</view>
|
||||
|
||||
<!-- xuchao: 非云闪付环境拦截弹窗,必须点「我知道了」关闭(决策 11) -->
|
||||
<view class="modal-mask" v-if="guideModal" @click.stop>
|
||||
<view class="modal-box">
|
||||
<view class="modal-text">{{ guideText }}</view>
|
||||
<view class="modal-ok" @click="guideModal = false">我知道了</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import {
|
||||
VOUCHER_NAME, VOUCHER_PRICE_TEXT, VOUCHER_GUIDE_TEXT, VOUCHER_CANCEL_TEXT,
|
||||
bizOk, bizMsg, bizData
|
||||
} from '@/common/petrolVoucher.js'
|
||||
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
phone: '',
|
||||
orderNo: '',
|
||||
submitting: false,
|
||||
guideModal: false,
|
||||
guideText: VOUCHER_GUIDE_TEXT,
|
||||
voucherName: VOUCHER_NAME,
|
||||
priceText: VOUCHER_PRICE_TEXT
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
maskedPhone() {
|
||||
if (!this.phone || this.phone.length !== 11) return this.phone || ''
|
||||
return this.phone.slice(0, 3) + '****' + this.phone.slice(7)
|
||||
}
|
||||
},
|
||||
onLoad(options) {
|
||||
this.phone = uni.getStorageSync('phone') || ''
|
||||
if (!this.phone) {
|
||||
// xuchao: 未登录先看登录,回跳本流程从门店页重新进入(决策 15)
|
||||
uni.redirectTo({ url: '/pages/index/login?redirect=' + encodeURIComponent('/pages/venue/detail?id=851219003520709&type=2') })
|
||||
return
|
||||
}
|
||||
this.loadUpSdk() // xuchao: 运行时兜底注入(静态标签已在发布脚本注入产物 index.html,见 h5-release.sh)
|
||||
if (options.orderNo) this.orderNo = options.orderNo
|
||||
this.initFromServer()
|
||||
},
|
||||
methods: {
|
||||
// xuchao: upsdk 运行时注入并返回就绪 Promise(同一加载只发起一次;超时/失败 resolve(false))。
|
||||
// 不能依赖 index.html 静态标签——HBuilderX 命令行构建的 H5 模板不吃根 index.html(会丢标签)。
|
||||
loadUpSdk(timeout = 9000) {
|
||||
if (typeof window === 'undefined' || typeof document === 'undefined') return Promise.resolve(false)
|
||||
if (window.upsdk) return Promise.resolve(true)
|
||||
if (this._upSdkPromise) return this._upSdkPromise
|
||||
const loading = new Promise(resolve => {
|
||||
let done = false
|
||||
const finish = v => { if (!done) { done = true; resolve(v) } }
|
||||
const exists = document.querySelector('script[data-upsdk]')
|
||||
if (exists) {
|
||||
// main.js 已预热注入:轮询等 window.upsdk 出现(避免重复插标签)
|
||||
const t0 = Date.now()
|
||||
const timer = setInterval(() => {
|
||||
if (window.upsdk) { clearInterval(timer); finish(true) }
|
||||
else if (Date.now() - t0 > timeout) { clearInterval(timer); finish(false) }
|
||||
}, 200)
|
||||
return
|
||||
}
|
||||
const s = document.createElement('script')
|
||||
s.src = 'https://open.95516.com/s/open/js/upsdk.js'
|
||||
s.setAttribute('data-upsdk', '1')
|
||||
s.onload = () => finish(!!window.upsdk)
|
||||
s.onerror = () => finish(false)
|
||||
document.head.appendChild(s)
|
||||
setTimeout(() => finish(!!window.upsdk), timeout)
|
||||
})
|
||||
this._upSdkPromise = loading
|
||||
return loading
|
||||
},
|
||||
// xuchao: 价格展示以服务端 latest 为准;已有待支付单自动续用;已发券直接跳券详情
|
||||
initFromServer() {
|
||||
this.$u.api.voucherLatest({ phone: this.phone }).then(res => {
|
||||
if (!bizOk(res)) return
|
||||
const d = bizData(res)
|
||||
if (d.price) this.priceText = (d.price / 100).toFixed(2)
|
||||
if (!this.orderNo && d.statusCode === 0 && d.orderNo) {
|
||||
this.orderNo = d.orderNo
|
||||
if (d.amount) this.priceText = (d.amount / 100).toFixed(2)
|
||||
}
|
||||
if (d.statusCode === 2) {
|
||||
uni.redirectTo({ url: '/pages/petrol/voucherDetail?orderNo=' + (d.orderNo || '') })
|
||||
}
|
||||
}).catch(() => {})
|
||||
},
|
||||
onConfirmPay() {
|
||||
if (this.submitting) return
|
||||
// xuchao: 不做容器/白名单前置拦截,直接发起;云闪付控件在站外唤不起时
|
||||
// 由 pay 的 fail 回调统一弹「去云闪付」指引模态(决策 11 修订:去白名单)
|
||||
this.submitting = true
|
||||
this.doPay()
|
||||
},
|
||||
doPay() {
|
||||
const step = this.orderNo
|
||||
? Promise.resolve({ orderNo: this.orderNo })
|
||||
: this.$u.api.voucherCreate({ phone: this.phone }).then(res => {
|
||||
if (!bizOk(res)) throw new Error(bizMsg(res) || '下单失败')
|
||||
return bizData(res)
|
||||
})
|
||||
step.then(d => {
|
||||
this.orderNo = d.orderNo
|
||||
return this.$u.api.voucherPrepay({ orderNo: this.orderNo, phone: this.phone })
|
||||
}).then(res => {
|
||||
if (!bizOk(res)) throw new Error(bizMsg(res) || '发起支付失败')
|
||||
const pre = bizData(res)
|
||||
const tn = pre.extendMap && pre.extendMap.resData
|
||||
if (!tn) throw new Error('未获取到支付凭证')
|
||||
this.launchUnionPay(tn)
|
||||
}).catch(err => {
|
||||
this.submitting = false
|
||||
uni.showToast({ title: (err && err.message) || '操作失败,请稍后再试', icon: 'none' })
|
||||
})
|
||||
},
|
||||
// xuchao: 云闪付控件唤起。先等 SDK 就绪(修复首点无反应:脚本异步加载未完成时
|
||||
// 旧逻辑只重试 4 秒且静默;就绪判定收敛到 loadUpSdk 的 Promise)。
|
||||
async launchUnionPay(tn) {
|
||||
const ready = await this.loadUpSdk()
|
||||
if (!ready) {
|
||||
this.submitting = false
|
||||
// xuchao: 临时诊断(定位弹窗真因后移除):SDK 加载不出来时展示 UA 片段
|
||||
this.guideText = '支付SDK未能加载[诊断] UA=' + (typeof navigator !== 'undefined' ? String(navigator.userAgent).slice(0, 120) : 'N/A')
|
||||
this.guideModal = true
|
||||
return
|
||||
}
|
||||
window.upsdk.pluginReady(() => {
|
||||
window.upsdk.pay({
|
||||
tn: tn,
|
||||
success: () => {
|
||||
uni.redirectTo({ url: '/pages/petrol/voucherDetail?orderNo=' + this.orderNo })
|
||||
},
|
||||
fail: (err) => {
|
||||
// xuchao: 控件回调失败(含用户取消)。按 xuchao 要求文案定为取消提示;
|
||||
// [诊断] 行临时保留采集真实错误码,区分"取消"与"容器不支持"后移除并分文案
|
||||
this.submitting = false
|
||||
this.guideText = VOUCHER_CANCEL_TEXT + '\n[诊断] ' + JSON.stringify(err || {})
|
||||
this.guideModal = true
|
||||
}
|
||||
})
|
||||
})
|
||||
// 控件无异步结果时兜底:3 秒后恢复按钮(支付成功路径以回跳/轮询为准)
|
||||
setTimeout(() => { this.submitting = false }, 3000)
|
||||
},
|
||||
goBack() {
|
||||
const pages = getCurrentPages()
|
||||
if (pages.length > 1) {
|
||||
uni.navigateBack()
|
||||
} else {
|
||||
uni.reLaunch({ url: '/pages/index/index' })
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style>
|
||||
.page { min-height: 100vh; background-color: #f2f2f7; padding-bottom: 80px; }
|
||||
|
||||
.nav-bar { display: flex; align-items: center; height: 56px; background-color: #ffffff; border-bottom: 1px solid #f0f0f0; position: relative; }
|
||||
.nav-back { position: absolute; left: 12px; top: 0; bottom: 0; display: flex; align-items: center; }
|
||||
.nav-title { flex: 1; text-align: center; font-size: 17px; font-weight: 600; color: #1a1818; padding: 0 56px; }
|
||||
|
||||
.ticket { position: relative; overflow: hidden; background: linear-gradient(135deg, #0d6fe0, #2f9bff); border-radius: 8px; margin: 12px; padding: 16px; color: #ffffff; }
|
||||
.ticket-amt { font-size: 26px; font-weight: 700; }
|
||||
.ticket-amt-sub { font-size: 13px; font-weight: 400; opacity: 0.9; margin-left: 4px; }
|
||||
.ticket-dsc { font-size: 12px; opacity: 0.9; margin-top: 6px; }
|
||||
.ticket-wm { position: absolute; right: 4px; bottom: -14px; font-size: 60px; font-weight: 800; opacity: 0.1; }
|
||||
|
||||
.card { background-color: #ffffff; border-radius: 8px; margin: 12px; padding: 4px 16px 8px; }
|
||||
.card-title { font-size: 15px; font-weight: 600; color: #1a1818; padding: 12px 0 4px; }
|
||||
.kv { display: flex; justify-content: space-between; align-items: center; font-size: 13px; padding: 11px 0; border-bottom: 1px solid #f2f2f7; }
|
||||
.kv:last-child { border-bottom: none; }
|
||||
.k { color: #999999; flex-shrink: 0; margin-right: 12px; }
|
||||
.v { color: #1a1818; text-align: right; word-break: break-all; }
|
||||
|
||||
.payrow { display: flex; align-items: center; padding: 6px 0 12px; }
|
||||
.pay-logo { width: 26px; height: 26px; border-radius: 5px; margin-right: 10px; flex-shrink: 0; }
|
||||
.pay-name { flex: 1; font-size: 14px; color: #1a1818; }
|
||||
.pay-radio { width: 18px; height: 18px; border-radius: 50%; background-color: #0088ff; position: relative; }
|
||||
.pay-radio::after { content: ''; position: absolute; left: 5px; top: 5px; width: 8px; height: 8px; border-radius: 50%; background-color: #ffffff; }
|
||||
|
||||
.foot-note { font-size: 12px; color: #999999; margin: 4px 16px; line-height: 1.6; }
|
||||
|
||||
.footbar { position: fixed; left: 0; right: 0; bottom: 0; height: 64px; background-color: #ffffff; border-top: 1px solid #f0f0f0; display: flex; align-items: center; padding: 0 16px; z-index: 5; }
|
||||
.foot-price { font-size: 20px; font-weight: 600; color: #ff4d4f; }
|
||||
.foot-price-label { font-size: 12px; font-weight: 400; color: #666666; }
|
||||
.foot-btn { flex: 1; margin-left: 14px; height: 44px; border-radius: 8px; background-color: #0088ff; color: #ffffff; font-size: 16px; display: flex; align-items: center; justify-content: center; }
|
||||
.foot-btn.disabled { background-color: #c8cdd4; }
|
||||
|
||||
.modal-mask { position: fixed; top: 0; left: 0; right: 0; bottom: 0; background-color: rgba(0, 0, 0, 0.45); display: flex; align-items: center; justify-content: center; z-index: 99; }
|
||||
.modal-box { width: 300px; background-color: #ffffff; border-radius: 12px; overflow: hidden; }
|
||||
.modal-text { padding: 24px 20px 20px; font-size: 14px; color: #1a1818; line-height: 1.7; text-align: center; }
|
||||
.modal-ok { height: 48px; border-top: 1px solid #f2f2f7; color: #0088ff; font-size: 16px; font-weight: 600; display: flex; align-items: center; justify-content: center; }
|
||||
</style>
|
||||
@@ -0,0 +1,261 @@
|
||||
<template>
|
||||
<view class="page">
|
||||
<view class="nav-bar">
|
||||
<view class="nav-back" @click="goBack">
|
||||
<u-icon name="arrow-left" color="#1a1818" size="40"></u-icon>
|
||||
</view>
|
||||
<text class="nav-title">券详情</text>
|
||||
</view>
|
||||
|
||||
<!-- 发券中(statusCode=1) -->
|
||||
<view class="issuing" v-if="status === 1">
|
||||
<view class="spinner"></view>
|
||||
<view class="issuing-t">支付成功,券发放中…</view>
|
||||
<view class="issuing-d">通常 10 秒内到账,请稍后刷新查看券码</view>
|
||||
<view class="btn-line" @click="refresh()">手动刷新</view>
|
||||
</view>
|
||||
|
||||
<!-- 已发券(statusCode=2):二维码 + 订单信息 -->
|
||||
<block v-else-if="status === 2">
|
||||
<view class="qrbox">
|
||||
<!-- 核销码为图片URL时直接展示 -->
|
||||
<image v-if="isQrImage" class="qr-img" :src="qrText" mode="widthFix" />
|
||||
<!-- 核销码为字符串时前端渲染二维码(每60秒向服务端换取新码) -->
|
||||
<view v-else id="petrol-qr" class="qr-canvas"></view>
|
||||
<view class="qr-tip">核销码每 60 秒自动刷新,请到店后出示给收银员扫码</view>
|
||||
</view>
|
||||
|
||||
<view class="card">
|
||||
<view class="card-title">订单信息</view>
|
||||
<view class="kv"><text class="k">券名称</text><text class="v">{{ voucherName }}</text></view>
|
||||
<view class="kv"><text class="k">有效期至</text><text class="v">{{ voucher.validUntil || '-' }}</text></view>
|
||||
<view class="kv"><text class="k">实付金额</text><text class="v">¥{{ amountText }}</text></view>
|
||||
<view class="kv"><text class="k">支付时间</text><text class="v">{{ fmtTime(voucher.payTime) }}</text></view>
|
||||
<view class="kv"><text class="k">订单号</text><text class="v">{{ voucher.orderNo }}</text></view>
|
||||
</view>
|
||||
</block>
|
||||
|
||||
<!-- 待支付(0):续付入口 -->
|
||||
<view class="state-card" v-else-if="status === 0">
|
||||
<view class="state-t">订单待支付</view>
|
||||
<view class="state-d">实付金额 ¥{{ amountText }},订单将在下单 30 分钟后自动关闭</view>
|
||||
<view class="btn-main" @click="goConfirm">继续支付</view>
|
||||
</view>
|
||||
|
||||
<!-- 已退款(3/4) -->
|
||||
<view class="state-card" v-else-if="status === 3 || status === 4">
|
||||
<view class="state-t">{{ status === 4 ? '退款处理中' : '已退款' }}</view>
|
||||
<view class="state-d">很抱歉,本券发放失败,支付金额已原路退回{{ status === 4 ? '处理中,到账请稍后查询' : '' }}。如有疑问请致电客服。</view>
|
||||
<view class="btn-main" @click="goConfirm">重新购买</view>
|
||||
</view>
|
||||
|
||||
<!-- 已关闭(5) -->
|
||||
<view class="state-card" v-else-if="status === 5">
|
||||
<view class="state-t">订单已关闭</view>
|
||||
<view class="state-d">该待支付订单已超时关闭,可重新下单购买。</view>
|
||||
<view class="btn-main" @click="goConfirm">重新购买</view>
|
||||
</view>
|
||||
|
||||
<!-- 加载中 / 无单 -->
|
||||
<view class="state-card" v-else>
|
||||
<view class="state-t">{{ status === null ? '加载中…' : '暂无券订单' }}</view>
|
||||
<view class="state-d" v-if="status === null">正在获取订单状态</view>
|
||||
<view class="state-d" v-else>您还没有购买汽油券,可返回门店页购买</view>
|
||||
<view class="btn-line" v-if="status !== null" @click="refresh()">刷新</view>
|
||||
</view>
|
||||
|
||||
<!-- 使用说明(有券或发券中都展示) -->
|
||||
<block v-if="status === 2 || status === 1">
|
||||
<view class="card">
|
||||
<view class="card-title">使用规则</view>
|
||||
<view class="ol-item" v-for="(t, i) in useRules" :key="'r' + i">{{ i + 1 }}、{{ t }}</view>
|
||||
</view>
|
||||
<view class="card">
|
||||
<view class="card-title">使用流程</view>
|
||||
<view class="ol-item" v-for="(t, i) in useFlow" :key="'f' + i">{{ i + 1 }}、{{ t }}</view>
|
||||
</view>
|
||||
</block>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import {
|
||||
VOUCHER_NAME, VOUCHER_USE_RULES, VOUCHER_USE_FLOW,
|
||||
bizOk, bizMsg, bizData
|
||||
} from '@/common/petrolVoucher.js'
|
||||
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
orderNo: '',
|
||||
phone: '',
|
||||
voucher: {},
|
||||
status: null, // null=加载中;含义对齐后端 statusCode
|
||||
qrText: '', // xuchao: 实时核销码(60 秒滚动,来自 /voucher/checkCode)
|
||||
pollTimer: null,
|
||||
pollLeft: 3,
|
||||
checkTimer: null,
|
||||
voucherName: VOUCHER_NAME,
|
||||
useRules: VOUCHER_USE_RULES,
|
||||
useFlow: VOUCHER_USE_FLOW
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
amountText() {
|
||||
const f = this.voucher.amount
|
||||
return f ? (f / 100).toFixed(2) : ''
|
||||
},
|
||||
isQrImage() {
|
||||
return typeof this.qrText === 'string' && /^https?:\/\//i.test(this.qrText)
|
||||
}
|
||||
},
|
||||
onLoad(options) {
|
||||
this.phone = uni.getStorageSync('phone') || ''
|
||||
this.orderNo = options.orderNo || ''
|
||||
if (!this.phone) {
|
||||
uni.redirectTo({ url: '/pages/index/login?redirect=' + encodeURIComponent('/pages/petrol/voucherDetail?orderNo=' + this.orderNo) })
|
||||
return
|
||||
}
|
||||
this.refresh(true)
|
||||
},
|
||||
onUnload() {
|
||||
this.stopPoll()
|
||||
this.stopCheckTimer()
|
||||
},
|
||||
methods: {
|
||||
refresh(first) {
|
||||
this.$u.api.voucherLatest({ phone: this.phone }).then(res => {
|
||||
if (!bizOk(res)) {
|
||||
uni.showToast({ title: bizMsg(res) || '查询失败', icon: 'none' })
|
||||
return
|
||||
}
|
||||
const d = bizData(res)
|
||||
if (!d || d.statusCode === undefined || d.statusCode === -1) {
|
||||
this.status = -1
|
||||
this.voucher = {}
|
||||
return
|
||||
}
|
||||
this.voucher = d
|
||||
this.status = d.statusCode
|
||||
if (this.status === 1) {
|
||||
// xuchao: 发券中轮询(支付回跳后 5 秒 ×3 次;手动刷新不限量)
|
||||
if (first && this.pollLeft > 0) this.startPoll()
|
||||
} else {
|
||||
this.stopPoll()
|
||||
}
|
||||
if (this.status === 2) {
|
||||
this.loadCheckCode()
|
||||
} else {
|
||||
this.stopCheckTimer()
|
||||
}
|
||||
}).catch(() => {
|
||||
if (first) uni.showToast({ title: '网络异常,请稍后重试', icon: 'none' })
|
||||
})
|
||||
},
|
||||
startPoll() {
|
||||
this.stopPoll()
|
||||
this.pollTimer = setInterval(() => {
|
||||
if (this.pollLeft <= 0) { this.stopPoll(); return }
|
||||
this.pollLeft -= 1
|
||||
this.refresh(false)
|
||||
}, 5000)
|
||||
},
|
||||
stopPoll() {
|
||||
if (this.pollTimer) { clearInterval(this.pollTimer); this.pollTimer = null }
|
||||
},
|
||||
// xuchao: 取实时核销码并渲染;CNPC 侧 60 秒滚动,前端每 55 秒预取刷新
|
||||
loadCheckCode() {
|
||||
const orderNo = this.voucher.orderNo || this.orderNo
|
||||
if (!orderNo) return
|
||||
this.$u.api.voucherCheckCode({ orderNo, phone: this.phone }).then(res => {
|
||||
if (!bizOk(res)) { uni.showToast({ title: bizMsg(res) || '获取核销码失败', icon: 'none' }); return }
|
||||
const d = bizData(res)
|
||||
this.qrText = d.checkCode || ''
|
||||
this.$nextTick(() => this.renderQr())
|
||||
this.startCheckTimer()
|
||||
}).catch(() => {})
|
||||
},
|
||||
startCheckTimer() {
|
||||
this.stopCheckTimer()
|
||||
this.checkTimer = setInterval(() => this.loadCheckCode(), 55000)
|
||||
},
|
||||
stopCheckTimer() {
|
||||
if (this.checkTimer) { clearInterval(this.checkTimer); this.checkTimer = null }
|
||||
},
|
||||
// xuchao: 核销码字符串→二维码渲染;qrcode.min.js 为本地静态资源(static/js/),动态注入一次
|
||||
renderQr() {
|
||||
if (this.isQrImage) return
|
||||
if (!this.qrText) return
|
||||
const draw = () => {
|
||||
if (typeof document === 'undefined' || typeof window.QRCode === 'undefined') return
|
||||
const el = document.getElementById('petrol-qr')
|
||||
if (!el) return
|
||||
el.innerHTML = ''
|
||||
// eslint-disable-next-line no-new
|
||||
new window.QRCode(el, {
|
||||
text: this.qrText,
|
||||
width: 200, height: 200, colorDark: '#1a1818', colorLight: '#ffffff',
|
||||
correctLevel: window.QRCode.CorrectLevel.H
|
||||
})
|
||||
}
|
||||
if (typeof window !== 'undefined' && window.QRCode) { draw(); return }
|
||||
if (typeof document === 'undefined') return
|
||||
const s = document.createElement('script')
|
||||
s.src = '/static/js/qrcode.min.js'
|
||||
s.onload = draw
|
||||
document.head.appendChild(s)
|
||||
},
|
||||
goConfirm() {
|
||||
uni.navigateTo({ url: '/pages/petrol/orderConfirm' + (this.status === 0 ? '?orderNo=' + this.voucher.orderNo : '') })
|
||||
},
|
||||
fmtTime(t) {
|
||||
if (!t) return '-'
|
||||
return String(t).replace('T', ' ').slice(0, 16)
|
||||
},
|
||||
goBack() {
|
||||
const pages = getCurrentPages()
|
||||
if (pages.length > 1) {
|
||||
uni.navigateBack()
|
||||
} else {
|
||||
uni.reLaunch({ url: '/pages/index/index' })
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style>
|
||||
.page { min-height: 100vh; background-color: #f2f2f7; padding-bottom: 24px; }
|
||||
|
||||
.nav-bar { display: flex; align-items: center; height: 56px; background-color: #ffffff; border-bottom: 1px solid #f0f0f0; position: relative; }
|
||||
.nav-back { position: absolute; left: 12px; top: 0; bottom: 0; display: flex; align-items: center; }
|
||||
.nav-title { flex: 1; text-align: center; font-size: 17px; font-weight: 600; color: #1a1818; padding: 0 56px; }
|
||||
|
||||
.qrbox { position: relative; background-color: #ffffff; border-radius: 8px; margin: 12px; padding: 28px 20px 18px; text-align: center; }
|
||||
.qr-canvas { display: inline-block; }
|
||||
.qr-canvas img, .qr-canvas canvas { display: block; }
|
||||
.qr-img { width: 200px; }
|
||||
.qr-tip { font-size: 12px; color: #999999; margin-top: 12px; }
|
||||
|
||||
.card { background-color: #ffffff; border-radius: 8px; margin: 12px; padding: 4px 16px 12px; }
|
||||
.card-title { font-size: 15px; font-weight: 600; color: #1a1818; padding: 14px 0 2px; }
|
||||
.kv { display: flex; justify-content: space-between; align-items: center; font-size: 13px; padding: 11px 0; border-bottom: 1px solid #f2f2f7; }
|
||||
.kv:last-child { border-bottom: none; }
|
||||
.k { color: #999999; flex-shrink: 0; margin-right: 12px; }
|
||||
.v { color: #1a1818; text-align: right; word-break: break-all; }
|
||||
.ol-item { font-size: 13px; color: #666666; line-height: 1.8; }
|
||||
|
||||
.issuing { background-color: #ffffff; border-radius: 8px; margin: 12px; padding: 46px 20px 26px; text-align: center; }
|
||||
.spinner { width: 44px; height: 44px; border: 3px solid #dbe9ff; border-top-color: #0088ff; border-radius: 50%; margin: 0 auto 16px; animation: spin 1s linear infinite; }
|
||||
@keyframes spin { to { transform: rotate(360deg); } }
|
||||
.issuing-t { font-size: 16px; color: #1a1818; font-weight: 600; margin-bottom: 6px; }
|
||||
.issuing-d { font-size: 12px; color: #999999; line-height: 1.7; margin-bottom: 18px; }
|
||||
|
||||
.state-card { background-color: #ffffff; border-radius: 8px; margin: 12px; padding: 30px 20px; text-align: center; }
|
||||
.state-t { font-size: 17px; font-weight: 600; color: #1a1818; margin-bottom: 8px; }
|
||||
.state-d { font-size: 13px; color: #999999; line-height: 1.7; margin-bottom: 20px; }
|
||||
|
||||
.btn-main { height: 44px; border-radius: 8px; background-color: #0088ff; color: #ffffff; font-size: 15px; display: flex; align-items: center; justify-content: center; }
|
||||
.btn-line { height: 42px; border-radius: 8px; border: 1px solid #0088ff; color: #0088ff; font-size: 15px; display: flex; align-items: center; justify-content: center; background-color: #ffffff; margin: 0 30px; }
|
||||
.issuing .btn-line { margin: 0; }
|
||||
</style>
|
||||
+10
-4
@@ -1,6 +1,8 @@
|
||||
<template>
|
||||
<view class="page">
|
||||
<view v-if="detail">
|
||||
<!-- xuchao: 底部「立即预约」是 fixed 不占位,短屏滚到底会把「权益说明」压住;
|
||||
有底栏时给内容区预留 80px(底栏 68px + 12px 呼吸位)+ 安全区 -->
|
||||
<view v-if="detail" :class="{ 'has-bottom-bar': detail.isAppointment }">
|
||||
<!-- 门店信息卡片(信息+地址合并容器) -->
|
||||
<view class="store-card">
|
||||
<view class="store-main">
|
||||
@@ -143,10 +145,9 @@ export default {
|
||||
}).catch(() => {
|
||||
uni.showToast({ title: '预约失败', icon: 'none' })
|
||||
})
|
||||
} else {
|
||||
// TODO: 调用使用接口
|
||||
uni.showToast({ title: '使用成功', icon: 'success' })
|
||||
}
|
||||
// xuchao: 非预约权益没有“线上使用”动作——到店由商户核销,结果体现在权益包「已使用」列表;
|
||||
// 底部按钮本身也只在 detail.isAppointment 时渲染,故删除原先只弹假 Toast 的不可达分支
|
||||
},
|
||||
loadDetail(ruleId) {
|
||||
const loc = uni.getStorageSync('lng') && uni.getStorageSync('lat')
|
||||
@@ -443,6 +444,11 @@ export default {
|
||||
}
|
||||
|
||||
/* 底部预约按钮 */
|
||||
/* xuchao: 内容区为 fixed 底栏预留的高度,短屏下「权益说明」才不会被遮住 */
|
||||
.has-bottom-bar {
|
||||
padding-bottom: calc(80px + env(safe-area-inset-bottom));
|
||||
}
|
||||
|
||||
.bottom-bar {
|
||||
position: fixed;
|
||||
bottom: 0;
|
||||
|
||||
+234
-158
@@ -46,7 +46,7 @@
|
||||
<view class="tips-list">
|
||||
<text class="tip-item">1. 请输入真实的身份信息用来进行活动权益资格认证</text>
|
||||
<text class="tip-item">2. 认证通过后系统会显示出您的所获得的权益信息</text>
|
||||
<text class="tip-item">3. 手机号码为您登录的手机,无法修改。若号码对,请更换登录手机。</text>
|
||||
<text class="tip-item">3. 手机号码为您登录的手机号,无法修改。若号码不对,请更换手机号重新登录。</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
@@ -89,7 +89,9 @@
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
</view>
|
||||
<!-- xuchao: Tab + 搜索 + 县区/类型筛选一起吸顶;筛选只作用于「待使用」(另两个 Tab 的接口不返回地址与分类) -->
|
||||
<view class="info-sticky">
|
||||
<!-- Tab 切换 -->
|
||||
<view class="tab-bar">
|
||||
<view v-for="(tab, index) in tabs" :key="index" class="tab-item"
|
||||
@@ -97,20 +99,27 @@
|
||||
<text class="tab-text">{{ tab }}</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<!-- 搜索栏 -->
|
||||
<view class="search-area" v-if="currentTab==0">
|
||||
<view class="search-bar">
|
||||
<u-icon name="search" color="#cccccc" size="24"></u-icon>
|
||||
<input class="search-input" v-model="keyword" placeholder="搜索权益商家" @confirm="onSearch" />
|
||||
<!-- 搜索栏 -->
|
||||
<view class="search-area" v-if="currentTab==0">
|
||||
<view class="search-bar">
|
||||
<u-icon name="search" color="#cccccc" size="24"></u-icon>
|
||||
<input class="search-input" v-model="keyword" placeholder="搜索权益商家" @confirm="onSearch" />
|
||||
</view>
|
||||
<!-- xuchao: 所属县区 + 所属类型筛选,选项与联动条数由列表接口一并返回 -->
|
||||
<hhrs-filter-bar :districts="filters.districts" :categories="filters.categories"
|
||||
:district-id="districtId" :category="category" @change="onFilterChange" />
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 权益列表 -->
|
||||
<scroll-view class="list-area" scroll-y @scrolltolower="loadMore" :lower-threshold="100"
|
||||
v-if="currentTab==0">
|
||||
<!-- xuchao: 三 Tab 列表统一改普通容器 + 页面级触底分页(scroll-view 无固定高度时 scrolltolower 永不触发) -->
|
||||
<view class="list-area list-area--todo" v-if="currentTab==0">
|
||||
<view class="rights-card" v-for="item in rightsList" :key="item.ruleId" @click="goDetail(item)">
|
||||
<image class="card-img" :src="item.image" mode="aspectFill" />
|
||||
<view class="card-thumb">
|
||||
<image class="card-img" :src="item.image" mode="aspectFill" />
|
||||
<!-- xuchao: 左上角所属地区角标(districtName 来自商铺「所在地区」,未录入则不显示) -->
|
||||
<text class="card-area" v-if="item.districtName">{{ shortDistrict(item.districtName) }}</text>
|
||||
</view>
|
||||
<view class="card-info">
|
||||
<view class="card-name">{{ item.name }}</view>
|
||||
<view class="card-category">{{ item.category }}</view>
|
||||
@@ -124,28 +133,33 @@
|
||||
</view>
|
||||
|
||||
<view class="empty-state" v-if="rightsList.length === 0 && !loading">
|
||||
<image class="empty-state-img" src="https://zhihuiyou.oss-cn-shenzhen.aliyuncs.com/hhrs/hhrs_wzj.png" mode="widthFix"></image>
|
||||
<image class="empty-state-img" src="https://aliyunoss.hn12301.net/hhrs/hhrs_wzj.png" mode="widthFix"></image>
|
||||
<text class="empty-state-text">暂无内容</text>
|
||||
</view>
|
||||
</scroll-view>
|
||||
<view v-if="pager[0].hasScrolled" class="nomore-area">
|
||||
<u-loadmore :status="loadStatuses[0]" :load-text="{ loadmore: '', loading: '加载中...', nomore: '我也是有底线的' }" />
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<scroll-view class="list-area" scroll-y @scrolltolower="loadAppointmentMore" :lower-threshold="100"
|
||||
v-if="currentTab==1">
|
||||
<view class="list-area" v-if="currentTab==1">
|
||||
<view class="rights-card" style="margin-top: 24rpx;flex-direction: column;" v-for="item in appointmentList"
|
||||
:key="item.id" >
|
||||
<view style="width: 654rpx;display: flex;justify-content: space-between;">
|
||||
<text>{{ item.resourceName }}</text><text style="color: #34C759;">已预约</text></view>
|
||||
<view style="font-size: 24rpx;color: #727272;margin-top: 24rpx;">预约游玩日期:{{ item.appTime.split(' ')[0] }}
|
||||
<!-- xuchao: appTime 为空时不再抛错拖垮整页渲染 -->
|
||||
<view style="font-size: 24rpx;color: #727272;margin-top: 24rpx;">预约游玩日期:{{ (item.appTime || '').split(' ')[0] }}
|
||||
<text v-if="item.timeName">({{ item.timeName }})</text></view>
|
||||
</view>
|
||||
|
||||
<view class="empty-state" v-if="appointmentList.length === 0 && !appointmentLoading">
|
||||
<image class="empty-state-img" src="https://zhihuiyou.oss-cn-shenzhen.aliyuncs.com/hhrs/hhrs_wzj.png" mode="widthFix"></image>
|
||||
<image class="empty-state-img" src="https://aliyunoss.hn12301.net/hhrs/hhrs_wzj.png" mode="widthFix"></image>
|
||||
<text class="empty-state-text">暂无内容</text>
|
||||
</view>
|
||||
</scroll-view>
|
||||
<scroll-view class="list-area" scroll-y @scrolltolower="loadCheckMore" :lower-threshold="100"
|
||||
v-if="currentTab==2">
|
||||
<view v-if="pager[1].hasScrolled" class="nomore-area">
|
||||
<u-loadmore :status="loadStatuses[1]" :load-text="{ loadmore: '', loading: '加载中...', nomore: '我也是有底线的' }" />
|
||||
</view>
|
||||
</view>
|
||||
<view class="list-area" v-if="currentTab==2">
|
||||
<view class="rights-card" style="margin-top: 24rpx;flex-direction: column;" v-for="item in checkList"
|
||||
:key="item.id" >
|
||||
<view style="width: 654rpx;display: flex;justify-content: space-between;">
|
||||
@@ -153,22 +167,26 @@
|
||||
<view style="font-size: 24rpx;color: #727272;margin-top: 24rpx;">核销时间:{{ item.checkTime }}</view>
|
||||
</view>
|
||||
<view class="empty-state" v-if="checkList.length === 0 && !checkLoading">
|
||||
<image class="empty-state-img" src="https://zhihuiyou.oss-cn-shenzhen.aliyuncs.com/hhrs/hhrs_wzj.png" mode="widthFix"></image>
|
||||
<image class="empty-state-img" src="https://aliyunoss.hn12301.net/hhrs/hhrs_wzj.png" mode="widthFix"></image>
|
||||
<text class="empty-state-text">暂无内容</text>
|
||||
</view>
|
||||
<view class="loading" v-if="checkLoading">
|
||||
<text class="loading-text">加载中...</text>
|
||||
<!-- xuchao: 原先自写的“加载中/没有更多”与另两个 Tab 不一致,统一换成 u-loadmore -->
|
||||
<view v-if="pager[2].hasScrolled" class="nomore-area">
|
||||
<u-loadmore :status="loadStatuses[2]" :load-text="{ loadmore: '', loading: '加载中...', nomore: '我也是有底线的' }" />
|
||||
</view>
|
||||
<view class="no-more" v-else-if="checkList.length >= checkTotal && checkList.length > 0">
|
||||
<text class="no-more-text">没有更多了</text>
|
||||
</view>
|
||||
</scroll-view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
// xuchao: 角标区县简称(后端返回的是行政区划全称)
|
||||
import { shortDistrict } from '@/common/district.js'
|
||||
// xuchao: 县区 + 类型筛选条,三个列表页共用(pages.json 的 easycom 只给 u- 前缀配了规则,这里显式引入)
|
||||
import HhrsFilterBar from '@/components/hhrs-filter-bar/hhrs-filter-bar.vue'
|
||||
|
||||
export default {
|
||||
components: { HhrsFilterBar },
|
||||
data() {
|
||||
return {
|
||||
status: 'auth',
|
||||
@@ -186,21 +204,27 @@
|
||||
tabs: ['待使用', '已预约', '已使用'],
|
||||
currentTab: 0,
|
||||
keyword: '',
|
||||
// xuchao: 待使用列表的县区/类型筛选条件与面板选项(选项由列表响应带回)
|
||||
districtId: '',
|
||||
category: '',
|
||||
filters: { districts: [], categories: [] },
|
||||
// xuchao: 待使用列表的县区/类型筛选条件与面板选项(选项由列表响应带回)
|
||||
districtId: '',
|
||||
category: '',
|
||||
filters: { districts: [], categories: [] },
|
||||
rightsList: [],
|
||||
pageNo: 1,
|
||||
pageSize: 1000,
|
||||
total: 0,
|
||||
appointmentList: [],
|
||||
checkList: [],
|
||||
// xuchao: 三个 Tab 各自独立的分页游标/加载态。原 pageSize=1000 是“一次拉全量 +
|
||||
// scroll-view 永不触发的假分页”,现改真实分页(与场馆/折扣页口径一致)
|
||||
pageSize: 10,
|
||||
pager: [
|
||||
{ pageNo: 1, total: 0, loading: false, reqSeq: 0, hasScrolled: false },
|
||||
{ pageNo: 1, total: 0, loading: false, reqSeq: 0, hasScrolled: false },
|
||||
{ pageNo: 1, total: 0, loading: false, reqSeq: 0, hasScrolled: false }
|
||||
],
|
||||
lng: '',
|
||||
lat: '',
|
||||
loading: false,
|
||||
appointmentList: [],
|
||||
appointmentPageNo: 1,
|
||||
appointmentTotal: 0,
|
||||
appointmentLoading: false,
|
||||
checkList: [],
|
||||
checkPageNo: 1,
|
||||
checkTotal: 0,
|
||||
checkLoading: false
|
||||
lat: ''
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
@@ -208,6 +232,24 @@
|
||||
totalValueText() {
|
||||
const yuan = this.totalValueFen / 100
|
||||
return Number.isInteger(yuan) ? String(yuan) : yuan.toFixed(2)
|
||||
},
|
||||
// xuchao: 模板沿用原有 loading / appointmentLoading / checkLoading 字段名
|
||||
loading() {
|
||||
return this.pager[0].loading
|
||||
},
|
||||
appointmentLoading() {
|
||||
return this.pager[1].loading
|
||||
},
|
||||
checkLoading() {
|
||||
return this.pager[2].loading
|
||||
},
|
||||
// xuchao: 各 Tab 底部“加载中/没有更多”独立计算,避免并行请求互相覆盖
|
||||
loadStatuses() {
|
||||
return this.pager.map((p, i) => {
|
||||
if (p.loading) return 'loading'
|
||||
const len = this.listOf(i).length
|
||||
return (len === 0 || len >= p.total) ? 'nomore' : 'loadmore'
|
||||
})
|
||||
}
|
||||
},
|
||||
onLoad(options) {
|
||||
@@ -231,7 +273,19 @@
|
||||
this.loadRightsList()
|
||||
}
|
||||
},
|
||||
// xuchao: 页面级触底加载 —— 只作用于当前 Tab
|
||||
onReachBottom() {
|
||||
if (this.status !== 'info') return
|
||||
const tab = this.currentTab
|
||||
const p = this.pager[tab]
|
||||
p.hasScrolled = true
|
||||
if (!p.loading && this.listOf(tab).length < p.total) {
|
||||
p.pageNo++
|
||||
this.loadList(tab)
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
shortDistrict,
|
||||
// xuchao: 缓存的权益状态可能过期(中奖/权益包会变化),每次进页面仅凭手机号向服务端
|
||||
// 复查最新状态并覆盖缓存(不带证件号,避免触发被动认证)
|
||||
refreshStatus() {
|
||||
@@ -427,110 +481,101 @@
|
||||
})
|
||||
})
|
||||
},
|
||||
loadRightsList() {
|
||||
const cardNumber = uni.getStorageSync('cardNumber') || ''
|
||||
this.fetchRightsList(cardNumber)
|
||||
// xuchao: Tab 索引 <-> 列表字段的唯一映射
|
||||
listOf(tab) {
|
||||
return tab === 1 ? this.appointmentList : tab === 2 ? this.checkList : this.rightsList
|
||||
},
|
||||
fetchRightsList(cardNumber) {
|
||||
if (this.loading) return
|
||||
this.loading = true
|
||||
this.$u.api.getRightsList({
|
||||
pageNo: this.pageNo,
|
||||
setList(tab, list) {
|
||||
if (tab === 1) {
|
||||
this.appointmentList = list
|
||||
} else if (tab === 2) {
|
||||
this.checkList = list
|
||||
} else {
|
||||
this.rightsList = list
|
||||
}
|
||||
},
|
||||
// xuchao: 三个 Tab 的统一分页加载器(reset=true 回到第一页重拉)
|
||||
loadList(tab, reset) {
|
||||
const p = this.pager[tab]
|
||||
if (reset) {
|
||||
p.pageNo = 1
|
||||
p.total = 0
|
||||
this.setList(tab, [])
|
||||
}
|
||||
// xuchao: 请求序号 —— 新请求取代在途请求,过期响应整体丢弃(治搜索/切 Tab 竞态)
|
||||
const seq = ++p.reqSeq
|
||||
p.loading = true
|
||||
const params = {
|
||||
pageNo: p.pageNo,
|
||||
pageSize: this.pageSize,
|
||||
keyword: this.keyword,
|
||||
lng: this.lng,
|
||||
lat: this.lat,
|
||||
cardNumber: cardNumber
|
||||
}).then(res => {
|
||||
cardNumber: uni.getStorageSync('cardNumber') || ''
|
||||
}
|
||||
let request
|
||||
if (tab === 1) {
|
||||
request = this.$u.api.getAppointmentList(params)
|
||||
} else if (tab === 2) {
|
||||
request = this.$u.api.getCheckList(params)
|
||||
} else {
|
||||
params.keyword = this.keyword
|
||||
params.lng = this.lng
|
||||
params.lat = this.lat
|
||||
if (this.districtId) params.districtId = this.districtId
|
||||
if (this.category) params.category = this.category
|
||||
request = this.$u.api.getRightsList(params)
|
||||
}
|
||||
request.then(res => {
|
||||
if (seq !== p.reqSeq) return
|
||||
// xuchao: 筛选面板选项只随「待使用」列表返回,另两个 Tab 不覆盖
|
||||
if (tab === 0 && res.errcode === 0 && res.data) {
|
||||
this.filters = {
|
||||
districts: res.data.districts || [],
|
||||
categories: res.data.categories || []
|
||||
}
|
||||
}
|
||||
if (res.errcode === 0 && res.data) {
|
||||
const list = res.data.list || []
|
||||
if (this.pageNo === 1) {
|
||||
this.rightsList = list
|
||||
const prev = this.listOf(tab)
|
||||
// xuchao: 按 id/ruleId 去重合并 —— 兜住后端忽略 pageNo 重复返回同一页的情况
|
||||
const seen = {}
|
||||
const merged = (p.pageNo === 1 ? list : prev.concat(list)).filter(item => {
|
||||
const k = (item.id === undefined || item.id === null) ? item.ruleId : item.id
|
||||
if (k === undefined || k === null) return true
|
||||
if (seen[k]) return false
|
||||
seen[k] = true
|
||||
return true
|
||||
})
|
||||
// xuchao: 本页不足一页 或 整页都是重复 => 视为已到尾部,钉住 total,
|
||||
// 防止 total 中途变大时反复空翻/空转
|
||||
if (list.length < this.pageSize || (p.pageNo !== 1 && merged.length === prev.length)) {
|
||||
p.total = merged.length
|
||||
} else {
|
||||
this.rightsList = this.rightsList.concat(list)
|
||||
p.total = res.data.total || 0
|
||||
}
|
||||
this.total = res.data.total || 0
|
||||
this.setList(tab, merged)
|
||||
}
|
||||
}).finally(() => {
|
||||
this.loading = false
|
||||
if (seq !== p.reqSeq) return
|
||||
p.loading = false
|
||||
})
|
||||
},
|
||||
loadMore() {
|
||||
if (this.rightsList.length < this.total && !this.loading) {
|
||||
this.pageNo++
|
||||
this.loadRightsList()
|
||||
}
|
||||
loadRightsList() {
|
||||
this.loadList(0, true)
|
||||
},
|
||||
switchTab(index) {
|
||||
this.currentTab = index
|
||||
if (index === 1 && this.appointmentList.length === 0) {
|
||||
this.appointmentPageNo = 1
|
||||
this.loadAppointmentList()
|
||||
}
|
||||
if (index === 2 && this.checkList.length === 0) {
|
||||
this.checkPageNo = 1
|
||||
this.loadCheckList()
|
||||
}
|
||||
},
|
||||
loadAppointmentList() {
|
||||
const cardNumber = uni.getStorageSync('cardNumber') || ''
|
||||
if (this.appointmentLoading) return
|
||||
this.appointmentLoading = true
|
||||
this.$u.api.getAppointmentList({
|
||||
pageNo: this.appointmentPageNo,
|
||||
pageSize: this.pageSize,
|
||||
cardNumber: cardNumber
|
||||
}).then(res => {
|
||||
if (res.errcode === 0 && res.data) {
|
||||
const list = res.data.list || []
|
||||
if (this.appointmentPageNo === 1) {
|
||||
this.appointmentList = list
|
||||
} else {
|
||||
this.appointmentList = this.appointmentList.concat(list)
|
||||
}
|
||||
this.appointmentTotal = res.data.total || 0
|
||||
}
|
||||
}).finally(() => {
|
||||
this.appointmentLoading = false
|
||||
})
|
||||
},
|
||||
loadAppointmentMore() {
|
||||
if (this.appointmentList.length < this.appointmentTotal && !this.appointmentLoading) {
|
||||
this.appointmentPageNo++
|
||||
this.loadAppointmentList()
|
||||
}
|
||||
},
|
||||
loadCheckList() {
|
||||
const cardNumber = uni.getStorageSync('cardNumber') || ''
|
||||
if (this.checkLoading) return
|
||||
this.checkLoading = true
|
||||
this.$u.api.getCheckList({
|
||||
pageNo: this.checkPageNo,
|
||||
pageSize: this.pageSize,
|
||||
cardNumber: cardNumber
|
||||
}).then(res => {
|
||||
if (res.errcode === 0 && res.data) {
|
||||
const list = res.data.list || []
|
||||
if (this.checkPageNo === 1) {
|
||||
this.checkList = list
|
||||
} else {
|
||||
this.checkList = this.checkList.concat(list)
|
||||
}
|
||||
this.checkTotal = res.data.total || 0
|
||||
}
|
||||
}).finally(() => {
|
||||
this.checkLoading = false
|
||||
})
|
||||
},
|
||||
loadCheckMore() {
|
||||
if (this.checkList.length < this.checkTotal && !this.checkLoading) {
|
||||
this.checkPageNo++
|
||||
this.loadCheckList()
|
||||
// xuchao: 首次进入该 Tab 才拉首页;已有数据保留各自游标继续分页
|
||||
if (this.listOf(index).length === 0 && !this.pager[index].loading) {
|
||||
this.loadList(index, true)
|
||||
}
|
||||
},
|
||||
onSearch() {
|
||||
this.pageNo = 1
|
||||
this.loadRightsList()
|
||||
this.loadList(0, true)
|
||||
},
|
||||
// xuchao: 换筛选条件即回第 1 页重查(关键词保持不变,两者为 AND)
|
||||
onFilterChange(e) {
|
||||
this.districtId = e.districtId
|
||||
this.category = e.category
|
||||
this.loadList(0, true)
|
||||
},
|
||||
goDetail(item) {
|
||||
uni.navigateTo({
|
||||
@@ -788,11 +833,20 @@
|
||||
background-color: #eeeeee;
|
||||
}
|
||||
|
||||
/* xuchao: Tab + 搜索 + 筛选条一起吸顶。padding-top 替代原 tab-bar 的 margin-top,
|
||||
否则吸顶后顶部会留一条能透出列表内容的缝隙;z-index 需高于筛选遮罩(90) */
|
||||
.info-sticky {
|
||||
background-color: #ffffff;
|
||||
padding-top: 12px;
|
||||
position: sticky;
|
||||
top: 0;
|
||||
z-index: 100;
|
||||
}
|
||||
|
||||
/* Tab 切换 */
|
||||
.tab-bar {
|
||||
display: flex;
|
||||
background-color: #ffffff;
|
||||
margin-top: 12px;
|
||||
padding: 0 16px;
|
||||
}
|
||||
|
||||
@@ -827,7 +881,8 @@
|
||||
|
||||
/* 搜索栏 */
|
||||
.search-area {
|
||||
padding: 12px;
|
||||
/* xuchao: 底部留白交给筛选条的 20rpx 上内边距,保证三段间距一致 */
|
||||
padding: 12px 12px 0;
|
||||
}
|
||||
|
||||
.search-bar {
|
||||
@@ -835,6 +890,10 @@
|
||||
align-items: center;
|
||||
height: 36px;
|
||||
background-color: #ffffff;
|
||||
/* xuchao: 头部改白底后,白色搜索框在白色吸顶栏上必须描边才分得出来;
|
||||
显式 border-box 保证加边框后高度仍是 36px */
|
||||
border: 1px solid #e5e5ea;
|
||||
box-sizing: border-box;
|
||||
border-radius: 18px;
|
||||
padding: 0 12px;
|
||||
gap: 8px;
|
||||
@@ -847,12 +906,23 @@
|
||||
}
|
||||
|
||||
/* 权益列表 */
|
||||
/* xuchao: 原 scroll-view 下 gap 不生效(卡片被包在 scroll-view-content 内),
|
||||
改普通容器后去掉 gap,卡片间距仍由 .rights-card 的 margin-bottom 提供,视觉不变 */
|
||||
.list-area {
|
||||
|
||||
width: 750rpx;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 10px;
|
||||
}
|
||||
|
||||
/* xuchao: 「待使用」列表顶部 24rpx(=12px) 灰底间隔,与卡片之间的间距一致,
|
||||
也与筛选条和列表之间的 12px 对齐;只加在这个 Tab,不影响「已预约/已使用」 */
|
||||
.list-area--todo {
|
||||
padding-top: 24rpx;
|
||||
}
|
||||
|
||||
.nomore-area {
|
||||
width: 100%;
|
||||
padding-bottom: 24px;
|
||||
}
|
||||
|
||||
.rights-card {
|
||||
@@ -865,12 +935,38 @@
|
||||
margin-bottom: 24rpx;
|
||||
}
|
||||
|
||||
.card-img {
|
||||
width: 150rpx;
|
||||
height: 150rpx;
|
||||
border-radius: 6px;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
.card-thumb {
|
||||
width: 150rpx;
|
||||
height: 150rpx;
|
||||
border-radius: 6px;
|
||||
overflow: hidden;
|
||||
position: relative;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
/* xuchao: image 由 thumb 裁圆角,自身不再设圆角 */
|
||||
.card-img {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
display: block;
|
||||
}
|
||||
|
||||
.card-area {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
display: block;
|
||||
max-width: 100%;
|
||||
padding: 1px 5px;
|
||||
border-radius: 0 0 6px 0;
|
||||
background: rgba(0, 0, 0, 0.45);
|
||||
color: #ffffff;
|
||||
font-size: 10px;
|
||||
line-height: 14px;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.card-info {
|
||||
width: 490rpx;
|
||||
@@ -924,26 +1020,6 @@
|
||||
color: #999999;
|
||||
}
|
||||
|
||||
.loading {
|
||||
text-align: center;
|
||||
padding: 16px 0;
|
||||
}
|
||||
|
||||
.loading-text {
|
||||
font-size: 14px;
|
||||
color: #999999;
|
||||
}
|
||||
|
||||
.no-more {
|
||||
text-align: center;
|
||||
padding: 16px 0;
|
||||
}
|
||||
|
||||
.no-more-text {
|
||||
font-size: 14px;
|
||||
color: #999999;
|
||||
}
|
||||
|
||||
.empty-state {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
|
||||
+115
-12
@@ -15,7 +15,7 @@
|
||||
<view class="store-info">
|
||||
<text class="store-name">{{ store.name }}</text>
|
||||
<text class="store-category">{{ store.category }}</text>
|
||||
<text class="store-hours">营业时间:{{ store.businessTime }}</text>
|
||||
<text class="store-hours" v-if="store.businessTime">营业时间:{{ store.businessTime }}</text>
|
||||
</view>
|
||||
</view>
|
||||
<view class="divider"></view>
|
||||
@@ -42,8 +42,8 @@
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 商品信息(内容取商铺门票信息字段) -->
|
||||
<view class="discount-section" v-if="ticketInfoList.length">
|
||||
<!-- 商品信息(仅商户折扣板块展示,内容取商铺门票信息字段) -->
|
||||
<view class="discount-section" v-if="!isVenue && ticketInfoList.length">
|
||||
<view class="section-title">
|
||||
<image src="https://aliyunoss.hn12301.net/hhrs/hhrs_qysm.png" style="width: 30rpx;height: 30rpx;"></image>
|
||||
<text class="discount-title">商品信息</text>
|
||||
@@ -53,16 +53,31 @@
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 商户优惠 -->
|
||||
<view class="discount-section">
|
||||
<!-- 文旅场馆显示「使用说明」(1001板块备注),商户折扣显示「商户优惠」(1002板块备注) -->
|
||||
<view class="discount-section" v-if="remarkList.length">
|
||||
<view class="section-title">
|
||||
<image src="https://aliyunoss.hn12301.net/hhrs/hhrs_qysm.png" style="width: 30rpx;height: 30rpx;"></image>
|
||||
<text class="discount-title">商户优惠</text>
|
||||
<text class="discount-title">{{ isVenue ? '使用说明' : '商户优惠' }}</text>
|
||||
</view>
|
||||
<view class="discount-list">
|
||||
<text class="discount-item" v-for="(item, index) in discountList" :key="index">{{ item }}</text>
|
||||
<text class="discount-item" v-for="(item, index) in remarkList" :key="index">{{ item }}</text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- xuchao: 怀化石油汽油券购买模块(shopId 写死特判,只服务该门店,决策 1/10/15) -->
|
||||
<view class="voucher-card" v-if="isPetrol">
|
||||
<view class="section-title">
|
||||
<image src="https://aliyunoss.hn12301.net/hhrs/hhrs_qysm.png" style="width: 30rpx;height: 30rpx;"></image>
|
||||
<text class="discount-title">汽油电子券</text>
|
||||
</view>
|
||||
<view class="voucher-ticket">
|
||||
<view class="voucher-amt">200元 <text class="voucher-amt-sub">汽油电子券</text></view>
|
||||
<view class="voucher-rule">无门槛 | 90 天有效 | 单日限用 1 张 | 可叠加</view>
|
||||
<text class="voucher-wm">90天</text>
|
||||
</view>
|
||||
<view class="voucher-tip">支付成功后券码即时展示;到店出示二维码,收银员以“中石油汽油券”通道扫码核销。券一经售出不支持退换。</view>
|
||||
<view class="voucher-btn" @click="onVoucherClick">{{ voucherBtnText }}</view>
|
||||
</view>
|
||||
</view>
|
||||
<!-- xuchao: 门店不存在或加载失败时的提示态,避免纯空白 -->
|
||||
<view class="page" v-else-if="loaded">
|
||||
@@ -80,21 +95,47 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { PETROL_SHOP_ID, bizOk, bizData } from '@/common/petrolVoucher.js'
|
||||
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
store: null,
|
||||
loaded: false
|
||||
loaded: false,
|
||||
detailType: '1',
|
||||
shopId: '',
|
||||
voucher: null // xuchao: 石油券最新订单状态(statusCode 语义见 common/petrolVoucher.js)
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
// xuchao: 入口板块:type=2 商户折扣,其余(含缺省)按文旅场馆渲染
|
||||
isVenue() {
|
||||
return this.detailType !== '2'
|
||||
},
|
||||
isPetrol() {
|
||||
// xuchao: 业务调整:该商铺不再需要特殊购买处理,前端入口整体隐藏;券页面/接口/SDK注入均保留,恢复时去掉下面的 return false 即可
|
||||
return false
|
||||
// xuchao: 后端券服务探活(latest 返回 price)后才展示购券模块——后端未部署期间整模块自动隐藏,无死入口
|
||||
// return this.loaded && String(this.shopId) === PETROL_SHOP_ID && !this.isVenue && !!(this.voucher && this.voucher.price)
|
||||
},
|
||||
voucherBtnText() {
|
||||
const s = this.voucher ? this.voucher.statusCode : -1
|
||||
if (s === 0) return '继续支付'
|
||||
if (s === 1 || s === 2) return '查看我的券'
|
||||
if (s === 3 || s === 4) return '重新购买'
|
||||
// xuchao: 购买按钮金额取服务端下发价(测试期 0.01);未登录无数据时用中性文案
|
||||
if (this.voucher && this.voucher.price) return '¥' + (this.voucher.price / 100).toFixed(2) + ' 购买'
|
||||
return '购买汽油券'
|
||||
},
|
||||
ticketInfoList() {
|
||||
if (!this.store || !this.store.ticketInfo) return []
|
||||
return this.store.ticketInfo.split('\n')
|
||||
},
|
||||
discountList() {
|
||||
if (!this.store || !this.store.merchantDiscount) return []
|
||||
return this.store.merchantDiscount.split('\n')
|
||||
remarkList() {
|
||||
if (!this.store) return []
|
||||
const text = this.isVenue ? this.store.usageNote : this.store.merchantDiscount
|
||||
if (!text) return []
|
||||
return text.split('\n')
|
||||
},
|
||||
// xuchao: 客服电话列表:按常见分隔符切分;无分隔符连写的多个11位手机号也自动拆开
|
||||
servicePhoneList() {
|
||||
@@ -121,11 +162,39 @@ export default {
|
||||
}
|
||||
},
|
||||
onLoad(options) {
|
||||
if (options.type) this.detailType = String(options.type)
|
||||
if (options.id) {
|
||||
this.shopId = String(options.id)
|
||||
this.loadDetail(options.id)
|
||||
}
|
||||
},
|
||||
onShow() {
|
||||
// xuchao: 支付/购券流程返回时刷新券按钮状态
|
||||
if (String(this.shopId) === PETROL_SHOP_ID) this.loadVoucher()
|
||||
},
|
||||
methods: {
|
||||
// xuchao: 拉取石油券最新订单状态(未登录也调用:作为后端服务探活,price 决定模块显隐)
|
||||
loadVoucher() {
|
||||
const phone = uni.getStorageSync('phone') || ''
|
||||
this.$u.api.voucherLatest({ phone }).then(res => {
|
||||
this.voucher = bizOk(res) ? bizData(res) : null
|
||||
}).catch(() => { this.voucher = null })
|
||||
},
|
||||
onVoucherClick() {
|
||||
const phone = uni.getStorageSync('phone')
|
||||
if (!phone) {
|
||||
uni.navigateTo({ url: '/pages/index/login?redirect=' + encodeURIComponent('/pages/venue/detail?id=' + this.shopId + '&type=' + this.detailType) })
|
||||
return
|
||||
}
|
||||
const s = this.voucher ? this.voucher.statusCode : -1
|
||||
if (s === 2 || s === 1) {
|
||||
uni.navigateTo({ url: '/pages/petrol/voucherDetail' })
|
||||
} else if (s === 0) {
|
||||
uni.navigateTo({ url: '/pages/petrol/orderConfirm?orderNo=' + this.voucher.orderNo })
|
||||
} else {
|
||||
uni.navigateTo({ url: '/pages/petrol/orderConfirm' })
|
||||
}
|
||||
},
|
||||
// xuchao: 点击某个商户电话唤起拨号(多个号码时逐个可点)
|
||||
callPhone(phone) {
|
||||
if (!phone) return
|
||||
@@ -251,7 +320,7 @@ export default {
|
||||
color: #999999;
|
||||
}
|
||||
|
||||
/* 商户优惠 */
|
||||
/* 使用说明 */
|
||||
.discount-section {
|
||||
background-color: #ffffff;
|
||||
margin: 12px;
|
||||
@@ -294,6 +363,40 @@ export default {
|
||||
color: #0088ff;
|
||||
}
|
||||
|
||||
/* xuchao: 石油汽油券购买模块 */
|
||||
.voucher-card {
|
||||
background-color: #ffffff;
|
||||
margin: 12px;
|
||||
border-radius: 8px;
|
||||
padding: 16px;
|
||||
}
|
||||
|
||||
.voucher-ticket {
|
||||
position: relative;
|
||||
overflow: hidden;
|
||||
background: linear-gradient(135deg, #0d6fe0, #2f9bff);
|
||||
border-radius: 8px;
|
||||
padding: 14px;
|
||||
color: #ffffff;
|
||||
}
|
||||
|
||||
.voucher-amt { font-size: 22px; font-weight: 700; }
|
||||
.voucher-amt-sub { font-size: 12px; font-weight: 400; opacity: 0.9; margin-left: 4px; }
|
||||
.voucher-rule { font-size: 12px; opacity: 0.9; margin-top: 6px; }
|
||||
.voucher-wm { position: absolute; right: 4px; bottom: -12px; font-size: 52px; font-weight: 800; opacity: 0.1; }
|
||||
.voucher-tip { font-size: 12px; color: #666666; line-height: 1.7; margin-top: 12px; }
|
||||
.voucher-btn {
|
||||
height: 42px;
|
||||
margin-top: 12px;
|
||||
border-radius: 8px;
|
||||
background-color: #0088ff;
|
||||
color: #ffffff;
|
||||
font-size: 15px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
/* xuchao: 加载失败提示态 */
|
||||
.load-failed {
|
||||
display: flex;
|
||||
|
||||
+74
-9
@@ -13,12 +13,19 @@
|
||||
<view class="search-btn" @click="onSearch">搜索</view>
|
||||
</view>
|
||||
</view>
|
||||
<!-- xuchao: 所属县区 + 所属类型筛选,选项与联动条数由列表接口一并返回 -->
|
||||
<hhrs-filter-bar :districts="filters.districts" :categories="filters.categories"
|
||||
:district-id="districtId" :category="category" @change="onFilterChange" />
|
||||
</view>
|
||||
|
||||
<!-- 场馆列表 -->
|
||||
<view class="list-area">
|
||||
<view class="venue-card" v-for="item in list" :key="item.shopId" @click="goDetail(item)">
|
||||
<image class="card-img" :src="item.image" mode="aspectFill" />
|
||||
<view class="venue-card" v-for="item in list" :key="item.shopId">
|
||||
<view class="card-thumb">
|
||||
<image class="card-img" :src="item.image" mode="aspectFill" />
|
||||
<!-- xuchao: 左上角所属地区角标(districtName 来自商铺「所在地区」,未录入则不显示) -->
|
||||
<text class="card-area" v-if="item.districtName">{{ shortDistrict(item.districtName) }}</text>
|
||||
</view>
|
||||
<view class="card-info">
|
||||
<text class="card-name">{{ item.name }}</text>
|
||||
<text class="card-category">{{ item.category }}</text>
|
||||
@@ -39,7 +46,13 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
// xuchao: 角标区县简称(后端返回的是行政区划全称)
|
||||
import { shortDistrict } from '@/common/district.js'
|
||||
// xuchao: 县区 + 类型筛选条,三个列表页共用(pages.json 的 easycom 只给 u- 前缀配了规则,这里显式引入)
|
||||
import HhrsFilterBar from '@/components/hhrs-filter-bar/hhrs-filter-bar.vue'
|
||||
|
||||
export default {
|
||||
components: { HhrsFilterBar },
|
||||
data() {
|
||||
return {
|
||||
keyword: '',
|
||||
@@ -52,7 +65,11 @@ export default {
|
||||
lat: '',
|
||||
loadStatus: 'loadmore',
|
||||
hasScrolled: false,
|
||||
reqSeq: 0
|
||||
reqSeq: 0,
|
||||
// xuchao: 筛选条件与面板选项(选项由列表响应带回)
|
||||
districtId: '',
|
||||
category: '',
|
||||
filters: { districts: [], categories: [] }
|
||||
}
|
||||
},
|
||||
onLoad() {
|
||||
@@ -70,6 +87,7 @@ export default {
|
||||
this.loadMore()
|
||||
},
|
||||
methods: {
|
||||
shortDistrict,
|
||||
loadList() {
|
||||
// xuchao: 请求序号 —— 新请求直接取代在途请求,过期响应整体丢弃(修复搜索竞态,故不再用 loading 提前 return)
|
||||
const seq = ++this.reqSeq
|
||||
@@ -83,9 +101,16 @@ export default {
|
||||
}
|
||||
if (this.lng) params.lng = this.lng
|
||||
if (this.lat) params.lat = this.lat
|
||||
if (this.districtId) params.districtId = this.districtId
|
||||
if (this.category) params.category = this.category
|
||||
this.$u.api.getStoreList(params).then(res => {
|
||||
if (seq !== this.reqSeq) return
|
||||
if (res.errcode === 0 && res.data) {
|
||||
// xuchao: 面板选项随列表一起回来(后端已按关键词与另一维度算好条数)
|
||||
this.filters = {
|
||||
districts: res.data.districts || [],
|
||||
categories: res.data.categories || []
|
||||
}
|
||||
const list = res.data.list || []
|
||||
if (this.pageNo === 1) {
|
||||
this.list = list
|
||||
@@ -124,13 +149,16 @@ export default {
|
||||
uni.reLaunch({ url: '/pages/index/index' })
|
||||
}
|
||||
},
|
||||
goDetail(item) {
|
||||
uni.navigateTo({ url: '/pages/venue/detail?id=' + item.shopId })
|
||||
},
|
||||
onSearch() {
|
||||
this.pageNo = 1
|
||||
this.list = []
|
||||
this.loadList()
|
||||
},
|
||||
// xuchao: 换筛选条件即回第 1 页重查(关键词保持不变,两者为 AND)
|
||||
onFilterChange(e) {
|
||||
this.districtId = e.districtId
|
||||
this.category = e.category
|
||||
this.onSearch()
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -145,7 +173,11 @@ export default {
|
||||
|
||||
.search-area {
|
||||
background-color: #ffffff;
|
||||
padding: 6px 12px;
|
||||
padding: 6px 12px 0;
|
||||
/* xuchao: 滚动时固定在页面顶部;z-index 高于筛选遮罩(90),保证面板与选中态不被压住 */
|
||||
position: sticky;
|
||||
top: 0;
|
||||
z-index: 100;
|
||||
}
|
||||
|
||||
.nav-row {
|
||||
@@ -196,6 +228,8 @@ export default {
|
||||
}
|
||||
|
||||
.list-area {
|
||||
/* xuchao: 顶部 12px 必须是页面灰底(不能放进头部的白底里),否则与白色卡片连成一片看不出间隔 */
|
||||
padding: 12px;
|
||||
}
|
||||
|
||||
.venue-card {
|
||||
@@ -204,21 +238,49 @@ export default {
|
||||
background-color: #ffffff;
|
||||
border: 1px solid #f2f2f7;
|
||||
border-radius: 6px;
|
||||
padding: 12px;
|
||||
padding: 24px 12px;
|
||||
gap: 12px;
|
||||
box-shadow: 0 2px 3px #f2f2f7;
|
||||
margin: 12px;
|
||||
}
|
||||
|
||||
.card-img {
|
||||
.card-thumb {
|
||||
width: 75px;
|
||||
height: 75px;
|
||||
border-radius: 6px;
|
||||
overflow: hidden;
|
||||
position: relative;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
/* xuchao: image 由 thumb 裁圆角,自身不再设圆角 */
|
||||
.card-img {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
display: block;
|
||||
}
|
||||
|
||||
.card-area {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
display: block;
|
||||
max-width: 100%;
|
||||
padding: 1px 5px;
|
||||
border-radius: 0 0 6px 0;
|
||||
background: rgba(0, 0, 0, 0.45);
|
||||
color: #ffffff;
|
||||
font-size: 10px;
|
||||
line-height: 14px;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.card-info {
|
||||
flex: 1;
|
||||
/* xuchao: flex 项默认 min-width:auto,nowrap 地址会把列宽撑破卡片;置 0 后子元素在实宽内省略 */
|
||||
min-width: 0;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0;
|
||||
@@ -240,6 +302,9 @@ export default {
|
||||
font-size: 14px;
|
||||
color: #727272;
|
||||
margin-top: 8px;
|
||||
/* xuchao: 分类为空也预留一行高度,防止卡片内容底部对齐时名称上下跳动 */
|
||||
min-height: 20px;
|
||||
line-height: 20px;
|
||||
}
|
||||
|
||||
.card-bottom {
|
||||
|
||||
+77
-17
@@ -8,12 +8,12 @@
|
||||
<text class="back-text">返回</text>
|
||||
</view>
|
||||
<view class="banner-header">
|
||||
<image class="banner-icon" src="https://zhihuiyou.oss-cn-shenzhen.aliyuncs.com/hhrs/hhrs_zjgs.png" mode="aspectFit"></image>
|
||||
<image class="banner-icon" src="https://aliyunoss.hn12301.net/hhrs/hhrs_zjgs.png" mode="aspectFit"></image>
|
||||
<text class="banner-title">中奖名单公示</text>
|
||||
</view>
|
||||
<text class="banner-subtitle">总计 10,000份权益包,分三期公证抽取</text>
|
||||
<text class="banner-subtitle">总计 10,000份权益包,全程公证抽取</text>
|
||||
<view class="stats-card">
|
||||
<image class="stats-gift" src="https://zhihuiyou.oss-cn-shenzhen.aliyuncs.com/hhrs/hhrs_xyckr.png" mode="aspectFit"></image>
|
||||
<image class="stats-gift" src="https://aliyunoss.hn12301.net/hhrs/hhrs_xyckr.png" mode="aspectFit"></image>
|
||||
<text class="stats-label">已产生</text>
|
||||
<text class="stats-number">{{ totalWinners.toLocaleString() }}</text>
|
||||
<text class="stats-label">名幸运持卡人</text>
|
||||
@@ -78,9 +78,14 @@ export default {
|
||||
currentTab: 0,
|
||||
tabs: [],
|
||||
winnerData: {},
|
||||
pageNo: 1,
|
||||
// xuchao: 页码改为按期维护(原单一 pageNo 在切期后会被沿用,导致同一页重复追加/跳页)
|
||||
pageNos: {},
|
||||
pageSize: 10,
|
||||
// xuchao: 搜索触发的全量拉取用大页尺寸(列表接口仅支持分页参数,无姓名检索)
|
||||
pageSizeFull: 500,
|
||||
totals: {},
|
||||
fullLoaded: {},
|
||||
loadingAll: {},
|
||||
totalWinners: 0,
|
||||
inFlight: 0,
|
||||
loadStatusMap: {},
|
||||
@@ -103,6 +108,15 @@ export default {
|
||||
return this.loadStatusMap[this.currentTab] || 'nomore'
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
// xuchao: 输入关键字即后台拉全当期名单,修复"没翻到的人物搜索无结果"
|
||||
keyword(val) {
|
||||
clearTimeout(this._kwTimer)
|
||||
if (val && val.trim() && !this.fullLoaded[this.currentTab]) {
|
||||
this._kwTimer = setTimeout(() => this.loadAll(this.currentTab), 400)
|
||||
}
|
||||
}
|
||||
},
|
||||
onLoad() {
|
||||
this.loadDates()
|
||||
},
|
||||
@@ -123,11 +137,13 @@ export default {
|
||||
data[index] = []
|
||||
})
|
||||
this.winnerData = data
|
||||
// xuchao: 预置各期 key,保证 totals/loadStatusMap 的响应式
|
||||
// xuchao: 预置各期 key,保证 totals/pageNos/loadStatusMap 的响应式
|
||||
this.totals = {}
|
||||
this.pageNos = {}
|
||||
this.loadStatusMap = {}
|
||||
dates.forEach((date, index) => {
|
||||
this.$set(this.totals, index, 0)
|
||||
this.$set(this.pageNos, index, 1)
|
||||
this.$set(this.loadStatusMap, index, 'loading')
|
||||
})
|
||||
// xuchao: 预取各期第一页,汇总已产生总人数
|
||||
@@ -142,21 +158,26 @@ export default {
|
||||
loadWinnerList(tabIndex, pageNo, allowConcurrent) {
|
||||
if (!this.tabs[tabIndex]) return
|
||||
if (this.inFlight > 0 && !allowConcurrent) return
|
||||
// xuchao: 本期页码独立计算,缺省续拉该期下一页
|
||||
const page = pageNo || (this.pageNos[tabIndex] || 1)
|
||||
this.inFlight++
|
||||
this.$set(this.loadStatusMap, tabIndex, 'loading')
|
||||
const drawDate = this.tabs[tabIndex].date
|
||||
this.$u.api.getWinnerList({
|
||||
pageNo: pageNo || this.pageNo,
|
||||
pageNo: page,
|
||||
pageSize: this.pageSize,
|
||||
drawDate: drawDate
|
||||
}).then(res => {
|
||||
// xuchao: 全量拉取已就绪/进行中时,旧的10条分页响应直接丢弃,避免覆盖全量列表
|
||||
if (this.fullLoaded[tabIndex] || this.loadingAll[tabIndex]) return
|
||||
if (res.errcode === 0 && res.data) {
|
||||
const list = res.data.list || []
|
||||
const page = pageNo || this.pageNo
|
||||
const prev = this.winnerData[tabIndex] || []
|
||||
this.$set(this.pageNos, tabIndex, page)
|
||||
if (page === 1) {
|
||||
this.$set(this.winnerData, tabIndex, list)
|
||||
} else {
|
||||
this.winnerData[tabIndex] = this.winnerData[tabIndex].concat(list)
|
||||
this.$set(this.winnerData, tabIndex, prev.concat(list))
|
||||
}
|
||||
this.$set(this.totals, tabIndex, res.data.total || 0)
|
||||
// xuchao: 各期总人数求和,用于顶部幸运持卡人数
|
||||
@@ -164,23 +185,61 @@ export default {
|
||||
}
|
||||
}).finally(() => {
|
||||
this.inFlight--
|
||||
const len = this.winnerData[tabIndex].length
|
||||
const len = (this.winnerData[tabIndex] || []).length
|
||||
const total = this.totals[tabIndex] || 0
|
||||
this.$set(this.loadStatusMap, tabIndex, len === 0 || len >= total ? 'nomore' : 'loadmore')
|
||||
})
|
||||
},
|
||||
loadMore() {
|
||||
const total = this.totals[this.currentTab] || 0
|
||||
if (this.winnerData[this.currentTab].length < total && this.inFlight === 0) {
|
||||
this.pageNo++
|
||||
this.loadWinnerList(this.currentTab)
|
||||
const tab = this.currentTab
|
||||
if (this.loadingAll[tab]) return
|
||||
const total = this.totals[tab] || 0
|
||||
const len = (this.winnerData[tab] || []).length
|
||||
if (len < total && this.inFlight === 0) {
|
||||
this.loadWinnerList(tab, (this.pageNos[tab] || 1) + 1)
|
||||
}
|
||||
},
|
||||
// xuchao: 按大页把当期名单一次拉全,搜索即可命中未翻到的人;完成后整期替换并标记 fullLoaded
|
||||
loadAll(tabIndex) {
|
||||
const tab = this.tabs[tabIndex]
|
||||
if (!tab || this.fullLoaded[tabIndex] || this.loadingAll[tabIndex]) return
|
||||
this.$set(this.loadingAll, tabIndex, true)
|
||||
this.$set(this.loadStatusMap, tabIndex, 'loading')
|
||||
const acc = []
|
||||
const pull = (pageNo) => this.$u.api.getWinnerList({
|
||||
pageNo: pageNo,
|
||||
pageSize: this.pageSizeFull,
|
||||
drawDate: tab.date
|
||||
}).then(res => {
|
||||
if (res.errcode !== 0 || !res.data) return
|
||||
const list = res.data.list || []
|
||||
const total = res.data.total || 0
|
||||
acc.push(...list)
|
||||
this.$set(this.totals, tabIndex, total)
|
||||
if (list.length > 0 && acc.length < total && pageNo < 50) return pull(pageNo + 1)
|
||||
})
|
||||
pull(1).then(() => {
|
||||
if (acc.length > 0) {
|
||||
this.$set(this.winnerData, tabIndex, acc)
|
||||
this.$set(this.fullLoaded, tabIndex, true)
|
||||
this.$set(this.pageNos, tabIndex, Math.ceil(acc.length / this.pageSizeFull))
|
||||
}
|
||||
this.totalWinners = Object.values(this.totals).reduce((s, n) => s + n, 0)
|
||||
}).catch(() => {
|
||||
// 拉全失败静默降级为已加载部分可搜
|
||||
}).finally(() => {
|
||||
this.$set(this.loadingAll, tabIndex, false)
|
||||
const len = (this.winnerData[tabIndex] || []).length
|
||||
const total = this.totals[tabIndex] || 0
|
||||
this.$set(this.loadStatusMap, tabIndex, len === 0 || len >= total ? 'nomore' : 'loadmore')
|
||||
})
|
||||
},
|
||||
switchTab(index) {
|
||||
this.currentTab = index
|
||||
this.pageNo = 1
|
||||
if (this.winnerData[index].length === 0) {
|
||||
this.loadWinnerList(index, 1)
|
||||
// xuchao: 不再重置全局 pageNo(各期游标自带);空列表补拉首页时允许并发,
|
||||
// 避免首屏预取仍在途时切期被丢弃后一直显示“暂无数据”
|
||||
if ((this.winnerData[index] || []).length === 0) {
|
||||
this.loadWinnerList(index, 1, true)
|
||||
} else {
|
||||
const total = this.totals[index] || 0
|
||||
this.$set(this.loadStatusMap, index, this.winnerData[index].length >= total ? 'nomore' : 'loadmore')
|
||||
@@ -196,7 +255,8 @@ export default {
|
||||
}
|
||||
},
|
||||
onSearch() {
|
||||
// 前端过滤,无需重新请求
|
||||
// xuchao: 点搜索立即确保当期全量已拉取(过滤仍在前端本地完成)
|
||||
if (!this.fullLoaded[this.currentTab]) this.loadAll(this.currentTab)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user