feat: 新增商家主页与名下信息流接口,新增优惠券与商户详情页面

这个提交包含在:
2026-10-23 17:36:25 +08:00
父节点 b8b32f1f1b
当前提交 526f22b27a
共有 12 个文件被更改,包括 5567 次插入 和 2298 次删除

查看文件

@@ -0,0 +1,218 @@
<?php
namespace app\api\controller;
use think\Db;
/**
* 用户端 · 商家门店与主页(Module-MERCHANT)
* 路由:
* GET /api/v1/merchant/:id M1 商家公开主页/门店详情
* GET /api/v1/merchant/:id/posts M2 商家名下发布的信息流(分页)
*/
class Merchant extends V1
{
/**
* M1 获取商家门店详情及公开档案
* GET /api/v1/merchant/:id
* 规则:允许游客;支持通过 merchant.id 或 user_id 查询;若提供客户端坐标则计算到店距离
*
* @return void
*/
public function detail()
{
$id = (int)$this->routeId();
if ($id <= 0) {
$id = (int)$this->input('id', 0) ?: (int)$this->input('userId', 0);
}
if ($id <= 0) {
$this->fail('缺少商家参数', 400);
}
// 优先按 merchant.id 查,若未命中再按 user_id 查
$m = Db::name('fc_merchant')->where('id', $id)->find();
if (!$m) {
$m = Db::name('fc_merchant')->where('user_id', $id)->find();
}
if (!$m) {
$this->fail('商家门店不存在', 404);
}
// 关联发布者基础信息
$user = Db::name('user')->where('id', $m['user_id'])->find();
$userNickname = $user ? (string)$user['nickname'] : '';
$userAvatar = $user ? (string)$user['avatar'] : '';
// 统计真实有效发布数量
$postCount = (int)Db::name('fc_post')
->where('user_id', $m['user_id'])
->where('status', 1)
->where('audit_status', 1)
->whereNull('deletetime')
->count();
// 计算用户与门店之间的物理距离(km)
$clientLat = $this->coord('lat', 90);
$clientLng = $this->coord('lng', 180);
$distance = null;
if ($clientLat !== null && $clientLng !== null && !empty($m['lat']) && !empty($m['lng'])) {
$distance = $this->calcDistance($clientLat, $clientLng, (float)$m['lat'], (float)$m['lng']);
}
// 首屏拉取前 6 条该商家的有效发帖
$posts = $this->fetchMerchantPosts($m['user_id'], 1, 6);
$data = [
'id' => (int)$m['id'],
'userId' => (int)$m['user_id'],
'name' => (string)$m['name'],
'logo' => (string)(isset($m['logo']) ? $m['logo'] : ''),
'banner' => (string)(isset($m['banner']) ? $m['banner'] : ''),
'address' => (string)(isset($m['address']) ? $m['address'] : ''),
'lat' => (isset($m['lat']) && $m['lat'] !== null && $m['lat'] !== '') ? (float)$m['lat'] : null,
'lng' => (isset($m['lng']) && $m['lng'] !== null && $m['lng'] !== '') ? (float)$m['lng'] : null,
'contact' => (string)(isset($m['contact']) ? $m['contact'] : ''),
'category' => (string)(isset($m['category']) ? $m['category'] : ''),
'notice' => (string)(isset($m['notice']) ? $m['notice'] : ''),
'auditStatus' => (int)$m['audit_status'],
'verified' => (int)$m['audit_status'] === 1,
'licenseVerified' => !empty($m['license']) && (int)$m['audit_status'] === 1,
'postCount' => $postCount,
'distance' => $distance,
'userNickname' => $userNickname,
'userAvatar' => $userAvatar,
'createdAt' => isset($m['createtime']) ? $this->iso($m['createtime']) : '',
'posts' => $posts['list'],
'hasMorePosts' => $posts['hasMore'],
];
$this->ok($data);
}
/**
* M2 获取商家名下的信息列表(支持分页)
* GET /api/v1/merchant/:id/posts
*
* @return void
*/
public function posts()
{
$id = (int)$this->routeId();
if ($id <= 0) {
$id = (int)$this->input('id', 0) ?: (int)$this->input('userId', 0);
}
if ($id <= 0) {
$this->fail('缺少商家参数', 400);
}
$userId = $id;
$m = Db::name('fc_merchant')->where('id', $id)->find();
if ($m) {
$userId = (int)$m['user_id'];
}
list($page, $size) = $this->pager(10, 30);
$res = $this->fetchMerchantPosts($userId, $page, $size);
$this->ok($res);
}
/**
* 查询指定商家的发帖列表统一组装
*
* @param int $userId 发布者用户ID
* @param int $page 页码
* @param int $size 每页数量
* @return array
*/
protected function fetchMerchantPosts($userId, $page, $size)
{
$q = Db::name('fc_post')
->where('user_id', $userId)
->where('status', 1)
->where('audit_status', 1)
->whereNull('deletetime');
$total = (int)$q->count();
$rows = Db::name('fc_post')
->where('user_id', $userId)
->where('status', 1)
->where('audit_status', 1)
->whereNull('deletetime')
->order('is_top desc, id desc')
->page($page, $size)
->select();
$list = [];
foreach ($rows as $r) {
$catName = '';
if (!empty($r['category_id'])) {
$cat = Db::name('fc_category')->where('id', $r['category_id'])->value('name');
$catName = $cat ? (string)$cat : '';
}
$cover = (string)$r['cover'];
$mediaArr = $this->jsonArr($r['media']);
if ($cover === '' && !empty($mediaArr)) {
$cover = $mediaArr[0];
}
$tags = [];
if (!empty($r['tags'])) {
foreach (explode(',', (string)$r['tags']) as $t) {
$t = trim($t);
if ($t !== '') {
$tags[] = $t;
}
}
}
$list[] = [
'id' => (int)$r['id'],
'title' => (string)$r['title'],
'content' => (string)$r['content'],
'price' => (float)$r['price'],
'priceUnit' => (string)$r['price_unit'],
'cover' => $cover,
'media' => $mediaArr,
'area' => (string)$r['area'],
'address' => (string)$r['address'],
'categoryId' => (int)$r['category_id'],
'categoryName' => $catName,
'isTop' => (int)$r['is_top'] === 1,
'views' => (int)$r['views'],
'commentCount' => (int)$r['comment_count'],
'createdAt' => $this->iso($r['createtime']),
'tags' => $tags,
];
}
return [
'list' => $list,
'total' => $total,
'page' => $page,
'size' => $size,
'hasMore' => ($page * $size) < $total,
];
}
/**
* 计算两点大地距离(单位 km,保留 1 位小数)
*
* @param float $lat1 纬度1
* @param float $lng1 经度1
* @param float $lat2 纬度2
* @param float $lng2 经度2
* @return float
*/
protected function calcDistance($lat1, $lng1, $lat2, $lng2)
{
$earthRadius = 6378.137;
$radLat1 = deg2rad($lat1);
$radLat2 = deg2rad($lat2);
$a = $radLat1 - $radLat2;
$b = deg2rad($lng1) - deg2rad($lng2);
$s = 2 * asin(sqrt(pow(sin($a / 2), 2) + cos($radLat1) * cos($radLat2) * pow(sin($b / 2), 2)));
$s = $s * $earthRadius;
return round($s, 1);
}
}

查看文件

