将门店有效期展示移至店铺设置

This commit is contained in:
2026-10-27 17:46:40 +08:00
parent ba118c514a
commit 6fb8ffd067
8 changed files with 99 additions and 22 deletions
@@ -14,9 +14,7 @@ Page({
timer: null,
smsExpanded: false,
unbindMode: false,
closureRequest: null,
businessExpireDateText: '',
businessExpiryStatusText: ''
closureRequest: null
},
onShow() { this.loadProfile(); this.loadClosureRequest() },
@@ -64,15 +62,7 @@ Page({
this.setData({ loading: true })
try {
const profile = await profileCache.getProfile(options)
const businessExpireDateText = profile.shopBusinessExpireTime ? String(profile.shopBusinessExpireTime).slice(0, 10) : '未设置'
const remainingDays = profile.shopBusinessRemainingDays
const hasRemainingDays = remainingDays !== null && remainingDays !== undefined && remainingDays !== '' && Number.isFinite(Number(remainingDays))
const businessExpiryStatusText = profile.shopBusinessExpired
? '已过期,暂不能新增预约'
: hasRemainingDays
? `剩余 ${remainingDays} 天`
: '有效期未设置'
this.setData({ profile, businessExpireDateText, businessExpiryStatusText, 'smsForm.phone': profile.phone || '' })
this.setData({ profile, 'smsForm.phone': profile.phone || '' })
const app = getApp()
const session = auth.getSession()
app.setSession({ ...session, userInfo: { ...(session.userInfo || {}), ...profile } })
@@ -38,8 +38,7 @@ async function run() {
shopBusinessExpired: false,
shopBusinessRemainingDays: null
})
assert.strictEqual(empty.businessExpireDateText, '未设置')
assert.strictEqual(empty.businessExpiryStatusText, '有效期未设置')
assert.strictEqual(empty.profile.shopBusinessExpireTime, null)
const active = await loadProfile({
type: 2,
@@ -47,8 +46,7 @@ async function run() {
shopBusinessExpired: false,
shopBusinessRemainingDays: 66
})
assert.strictEqual(active.businessExpireDateText, '2026-12-31')
assert.strictEqual(active.businessExpiryStatusText, '剩余 66 天')
assert.strictEqual(active.profile.shopBusinessExpireTime, '2026-12-31T23:59:59')
}
run().catch(error => {
@@ -1,10 +1,5 @@
<view class="page settings-page">
<view class="card identity-card"><view class="identity-mark">微</view><view class="identity-copy"><text class="identity-title">微信身份</text><text class="identity-status">已安全关联当前账号</text></view><text class="linked-badge">已关联</text></view>
<view wx:if="{{profile.type == 2}}" class="card business-expiry-card">
<view class="business-expiry-head"><text class="section-title">门店经营有效期</text><text class="business-expiry-status {{profile.shopBusinessExpired ? 'expired' : ''}}">{{businessExpiryStatusText}}</text></view>
<view class="business-expiry-date"><text>有效期至</text><strong>{{businessExpireDateText}}</strong></view>
<text wx:if="{{profile.shopBusinessExpired}}" class="business-expiry-note">到期后暂不可新增普通预约,历史订单、查询和补录不受影响。请联系平台管理员办理续期。</text>
</view>
<view class="card phone-card">
<view class="section-title">手机号</view>
<view class="phone-status"><text>{{profile.phoneVerified == 1 ? (profile.maskedPhone || profile.phone) : '尚未绑定'}}</text><text class="status-tag {{profile.phoneVerified == 1 ? 'done' : ''}}">{{profile.phoneVerified == 1 ? '已验证' : '待绑定'}}</text></view>
@@ -1,5 +1,4 @@
.settings-page { padding-top:24rpx; }.identity-card { display:flex; align-items:center; padding:26rpx; }.identity-mark { display:flex; align-items:center; justify-content:center; width:68rpx; height:68rpx; border-radius:20rpx; background:#e5f4ed; color:#247b63; font-size:28rpx; font-weight:800; }.identity-copy { display:flex; flex:1; flex-direction:column; margin-left:18rpx; }.identity-title,.section-title { color:#17211f; font-size:28rpx; font-weight:800; }.identity-status { margin-top:6rpx; color:#71807a; font-size:21rpx; }.linked-badge,.status-tag { padding:7rpx 14rpx; border-radius:999rpx; background:#e5f2e8; color:#397055; font-size:20rpx; }
.business-expiry-card { margin-top:20rpx; padding:26rpx; }.business-expiry-head,.business-expiry-date { display:flex; align-items:center; justify-content:space-between; gap:16rpx; }.business-expiry-status { color:#397055; font-size:22rpx; }.business-expiry-status.expired { color:#a24f42; }.business-expiry-date { margin-top:20rpx; padding-top:18rpx; border-top:1rpx solid #e5ebe7; color:#71807a; font-size:23rpx; }.business-expiry-date strong { color:#17211f; font-size:25rpx; }.business-expiry-note { display:block; margin-top:14rpx; color:#a24f42; font-size:21rpx; line-height:1.6; }
.phone-card { margin-top:20rpx; padding:28rpx; }.phone-status { display:flex; align-items:center; justify-content:space-between; margin-top:20rpx; padding:20rpx; border-radius:14rpx; background:#f3f7f4; color:#71807a; font-size:26rpx; }.status-tag { background:#fff0db; color:#9a682e; }.status-tag.done { background:#e5f2e8; color:#397055; }.wechat-phone-btn,.sms-bind-btn { height:80rpx; margin-top:22rpx; border-radius:14rpx; background:#247b63; color:#fff; font-size:26rpx; line-height:80rpx; }.sms-entry { display:flex; min-height:82rpx; align-items:center; margin-top:22rpx; border-top:1rpx solid #e5ebe7; color:#71807a; font-size:23rpx; }.sms-arrow { margin-left:auto; color:#95a198; font-size:36rpx; transition:transform 180ms ease; }.sms-arrow.expanded { transform:rotate(90deg); }.sms-panel { padding-top:2rpx; }.field input,.code-row input { box-sizing:border-box; height:78rpx; padding:0 20rpx; border:1rpx solid #dde8e0; border-radius:12rpx; background:#f8faf8; }.code-row { display:flex; gap:12rpx; margin-top:14rpx; }.code-row input { min-width:0; flex:1; }.code-row button { width:190rpx; height:78rpx; padding:0; border-radius:12rpx; background:#e7f0ea; color:#426c57; font-size:23rpx; line-height:78rpx; }.sms-bind-btn { background:#eef4f0; color:#247b63; }.account-note { margin:24rpx 18rpx; color:#71807a; font-size:21rpx; line-height:1.6; }.logout-btn { margin-top:52rpx; background:transparent; color:#a24f42; font-size:25rpx; }
.privacy-note {
margin: 12rpx 0;
@@ -1,9 +1,30 @@
const { BRAND_CONFIG } = require('../../utils/config')
const profileCache = require('../../utils/profile-cache')
Page({
data: {
profile: {},
businessExpireDateText: '未设置',
businessExpiryStatusText: '有效期未设置',
form: { shopName: BRAND_CONFIG.defaultShopName, startTime: '10:00', endTime: '22:00', defaultDuration: 60, rule: '必须选择已有作品作为项目来源' }
},
onShow() { this.loadProfile() },
async loadProfile(options = {}) {
try {
const profile = await profileCache.getProfile(options)
const businessExpireDateText = profile.shopBusinessExpireTime ? String(profile.shopBusinessExpireTime).slice(0, 10) : '未设置'
const remainingDays = profile.shopBusinessRemainingDays
const hasRemainingDays = remainingDays !== null && remainingDays !== undefined && remainingDays !== '' && Number.isFinite(Number(remainingDays))
const businessExpiryStatusText = profile.shopBusinessExpired
? '已过期,暂不能新增预约'
: hasRemainingDays
? `剩余 ${remainingDays} 天`
: '有效期未设置'
this.setData({ profile, businessExpireDateText, businessExpiryStatusText })
} catch (error) {
this.setData({ profile: {} })
}
},
onInput(event) { this.setData({ [`form.${event.currentTarget.dataset.field}`]: event.detail.value }) },
onStartChange(event) { this.setData({ 'form.startTime': event.detail.value }) },
onEndChange(event) { this.setData({ 'form.endTime': event.detail.value }) },
@@ -0,0 +1,67 @@
const assert = require('assert')
const fs = require('fs')
const path = require('path')
let pageDefinition
let currentProfile
global.Page = definition => { pageDefinition = definition }
global.wx = { showToast: () => {} }
const profileCache = require('../../utils/profile-cache')
profileCache.getProfile = async () => currentProfile
require('./index')
async function loadProfile(profile) {
currentProfile = profile
const page = {
data: { ...pageDefinition.data },
setData(values) {
Object.entries(values).forEach(([key, value]) => {
const parts = key.split('.')
if (parts.length === 1) this.data[key] = value
else this.data[parts[0]] = { ...this.data[parts[0]], [parts[1]]: value }
})
}
}
await pageDefinition.loadProfile.call(page)
return page.data
}
async function run() {
const empty = await loadProfile({
type: 2,
shopBusinessExpireTime: null,
shopBusinessExpired: false,
shopBusinessRemainingDays: null
})
assert.strictEqual(empty.businessExpireDateText, '未设置')
assert.strictEqual(empty.businessExpiryStatusText, '有效期未设置')
const active = await loadProfile({
type: 2,
shopBusinessExpireTime: '2026-12-31T23:59:59',
shopBusinessExpired: false,
shopBusinessRemainingDays: 66
})
assert.strictEqual(active.businessExpireDateText, '2026-12-31')
assert.strictEqual(active.businessExpiryStatusText, '剩余 66 天')
const expired = await loadProfile({
type: 2,
shopBusinessExpireTime: '2026-10-01T00:00:00',
shopBusinessExpired: true,
shopBusinessRemainingDays: 0
})
assert.strictEqual(expired.businessExpiryStatusText, '已过期,暂不能新增预约')
const shopSettingsWxml = fs.readFileSync(path.join(__dirname, 'index.wxml'), 'utf8')
const accountSettingsWxml = fs.readFileSync(path.join(__dirname, '../account-settings/index.wxml'), 'utf8')
assert(shopSettingsWxml.includes('wx:if="{{profile.type == 2}}" class="card business-expiry-card"'))
assert(!accountSettingsWxml.includes('business-expiry-card'))
}
run().catch(error => {
console.error(error)
process.exitCode = 1
})
@@ -1,4 +1,9 @@
<view class="page no-tab">
<view wx:if="{{profile.type == 2}}" class="card business-expiry-card">
<view class="business-expiry-head"><text class="section-title">门店经营有效期</text><text class="business-expiry-status {{profile.shopBusinessExpired ? 'expired' : ''}}">{{businessExpiryStatusText}}</text></view>
<view class="business-expiry-date"><text>有效期至</text><strong>{{businessExpireDateText}}</strong></view>
<text wx:if="{{profile.shopBusinessExpired}}" class="business-expiry-note">到期后暂不可新增普通预约,历史订单、查询和补录不受影响。请联系平台管理员办理续期。</text>
</view>
<view class="card form-card">
<view class="field"><text class="field-label">店铺名称</text><input value="{{form.shopName}}" data-field="shopName" bindinput="onInput" /></view>
<view class="field"><text class="field-label">营业开始</text><picker mode="time" value="{{form.startTime}}" bindchange="onStartChange"><view class="field-value">{{form.startTime}}</view></picker></view>
@@ -1,4 +1,6 @@
.business-expiry-card { margin-top:20rpx; padding:26rpx; }.business-expiry-head,.business-expiry-date { display:flex; align-items:center; justify-content:space-between; gap:16rpx; }.business-expiry-status { color:#397055; font-size:22rpx; }.business-expiry-status.expired { color:#a24f42; }.business-expiry-date { margin-top:20rpx; padding-top:18rpx; border-top:1rpx solid #e5ebe7; color:#71807a; font-size:23rpx; }.business-expiry-date strong { color:#17211f; font-size:25rpx; }.business-expiry-note { display:block; margin-top:14rpx; color:#a24f42; font-size:21rpx; line-height:1.6; }
.label-with-help {
display: flex;
align-items: center;