功能:新增微信小程序界面

This commit is contained in:
xiaowang
2026-04-01 15:18:35 +08:00
parent bb2d8c4410
commit 7fa67d0511
92 changed files with 7463 additions and 0 deletions
+98
View File
@@ -0,0 +1,98 @@
const shopApi = require('../../api/shop')
const navigation = require('../../utils/navigation')
const { resolveImageList } = require('../../utils/file')
const { DEFAULT_SHOP_IMAGE } = require('../../utils/config')
Page({
data: {
loading: true,
loadError: '',
shopId: '',
returnTo: '/pages/home/index',
shopInfo: null,
shopImages: []
},
onLoad(options) {
this.setData({
shopId: options && options.id ? options.id : '',
returnTo: options && options.returnTo ? decodeURIComponent(options.returnTo) : '/pages/home/index'
})
this.loadShopDetail()
},
async onPullDownRefresh() {
await this.loadShopDetail()
wx.stopPullDownRefresh()
},
async loadShopDetail() {
if (!this.data.shopId) {
this.setData({
loading: false,
loadError: '门店 ID 不存在'
})
return
}
this.setData({
loading: true,
loadError: ''
})
try {
const shopInfo = await shopApi.getShopById(this.data.shopId)
const shopImages = await resolveImageList(shopInfo.imageFileIds || shopInfo.coverImageFileId, DEFAULT_SHOP_IMAGE)
this.setData({
shopInfo,
shopImages
})
} catch (error) {
this.setData({
loadError: error.message || '门店详情加载失败'
})
} finally {
this.setData({
loading: false
})
}
},
handleBack() {
navigation.goBack(this.data.returnTo || '/pages/home/index')
},
handlePreviewImage(event) {
const url = event.currentTarget.dataset.url
if (!url) {
return
}
wx.previewImage({
current: url,
urls: this.data.shopImages
})
},
handleCopyName() {
const shopInfo = this.data.shopInfo
if (!shopInfo || !shopInfo.shopName) {
return
}
wx.setClipboardData({
data: shopInfo.shopName
})
},
handleCopyAddress() {
const shopInfo = this.data.shopInfo
if (!shopInfo || !shopInfo.address) {
return
}
wx.setClipboardData({
data: shopInfo.address
})
}
})
@@ -0,0 +1,5 @@
{
"usingComponents": {
"navigation-bar": "/components/navigation-bar/navigation-bar"
}
}
@@ -0,0 +1,74 @@
<navigation-bar title="{{shopInfo ? shopInfo.shopName : '门店详情'}}" color="#ffffff" background="transparent" bindback="handleBack"></navigation-bar>
<view class="page-shell shop-page">
<view class="shop-hero">
<image wx:if="{{shopImages.length}}" class="shop-hero-image" src="{{shopImages[0]}}" mode="aspectFill"></image>
<view class="shop-hero-mask"></view>
</view>
<view wx:if="{{loadError}}" class="page-content shop-content">
<view class="page-card empty-card">
<text class="empty-title">暂时无法查看门店详情</text>
<text class="empty-desc">{{loadError}}</text>
<view class="ghost-btn" bindtap="handleBack">返回上一页</view>
</view>
</view>
<view wx:elif="{{shopInfo}}" class="page-content shop-content">
<view class="page-card shop-card">
<view class="section-kicker">门店详情</view>
<view class="shop-title">{{shopInfo.shopName}}</view>
<view class="shop-address" bindtap="handleCopyAddress">{{shopInfo.address || '门店地址待补充'}}</view>
<view class="summary-strip shop-summary">
<view class="summary-metric">
<text class="summary-label">营业时间</text>
<text class="summary-value shop-summary-value">{{shopInfo.businessHours || '待补充'}}</text>
<text class="summary-note">以到店服务时间为准</text>
</view>
<view class="summary-metric">
<text class="summary-label">环境图片</text>
<text class="summary-value shop-summary-value">{{shopImages.length ? shopImages.length : 0}} 张</text>
<text class="summary-note">支持点击放大查看</text>
</view>
</view>
<view class="detail-group">
<view class="detail-label">营业时间</view>
<view class="detail-value">{{shopInfo.businessHours || '待补充'}}</view>
</view>
<view class="detail-group">
<view class="detail-label">门店介绍</view>
<view class="detail-value">{{shopInfo.description || '门店介绍待补充'}}</view>
</view>
<view class="copy-row">
<view class="ghost-btn" bindtap="handleCopyName">复制门店名</view>
<view class="ghost-btn" bindtap="handleCopyAddress">复制地址</view>
</view>
</view>
<view class="section-block">
<view class="section-head">
<view class="section-copy">
<text class="section-kicker">实景展示</text>
<text class="section-title">门店环境图</text>
<text class="section-subtitle">点击图片可以放大查看,更直观地感受门店氛围。</text>
</view>
</view>
<view class="gallery-list">
<image
wx:for="{{shopImages}}"
wx:key="*this"
class="gallery-image"
src="{{item}}"
mode="aspectFill"
data-url="{{item}}"
bindtap="handlePreviewImage"
></image>
</view>
</view>
</view>
</view>
@@ -0,0 +1,91 @@
.shop-page {
background: linear-gradient(180deg, #f4dbe3 0%, #fff8fa 220rpx, #fffdfc 100%);
}
.shop-hero {
position: fixed;
top: 0;
left: 0;
right: 0;
height: 320rpx;
background: linear-gradient(135deg, #c6597d 0%, #8d4763 100%);
}
.shop-hero-image {
width: 100%;
height: 100%;
}
.shop-hero-mask {
position: absolute;
inset: 0;
background: linear-gradient(180deg, rgba(34, 21, 27, 0.12), rgba(34, 21, 27, 0.42));
}
.shop-content {
position: relative;
z-index: 1;
padding-top: 160rpx;
}
.shop-card {
padding: 30rpx;
}
.shop-title {
font-size: 42rpx;
font-weight: 700;
line-height: 1.4;
color: #2d2430;
}
.shop-address {
margin-top: 16rpx;
font-size: 26rpx;
color: #8d7a84;
line-height: 1.7;
}
.shop-summary {
margin-top: 24rpx;
}
.shop-summary-value {
font-size: 26rpx;
line-height: 1.6;
}
.detail-group {
margin-top: 24rpx;
}
.detail-label {
font-size: 24rpx;
color: #8d7a84;
}
.detail-value {
margin-top: 12rpx;
font-size: 28rpx;
color: #2d2430;
line-height: 1.8;
}
.copy-row {
display: flex;
gap: 16rpx;
margin-top: 26rpx;
}
.gallery-list {
display: flex;
flex-wrap: wrap;
gap: 18rpx;
}
.gallery-image {
width: calc(50% - 9rpx);
height: 240rpx;
border-radius: 24rpx;
background: #f6edf1;
}