Files
hhrs/pages/shop/detail.vue
T
jacobxu666andClaude Fable 5 b4d8376dd4 fix:商户详情页移除付款码按钮及 upsdk 相关逻辑(真机容器链路待排查后再定方案)
- 移除头部卡付款码按钮、onPayCode/payGuide/loadUpSdk 方法与样式
- 已发布 hh.hn12301.net,入口 index.90c150ed.js,分片 ea4cd3b0 线上与本地 MD5 一致

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-10-27 16:40:21 +08:00

239 lines
10 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<template>
<!-- xuchao: 商户(品牌)详情页,按参考图三卡布局;brand 未关联/后端未发布时全部字段走回退,页面不留白 -->
<view class="page">
<!-- 导航 -->
<view class="nav-bar">
<view class="back-btn" @click="goBack">
<u-icon name="arrow-left" color="#333333" size="40"></u-icon>
<text class="back-text">返回</text>
</view>
<text class="nav-title">商户详情</text>
<view style="width: 100rpx;"></view>
</view>
<view class="body" v-if="shop">
<!-- 头部卡 -->
<view class="head-card">
<view class="head-top">
<view class="logo-box">
<image class="logo" :src="shop.brandLogo || shop.image" mode="aspectFill"></image>
</view>
<text class="head-name">{{ shop.brandName || shop.name }}</text>
<view class="badge" v-if="badgeMain">
<text class="badge-main">{{ badgeMain }}</text>
<text class="badge-sub" v-if="badgeSub">{{ badgeSub }}</text>
</view>
</view>
<view class="head-divider"></view>
<view class="head-meta">
<text class="meta-line" v-if="shop.brandType || shop.category">{{ shop.brandType || shop.category }}</text>
<text class="meta-line" v-if="shop.businessTime">营业时间:{{ shop.businessTime }}</text>
</view>
</view>
<!-- 优惠说明 -->
<view class="card">
<view class="card-title"><view class="bar"></view><text>优惠说明</text></view>
<!-- 品牌富文本优先 -->
<rich-text v-if="shop.discountRules" :nodes="shop.discountRules" class="rules-rich"></rich-text>
<!-- 回退:merchantDiscount/remark 按分号换行拆编号列表 -->
<view v-else-if="fallbackRules.length">
<view class="rule-line" v-for="(r, i) in fallbackRules" :key="i">
<text class="rule-no">{{ i + 1 }}</text>
<text class="rule-txt">{{ r }}</text>
</view>
</view>
<text v-else class="rule-empty">到店出示社保卡咨询店员</text>
</view>
<!-- 适用门店 -->
<view class="card" v-if="shops.length">
<view class="shops-head">
<text class="shops-title">适用门店<text class="shops-count">(共{{ shops.length }}家)</text></text>
<view class="shops-more" v-if="shops.length > 4 && !showAll" @click="showAll = true">
<text>查看全部</text><view class="chev"></view>
</view>
</view>
<view class="shop-row" v-for="(s, i) in visibleShops" :key="s.shopId">
<view class="pin">
<svg width="15" height="19" viewBox="0 0 15 19"><path d="M7.5 1C4 1 1.2 3.8 1.2 7.3c0 4.5 6.3 10.7 6.3 10.7s6.3-6.2 6.3-10.7C13.8 3.8 11 1 7.5 1z" fill="#E8542F"/><circle cx="7.5" cy="7.2" r="2.4" fill="#fff"/></svg>
</view>
<view class="shop-info">
<text class="shop-name">{{ s.name }}</text>
<text class="shop-addr">{{ s.address }}</text>
</view>
<view class="shop-right">
<text class="shop-dist" v-if="s.distance != null">{{ s.distance < 1 ? Math.round(s.distance * 1000) + 'm' : s.distance.toFixed(1) + 'km' }}</text>
<view class="icon-btn" @click.stop="navTo(s)">
<svg width="15" height="15" viewBox="0 0 24 24" fill="none"><path d="M12 2 20 21l-8-5.2L4 21Z" fill="#333"/></svg>
</view>
<view class="icon-btn" @click.stop="callShop(s)" v-if="s.mobile">
<svg width="15" height="15" viewBox="0 0 24 24" fill="none"><path d="M5 4h4l1.8 4.3-2.4 1.7a12 12 0 0 0 5.6 5.6l1.7-2.4L20 15v4a1.8 1.8 0 0 1-2 1.8C9.7 20 4 14.3 3.2 6A1.8 1.8 0 0 1 5 4Z" fill="#333"/></svg>
</view>
</view>
</view>
<view class="collapse" v-if="showAll && shops.length > 4" @click="showAll = false">收起 <text class="chev up"></text></view>
</view>
</view>
<view class="loading-tip" v-else>加载中…</view>
</view>
</template>
<script>
export default {
data() {
return {
shopId: '',
shop: null,
showAll: false
}
},
computed: {
// xuchao: 角标主文案 = 结构化优惠文案;未迁移回退从原文提取优惠词(X折/满X减X),避免整段撑爆角标
badgeMain() {
if (!this.shop) return ''
if (this.shop.discountDisplay) return this.shop.discountDisplay
const m = (this.shop.merchantDiscount || '').match(/(\d+(?:\.\d+)?折|满\s*\d+(?:\.\d+)?\s*(?:元)?\s*减\s*\d+(?:\.\d+)?\s*元|立减\s*\d+(?:\.\d+)?\s*元|免费体验)/)
if (m) return m[1].replace(/\s/g, '')
const t = (this.shop.merchantDiscount || '').split(/[;;\n]/)[0]
return t ? t.slice(0, 8) : ''
},
badgeSub() {
if (!this.shop) return ''
if (this.shop.discountDisplay) return this.shop.payRule || (this.shop.payMode ? '付款立减' : '付款立减')
return ''
},
fallbackRules() {
const t = (this.shop && (this.shop.merchantDiscount || this.shop.usageNote)) || ''
return t.split(/[;;\n]/).map(x => x.trim()).filter(Boolean)
},
shops() {
if (!this.shop) return []
if (this.shop.brandShops && this.shop.brandShops.length) return this.shop.brandShops
// xuchao: 品牌未关联时退化为当前单店一行,模块结构不消失
return [{ shopId: this.shop.shopId, name: this.shop.name, address: this.shop.address,
distance: this.shop.distance, mobile: this.shop.servicePhone,
lng: this.shop.lng, lat: this.shop.lat }]
},
visibleShops() {
return this.showAll ? this.shops : this.shops.slice(0, 4)
}
},
onLoad(options) {
this.shopId = options.id || options.shopId
const lng = uni.getStorageSync('lng')
const lat = uni.getStorageSync('lat')
const params = { shopId: this.shopId }
if (lng) params.lng = lng
if (lat) params.lat = lat
this.$u.api.getStoreDetail(params).then(res => {
if (res.errcode === 0 && res.data) {
this.shop = res.data
} else {
uni.showToast({ title: res.errmsg || '门店不存在', icon: 'none' })
}
})
},
methods: {
goBack() {
const pages = getCurrentPages()
if (pages.length > 1) uni.navigateBack()
else uni.reLaunch({ url: '/pages/index/index' })
},
navTo(s) {
if (!s.lng || !s.lat) {
uni.showToast({ title: '该门店暂未录入坐标', icon: 'none' })
return
}
// #ifdef H5
window.open('https://uri.amap.com/marker?position=' + s.lng + ',' + s.lat + '&name=' + encodeURIComponent(s.name), '_blank')
// #endif
},
callShop(s) {
if (!s.mobile) return
uni.makePhoneCall({ phoneNumber: String(s.mobile), fail: () => uni.showToast({ title: '拨号取消', icon: 'none' }) })
}
}
}
</script>
<style>
.page { min-height: 100vh; background: #F6EFE6; }
</style>
<style lang="less" scoped>
.nav-bar {
display: flex; align-items: center; justify-content: space-between;
height: 88rpx; padding: 0 24rpx; padding-top: var(--status-bar-height);
background: #FFF;
}
.back-btn { display: flex; align-items: center; width: 100rpx; }
.back-text { font-size: 28rpx; color: #333; margin-left: 4rpx; }
.nav-title { font-size: 34rpx; font-weight: 600; color: #333; }
.body { padding: 24rpx; }
.head-card {
background: linear-gradient(180deg, #FFF7EC 0%, #FFFDF9 40%, #FFFFFF 100%);
border-radius: 28rpx; padding: 28rpx;
}
.head-top { display: flex; align-items: center; gap: 20rpx; }
.logo-box {
width: 96rpx; height: 96rpx; border-radius: 16rpx; overflow: hidden;
background: #fff; border: 1rpx solid #F2E4D0; flex-shrink: 0;
}
.logo { width: 100%; height: 100%; display: block; }
.head-name {
flex: 1; min-width: 0; font-size: 36rpx; font-weight: 800; color: #33200F;
/* xuchao: 店铺名完整显示,允许换行,不用省略号 */
white-space: normal;
word-break: break-all;
line-height: 1.35;
}
.badge {
flex-shrink: 0; min-width: 132rpx; border-radius: 14rpx; padding: 12rpx 16rpx;
background: linear-gradient(160deg, #F0623A, #D8431F);
display: flex; flex-direction: column; align-items: center;
box-shadow: 0 6rpx 14rpx rgba(216, 67, 31, .35);
}
.badge-main { font-size: 30rpx; font-weight: 900; color: #fff; line-height: 1.2; white-space: nowrap; }
.badge-sub { font-size: 18rpx; color: rgba(255, 255, 255, .92); margin-top: 4rpx; white-space: nowrap; }
.head-divider { height: 1rpx; background: #F3E7D7; margin: 24rpx 0 18rpx; }
.head-meta { display: flex; flex-direction: column; gap: 8rpx; }
.meta-line { font-size: 24rpx; color: #8A6E56; }
.card { background: #fff; border-radius: 28rpx; padding: 28rpx; margin-top: 24rpx; }
.card-title { display: flex; align-items: center; gap: 14rpx; font-size: 32rpx; font-weight: 800; color: #33200F; }
.bar { width: 8rpx; height: 30rpx; border-radius: 4rpx; background: linear-gradient(180deg, #F6613C, #E01818); }
.rules-rich { display: block; margin-top: 20rpx; font-size: 28rpx; color: #4A3A2E; line-height: 1.7; }
.rule-line { display: flex; margin-top: 20rpx; }
.rule-no { width: 32rpx; flex-shrink: 0; font-size: 28rpx; color: #4A3A2E; line-height: 1.7; }
.rule-txt { flex: 1; font-size: 28rpx; color: #4A3A2E; line-height: 1.7; }
.rule-empty { display: block; margin-top: 16rpx; font-size: 26rpx; color: #B8A28E; }
.shops-head { display: flex; align-items: center; justify-content: space-between; }
.shops-title { font-size: 32rpx; font-weight: 800; color: #33200F; }
.shops-count { font-size: 24rpx; font-weight: 400; color: #A78D75; }
.shops-more { display: flex; align-items: center; gap: 4rpx; font-size: 26rpx; color: #E0342B; font-weight: 600; }
.chev { width: 10rpx; height: 10rpx; border-top: 3rpx solid #E0342B; border-right: 3rpx solid #E0342B; transform: rotate(45deg); }
.chev.up { transform: rotate(-135deg); width: 8rpx; height: 8rpx; }
.shop-row {
display: flex; align-items: center; gap: 16rpx;
padding: 26rpx 0; border-bottom: 1rpx solid #F5EDE2;
}
.shop-row:last-child { border-bottom: none; }
.pin { flex-shrink: 0; }
.shop-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6rpx; }
.shop-name { font-size: 28rpx; font-weight: 700; color: #33200F; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.shop-addr { font-size: 22rpx; color: #A78D75; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.shop-right { display: flex; align-items: center; gap: 14rpx; flex-shrink: 0; }
.shop-dist { font-size: 22rpx; color: #C8542B; margin-right: 4rpx; }
.icon-btn {
width: 56rpx; height: 56rpx; border-radius: 50%; background: #F6F2EC;
display: flex; align-items: center; justify-content: center;
}
.collapse { text-align: center; font-size: 24rpx; color: #A78D75; padding-top: 20rpx; display: flex; align-items: center; justify-content: center; gap: 8rpx; }
.loading-tip { text-align: center; color: #B8A28E; font-size: 26rpx; padding: 120rpx 0; }
</style>