@@ -65,6 +65,10 @@ return [
'api/v1/post/upload' => 'api/Post/uploadMedia',
'api/v1/post/:id' => 'api/Post/detail',
/* =============== 三·A、用户端 · 商家主页与门店详情 =============== */
'api/v1/merchant/:id/posts' => 'api/Merchant/posts',
'api/v1/merchant/:id' => 'api/Merchant/detail',
/* =============== 三·B、用户端 · 互动(举报 / 收藏 / 关注) ===============
* 顺序说明:本组全部是「同前缀、不同后缀」的静态路径(favorite/list、favorite/toggle、
* favorite/status、follow/toggle),彼此不构成前缀包含关系,注册顺序互不吞并;

查看文件

@@ -3,14 +3,27 @@
* 对应契约 §2.1:
* GET /coupon/list {page,size} → 分页(可领取 + 已领取标记 received)
* POST /coupon/receive {couponId} → {userCouponId}
* GET /member/assets → {coupons,couponCount,...}
*/
import { get, post } from '../utils/request.js'
export const couponApi = {
/** 可领取优惠券列表(含 received 已领取标记) */
/**
* 可领取优惠券列表(含 received 已领取标记)
* @param {Object} params {page, size}
*/
list: (params = {}) => get('/coupon/list', params, { silent: true }),
/** 领取优惠券 */
/**
* 领取优惠券
* @param {number|string} couponId 优惠券模板ID
*/
receive: (couponId) => post('/coupon/receive', { couponId }, { silent: true }),
/**
* 我的优惠券与资产
*/
my: () => get('/member/assets', {}, { silent: true }),
}
export default couponApi

查看文件

@@ -16,3 +16,4 @@ export { reportApi } from './report.js'
export { orderApi } from './order.js'
export { payApi } from './pay.js'
export { couponApi } from './coupon.js'
export { merchantApi } from './merchant.js'

查看文件

@@ -0,0 +1,27 @@
/**
* 接口模块 · 商家门店与主页(用户端)
* 对应路由:
* GET /api/v1/merchant/:id 获取商家门店公开主页与档案
* GET /api/v1/merchant/:id/posts 获取商家名下发布的信息列表
*/
import { get } from '../utils/request.js'
export const merchantApi = {
/**
* 获取商家门店公开主页
* @param {number|string} id 商家ID或用户ID
* @param {Object} params 可选参数 {lat, lng}
* @returns {Promise<Object>}
*/
detail: (id, params = {}) => get(`/merchant/${id}`, params, { silent: true }),
/**
* 获取商家发布的信息流(分页)
* @param {number|string} id 商家ID或用户ID
* @param {Object} params {page, size}
* @returns {Promise<{list:Array, total:number, hasMore:boolean}>}
*/
posts: (id, params = {}) => get(`/merchant/${id}/posts`, params, { silent: true }),
}
export default merchantApi

查看文件

@@ -447,6 +447,40 @@ export const mockRoutes = {
}))
),
// ==================== 用户端 · 商家主页与门店详情 ====================
'GET /merchant/:id': ({ params }) => {
const id = params && params.id
const m = (datasets.merchants || []).find((x) => String(x.id) === String(id) || String(x.user_id) === String(id)) || datasets.merchants[0]
if (!m) fail('商家门店不存在', 404)
const posts = (datasets.posts || []).filter((p) => p.publisher && (String(p.publisher.id) === String(m.id) || String(p.publisher.name) === String(m.name)))
return ok({
id: m.id,
userId: m.user_id || m.id,
name: m.name,
logo: m.logo || '',
banner: m.banner || '',
address: m.address || '同城便民服务实体店',
lat: m.lat || 26.5716,
lng: m.lng || 106.7314,
contact: m.contact || '13566666666',
category: m.category || '综合便民',
notice: m.notice || '诚信经营,品质保障,欢迎新老顾客垂询!',
auditStatus: m.auditStatus != null ? m.auditStatus : 1,
verified: true,
licenseVerified: true,
postCount: posts.length || m.postCount || 12,
distance: 1.2,
posts: posts.slice(0, 6),
hasMorePosts: posts.length > 6,
})
},
'GET /merchant/:id/posts': ({ params, data }) => {
const id = params && params.id
const m = (datasets.merchants || []).find((x) => String(x.id) === String(id) || String(x.user_id) === String(id)) || datasets.merchants[0]
const posts = (datasets.posts || []).filter((p) => p.publisher && (String(p.publisher.id) === String(m.id) || String(p.publisher.name) === String(m.name)))
return ok(paginate(posts, data && data.page, data && data.size))
},
// ==================== 用户端 · 会员中心 ====================
'GET /member/plans': () => ok(datasets.memberPlans),
'GET /member/benefits': () => ok(datasets.memberBenefits),

查看文件

