- 新增 pages/shop/detail 品牌详情页:头部卡(logo/角标/付款码按钮)、富文本优惠说明(数字标红)、适用门店清单(距离排序+高德导航+拨号,无二级页);付款码走 upsdk.qrCodePay 容器原生拉起,非云闪付环境 3s 超时给引导弹窗 - 折扣列表行按参考图改版:logo/品牌名/券类型标签/付款方式纵排,右侧结构化优惠数字放大红色+直线距离;搜索区瘦身;未迁移门店全字段回退旧文案不断档 - 首页宫格与列表统一跳新详情页 - docs:brand 建表 DDL、后端需求文档、终版收集表(187 品牌/197 门店已导入 UAT+DEV,脚本按名称幂等) Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
375 lines
9.9 KiB
Vue
375 lines
9.9 KiB
Vue
<template>
|
||
<view class="page">
|
||
<!-- 搜索栏 -->
|
||
<view class="search-area">
|
||
<view class="nav-row">
|
||
<view class="back-btn" @click="goBack">
|
||
<u-icon name="arrow-left" color="#333333" size="32"></u-icon>
|
||
<text class="back-text">返回</text>
|
||
</view>
|
||
<view class="search-bar">
|
||
<u-icon name="search" color="#8e8e93" size="30"></u-icon>
|
||
<input class="search-input" v-model="keyword" placeholder="请搜索商户名" confirm-type="search" @confirm="onSearch" />
|
||
<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>
|
||
|
||
<!-- 商户列表(xuchao: 参考图行样式——logo+券类型标签+付款方式,右列结构化优惠+距离;未迁移门店回退旧文案) -->
|
||
<view class="list-area">
|
||
<view class="venue-card" v-for="item in list" :key="item.shopId" @click="goDetail(item)">
|
||
<view class="card-thumb">
|
||
<image class="card-img" :src="item.brandLogo || item.image" mode="aspectFill" />
|
||
</view>
|
||
<view class="card-info">
|
||
<text class="card-name">{{ item.brandName || item.name }}</text>
|
||
<!-- xuchao: 参考图为纵向三行——店名 / 券类型标签 / 付款方式,标签与付款码不同行 -->
|
||
<text class="tag-coupon" v-if="couponLabel(item)">{{ couponLabel(item) }}</text>
|
||
<text class="card-pay">{{ item.payMode || item.category || '' }}</text>
|
||
</view>
|
||
<view class="offer-col">
|
||
<view class="offer" v-if="item.discountDisplay">
|
||
<text v-for="(seg, si) in splitOffer(item.discountDisplay)" :key="si" :class="seg.n ? 'offer-num' : 'offer-txt'">{{ seg.t }}</text>
|
||
</view>
|
||
<text class="offer-fallback" v-else>{{ item.merchantDiscount || item.category || '' }}</text>
|
||
<text class="offer-dist" v-if="item.distance !== null && item.distance !== undefined">直线{{ item.distance < 1 ? Math.round(item.distance * 1000) + 'm' : Math.round(item.distance) + 'km' }}</text>
|
||
</view>
|
||
</view>
|
||
<view v-if="hasScrolled" class="nomore-area">
|
||
<u-loadmore :status="loadStatus" :load-text="{ loadmore: '', loading: '加载中...', nomore: '我也是有底线的' }" />
|
||
</view>
|
||
</view>
|
||
</view>
|
||
</template>
|
||
|
||
<script>
|
||
// xuchao: 县区 + 类型筛选条,三个列表页共用(pages.json 的 easycom 只给 u- 前缀配了规则,这里显式引入)
|
||
import HhrsFilterBar from '@/components/hhrs-filter-bar/hhrs-filter-bar.vue'
|
||
|
||
export default {
|
||
components: { HhrsFilterBar },
|
||
data() {
|
||
return {
|
||
keyword: '',
|
||
list: [],
|
||
pageNo: 1,
|
||
pageSize: 10,
|
||
total: 0,
|
||
loading: false,
|
||
lng: '',
|
||
lat: '',
|
||
loadStatus: 'loadmore',
|
||
hasScrolled: false,
|
||
reqSeq: 0,
|
||
// xuchao: 筛选条件与面板选项(选项由列表响应带回)
|
||
districtId: '',
|
||
category: '',
|
||
filters: { districts: [], categories: [] }
|
||
}
|
||
},
|
||
onLoad() {
|
||
const hasLoc = uni.getStorageSync('lng') && uni.getStorageSync('lat')
|
||
if (hasLoc) {
|
||
this.lng = uni.getStorageSync('lng')
|
||
this.lat = uni.getStorageSync('lat')
|
||
this.loadList()
|
||
} else {
|
||
// xuchao: 定位仅在首页触发过,直接进本页无缓存时主动获取一次,保证距离列可展示
|
||
import('@/common/location.js').then(module => module.default.getLocation())
|
||
.then(({ lng, lat }) => {
|
||
this.lng = lng
|
||
this.lat = lat
|
||
})
|
||
.catch(() => {})
|
||
.finally(() => this.loadList())
|
||
}
|
||
},
|
||
// xuchao: 改用页面级触底加载(scroll-view 无固定高度时 scrolltolower 永不触发)
|
||
onReachBottom() {
|
||
this.loadMore()
|
||
},
|
||
methods: {
|
||
// xuchao: 券类型角标:品牌结构化类型优先;无品牌的未迁移门店不显示角标(避免与业态文字重复)
|
||
couponLabel(item) {
|
||
const map = { 1: '满减券', 2: '折扣券', 3: '立减券', 4: '余额券', 5: '免费体验', 6: '固定价', 9: '其他' }
|
||
return item.discountType ? map[item.discountType] : (item.brandId ? '优惠' : '')
|
||
},
|
||
// xuchao: 优惠文案拆「数字段/文字段」,数字放大红色(对齐参考图)
|
||
splitOffer(s) {
|
||
const parts = String(s).split(/(\d+(?:\.\d+)?)/).filter(x => x !== '')
|
||
return parts.map(t => ({ t, n: /^\d/.test(t) }))
|
||
},
|
||
loadList() {
|
||
// xuchao: 请求序号 —— 新请求直接取代在途请求,过期响应整体丢弃(修复搜索竞态,故不再用 loading 提前 return)
|
||
const seq = ++this.reqSeq
|
||
this.loading = true
|
||
this.loadStatus = 'loading'
|
||
const params = {
|
||
pageNo: this.pageNo,
|
||
pageSize: this.pageSize,
|
||
keyword: this.keyword,
|
||
typeId: 2
|
||
}
|
||
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
|
||
} else {
|
||
this.list = this.list.concat(list)
|
||
}
|
||
this.total = res.data.total || 0
|
||
// xuchao: 本页不足一页即已到尾部,钉住 total,防止 total 中途变大时空翻
|
||
if (list.length < this.pageSize) this.total = this.list.length
|
||
}
|
||
}).finally(() => {
|
||
if (seq !== this.reqSeq) return
|
||
this.loading = false
|
||
if (this.list.length === 0) {
|
||
this.loadStatus = 'nomore'
|
||
} else if (this.list.length >= this.total) {
|
||
this.loadStatus = 'nomore'
|
||
} else {
|
||
this.loadStatus = 'loadmore'
|
||
}
|
||
})
|
||
},
|
||
loadMore() {
|
||
this.hasScrolled = true
|
||
if (this.list.length < this.total && !this.loading) {
|
||
this.pageNo++
|
||
this.loadList()
|
||
}
|
||
},
|
||
goBack() {
|
||
// xuchao: 直接通过链接进入(无历史栈)时回到首页
|
||
const pages = getCurrentPages()
|
||
if (pages.length > 1) {
|
||
uni.navigateBack()
|
||
} else {
|
||
uni.reLaunch({ url: '/pages/index/index' })
|
||
}
|
||
},
|
||
goDetail(item) {
|
||
// xuchao: 商户折扣行跳品牌详情页(含适用门店/优惠说明);文旅场馆仍走 venue/detail
|
||
uni.navigateTo({ url: '/pages/shop/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()
|
||
}
|
||
}
|
||
}
|
||
</script>
|
||
<style>
|
||
page {
|
||
background-color: #f2f2f7;
|
||
}
|
||
</style>
|
||
<style scoped lang="less">
|
||
|
||
|
||
.search-area {
|
||
background-color: #ffffff;
|
||
// xuchao: 底部留 8px,与下方列表灰色间隔衔接,白块不再贴死卡片
|
||
padding: 6px 12px 8px;
|
||
// xuchao: 滚动时固定在页面顶部;z-index 高于筛选遮罩(90),保证面板与选中态不被压住
|
||
position: sticky;
|
||
top: 0;
|
||
z-index: 100;
|
||
}
|
||
|
||
.nav-row {
|
||
display: flex;
|
||
align-items: center;
|
||
gap: 12px;
|
||
}
|
||
|
||
.back-btn {
|
||
display: flex;
|
||
align-items: center;
|
||
justify-content: center;
|
||
height: 36px;
|
||
flex-shrink: 0;
|
||
gap: 2px;
|
||
}
|
||
|
||
.back-text {
|
||
font-size: 14px;
|
||
color: #333333;
|
||
}
|
||
|
||
.search-bar {
|
||
flex: 1;
|
||
display: flex;
|
||
align-items: center;
|
||
height: 36px;
|
||
background-color: #ffffff;
|
||
border: 1px solid #f2f2f7;
|
||
border-radius: 100px;
|
||
padding: 4px 8px;
|
||
gap: 10px;
|
||
}
|
||
|
||
.search-input {
|
||
flex: 1;
|
||
font-size: 14px;
|
||
color: #333;
|
||
}
|
||
|
||
.search-btn {
|
||
background-color: #0088ff;
|
||
color: #ffffff;
|
||
font-size: 13px;
|
||
padding: 3px 10px;
|
||
border-radius: 50px;
|
||
white-space: nowrap;
|
||
}
|
||
|
||
.list-area {
|
||
// xuchao: 顶部 12px 必须是页面灰底(不能放进头部的白底里),否则与白色卡片连成一片看不出间隔
|
||
padding: 12px;
|
||
// xuchao: border-box 防止 padding 撑出页面横向滚动
|
||
box-sizing: border-box;
|
||
}
|
||
|
||
.venue-card {
|
||
display: flex;
|
||
align-items: center;
|
||
box-sizing: border-box;
|
||
background-color: #ffffff;
|
||
border: 1px solid #f2f2f7;
|
||
border-radius: 16rpx;
|
||
width: 702rpx;
|
||
padding: 28rpx 24rpx;
|
||
gap: 20rpx;
|
||
box-shadow: 0 2px 3px #f2f2f7;
|
||
margin-bottom: 12px;
|
||
}
|
||
|
||
.card-thumb {
|
||
width: 88rpx;
|
||
height: 88rpx;
|
||
border-radius: 16rpx;
|
||
overflow: hidden;
|
||
position: relative;
|
||
flex-shrink: 0;
|
||
background-color: #f7f7f7;
|
||
}
|
||
|
||
/* xuchao: image 由 thumb 裁圆角,自身不再设圆角 */
|
||
.card-img {
|
||
width: 100%;
|
||
height: 100%;
|
||
display: block;
|
||
}
|
||
|
||
.card-info {
|
||
flex: 1;
|
||
// xuchao: min-width:0 允许 flex 子项收缩到内容宽度以下,配合 nowrap 文本出省略号
|
||
min-width: 0;
|
||
display: flex;
|
||
flex-direction: column;
|
||
align-items: flex-start;
|
||
gap: 8rpx;
|
||
}
|
||
|
||
.card-name {
|
||
font-size: 30rpx;
|
||
font-weight: 600;
|
||
color: #000000;
|
||
width: 100%;
|
||
overflow: hidden;
|
||
text-overflow: ellipsis;
|
||
white-space: nowrap;
|
||
}
|
||
|
||
.tag-coupon {
|
||
flex-shrink: 0;
|
||
font-size: 20rpx;
|
||
color: #666666;
|
||
background: #f2f3f5;
|
||
border-radius: 6rpx;
|
||
padding: 4rpx 10rpx;
|
||
line-height: 1.4;
|
||
}
|
||
|
||
.card-pay {
|
||
font-size: 22rpx;
|
||
color: #999999;
|
||
max-width: 100%;
|
||
overflow: hidden;
|
||
text-overflow: ellipsis;
|
||
white-space: nowrap;
|
||
}
|
||
|
||
/* xuchao: 右侧优惠列——数字放大红色(对齐参考图),offer 与直线距离间隔一行行距 */
|
||
.offer-col {
|
||
flex-shrink: 0;
|
||
max-width: 230rpx;
|
||
display: flex;
|
||
flex-direction: column;
|
||
align-items: flex-end;
|
||
gap: 16rpx;
|
||
}
|
||
|
||
.offer {
|
||
display: flex;
|
||
align-items: baseline;
|
||
flex-wrap: wrap;
|
||
justify-content: flex-end;
|
||
}
|
||
|
||
.offer-num {
|
||
font-size: 34rpx;
|
||
font-weight: 800;
|
||
color: #E60012;
|
||
line-height: 1.1;
|
||
}
|
||
|
||
.offer-txt {
|
||
font-size: 22rpx;
|
||
font-weight: 600;
|
||
color: #E60012;
|
||
}
|
||
|
||
.offer-fallback {
|
||
font-size: 22rpx;
|
||
color: #E60012;
|
||
text-align: right;
|
||
display: -webkit-box;
|
||
-webkit-box-orient: vertical;
|
||
-webkit-line-clamp: 2;
|
||
overflow: hidden;
|
||
}
|
||
|
||
.offer-dist {
|
||
font-size: 22rpx;
|
||
color: #999999;
|
||
}
|
||
|
||
.nomore-area {
|
||
padding-top: 24px;
|
||
}
|
||
</style>
|