优化店务小程序店铺设置和表单体验
This commit is contained in:
@@ -598,6 +598,7 @@ Page({
|
||||
},
|
||||
customerOptions: [],
|
||||
customerDropdownVisible: false,
|
||||
customerNameFocused: false,
|
||||
customerLoading: false,
|
||||
customerError: '',
|
||||
products: [],
|
||||
@@ -651,6 +652,9 @@ Page({
|
||||
}
|
||||
this.loadOptions()
|
||||
this.searchCustomers()
|
||||
wx.nextTick(() => {
|
||||
this.setData({ customerNameFocused: true })
|
||||
})
|
||||
},
|
||||
|
||||
async loadOptions() {
|
||||
@@ -745,7 +749,10 @@ Page({
|
||||
|
||||
onCustomerFocus(event) {
|
||||
const field = event.currentTarget.dataset.field
|
||||
this.setData({ customerDropdownVisible: true })
|
||||
this.setData({
|
||||
customerDropdownVisible: true,
|
||||
customerNameFocused: field === 'customerName'
|
||||
})
|
||||
this.searchCustomers(field)
|
||||
},
|
||||
|
||||
@@ -794,7 +801,10 @@ Page({
|
||||
|
||||
hideCustomerDropdown() {
|
||||
setTimeout(() => {
|
||||
this.setData({ customerDropdownVisible: false })
|
||||
this.setData({
|
||||
customerDropdownVisible: false,
|
||||
customerNameFocused: false
|
||||
})
|
||||
}, 180)
|
||||
},
|
||||
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
<view class="page no-tab">
|
||||
<view class="card form-card">
|
||||
<view class="customer-select">
|
||||
<view class="field">
|
||||
<view class="field {{customerNameFocused ? 'is-focused' : ''}}">
|
||||
<text class="field-label required">客户姓名</text>
|
||||
<input value="{{form.customerName}}" data-field="customerName" bindinput="onInput" bindfocus="onCustomerFocus" bindblur="hideCustomerDropdown" placeholder="搜索或输入客户姓名" />
|
||||
<input value="{{form.customerName}}" data-field="customerName" bindinput="onInput" bindfocus="onCustomerFocus" bindblur="hideCustomerDropdown" placeholder="搜索或输入客户姓名" focus="{{customerNameFocused}}" />
|
||||
</view>
|
||||
<view class="field">
|
||||
<text class="field-label">手机号</text>
|
||||
|
||||
@@ -1,3 +1,35 @@
|
||||
.form-card {
|
||||
padding: 8rpx 0;
|
||||
overflow: visible;
|
||||
}
|
||||
|
||||
.form-card .field {
|
||||
min-height: 112rpx;
|
||||
padding: 12rpx 24rpx;
|
||||
}
|
||||
|
||||
.form-card .field-label {
|
||||
width: 180rpx;
|
||||
min-width: 180rpx;
|
||||
color: #62574d;
|
||||
font-weight: 800;
|
||||
}
|
||||
|
||||
.form-card .field input,
|
||||
.form-card .field-value {
|
||||
min-height: 72rpx;
|
||||
padding: 0 22rpx;
|
||||
border: 1rpx solid #eadfd2;
|
||||
border-radius: 18rpx;
|
||||
background: #fffdf8;
|
||||
line-height: 72rpx;
|
||||
}
|
||||
|
||||
.form-card .field.is-focused input {
|
||||
border-color: #78a78f;
|
||||
box-shadow: 0 0 0 4rpx rgba(120, 167, 143, 0.12);
|
||||
}
|
||||
|
||||
.unit {
|
||||
color: #9a9288;
|
||||
font-size: 24rpx;
|
||||
|
||||
@@ -1,8 +1,13 @@
|
||||
<view class="page no-tab">
|
||||
<view class="card form-card">
|
||||
<view class="field"><text class="field-label">原密码</text><input password value="{{form.oldPassword}}" data-field="oldPassword" bindinput="onInput" /></view>
|
||||
<view class="field"><text class="field-label">新密码</text><input password value="{{form.newPassword}}" data-field="newPassword" bindinput="onInput" /></view>
|
||||
<view class="field"><text class="field-label">确认密码</text><input password value="{{form.confirmPassword}}" data-field="confirmPassword" bindinput="onInput" /></view>
|
||||
<view class="card password-guide">
|
||||
<text class="password-guide-title">保护当前账号</text>
|
||||
<text class="password-guide-desc">修改成功后会重新登录,请确认新密码已经记牢。</text>
|
||||
</view>
|
||||
<view class="card form-card">
|
||||
<view class="field password-field password-field-active"><text class="field-label">原密码</text><input password value="{{form.oldPassword}}" data-field="oldPassword" bindinput="onInput" placeholder="请输入原密码" focus="{{true}}" /></view>
|
||||
<view class="field password-field"><text class="field-label">新密码</text><input password value="{{form.newPassword}}" data-field="newPassword" bindinput="onInput" placeholder="请输入新密码" /></view>
|
||||
<view class="field password-field"><text class="field-label">确认密码</text><input password value="{{form.confirmPassword}}" data-field="confirmPassword" bindinput="onInput" placeholder="再次输入新密码" /></view>
|
||||
</view>
|
||||
<view class="card password-tip">建议使用 8 位以上密码,包含字母和数字,不要与其他平台共用密码。</view>
|
||||
<view class="fixed-bottom"><button class="primary-btn" loading="{{saving}}" disabled="{{saving}}" bindtap="save">保存密码</button></view>
|
||||
</view>
|
||||
|
||||
@@ -1 +1,67 @@
|
||||
|
||||
.password-guide {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 12rpx;
|
||||
margin-bottom: 22rpx;
|
||||
padding: 28rpx;
|
||||
background: linear-gradient(135deg, #fffdf8, #ecf5ef);
|
||||
}
|
||||
|
||||
.password-guide-title {
|
||||
color: #27231f;
|
||||
font-size: 34rpx;
|
||||
font-weight: 900;
|
||||
}
|
||||
|
||||
.password-guide-desc {
|
||||
color: #756b61;
|
||||
font-size: 25rpx;
|
||||
line-height: 1.5;
|
||||
}
|
||||
|
||||
.form-card {
|
||||
padding: 8rpx 0;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.password-field {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: stretch;
|
||||
gap: 12rpx;
|
||||
min-height: 130rpx;
|
||||
padding: 20rpx 24rpx;
|
||||
}
|
||||
|
||||
.password-field .field-label {
|
||||
width: auto;
|
||||
color: #62574d;
|
||||
font-size: 25rpx;
|
||||
font-weight: 900;
|
||||
}
|
||||
|
||||
.password-field input {
|
||||
width: 100%;
|
||||
min-height: 76rpx;
|
||||
padding: 0 22rpx;
|
||||
border: 1rpx solid #eadfd2;
|
||||
border-radius: 18rpx;
|
||||
background: #fffdf8;
|
||||
color: #2d2722;
|
||||
font-size: 28rpx;
|
||||
line-height: 76rpx;
|
||||
}
|
||||
|
||||
.password-field-active input {
|
||||
border-color: #78a78f;
|
||||
box-shadow: 0 0 0 4rpx rgba(120, 167, 143, 0.12);
|
||||
}
|
||||
|
||||
.password-tip {
|
||||
margin-top: 22rpx;
|
||||
padding: 24rpx;
|
||||
color: #82776c;
|
||||
font-size: 24rpx;
|
||||
line-height: 1.5;
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
const planningApi = require('../../api/planning')
|
||||
const shopApi = require('../../api/shop')
|
||||
const dateUtil = require('../../utils/date')
|
||||
|
||||
const CALENDAR_ERROR_FALLBACK_MESSAGE = '规划数据暂时不可用,请稍后重试'
|
||||
@@ -98,6 +99,44 @@ function resolveDayStatusClass(items) {
|
||||
return ''
|
||||
}
|
||||
|
||||
function normalizeWorkDays(workDays, presetType) {
|
||||
if (presetType === 'DOUBLE_REST') {
|
||||
return [1, 2, 3, 4, 5]
|
||||
}
|
||||
if (presetType === 'SINGLE_REST') {
|
||||
return [1, 2, 3, 4, 5, 6]
|
||||
}
|
||||
if (presetType === 'EVERYDAY') {
|
||||
return [1, 2, 3, 4, 5, 6, 7]
|
||||
}
|
||||
const values = String(workDays || '')
|
||||
.split(',')
|
||||
.map(item => Number(String(item).trim()))
|
||||
.filter(item => item >= 1 && item <= 7)
|
||||
return Array.from(new Set(values.length ? values : [1, 2, 3, 4, 5, 6, 7]))
|
||||
}
|
||||
|
||||
function buildExceptionMap(exceptions) {
|
||||
return (exceptions || []).reduce((map, item) => {
|
||||
if (item && item.workDate) {
|
||||
map[item.workDate] = item.exceptionType
|
||||
}
|
||||
return map
|
||||
}, {})
|
||||
}
|
||||
|
||||
function isShopRestDate(date, workDays, exceptionMap) {
|
||||
const exceptionType = exceptionMap[date]
|
||||
if (exceptionType === 'REST') {
|
||||
return true
|
||||
}
|
||||
if (exceptionType === 'EXTRA_WORK' || exceptionType === 'CHANGE_SHIFT') {
|
||||
return false
|
||||
}
|
||||
const weekDay = toLocalDate(date).getDay() || 7
|
||||
return !workDays.includes(weekDay)
|
||||
}
|
||||
|
||||
Page({
|
||||
data: {
|
||||
viewMode: 'month',
|
||||
@@ -126,6 +165,7 @@ Page({
|
||||
artists: [],
|
||||
appointments: [],
|
||||
daySummaries: [],
|
||||
shopRestDates: [],
|
||||
monthDays: [],
|
||||
weekDays: [],
|
||||
dayLanes: [],
|
||||
@@ -234,7 +274,8 @@ Page({
|
||||
endDate: range.end,
|
||||
artistId: this.data.selectedArtistId || undefined
|
||||
})
|
||||
this.applyCalendar(data)
|
||||
const shopSchedule = await this.loadShopSchedule(range)
|
||||
this.applyCalendar(data, shopSchedule)
|
||||
this.setData({ calendarError: '' })
|
||||
} catch (error) {
|
||||
this.clearCalendarView()
|
||||
@@ -259,6 +300,7 @@ Page({
|
||||
artists: [],
|
||||
appointments: [],
|
||||
daySummaries: [],
|
||||
shopRestDates: [],
|
||||
monthDays: [],
|
||||
weekDays: [],
|
||||
dayLanes: [],
|
||||
@@ -286,18 +328,40 @@ Page({
|
||||
return { start: current, end: current }
|
||||
},
|
||||
|
||||
applyCalendar(calendar) {
|
||||
applyCalendar(calendar, shopSchedule) {
|
||||
const artists = calendar.artists || []
|
||||
this.setData({
|
||||
businessStartTime: (calendar.businessStartTime || '10:00').slice(0, 5),
|
||||
businessEndTime: (calendar.businessEndTime || '22:00').slice(0, 5),
|
||||
artists,
|
||||
appointments: calendar.appointments || [],
|
||||
daySummaries: calendar.daySummaries || []
|
||||
daySummaries: calendar.daySummaries || [],
|
||||
shopRestDates: shopSchedule ? shopSchedule.restDates : []
|
||||
})
|
||||
this.prepareView()
|
||||
},
|
||||
|
||||
async loadShopSchedule(range) {
|
||||
const [settings, exceptions] = await Promise.all([
|
||||
shopApi.settings(),
|
||||
shopApi.scheduleExceptions({
|
||||
startDate: range.start,
|
||||
endDate: range.end
|
||||
})
|
||||
])
|
||||
const workDays = normalizeWorkDays(settings.scheduleWorkDays, settings.schedulePresetType)
|
||||
const exceptionMap = buildExceptionMap(exceptions)
|
||||
const restDates = []
|
||||
let cursor = range.start
|
||||
while (cursor <= range.end) {
|
||||
if (isShopRestDate(cursor, workDays, exceptionMap)) {
|
||||
restDates.push(cursor)
|
||||
}
|
||||
cursor = dateUtil.formatDate(dateUtil.addDays(cursor, 1))
|
||||
}
|
||||
return { restDates }
|
||||
},
|
||||
|
||||
prepareView() {
|
||||
const current = this.data.currentDateText
|
||||
const range = this.resolveRange()
|
||||
@@ -319,6 +383,7 @@ Page({
|
||||
buildMonthDays() {
|
||||
const summaryMap = this.summaryMap()
|
||||
const todayText = dateUtil.formatDate(new Date())
|
||||
const shopRestDates = this.data.shopRestDates || []
|
||||
const artistTemplate = this.data.artists.map(artist => ({
|
||||
artistId: artist.id,
|
||||
artistName: artist.name,
|
||||
@@ -338,6 +403,7 @@ Page({
|
||||
isPast: day.date < todayText,
|
||||
totalCount: summary.totalCount || 0,
|
||||
dayStatus: summary.dayStatus || 'free',
|
||||
shopRest: shopRestDates.includes(day.date),
|
||||
artistCounts,
|
||||
expandedBlocks: this.buildExpandedBlocks(artistCounts),
|
||||
rowBlocks: this.buildRowBlocks(artistCounts),
|
||||
|
||||
@@ -125,8 +125,8 @@
|
||||
<view wx:for="{{monthDays}}" wx:key="date" class="month-cell {{item.isCurrentMonth ? '' : 'out-month'}} {{item.date === currentDateText ? 'selected' : ''}}" data-date="{{item.date}}" bindtap="selectDate">
|
||||
<view class="month-cell-head">
|
||||
<text class="month-day">{{item.day}}</text>
|
||||
<text wx:if="{{!item.isPast && item.dayStatus === 'full'}}" class="day-mark full">满</text>
|
||||
<text wx:elif="{{!item.isPast && item.dayStatus === 'rest'}}" class="day-mark rest">休</text>
|
||||
<text wx:if="{{!item.isPast && item.shopRest}}" class="day-mark rest">休</text>
|
||||
<text wx:elif="{{!item.isPast && item.dayStatus === 'full'}}" class="day-mark full">满</text>
|
||||
</view>
|
||||
<view wx:if="{{monthDisplayMode === 'count'}}" class="month-bars">
|
||||
<view wx:for="{{item.artistCounts}}" wx:for-item="count" wx:key="key" wx:if="{{count.count > 0}}" class="month-artist-bar {{count.statusClass}}" style="background: {{count.color}};">
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
const { BRAND_CONFIG } = require('../../utils/config')
|
||||
const userApi = require('../../api/user')
|
||||
const shopApi = require('../../api/shop')
|
||||
const authApi = require('../../api/auth')
|
||||
const auth = require('../../utils/auth')
|
||||
const { chooseImageFilePath, uploadAvatar } = require('../../utils/upload')
|
||||
@@ -27,9 +28,17 @@ function resolveDisplayAvatar(avatar) {
|
||||
return value
|
||||
}
|
||||
|
||||
function resolveShopCoverImage(settings) {
|
||||
if (!settings || !Array.isArray(settings.coverImageUrls)) {
|
||||
return ''
|
||||
}
|
||||
return String(settings.coverImageUrls[0] || '').trim()
|
||||
}
|
||||
|
||||
Page({
|
||||
data: {
|
||||
shopName: BRAND_CONFIG.defaultShopName,
|
||||
shopCoverImage: '',
|
||||
phone: '店长端',
|
||||
roleText: '管理端',
|
||||
userInfo: {},
|
||||
@@ -56,6 +65,7 @@ Page({
|
||||
|
||||
onShow() {
|
||||
this.refreshFromSession()
|
||||
this.loadShopHeader()
|
||||
this.loadProfile()
|
||||
},
|
||||
|
||||
@@ -65,6 +75,7 @@ Page({
|
||||
const displayAvatar = resolveDisplayAvatar(userInfo.avatar)
|
||||
this.setData({
|
||||
shopName: app.globalData.shopName || BRAND_CONFIG.appName,
|
||||
shopCoverImage: app.globalData.shopCoverImage || '',
|
||||
phone: userInfo.contactPhone || userInfo.phone || userInfo.account || '店长端',
|
||||
roleText: resolveRoleText(userInfo.type),
|
||||
userInfo: {
|
||||
@@ -74,6 +85,23 @@ Page({
|
||||
})
|
||||
},
|
||||
|
||||
async loadShopHeader() {
|
||||
try {
|
||||
const settings = await shopApi.settings()
|
||||
const app = getApp()
|
||||
const shopName = settings.shopName || settings.name || app.globalData.shopName || BRAND_CONFIG.appName
|
||||
const shopCoverImage = resolveShopCoverImage(settings)
|
||||
app.globalData.shopName = shopName
|
||||
app.globalData.shopCoverImage = shopCoverImage
|
||||
this.setData({
|
||||
shopName,
|
||||
shopCoverImage
|
||||
})
|
||||
} catch (error) {
|
||||
wx.showToast({ title: error.message || '店铺信息加载失败', icon: 'none' })
|
||||
}
|
||||
},
|
||||
|
||||
go(event) {
|
||||
const action = event.currentTarget.dataset.action
|
||||
if (action === 'editProfile') {
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
<view class="page">
|
||||
<view class="card profile-card">
|
||||
<view class="profile-main">
|
||||
<view wx:if="{{userInfo.displayAvatar}}" class="shop-logo image-avatar">
|
||||
<image src="{{userInfo.displayAvatar}}" mode="aspectFill"></image>
|
||||
<view wx:if="{{shopCoverImage || userInfo.displayAvatar}}" class="shop-logo image-avatar">
|
||||
<image src="{{shopCoverImage || userInfo.displayAvatar}}" mode="aspectFill"></image>
|
||||
</view>
|
||||
<view wx:else class="shop-logo">指</view>
|
||||
<view wx:else class="shop-logo">店</view>
|
||||
<view class="profile-copy">
|
||||
<text class="shop-name">{{shopName}}</text>
|
||||
<text class="phone">{{phone}}</text>
|
||||
@@ -20,7 +20,7 @@
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view wx:if="{{editModalVisible}}" class="modal-mask" bindtap="closeEditProfile">
|
||||
<view wx:if="{{editModalVisible}}" class="modal-mask" catchtap="stopTap">
|
||||
<view class="profile-modal" catchtap="stopTap">
|
||||
<view class="modal-head">
|
||||
<text class="modal-title">个人信息</text>
|
||||
@@ -31,25 +31,35 @@
|
||||
<image src="{{profileForm.avatar}}" mode="aspectFill"></image>
|
||||
</view>
|
||||
<view wx:else class="profile-avatar">头像</view>
|
||||
<button class="secondary-btn avatar-btn" loading="{{avatarUploading}}" bindtap="chooseProfileAvatar">上传头像</button>
|
||||
<button wx:if="{{profileForm.avatar}}" class="text-btn avatar-remove" bindtap="removeProfileAvatar">移除</button>
|
||||
<view class="profile-avatar-copy">
|
||||
<text class="profile-avatar-name">{{profileForm.nickname || userInfo.nickname || '个人头像'}}</text>
|
||||
<text class="profile-avatar-desc">这里只修改个人资料头像</text>
|
||||
</view>
|
||||
<button class="avatar-btn" loading="{{avatarUploading}}" bindtap="chooseProfileAvatar">上传</button>
|
||||
<button wx:if="{{profileForm.avatar}}" class="avatar-remove" bindtap="removeProfileAvatar">移除</button>
|
||||
</view>
|
||||
<view class="profile-info-grid">
|
||||
<view class="profile-info-item">
|
||||
<text>登录账号</text>
|
||||
<view>{{userInfo.account || '未设置'}}</view>
|
||||
</view>
|
||||
<view class="profile-info-item">
|
||||
<text>身份</text>
|
||||
<view>{{roleText}}</view>
|
||||
</view>
|
||||
<view class="profile-info-item">
|
||||
<text>登录手机号</text>
|
||||
<view>{{userInfo.phone || '未绑定'}}</view>
|
||||
</view>
|
||||
<view class="profile-info-item">
|
||||
<text>当前店铺</text>
|
||||
<view>{{shopName}}</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="modal-field">
|
||||
<text class="required-label">昵称</text>
|
||||
<input value="{{profileForm.nickname}}" data-field="nickname" bindinput="onProfileInput" placeholder="请输入昵称" />
|
||||
</view>
|
||||
<view class="modal-field readonly-field">
|
||||
<text>登录账号</text>
|
||||
<view>{{userInfo.account || '未设置'}}</view>
|
||||
</view>
|
||||
<view class="modal-field readonly-field">
|
||||
<text>身份</text>
|
||||
<view>{{roleText}}</view>
|
||||
</view>
|
||||
<view class="modal-field readonly-field">
|
||||
<text>登录手机号</text>
|
||||
<view>{{userInfo.phone || '未绑定'}}</view>
|
||||
</view>
|
||||
<view class="modal-field">
|
||||
<text>联系电话</text>
|
||||
<input value="{{profileForm.contactPhone}}" data-field="contactPhone" bindinput="onProfileInput" type="number" placeholder="请输入联系电话" />
|
||||
|
||||
@@ -112,7 +112,7 @@
|
||||
width: 100%;
|
||||
max-height: 88vh;
|
||||
overflow-y: auto;
|
||||
padding: 28rpx 28rpx calc(28rpx + env(safe-area-inset-bottom));
|
||||
padding: 28rpx 28rpx calc(30rpx + env(safe-area-inset-bottom));
|
||||
border-radius: 28rpx 28rpx 0 0;
|
||||
background: #fffaf4;
|
||||
box-shadow: 0 -18rpx 40rpx rgba(41, 31, 23, 0.16);
|
||||
@@ -170,10 +170,10 @@
|
||||
.profile-avatar-row {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 16rpx;
|
||||
gap: 18rpx;
|
||||
margin-bottom: 18rpx;
|
||||
padding: 18rpx;
|
||||
border-radius: 18rpx;
|
||||
border-radius: 20rpx;
|
||||
background: #f7efe7;
|
||||
}
|
||||
|
||||
@@ -197,14 +197,96 @@
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.avatar-btn {
|
||||
flex: 1;
|
||||
.profile-avatar-copy {
|
||||
min-width: 0;
|
||||
max-width: none;
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.profile-avatar-name,
|
||||
.profile-avatar-desc {
|
||||
display: block;
|
||||
min-width: 0;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.profile-avatar-name {
|
||||
color: #29241f;
|
||||
font-size: 28rpx;
|
||||
font-weight: 900;
|
||||
}
|
||||
|
||||
.profile-avatar-desc {
|
||||
margin-top: 8rpx;
|
||||
color: #8a7f75;
|
||||
font-size: 22rpx;
|
||||
}
|
||||
|
||||
.avatar-btn {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
flex: 0 0 auto;
|
||||
min-width: 104rpx;
|
||||
min-height: 58rpx;
|
||||
padding: 0 18rpx;
|
||||
border-radius: 16rpx;
|
||||
background: #fffdf8;
|
||||
color: #72553b;
|
||||
font-size: 24rpx;
|
||||
font-weight: 900;
|
||||
}
|
||||
|
||||
.avatar-remove {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
flex: 0 0 auto;
|
||||
min-width: 76rpx;
|
||||
min-height: 58rpx;
|
||||
padding: 0 16rpx;
|
||||
border-radius: 16rpx;
|
||||
background: #f0e5dc;
|
||||
color: #9a5f43;
|
||||
font-size: 24rpx;
|
||||
font-weight: 900;
|
||||
}
|
||||
|
||||
.profile-info-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||
gap: 14rpx;
|
||||
margin-bottom: 18rpx;
|
||||
}
|
||||
|
||||
.profile-info-item {
|
||||
min-width: 0;
|
||||
padding: 16rpx;
|
||||
border-radius: 18rpx;
|
||||
background: #f7efe7;
|
||||
}
|
||||
|
||||
.profile-info-item text,
|
||||
.profile-info-item view {
|
||||
display: block;
|
||||
min-width: 0;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.profile-info-item text {
|
||||
color: #8a7f75;
|
||||
font-size: 22rpx;
|
||||
font-weight: 800;
|
||||
}
|
||||
|
||||
.profile-info-item view {
|
||||
margin-top: 8rpx;
|
||||
color: #2c2722;
|
||||
font-size: 25rpx;
|
||||
font-weight: 900;
|
||||
}
|
||||
|
||||
.modal-field {
|
||||
@@ -226,18 +308,24 @@
|
||||
.modal-field textarea,
|
||||
.readonly-field view {
|
||||
width: 100%;
|
||||
padding: 0 18rpx;
|
||||
border: 1rpx solid #eadfd2;
|
||||
border-radius: 16rpx;
|
||||
background: #fffdf8;
|
||||
color: #2c2722;
|
||||
font-size: 28rpx;
|
||||
}
|
||||
|
||||
.modal-field input,
|
||||
.readonly-field view {
|
||||
min-height: 58rpx;
|
||||
line-height: 58rpx;
|
||||
min-height: 70rpx;
|
||||
line-height: 70rpx;
|
||||
}
|
||||
|
||||
.modal-field textarea {
|
||||
min-height: 120rpx;
|
||||
padding-top: 18rpx;
|
||||
padding-bottom: 18rpx;
|
||||
}
|
||||
|
||||
.readonly-field view {
|
||||
|
||||
@@ -2,6 +2,7 @@ const shopApi = require('../../api/shop')
|
||||
const dateUtil = require('../../utils/date')
|
||||
const { BRAND_CONFIG } = require('../../utils/config')
|
||||
const { markPlanningRefresh } = require('../../utils/planning-refresh')
|
||||
const { chooseImageFilePath, uploadObjectFile, resolveUploadedImagePreviewUrl } = require('../../utils/upload')
|
||||
|
||||
const PRESETS = [
|
||||
{ value: 'EVERYDAY', label: '全周营业', workDays: [1, 2, 3, 4, 5, 6, 7], startTime: '10:00', endTime: '22:00' },
|
||||
@@ -66,6 +67,10 @@ function buildExceptionSummary(item) {
|
||||
return `${item.workDate} ${exceptionTypeLabel(item.exceptionType)} ${String(item.startTime || '').slice(0, 5)}-${String(item.endTime || '').slice(0, 5)}`
|
||||
}
|
||||
|
||||
function resolveFirstImageUrl(urls) {
|
||||
return Array.isArray(urls) ? String(urls[0] || '').trim() : ''
|
||||
}
|
||||
|
||||
Page({
|
||||
data: {
|
||||
presets: PRESETS,
|
||||
@@ -78,6 +83,8 @@ Page({
|
||||
exceptions: [],
|
||||
loading: false,
|
||||
saving: false,
|
||||
coverUploading: false,
|
||||
coverImagePreviewUrl: '',
|
||||
form: {
|
||||
shopName: BRAND_CONFIG.defaultShopName,
|
||||
startTime: '10:00',
|
||||
@@ -86,7 +93,8 @@ Page({
|
||||
rule: '必须选择已有作品作为项目来源',
|
||||
schedulePresetType: 'EVERYDAY',
|
||||
scheduleWorkDays: [1, 2, 3, 4, 5, 6, 7],
|
||||
scheduleRemark: ''
|
||||
scheduleRemark: '',
|
||||
coverImageFileId: ''
|
||||
},
|
||||
exceptionForm: {
|
||||
workDate: dateUtil.formatDate(new Date()),
|
||||
@@ -118,10 +126,12 @@ Page({
|
||||
rule: settings.description || this.data.form.rule,
|
||||
schedulePresetType: settings.schedulePresetType || preset.value,
|
||||
scheduleWorkDays: copyWorkDays(settings.scheduleWorkDays || preset.workDays),
|
||||
scheduleRemark: settings.scheduleRemark || ''
|
||||
scheduleRemark: settings.scheduleRemark || '',
|
||||
coverImageFileId: settings.coverImageFileId || ''
|
||||
}
|
||||
this.setData({
|
||||
form,
|
||||
coverImagePreviewUrl: resolveFirstImageUrl(settings.coverImageUrls),
|
||||
presetOptions: buildPresetOptions(form.schedulePresetType),
|
||||
weekdayOptions: buildWeekdayOptions(form.scheduleWorkDays),
|
||||
exceptions: (exceptions || []).map(item => ({
|
||||
@@ -142,6 +152,42 @@ Page({
|
||||
this.setData({ [`form.${event.currentTarget.dataset.field}`]: event.detail.value })
|
||||
},
|
||||
|
||||
async chooseCoverImage() {
|
||||
if (this.data.coverUploading || this.data.saving) {
|
||||
return
|
||||
}
|
||||
try {
|
||||
const filePath = await chooseImageFilePath()
|
||||
if (!filePath) {
|
||||
return
|
||||
}
|
||||
this.setData({ coverUploading: true })
|
||||
const uploadResult = await uploadObjectFile(filePath)
|
||||
const fileId = String(uploadResult && uploadResult.id ? uploadResult.id : '').trim()
|
||||
if (!fileId) {
|
||||
throw new Error('店铺主图上传失败:上传接口未返回文件ID')
|
||||
}
|
||||
this.setData({
|
||||
'form.coverImageFileId': fileId,
|
||||
coverImagePreviewUrl: resolveUploadedImagePreviewUrl(uploadResult, filePath)
|
||||
})
|
||||
} catch (error) {
|
||||
wx.showToast({ title: error.message || '店铺主图上传失败', icon: 'none' })
|
||||
} finally {
|
||||
this.setData({ coverUploading: false })
|
||||
}
|
||||
},
|
||||
|
||||
removeCoverImage() {
|
||||
if (this.data.coverUploading || this.data.saving) {
|
||||
return
|
||||
}
|
||||
this.setData({
|
||||
'form.coverImageFileId': '',
|
||||
coverImagePreviewUrl: ''
|
||||
})
|
||||
},
|
||||
|
||||
onExceptionInput(event) {
|
||||
this.setData({ [`exceptionForm.${event.currentTarget.dataset.field}`]: event.detail.value })
|
||||
},
|
||||
@@ -257,7 +303,8 @@ Page({
|
||||
description: form.rule,
|
||||
schedulePresetType: form.schedulePresetType,
|
||||
scheduleWorkDays: encodeWorkDays(workDays),
|
||||
scheduleRemark: String(form.scheduleRemark || '').trim()
|
||||
scheduleRemark: String(form.scheduleRemark || '').trim(),
|
||||
coverImageFileId: String(form.coverImageFileId || '').trim()
|
||||
})
|
||||
markPlanningRefresh()
|
||||
wx.showToast({ title: '已保存', icon: 'success' })
|
||||
|
||||
@@ -1,8 +1,27 @@
|
||||
<view class="page no-tab">
|
||||
<view wx:if="{{loading}}" class="loading-state">店铺设置加载中</view>
|
||||
<block wx:else>
|
||||
<view class="cover-card">
|
||||
<view wx:if="{{coverImagePreviewUrl}}" class="cover-preview">
|
||||
<image src="{{coverImagePreviewUrl}}" mode="aspectFill"></image>
|
||||
</view>
|
||||
<view wx:else class="cover-preview cover-empty">
|
||||
<text>店铺主图</text>
|
||||
</view>
|
||||
<view class="cover-shade">
|
||||
<view class="cover-copy">
|
||||
<text class="cover-title">{{form.shopName || '店铺主图'}}</text>
|
||||
<text class="cover-desc">我的页顶部展示这张图片</text>
|
||||
</view>
|
||||
<view class="cover-actions">
|
||||
<button class="cover-btn" loading="{{coverUploading}}" bindtap="chooseCoverImage">更换主图</button>
|
||||
<button wx:if="{{coverImagePreviewUrl}}" class="cover-remove" bindtap="removeCoverImage">移除</button>
|
||||
</view>
|
||||
</view>
|
||||
</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><input value="{{form.shopName}}" data-field="shopName" bindinput="onInput" placeholder="请输入店铺名称" /></view>
|
||||
<view class="field">
|
||||
<view class="label-with-help">
|
||||
<text class="field-label">默认时长</text>
|
||||
|
||||
@@ -1,8 +1,128 @@
|
||||
|
||||
.cover-card {
|
||||
position: relative;
|
||||
height: 300rpx;
|
||||
margin-bottom: 24rpx;
|
||||
overflow: hidden;
|
||||
border-radius: 22rpx;
|
||||
background: linear-gradient(135deg, #7b9987, #c4996e);
|
||||
box-shadow: 0 18rpx 36rpx rgba(83, 64, 44, 0.14);
|
||||
}
|
||||
|
||||
.cover-preview,
|
||||
.cover-preview image {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.cover-empty {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
color: rgba(255, 255, 255, 0.82);
|
||||
font-size: 34rpx;
|
||||
font-weight: 900;
|
||||
}
|
||||
|
||||
.cover-shade {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
display: flex;
|
||||
align-items: flex-end;
|
||||
justify-content: space-between;
|
||||
gap: 20rpx;
|
||||
padding: 28rpx;
|
||||
background: linear-gradient(180deg, rgba(30, 24, 19, 0.08), rgba(30, 24, 19, 0.48));
|
||||
}
|
||||
|
||||
.cover-copy {
|
||||
min-width: 0;
|
||||
color: #fffdf8;
|
||||
}
|
||||
|
||||
.cover-title,
|
||||
.cover-desc {
|
||||
display: block;
|
||||
}
|
||||
|
||||
.cover-title {
|
||||
overflow: hidden;
|
||||
font-size: 34rpx;
|
||||
font-weight: 900;
|
||||
line-height: 1.25;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.cover-desc {
|
||||
margin-top: 8rpx;
|
||||
font-size: 23rpx;
|
||||
opacity: 0.9;
|
||||
}
|
||||
|
||||
.cover-actions {
|
||||
display: flex;
|
||||
flex: 0 0 auto;
|
||||
flex-direction: column;
|
||||
gap: 10rpx;
|
||||
}
|
||||
|
||||
.cover-btn,
|
||||
.cover-remove {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
min-width: 154rpx;
|
||||
min-height: 58rpx;
|
||||
padding: 0 20rpx;
|
||||
border-radius: 16rpx;
|
||||
font-size: 24rpx;
|
||||
font-weight: 900;
|
||||
}
|
||||
|
||||
.cover-btn {
|
||||
background: #fffdf8;
|
||||
color: #72553b;
|
||||
}
|
||||
|
||||
.cover-remove {
|
||||
background: rgba(255, 253, 248, 0.18);
|
||||
color: #fffdf8;
|
||||
}
|
||||
|
||||
.form-card,
|
||||
.rule-card {
|
||||
padding: 10rpx 0;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.field {
|
||||
min-height: 108rpx;
|
||||
padding: 12rpx 24rpx;
|
||||
}
|
||||
|
||||
.field-label,
|
||||
.label-with-help {
|
||||
width: 180rpx;
|
||||
min-width: 180rpx;
|
||||
}
|
||||
|
||||
.field input,
|
||||
.field-value {
|
||||
min-height: 70rpx;
|
||||
padding: 0 22rpx;
|
||||
border: 1rpx solid #eadfd2;
|
||||
border-radius: 18rpx;
|
||||
background: #fffaf4;
|
||||
line-height: 70rpx;
|
||||
}
|
||||
|
||||
.label-with-help {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
min-width: 144rpx;
|
||||
}
|
||||
|
||||
.label-with-help .field-label {
|
||||
|
||||
@@ -264,3 +264,11 @@
|
||||
- 处理方式:员工排班刷数 SQL 以 active `t_user_shop_binding` 的每个 `(user_id, shop_id)` 为准生成规则,并用 `t_user.shop_id` 作为无绑定记录时的回退来源。
|
||||
- 以后避免:涉及员工、店长、门店绑定关系的数据修复时,不要默认一人一店;先看绑定表语义,按业务需要逐绑定处理。
|
||||
- 验证方式:构造一个 `type=3` 员工绑定两个有效门店,执行迁移后应有两条 active `t_artist_schedule_rule`,且均为 `EVERYDAY`、`1,2,3,4,5,6,7`、`00:00:00-23:59:59`。
|
||||
|
||||
## 2026-07-22 Windows PowerShell 执行临时脚本要注意 UTF-8 BOM
|
||||
|
||||
- 问题:用 `apply_patch` 生成的临时 `.ps1` 预览脚本含中文字符串,直接 `powershell -File` 执行时被 Windows PowerShell 按 ANSI 解码,中文变成乱码并导致数组字符串解析失败。
|
||||
- 原因:Windows PowerShell 5 对无 BOM 的 UTF-8 脚本兼容性差;仓库和补丁默认 UTF-8 无 BOM,直接执行会走本机 ANSI 代码页。
|
||||
- 处理方式:临时脚本执行前用 UTF-8 BOM 重写一次,或改用 `Get-Content -Encoding UTF8` 读取后执行;复杂脚本仍放在 `D:\codex\tmp`。
|
||||
- 以后避免:包含中文或非 ASCII 的临时 PowerShell 脚本,不要直接 `powershell -File` 执行无 BOM 文件;先显式保证编码。
|
||||
- 验证方式:执行前后检查脚本中的中文数组/字符串能被正确解析,并确认生成物存在且非零字节。
|
||||
|
||||
Reference in New Issue
Block a user