@@ -131,6 +131,15 @@
"backgroundColor": "#f2fef7"
}
},
{
"path": "pages/member/coupons",
"style": {
"navigationBarTitleText": "优惠券中心",
"navigationStyle": "custom",
"backgroundColor": "#f2fef7",
"enablePullDownRefresh": true
}
},
{
"path": "pages/favorite/index",
"style": {
@@ -163,6 +172,14 @@
"backgroundColor": "#f2fef7"
}
},
{
"path": "pages/merchant/detail",
"style": {
"navigationBarTitleText": "店铺详情",
"navigationStyle": "custom",
"backgroundColor": "#f2fef7"
}
},
{
"path": "pages/mine/profile",
"style": {

查看文件

@@ -144,13 +144,16 @@
</view>
<!-- 商家门店专区(仅商家发布或关联认证商户时展示) -->
<view v-if="isMerchantPost" class="fc-card detail__merchant">
<view v-if="isMerchantPost" class="fc-card detail__merchant" @click="goShopDetail">
<view class="detail__merchant-badge-bar">
<view class="detail__merchant-flag">
<image class="fc-icon fc-icon--xs" :src="iconUrl('shield')" mode="aspectFit" />
<text class="detail__merchant-flag-txt">认证商家官方门店</text>
</view>
<text class="detail__merchant-security">工商资质已核验</text>
<view class="detail__merchant-entry">
<text class="detail__merchant-entry-txt">进店逛逛</text>
<text class="detail__merchant-entry-arrow">›</text>
</view>
</view>
<view class="detail__merchant-main">
@@ -183,7 +186,7 @@
</view>
<!-- 实体门店地址与一键导航 -->
<view v-if="merchantAddress" class="detail__merchant-address-box" @click="openMerchantLocation">
<view v-if="merchantAddress" class="detail__merchant-address-box" @click.stop="openMerchantLocation">
<view class="detail__merchant-address-left">
<image class="fc-icon fc-icon--sm" :src="iconUrl('home-location')" mode="aspectFit" />
<text class="detail__merchant-address-txt">{{ merchantAddress }}</text>
@@ -1001,6 +1004,23 @@ export default {
/**
* 导航或复制地址
*/
/**
* 跳转至商家店铺详情主页
*/
goShopDetail() {
const m = this.merchantInfo
const shopId = (m && (m.id || m.merchantId)) || (this.post.publisher && this.post.publisher.id) || (this.post.userId || this.post.user_id)
if (!shopId) {
uni.showToast({ title: '暂未获取到店铺信息', icon: 'none' })
return
}
uni.navigateTo({
url: '/pages/merchant/detail?id=' + shopId,
fail: (err) => {
console.warn('跳转商家详情失败:', err)
}
})
},
/**
* 导航前往商家门店或复制实体地址
*/
@@ -1638,7 +1658,28 @@ export default {
background: #ffffff;
border-radius: $fc-radius-lg;
padding: 24rpx;
border: 1rpx solid #e2f4ea;
border: 1rpx solid #dcf3e5;
box-shadow: 0 4rpx 16rpx rgba(0, 224, 112, 0.05);
transition: all 0.2s ease;
&:active {
transform: scale(0.995);
background: #fbfdfc;
}
}
.detail__merchant-entry {
display: flex;
align-items: center;
gap: 4rpx;
}
.detail__merchant-entry-txt {
font-size: 22rpx;
color: #04874a;
font-weight: 600;
}
.detail__merchant-entry-arrow {
font-size: 24rpx;
color: #04874a;
font-weight: 700;
}
.detail__merchant-badge-bar {
display: flex;

查看文件

@@ -0,0 +1,845 @@
<template>
<view class="coupon-page fc-page">
<!-- 自定义导航栏:深绿渐变沉浸式 -->
<fc-navbar title="优惠券中心" theme="gradient" :show-back="true" />
<!-- 顶部深绿沉浸底座 -->
<view class="coupon-page__backdrop">
<view class="coupon-page__backdrop-ambient"></view>
</view>
<!-- 顶部主标签页(我的卡券 vs 领券中心) -->
<view class="coupon-page__tabs-wrap">
<view class="coupon-page__tabs">
<view
class="coupon-page__tab-item"
:class="{ 'coupon-page__tab-item--active': mainTab === 'mine' }"
@click="switchMainTab('mine')"
>
<text class="coupon-page__tab-text">我的卡券</text>
<text v-if="myCouponCount > 0" class="coupon-page__tab-badge">{{ myCouponCount }}</text>
<view v-if="mainTab === 'mine'" class="coupon-page__tab-line"></view>
</view>
<view
class="coupon-page__tab-item"
:class="{ 'coupon-page__tab-item--active': mainTab === 'market' }"
@click="switchMainTab('market')"
>
<text class="coupon-page__tab-text">领券中心</text>
<view v-if="marketAvailableCount > 0" class="coupon-page__tab-dot"></view>
<view v-if="mainTab === 'market'" class="coupon-page__tab-line"></view>
</view>
</view>
</view>
<!-- 二级筛选栏(仅在「我的卡券」显示:全部 / 未使用 / 已使用 / 已过期) -->
<view v-if="mainTab === 'mine'" class="coupon-page__sub-filter">
<view
v-for="f in subFilters"
:key="f.key"
class="coupon-page__filter-chip"
:class="{ 'coupon-page__filter-chip--active': subStatus === f.key }"
@click="switchSubStatus(f.key)"
>
<text class="coupon-page__filter-chip-text">{{ f.label }}</text>
<text v-if="f.count > 0" class="coupon-page__filter-chip-num">({{ f.count }})</text>
</view>
</view>
<!-- 卡券列表主体容器 -->
<view class="coupon-page__body">
<!-- 骨架/加载占位 -->
<view v-if="loading" class="coupon-page__loading">
<text class="coupon-page__loading-text">正在加载优惠券...</text>
</view>
<!-- 1. 我的卡券列表 -->
<view v-else-if="mainTab === 'mine'">
<view v-if="filteredMyCoupons.length > 0" class="coupon-list">
<view
v-for="item in filteredMyCoupons"
:key="item.id"
class="coupon-card"
:class="[`coupon-card--${item.status}`]"
>
<!-- 卡片左侧:金额与门槛 -->
<view class="coupon-card__left">
<view class="coupon-card__amount-row">
<text class="coupon-card__currency">¥</text>
<text class="coupon-card__amount">{{ formatAmount(item.amount) }}</text>
</view>
<text class="coupon-card__condition">
{{ item.minAmount > 0 ? `满${item.minAmount}元可用` : '无门槛' }}
</text>
</view>
<!-- 中间齿孔分隔 -->
<view class="coupon-card__divider">
<view class="coupon-card__hole coupon-card__hole--top"></view>
<view class="coupon-card__dash"></view>
<view class="coupon-card__hole coupon-card__hole--bottom"></view>
</view>
<!-- 卡片右侧:信息与操作 -->
<view class="coupon-card__right">
<view class="coupon-card__info">
<view class="coupon-card__title-row">
<text class="coupon-card__tag">{{ getCouponTypeLabel(item.type) }}</text>
<text class="coupon-card__title fc-ellipsis">{{ item.name || '通用优惠券' }}</text>
</view>
<text class="coupon-card__date">
{{ item.expireAt ? `有效期至 ${formatDate(item.expireAt)}` : '永久有效' }}
</text>
</view>
<!-- 右侧操作/状态印章 -->
<view class="coupon-card__action">
<!-- 未使用态:去使用按钮(春绿底墨绿字) -->
<view
v-if="item.status === 'unused'"
class="coupon-card__btn coupon-card__btn--use"
@click="goUseCoupon(item)"
>
<text class="coupon-card__btn-text">去使用</text>
</view>
<!-- 已使用印章 -->
<view v-else-if="item.status === 'used'" class="coupon-card__stamp coupon-card__stamp--used">
<text class="coupon-card__stamp-text">已使用</text>
</view>
<!-- 已过期印章 -->
<view v-else class="coupon-card__stamp coupon-card__stamp--expired">
<text class="coupon-card__stamp-text">已过期</text>
</view>
</view>
</view>
</view>
</view>
<!-- 我的卡券空状态 -->
<fc-empty
v-else
icon="inbox"
:text="emptyTextMine"
btn-text="去领券中心"
@action="switchMainTab('market')"
/>
</view>
<!-- 2. 领券中心列表 -->
<view v-else-if="mainTab === 'market'">
<view v-if="marketCoupons.length > 0" class="coupon-list">
<view
v-for="c in marketCoupons"
:key="c.id"
class="coupon-card"
:class="{ 'coupon-card--received': c.received || c.left === 0 }"
>
<!-- 卡片左侧:面额与门槛 -->
<view class="coupon-card__left">
<view class="coupon-card__amount-row">
<text class="coupon-card__currency">¥</text>
<text class="coupon-card__amount">{{ formatAmount(c.amount) }}</text>
</view>
<text class="coupon-card__condition">
{{ c.minAmount > 0 ? `满${c.minAmount}元可用` : '无门槛' }}
</text>
</view>
<!-- 中间齿孔分隔 -->
<view class="coupon-card__divider">
<view class="coupon-card__hole coupon-card__hole--top"></view>
<view class="coupon-card__dash"></view>
<view class="coupon-card__hole coupon-card__hole--bottom"></view>
</view>
<!-- 卡片右侧:券信息与领取按钮 -->
<view class="coupon-card__right">
<view class="coupon-card__info">
<view class="coupon-card__title-row">
<text class="coupon-card__tag">{{ getCouponTypeLabel(c.type) }}</text>
<text class="coupon-card__title fc-ellipsis">{{ c.name || '通用优惠券' }}</text>
</view>
<view class="coupon-card__meta-row">
<text class="coupon-card__date">
{{ c.days > 0 ? `领取后 ${c.days} 天内有效` : '永久有效' }}
</text>
<text v-if="c.left > 0" class="coupon-card__stock">仅剩{{ c.left }}张</text>
</view>
</view>
<view class="coupon-card__action">
<!-- 已领取 -->
<view v-if="c.received" class="coupon-card__btn coupon-card__btn--disabled">
<text class="coupon-card__btn-text--disabled">已领取</text>
</view>
<!-- 已抢光 -->
<view v-else-if="c.left === 0" class="coupon-card__btn coupon-card__btn--disabled">
<text class="coupon-card__btn-text--disabled">已抢光</text>
</view>
<!-- 立即领取按钮(亮绿底墨绿字) -->
<view
v-else
class="coupon-card__btn coupon-card__btn--receive"
:class="{ 'coupon-card__btn--loading': receivingId === c.id }"
@click="handleReceive(c)"
>
<text class="coupon-card__btn-text">
{{ receivingId === c.id ? '领取中' : '立即领取' }}
</text>
</view>
</view>
</view>
</view>
</view>
<!-- 领券中心空状态 -->
<fc-empty
v-else
icon="inbox"
text="暂无可领取的优惠券,稍后再来瞧瞧吧"
/>
</view>
</view>
</view>
</template>
<script>
import FcNavbar from '@/components/fc-navbar/fc-navbar.vue'
import FcEmpty from '@/components/fc-empty/fc-empty.vue'
import couponApi from '@/common/api/coupon.js'
import memberApi from '@/common/api/member.js'
import { useUserStore } from '@/common/store/index.js'
export default {
name: 'CouponsPage',
components: {
FcNavbar,
FcEmpty,
},
data() {
return {
/** 当前主 Tab:mine(我的卡券) | market(领券中心) */
mainTab: 'mine',
/** 我的卡券二级筛选状态:all(全部) | unused(未使用) | used(已使用) | expired(已过期) */
subStatus: 'unused',
/** 数据加载状态 */
loading: false,
/** 正在领取的券ID */
receivingId: null,
/** 用户拥有的卡券列表 */
myCoupons: [],
/** 领券中心的券模板列表 */
marketCoupons: [],
}
},
computed: {
/**
* 检查当前是否登录
* @returns {boolean}
*/
isLogin() {
try {
return useUserStore().isLogin.value
} catch (e) {
return false
}
},
/**
* 我的可用卡券总数
* @returns {number}
*/
myCouponCount() {
return this.myCoupons.filter((c) => c.status === 'unused').length
},
/**
* 领券中心剩余可领取数量标记
* @returns {number}
*/
marketAvailableCount() {
return this.marketCoupons.filter((c) => !c.received && (c.left === -1 || c.left > 0)).length
},
/**
* 我的卡券二级分类配置及各状态计数
* @returns {Array<{key: string, label: string, count: number}>}
*/
subFilters() {
const unusedCount = this.myCoupons.filter((c) => c.status === 'unused').length
const usedCount = this.myCoupons.filter((c) => c.status === 'used').length
const expiredCount = this.myCoupons.filter((c) => c.status === 'expired').length
return [
{ key: 'unused', label: '未使用', count: unusedCount },
{ key: 'all', label: '全部', count: this.myCoupons.length },
{ key: 'used', label: '已使用', count: usedCount },
{ key: 'expired', label: '已过期', count: expiredCount },
]
},
/**
* 经过二级分类筛选后的卡券列表
* @returns {Array}
*/
filteredMyCoupons() {
if (this.subStatus === 'all') {
return this.myCoupons
}
return this.myCoupons.filter((c) => c.status === this.subStatus)
},
/**
* 我的卡券空状态提示语
* @returns {string}
*/
emptyTextMine() {
if (this.subStatus === 'unused') return '暂无未使用的优惠券'
if (this.subStatus === 'used') return '暂无已使用的优惠券记录'
if (this.subStatus === 'expired') return '暂无过期的优惠券'
return '您还没有优惠券,快去领取专属福利吧'
},
},
/**
* 页面加载生命周期
* @param {Object} options 页面传参,可指定 tab=mine|market
*/
onLoad(options) {
if (options && options.tab === 'market') {
this.mainTab = 'market'
}
this.initData()
},
/**
* 下拉刷新生命周期
*/
async onPullDownRefresh() {
await this.initData()
uni.stopPullDownRefresh()
},
methods: {
/**
* 初始化加载所有卡券数据
*/
async initData() {
this.loading = true
try {
await Promise.all([this.loadMyCoupons(), this.loadMarketCoupons()])
} finally {
this.loading = false
}
},
/**
* 加载我的卡券资产
*/
async loadMyCoupons() {
if (!this.isLogin) {
this.myCoupons = []
return
}
try {
const res = await memberApi.assets()
this.myCoupons = (res && Array.isArray(res.coupons)) ? res.coupons : []
} catch (err) {
this.myCoupons = []
}
},
/**
* 加载领券中心公开列表
*/
async loadMarketCoupons() {
try {
const res = await couponApi.list({ page: 1, size: 50 })
this.marketCoupons = (res && Array.isArray(res.list)) ? res.list : []
} catch (err) {
this.marketCoupons = []
}
},
/**
* 切换一级主 Tab
* @param {'mine'|'market'} tab
*/
switchMainTab(tab) {
this.mainTab = tab
},
/**
* 切换二级状态筛选
* @param {'all'|'unused'|'used'|'expired'} key
*/
switchSubStatus(key) {
this.subStatus = key
},
/**
* 点击去使用优惠券
* @param {Object} item 优惠券对象
*/
goUseCoupon(item) {
uni.showActionSheet({
itemList: ['发布同城信息(可用券抵扣)', '浏览最新同城信息'],
success: (res) => {
if (res.tapIndex === 0) {
uni.navigateTo({ url: '/pages/post/create' })
} else {
uni.switchTab({ url: '/pages/index/index' })
}
},
})
},
/**
* 领取优惠券操作
* @param {Object} c 券对象
*/
async handleReceive(c) {
if (!this.isLogin) {
uni.showToast({ title: '请先登录后再领券', icon: 'none' })
setTimeout(() => {
uni.navigateTo({ url: '/pages/auth/login' })
}, 600)
return
}
if (this.receivingId) return
this.receivingId = c.id
try {
await couponApi.receive(c.id)
uni.showToast({ title: '领取成功!', icon: 'success' })
// 标记已领取
c.received = true
if (c.left > 0) c.left -= 1
// 重新静默拉取我的资产
this.loadMyCoupons()
} catch (e) {
// 提示已由 request 拦截层处理或直接提示
uni.showToast({ title: (e && e.message) || '领取失败,请重试', icon: 'none' })
} finally {
this.receivingId = null
}
},
/**
* 格式化金额数值
* @param {number|string} val
* @returns {string}
*/
formatAmount(val) {
const n = Number(val)
if (isNaN(n)) return '0'
return Number.isInteger(n) ? String(n) : n.toFixed(1)
},
/**
* 格式化时间字符串至年月日
* @param {string} dateStr
* @returns {string}
*/
formatDate(dateStr) {
if (!dateStr) return ''
return String(dateStr).slice(0, 10)
},
/**
* 解析优惠券类型文案
* @param {string} type
* @returns {string}
*/
getCouponTypeLabel(type) {
if (type === 'discount') return '折扣券'
if (type === 'cash') return '现金抵扣'
return '满减券'
},
},
}
</script>
<style lang="scss" scoped>
/* 页面根容器 */
.coupon-page {
min-height: 100vh;
background-color: $fc-bg;
position: relative;
padding-bottom: 60rpx;
}
/* 顶部沉浸底座 */
.coupon-page__backdrop {
position: absolute;
top: 0;
left: 0;
right: 0;
height: 380rpx;
background: $fc-gradient-hero;
overflow: hidden;
z-index: 0;
pointer-events: none;
}
.coupon-page__backdrop-ambient {
position: absolute;
top: -60rpx;
right: -60rpx;
width: 320rpx;
height: 320rpx;
border-radius: 50%;
background: radial-gradient(circle, rgba(0, 224, 112, 0.28) 0%, rgba(0, 224, 112, 0) 70%);
filter: blur(20px);
}
/* 主标签页切换条 */
.coupon-page__tabs-wrap {
position: relative;
z-index: 2;
padding: 16rpx 32rpx 0;
}
.coupon-page__tabs {
display: flex;
align-items: center;
justify-content: space-around;
height: 88rpx;
}
.coupon-page__tab-item {
position: relative;
display: flex;
align-items: center;
padding: 12rpx 24rpx;
}
.coupon-page__tab-text {
font-size: 32rpx;
font-weight: 500;
color: rgba(255, 255, 255, 0.75);
transition: all 0.2s ease;
}
.coupon-page__tab-item--active .coupon-page__tab-text {
font-size: 34rpx;
font-weight: 700;
color: #ffffff;
}
.coupon-page__tab-badge {
margin-left: 8rpx;
padding: 2rpx 12rpx;
border-radius: 20rpx;
background-color: $fc-accent;
color: #ffffff;
font-size: 20rpx;
font-weight: 700;
line-height: 28rpx;
}
.coupon-page__tab-dot {
width: 12rpx;
height: 12rpx;
border-radius: 50%;
background-color: $fc-primary;
margin-left: 8rpx;
}
.coupon-page__tab-line {
position: absolute;
bottom: 0;
left: 50%;
transform: translateX(-50%);
width: 48rpx;
height: 6rpx;
border-radius: 4rpx;
background-color: $fc-primary;
}
/* 二级筛选栏(胶囊筛选) */
.coupon-page__sub-filter {
position: relative;
z-index: 2;
display: flex;
align-items: center;
padding: 20rpx 32rpx 10rpx;
gap: 16rpx;
overflow-x: auto;
}
.coupon-page__filter-chip {
display: flex;
align-items: center;
padding: 10rpx 24rpx;
border-radius: 32rpx;
background-color: rgba(255, 255, 255, 0.2);
backdrop-filter: blur(8px);
border: 1rpx solid rgba(255, 255, 255, 0.25);
transition: all 0.2s ease;
}
.coupon-page__filter-chip--active {
background-color: #ffffff;
border-color: #ffffff;
box-shadow: 0 4rpx 12rpx rgba(4, 48, 30, 0.1);
}
.coupon-page__filter-chip-text {
font-size: 24rpx;
color: rgba(255, 255, 255, 0.9);
font-weight: 500;
}
.coupon-page__filter-chip--active .coupon-page__filter-chip-text {
color: $fc-primary-text;
font-weight: 600;
}
.coupon-page__filter-chip-num {
font-size: 22rpx;
color: rgba(255, 255, 255, 0.8);
margin-left: 6rpx;
}
.coupon-page__filter-chip--active .coupon-page__filter-chip-num {
color: $fc-primary-text;
}
/* 内容主体 */
.coupon-page__body {
position: relative;
z-index: 2;
padding: 20rpx 28rpx;
}
/* 加载中状态 */
.coupon-page__loading {
padding: 100rpx 0;
text-align: center;
}
.coupon-page__loading-text {
font-size: 26rpx;
color: rgba(255, 255, 255, 0.8);
}
/* 卡券列表 */
.coupon-list {
display: flex;
flex-direction: column;
gap: 24rpx;
}
/* 经典打孔卡券卡片 */
.coupon-card {
display: flex;
height: 196rpx;
background-color: #ffffff;
border-radius: 20rpx;
box-shadow: 0 6rpx 20rpx rgba(4, 48, 30, 0.05);
overflow: hidden;
position: relative;
transition: all 0.2s ease;
}
/* 卡片左侧:阳光金价值面额 */
.coupon-card__left {
width: 200rpx;
background: linear-gradient(135deg, #fffcf5 0%, #fff7e6 100%);
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
padding: 16rpx 12rpx;
flex-shrink: 0;
}
.coupon-card__amount-row {
display: flex;
align-items: baseline;
color: $fc-accent;
}
.coupon-card__currency {
font-size: 26rpx;
font-weight: 700;
margin-right: 2rpx;
}
.coupon-card__amount {
font-size: 54rpx;
font-weight: 800;
line-height: 1;
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}
.coupon-card__condition {
margin-top: 10rpx;
font-size: 20rpx;
color: $fc-accent-dark;
background-color: rgba(245, 166, 35, 0.12);
padding: 2rpx 12rpx;
border-radius: 12rpx;
text-align: center;
}
/* 中间打孔虚线 */
.coupon-card__divider {
width: 24rpx;
position: relative;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
background-color: #ffffff;
flex-shrink: 0;
}
.coupon-card__hole {
position: absolute;
width: 24rpx;
height: 24rpx;
border-radius: 50%;
background-color: $fc-bg;
left: 0;
z-index: 2;
}
.coupon-card__hole--top {
top: -12rpx;
}
.coupon-card__hole--bottom {
bottom: -12rpx;
}
.coupon-card__dash {
height: 120rpx;
border-left: 2rpx dashed #e2e8e4;
}
/* 卡片右侧:详情与操作 */
.coupon-card__right {
flex: 1;
display: flex;
align-items: center;
justify-content: space-between;
padding: 20rpx 24rpx 20rpx 16rpx;
min-width: 0;
}
.coupon-card__info {
flex: 1;
min-width: 0;
display: flex;
flex-direction: column;
justify-content: center;
padding-right: 16rpx;
}
.coupon-card__title-row {
display: flex;
align-items: center;
gap: 10rpx;
margin-bottom: 12rpx;
}
.coupon-card__tag {
font-size: 20rpx;
color: $fc-primary-ink;
background: $fc-primary;
padding: 2rpx 10rpx;
border-radius: 6rpx;
font-weight: 600;
flex-shrink: 0;
}
.coupon-card__title {
font-size: 28rpx;
font-weight: 700;
color: $fc-text;
}
.coupon-card__date {
font-size: 22rpx;
color: $fc-text-placeholder;
}
.coupon-card__meta-row {
display: flex;
align-items: center;
gap: 12rpx;
}
.coupon-card__stock {
font-size: 20rpx;
color: $fc-accent;
background: $fc-accent-lighter;
padding: 2rpx 8rpx;
border-radius: 6rpx;
}
/* 操作区域 */
.coupon-card__action {
flex-shrink: 0;
}
/* 按钮通用 */
.coupon-card__btn {
padding: 14rpx 30rpx;
border-radius: 32rpx;
display: flex;
align-items: center;
justify-content: center;
min-width: 140rpx;
box-shadow: 0 4rpx 12rpx rgba(0, 224, 112, 0.2);
transition: all 0.2s ease;
}
.coupon-card__btn:active {
transform: scale(0.96);
}
/* 亮绿主按钮:规范严格执行亮绿底用深墨绿字 */
.coupon-card__btn--use,
.coupon-card__btn--receive {
background: $fc-gradient-primary;
}
.coupon-card__btn-text {
font-size: 24rpx;
font-weight: 700;
color: $fc-primary-ink; /* 亮绿底配深墨绿字,符合高对比度规范 */
}
/* 禁用态按钮 */
.coupon-card__btn--disabled {
background: #f0f3f1;
box-shadow: none;
pointer-events: none;
}
.coupon-card__btn-text--disabled {
font-size: 24rpx;
color: #9eb1a7;
font-weight: 500;
}
/* 状态印章(微倾斜盖章质感) */
.coupon-card__stamp {
width: 110rpx;
height: 110rpx;
border-radius: 50%;
border: 3rpx dashed #b8c7bf;
display: flex;
align-items: center;
justify-content: center;
transform: rotate(-15deg);
opacity: 0.6;
}
.coupon-card__stamp-text {
font-size: 22rpx;
font-weight: 700;
color: #7b9286;
}
.coupon-card__stamp--used {
border-color: #8fa398;
}
.coupon-card__stamp--expired {
border-color: #d1b8b8;
}
.coupon-card__stamp--expired .coupon-card__stamp-text {
color: #a88d8d;
}
/* 针对已失效或已领取的弱化卡面 */
.coupon-card--used,
.coupon-card--expired {
opacity: 0.72;
}
.coupon-card--used .coupon-card__left,
.coupon-card--expired .coupon-card__left {
background: #f7f9f8;
}
.coupon-card--used .coupon-card__amount-row,
.coupon-card--expired .coupon-card__amount-row {
color: #8c9e95;
}
.coupon-card--used .coupon-card__condition,
.coupon-card--expired .coupon-card__condition {
color: #8c9e95;
background-color: #ecefe5;
}
.coupon-card--used .coupon-card__tag,
.coupon-card--expired .coupon-card__tag {
background: #e2e8e4;
color: #63776d;
}
</style>

文件差异内容过多而无法显示 加载差异

查看文件

@@ -0,0 +1,782 @@
<template>
<view class="shop-detail fc-page">
<!-- 统一沉浸式深绿质感导航栏 -->
<fc-navbar :title="pageTitle" theme="gradient" :show-back="true">
<template #right>
<view class="shop-detail__share-nav" @click="onShareTap">
<image class="fc-icon fc-icon--sm" :src="iconUrl('share')" mode="aspectFit" />
</view>
</template>
</fc-navbar>
<!-- 骨架屏占位态 -->
<view v-if="loading && !loaded" class="shop-detail__skeleton">
<view class="shop-detail__skeleton-hero fc-skeleton"></view>
<view class="fc-card shop-detail__skeleton-card">
<view class="shop-detail__skeleton-line fc-skeleton" style="width: 60%; height: 36rpx;"></view>
<view class="shop-detail__skeleton-line fc-skeleton" style="width: 40%; height: 26rpx; margin-top: 18rpx;"></view>
</view>
<view class="fc-card shop-detail__skeleton-card">
<view class="shop-detail__skeleton-line fc-skeleton" style="width: 100%; height: 80rpx;"></view>
</view>
</view>
<!-- 真实内容视图 -->
<view v-else class="shop-detail__body">
<!-- 1. 商家 Hero 形象卡片 -->
<view class="shop-detail__hero-card fc-card">
<view class="shop-detail__hero-top">
<image
v-if="merchant.logo"
class="shop-detail__logo"
:src="assetUrl(merchant.logo)"
mode="aspectFill"
/>
<view v-else class="shop-detail__logo shop-detail__logo--empty">
<image class="fc-icon fc-icon--lg" :src="iconUrl('login-shop') || iconUrl('home-nearby')" mode="aspectFit" />
</view>
<view class="shop-detail__hero-info">
<view class="shop-detail__title-row">
<text class="shop-detail__name">{{ merchant.name || '同城认证门店' }}</text>
</view>
<view class="shop-detail__badges">
<view class="shop-detail__badge-pill shop-detail__badge-pill--green">
<image class="fc-icon fc-icon--xs" :src="iconUrl('check') || iconUrl('shield')" mode="aspectFit" />
<text>官方认证商家</text>
</view>
<text v-if="merchant.category" class="shop-detail__badge-pill shop-detail__badge-pill--gold">
{{ merchant.category }}
</text>
</view>
<text class="shop-detail__slogan">营业执照官方核验 · 实体门店信用保障</text>
</view>
</view>
<!-- 店铺数据栏 -->
<view class="shop-detail__stat-row">
<view class="shop-detail__stat-item">
<text class="shop-detail__stat-val">{{ merchant.postCount || postTotal || 0 }}</text>
<text class="shop-detail__stat-lbl">在招/在售</text>
</view>
<view class="shop-detail__stat-sep"></view>
<view class="shop-detail__stat-item">
<text class="shop-detail__stat-val">100%</text>
<text class="shop-detail__stat-lbl">实体真店</text>
</view>
<view class="shop-detail__stat-sep"></view>
<view class="shop-detail__stat-item">
<text class="shop-detail__stat-val">{{ distanceText || '同城' }}</text>
<text class="shop-detail__stat-lbl">到店距离</text>
</view>
</view>
</view>
<!-- 2. 店铺实体档案卡片(地址导航、咨询电话、营业公告) -->
<view class="fc-card shop-detail__section">
<text class="shop-detail__section-title">门店实体档案</text>
<!-- 门店地址行 -->
<view class="shop-detail__address-row" @click="openLocation">
<view class="shop-detail__address-left">
<image class="fc-icon fc-icon--sm" :src="iconUrl('home-location')" mode="aspectFit" />
<text class="shop-detail__address-txt">{{ merchant.address || '贵州省同城实体门店' }}</text>
</view>
<view class="shop-detail__nav-btn" @click.stop="openLocation">
<text>{{ hasLocation ? '导航到店' : '复制地址' }}</text>
<text class="shop-detail__nav-arrow">›</text>
</view>
</view>
<!-- 门店电话行 -->
<view v-if="merchant.contact" class="shop-detail__cell-row" @click="callPhone">
<view class="shop-detail__cell-left">
<image class="fc-icon fc-icon--sm" :src="iconUrl('phone')" mode="aspectFit" />
<text class="shop-detail__cell-txt">联系咨询:{{ merchant.contact }}</text>
</view>
<view class="shop-detail__call-link">
<text>立即拨打 ›</text>
</view>
</view>
<!-- 店铺公告栏 -->
<view v-if="merchant.notice" class="shop-detail__notice-box">
<view class="shop-detail__notice-head">
<image class="fc-icon fc-icon--xs" :src="iconUrl('notice')" mode="aspectFit" />
<text class="shop-detail__notice-title">店铺公告</text>
</view>
<text class="shop-detail__notice-content">{{ merchant.notice }}</text>
</view>
</view>
<!-- 3. 工商资质认证背书卡片 -->
<view class="fc-card shop-detail__verify-card">
<view class="shop-detail__verify-item">
<image class="fc-icon fc-icon--sm" :src="iconUrl('check')" mode="aspectFit" />
<text class="shop-detail__verify-txt">工商执照认证已核验</text>
</view>
<view class="shop-detail__verify-item">
<image class="fc-icon fc-icon--sm" :src="iconUrl('check')" mode="aspectFit" />
<text class="shop-detail__verify-txt">线下实体门店经营</text>
</view>
<view class="shop-detail__verify-item">
<image class="fc-icon fc-icon--sm" :src="iconUrl('check')" mode="aspectFit" />
<text class="shop-detail__verify-txt">平台消费者权益保障</text>
</view>
</view>
<!-- 4. 商家全部在售/发布信息列表 -->
<view class="shop-detail__posts-wrap">
<view class="shop-detail__posts-head">
<text class="shop-detail__section-title">在售服务 / 发布信息 ({{ postTotal }})</text>
</view>
<view v-if="posts && posts.length" class="shop-detail__posts-list">
<fc-post-card
v-for="p in posts"
:key="p.id"
:post="p"
@click="goPostDetail(p)"
/>
<view class="shop-detail__more">
<text v-if="loadingMore">加载中…</text>
<text v-else-if="!hasMore">— 已经到底了 —</text>
<text v-else @click="loadMore">点击加载更多</text>
</view>
</view>
<fc-empty v-else text="该商家暂未发布其他信息" />
</view>
</view>
<!-- 底部留白 -->
<view class="shop-detail__bar-space"></view>
<!-- 固定底部快捷主控栏 -->
<view class="shop-detail__bar">
<view class="shop-detail__bar-icon-btn" @click="goHome">
<image class="fc-icon fc-icon--md" :src="iconUrl('tab-home-active') || iconUrl('home-location')" mode="aspectFit" />
<text class="shop-detail__bar-icon-txt">首页</text>
</view>
<view class="shop-detail__bar-icon-btn" @click="onShareTap">
<image class="fc-icon fc-icon--md" :src="iconUrl('share')" mode="aspectFit" />
<text class="shop-detail__bar-icon-txt">分享</text>
</view>
<view class="shop-detail__bar-actions">
<view class="shop-detail__btn-nav" @click="openLocation">
<image class="fc-icon fc-icon--xs" :src="iconUrl('home-location')" mode="aspectFit" />
<text>地图导航</text>
</view>
<view class="shop-detail__btn-call" @click="callPhone">
<image class="fc-icon fc-icon--xs" :src="iconUrl('phone')" mode="aspectFit" />
<text>联系店长</text>
</view>
</view>
</view>
<view class="fc-safe-bottom"></view>
</view>
</template>
<script>
/**
* 商家门店公开主页详情页(春绿生态设计主题)
* 核心功能:
* 1. 深度展示商家官方认证身份、门头形象、主营类目与信用资质;
* 2. 实体门店地址一键微信地图路线规划(openLocation)与电话一键呼叫;
* 3. 聚合展示该商家名下全部在售服务与信息流,支持点击跳转并无缝联通;
* 4. 严格遵循春绿 Spring Green 视觉规范,高对比度无障碍交互。
*/
import FcNavbar from '@/components/fc-navbar/fc-navbar.vue'
import FcPostCard from '@/components/fc-post-card/fc-post-card.vue'
import FcEmpty from '@/components/fc-empty/fc-empty.vue'
import { merchantApi } from '@/common/api/merchant.js'
import { iconUrl, loadUiConfig } from '@/common/store/ui.js'
import { assetUrl } from '@/common/utils/format.js'
export default {
components: { FcNavbar, FcPostCard, FcEmpty },
data() {
return {
merchantId: 0,
loading: true,
loaded: false,
merchant: {},
posts: [],
page: 1,
size: 10,
postTotal: 0,
hasMore: false,
loadingMore: false,
userLat: null,
userLng: null,
}
},
computed: {
/**
* 页面顶部导航栏标题
* @returns {string}
*/
pageTitle() {
return (this.merchant && this.merchant.name) || '店铺主页'
},
/**
* 店铺是否具备真实经纬度坐标
* @returns {boolean}
*/
hasLocation() {
const m = this.merchant
return !!(m && m.lat != null && m.lng != null && Number(m.lat) !== 0 && Number(m.lng) !== 0)
},
/**
* 距离文本格式化
* @returns {string}
*/
distanceText() {
if (this.merchant && this.merchant.distance != null) {
const d = Number(this.merchant.distance)
return d < 1 ? `${Math.round(d * 1000)}m` : `${d.toFixed(1)}km`
}
return ''
},
},
/**
* 页面加载入参初始化
* @param {Object} query 路由入参
*/
onLoad(query) {
this.merchantId = Number(query.id || query.userId || 0)
loadUiConfig()
this.fetchLocation()
this.loadDetail()
},
/**
* 触底加载下一页信息流
*/
onReachBottom() {
this.loadMore()
},
/**
* 下拉刷新
*/
async onPullDownRefresh() {
try {
await this.loadDetail(true)
} finally {
uni.stopPullDownRefresh()
}
},
/**
* 微信好友分享配置
*/
onShareAppMessage() {
return {
title: `【认证商家】${this.merchant.name || '同城实体门店'}`,
path: `/pages/merchant/detail?id=${this.merchantId}`,
imageUrl: this.merchant.logo ? assetUrl(this.merchant.logo) : undefined,
}
},
methods: {
iconUrl,
assetUrl,
/**
* 静默获取当前定位经纬度,便于计算到店物理距离
*/
fetchLocation() {
if (typeof uni === 'undefined' || !uni.getLocation) return
uni.getLocation({
type: 'gcj02',
success: (res) => {
this.userLat = res.latitude
this.userLng = res.longitude
},
fail: () => {},
})
},
/**
* 加载商家门店详情主档案
* @param {boolean} refresh 是否为下拉刷新重载
*/
async loadDetail(refresh = false) {
if (!this.merchantId) {
uni.showToast({ title: '参数错误', icon: 'none' })
return
}
if (!refresh) this.loading = true
try {
const params = {}
if (this.userLat != null && this.userLng != null) {
params.lat = this.userLat
params.lng = this.userLng
}
const data = await merchantApi.detail(this.merchantId, params)
if (data) {
this.merchant = data
this.posts = Array.isArray(data.posts) ? data.posts : []
this.postTotal = data.postCount || this.posts.length
this.hasMore = !!data.hasMorePosts
this.page = 1
this.loaded = true
}
} catch (e) {
uni.showToast({ title: (e && e.message) || '店铺信息加载失败', icon: 'none' })
} finally {
this.loading = false
}
},
/**
* 分页加载更多商家名下信息
*/
async loadMore() {
if (!this.hasMore || this.loadingMore) return
this.loadingMore = true
try {
const nextPage = this.page + 1
const res = await merchantApi.posts(this.merchantId, {
page: nextPage,
size: this.size,
})
if (res && Array.isArray(res.list)) {
this.posts = this.posts.concat(res.list)
this.page = nextPage
this.hasMore = !!res.hasMore
if (res.total != null) this.postTotal = res.total
}
} catch (e) {
uni.showToast({ title: '加载更多失败', icon: 'none' })
} finally {
this.loadingMore = false
}
},
/**
* 调起微信地图或复制地址
*/
openLocation() {
const m = this.merchant
const addr = (m && m.address) || ''
const lat = m && m.lat != null ? Number(m.lat) : null
const lng = m && m.lng != null ? Number(m.lng) : null
if (lat != null && lng != null && lat !== 0 && lng !== 0) {
uni.openLocation({
latitude: lat,
longitude: lng,
name: m.name || '商家门店',
address: addr || '实体店详细地址',
fail: () => {
if (addr) {
uni.setClipboardData({
data: addr,
success: () => uni.showToast({ title: '地址已复制', icon: 'none' }),
})
}
},
})
} else if (addr) {
uni.setClipboardData({
data: addr,
success: () => uni.showToast({ title: '门店地址已复制', icon: 'none' }),
})
} else {
uni.showToast({ title: '暂未提供详细地址', icon: 'none' })
}
},
/**
* 一键拨打商家咨询电话
*/
callPhone() {
const phone = this.merchant && this.merchant.contact
if (!phone) {
uni.showToast({ title: '商家暂未公开联系电话', icon: 'none' })
return
}
uni.makePhoneCall({
phoneNumber: String(phone).trim(),
fail: () => {},
})
},
/**
* 跳转到信息详情页
* @param {Object} p 信息项
*/
goPostDetail(p) {
if (!p || !p.id) return
uni.navigateTo({
url: `/pages/detail/detail?id=${p.id}`,
})
},
/**
* 返回小程序首页
*/
goHome() {
uni.reLaunch({
url: '/pages/index/index',
})
},
/**
* 点击分享提示
*/
onShareTap() {
uni.showToast({
title: '点击右上角三个点转发给好友',
icon: 'none',
})
},
},
}
</script>
<style lang="scss" scoped>
.shop-detail {
min-height: 100vh;
background: $fc-bg;
}
.shop-detail__share-nav {
padding: 10rpx 14rpx;
display: flex;
align-items: center;
}
/* 骨架屏 */
.shop-detail__skeleton {
padding: 24rpx;
}
.shop-detail__skeleton-hero {
height: 240rpx;
border-radius: $fc-radius-lg;
margin-bottom: 24rpx;
}
.shop-detail__skeleton-card {
padding: 30rpx;
margin-bottom: 24rpx;
}
.shop-detail__skeleton-line {
border-radius: 8rpx;
}
/* 真实页面主体 */
.shop-detail__body {
padding: 20rpx 24rpx;
}
/* 1. Hero 形象卡片 */
.shop-detail__hero-card {
background: #ffffff;
border-radius: $fc-radius-lg;
padding: 30rpx 26rpx;
border: 1rpx solid #e2f4ea;
box-shadow: 0 4rpx 20rpx rgba(4, 48, 30, 0.04);
}
.shop-detail__hero-top {
display: flex;
align-items: center;
}
.shop-detail__logo {
width: 120rpx;
height: 120rpx;
border-radius: 20rpx;
border: 2rpx solid #eef6f1;
box-shadow: 0 4rpx 14rpx rgba(4, 48, 30, 0.08);
flex-shrink: 0;
background: #f8faf8;
&--empty {
background: #f0fbf5;
display: flex;
align-items: center;
justify-content: center;
border-color: #dcf3e5;
}
}
.shop-detail__hero-info {
flex: 1;
margin-left: 24rpx;
}
.shop-detail__title-row {
display: flex;
align-items: center;
}
.shop-detail__name {
font-size: 34rpx;
font-weight: 700;
color: #0f172a;
line-height: 1.3;
}
.shop-detail__badges {
display: flex;
align-items: center;
flex-wrap: wrap;
gap: 10rpx;
margin-top: 10rpx;
}
.shop-detail__badge-pill {
display: inline-flex;
align-items: center;
gap: 6rpx;
font-size: 20rpx;
padding: 4rpx 14rpx;
border-radius: 6rpx;
font-weight: 600;
&--green {
background: #e6f9ef;
color: #04874a;
border: 1rpx solid #b8ebd0;
}
&--gold {
background: #fef7ec;
color: #d97706;
border: 1rpx solid #fde68a;
}
}
.shop-detail__slogan {
display: block;
font-size: 22rpx;
color: $fc-text-placeholder;
margin-top: 10rpx;
}
/* 店铺数据指标条 */
.shop-detail__stat-row {
display: flex;
align-items: center;
justify-content: space-around;
margin-top: 26rpx;
padding-top: 22rpx;
border-top: 1rpx solid #f0f5f2;
}
.shop-detail__stat-item {
display: flex;
flex-direction: column;
align-items: center;
}
.shop-detail__stat-val {
font-size: 32rpx;
font-weight: 700;
color: #04874a;
}
.shop-detail__stat-lbl {
font-size: 22rpx;
color: $fc-text-secondary;
margin-top: 4rpx;
}
.shop-detail__stat-sep {
width: 2rpx;
height: 40rpx;
background: #eef2ef;
}
/* 2. 档案与地址卡片 */
.shop-detail__section {
margin-top: 20rpx;
background: #ffffff;
border-radius: $fc-radius-lg;
padding: 26rpx;
border: 1rpx solid #eef4f0;
}
.shop-detail__section-title {
font-size: 30rpx;
font-weight: 700;
color: $fc-text;
margin-bottom: 20rpx;
display: block;
}
.shop-detail__address-row {
display: flex;
align-items: center;
justify-content: space-between;
background: #f8faf8;
border-radius: 14rpx;
padding: 18rpx 20rpx;
cursor: pointer;
}
.shop-detail__address-left {
display: flex;
align-items: center;
gap: 12rpx;
flex: 1;
margin-right: 16rpx;
}
.shop-detail__address-txt {
font-size: 26rpx;
color: #1e293b;
font-weight: 500;
line-height: 1.4;
}
.shop-detail__nav-btn {
background: #00e070;
color: #04301e;
font-size: 22rpx;
font-weight: 700;
padding: 8rpx 18rpx;
border-radius: 30rpx;
display: flex;
align-items: center;
gap: 4rpx;
flex-shrink: 0;
}
.shop-detail__nav-arrow {
font-size: 24rpx;
font-weight: 700;
}
.shop-detail__cell-row {
display: flex;
align-items: center;
justify-content: space-between;
padding: 20rpx 4rpx 6rpx;
cursor: pointer;
}
.shop-detail__cell-left {
display: flex;
align-items: center;
gap: 12rpx;
}
.shop-detail__cell-txt {
font-size: 26rpx;
color: #334155;
font-weight: 500;
}
.shop-detail__call-link {
font-size: 24rpx;
font-weight: 600;
color: #04874a;
}
.shop-detail__notice-box {
background: #fbfdfc;
border: 1rpx dashed #d1eedc;
border-radius: 12rpx;
padding: 16rpx 20rpx;
margin-top: 20rpx;
}
.shop-detail__notice-head {
display: flex;
align-items: center;
gap: 8rpx;
margin-bottom: 8rpx;
}
.shop-detail__notice-title {
font-size: 22rpx;
font-weight: 700;
color: #04874a;
}
.shop-detail__notice-content {
font-size: 24rpx;
color: #334155;
line-height: 1.5;
}
/* 3. 资质背书 */
.shop-detail__verify-card {
margin-top: 20rpx;
background: linear-gradient(135deg, #f0fbf5 0%, #f9fdfb 100%);
border-radius: $fc-radius-lg;
padding: 20rpx 24rpx;
display: flex;
align-items: center;
justify-content: space-between;
border: 1rpx solid #dcf3e5;
}
.shop-detail__verify-item {
display: flex;
align-items: center;
gap: 6rpx;
}
.shop-detail__verify-txt {
font-size: 20rpx;
color: #04874a;
font-weight: 600;
}
/* 4. 商家信息流 */
.shop-detail__posts-wrap {
margin-top: 28rpx;
}
.shop-detail__posts-head {
padding: 0 4rpx 16rpx;
}
.shop-detail__posts-list {
display: flex;
flex-direction: column;
gap: 20rpx;
}
.shop-detail__more {
text-align: center;
padding: 24rpx 0;
font-size: 24rpx;
color: $fc-text-placeholder;
}
/* 底部操作栏 */
.shop-detail__bar-space {
height: 130rpx;
}
.shop-detail__bar {
position: fixed;
bottom: 0;
left: 0;
right: 0;
background: #ffffff;
border-top: 1rpx solid #eef2ef;
padding: 16rpx 28rpx calc(16rpx + env(safe-area-inset-bottom));
display: flex;
align-items: center;
z-index: 99;
box-shadow: 0 -4rpx 16rpx rgba(0, 0, 0, 0.04);
}
.shop-detail__bar-icon-btn {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
padding: 0 20rpx;
cursor: pointer;
}
.shop-detail__bar-icon-txt {
font-size: 20rpx;
color: #64748b;
margin-top: 4rpx;
}
.shop-detail__bar-actions {
flex: 1;
display: flex;
align-items: center;
gap: 16rpx;
margin-left: 16rpx;
}
.shop-detail__btn-nav {
flex: 1;
height: 80rpx;
border-radius: $fc-radius-pill;
background: #edfbf3;
border: 1rpx solid #a8ebd0;
color: #04874a;
font-size: 26rpx;
font-weight: 700;
display: flex;
align-items: center;
justify-content: center;
gap: 8rpx;
cursor: pointer;
}
.shop-detail__btn-call {
flex: 1.2;
height: 80rpx;
border-radius: $fc-radius-pill;
background: #00e070;
color: #04301e;
font-size: 28rpx;
font-weight: 700;
display: flex;
align-items: center;
justify-content: center;
gap: 8rpx;
cursor: pointer;
box-shadow: 0 6rpx 18rpx rgba(0, 224, 112, 0.3);
}
</style>

文件差异内容过多而无法显示 加载差异