|
|
@ -8,30 +8,33 @@ |
|
|
<view class="form-wrap"> |
|
|
<view class="form-wrap"> |
|
|
<view class="content"> |
|
|
<view class="content"> |
|
|
<view class="section-title">营业设置</view> |
|
|
<view class="section-title">营业设置</view> |
|
|
<view class="value"> |
|
|
<view class="business-hour-block"> |
|
|
<view class="name">营业开始时间</view> |
|
|
<view class="business-hour-title">营业时段</view> |
|
|
<view class="text"> |
|
|
<view class="period-card" v-for="(item, index) in businessHourPeriods" :key="index"> |
|
|
<picker mode="time" :value="shop.businessHourBegin" start="00:00" end="23:59" |
|
|
<view class="period-header"> |
|
|
@change="bindTimeChange($event,'businessHourBegin')"> |
|
|
<text>时段{{index + 1}}</text> |
|
|
<view class="picker-text" :class="{ placeholder: !shop.businessHourBegin }"> |
|
|
<view class="period-delete" v-if="businessHourPeriods.length > 1" @tap="removeBusinessHour(index)">删除</view> |
|
|
{{shop.businessHourBegin || '请选择开始时间'}} |
|
|
</view> |
|
|
|
|
|
<view class="period-times"> |
|
|
|
|
|
<picker mode="time" :value="item.begin" start="00:00" end="23:59" |
|
|
|
|
|
@change="bindBusinessTimeChange($event, index, 'begin')"> |
|
|
|
|
|
<view class="time-picker" :class="{ placeholder: !item.begin }"> |
|
|
|
|
|
{{item.begin || '开始时间'}} |
|
|
<uni-icons type="bottom" size="14" color="#999"></uni-icons> |
|
|
<uni-icons type="bottom" size="14" color="#999"></uni-icons> |
|
|
</view> |
|
|
</view> |
|
|
</picker> |
|
|
</picker> |
|
|
</view> |
|
|
<view class="time-split">至</view> |
|
|
</view> |
|
|
<picker mode="time" :value="item.end" start="00:00" end="23:59" |
|
|
<view class="value"> |
|
|
@change="bindBusinessTimeChange($event, index, 'end')"> |
|
|
<view class="name">营业结束时间</view> |
|
|
<view class="time-picker" :class="{ placeholder: !item.end }"> |
|
|
<view class="text"> |
|
|
{{item.end || '结束时间'}} |
|
|
<picker mode="time" :value="shop.businessHourEnd" start="00:00" end="23:59" |
|
|
|
|
|
@change="bindTimeChange($event,'businessHourEnd')"> |
|
|
|
|
|
<view class="picker-text" :class="{ placeholder: !shop.businessHourEnd }"> |
|
|
|
|
|
{{shop.businessHourEnd || '请选择结束时间'}} |
|
|
|
|
|
<uni-icons type="bottom" size="14" color="#999"></uni-icons> |
|
|
<uni-icons type="bottom" size="14" color="#999"></uni-icons> |
|
|
</view> |
|
|
</view> |
|
|
</picker> |
|
|
</picker> |
|
|
</view> |
|
|
</view> |
|
|
</view> |
|
|
</view> |
|
|
|
|
|
<view class="add-period" @tap="addBusinessHour">+ 添加营业时段</view> |
|
|
|
|
|
</view> |
|
|
<view class="value"> |
|
|
<view class="value"> |
|
|
<view class="name">营业状态</view> |
|
|
<view class="name">营业状态</view> |
|
|
<view class="text"> |
|
|
<view class="text"> |
|
|
@ -89,8 +92,13 @@ |
|
|
virtualGroupCommissionRate: '', |
|
|
virtualGroupCommissionRate: '', |
|
|
type: '', |
|
|
type: '', |
|
|
isDelivery: 0, |
|
|
isDelivery: 0, |
|
|
cookingTime: '' |
|
|
cookingTime: '', |
|
|
|
|
|
businessHours: '' |
|
|
}, |
|
|
}, |
|
|
|
|
|
businessHourPeriods: [{ |
|
|
|
|
|
begin: '', |
|
|
|
|
|
end: '' |
|
|
|
|
|
}], |
|
|
submitLoading: false, |
|
|
submitLoading: false, |
|
|
statusList: [{ |
|
|
statusList: [{ |
|
|
value: 0, |
|
|
value: 0, |
|
|
@ -117,48 +125,120 @@ |
|
|
shopId: uni.getStorageSync('shopId') |
|
|
shopId: uni.getStorageSync('shopId') |
|
|
}, false, 'get', 'application/x-www-form-urlencoded').then(res => { |
|
|
}, false, 'get', 'application/x-www-form-urlencoded').then(res => { |
|
|
if (res.code == 200) { |
|
|
if (res.code == 200) { |
|
|
this.shop = res.result |
|
|
const result = Object.assign({}, res.result || {}) |
|
|
for (let key in this.shop) { |
|
|
for (let key in result) { |
|
|
if (this.shop[key] === null) { |
|
|
if (result[key] === null) { |
|
|
delete this.shop[key]; |
|
|
delete result[key] |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
this.shop = Object.assign({}, this.shop, result) |
|
|
|
|
|
this.businessHourPeriods = this.parseBusinessHourPeriods(this.shop) |
|
|
} else { |
|
|
} else { |
|
|
uni.showToast(res.message) |
|
|
uni.showToast(res.message) |
|
|
} |
|
|
} |
|
|
}) |
|
|
}) |
|
|
|
|
|
|
|
|
}, |
|
|
}, |
|
|
bindTimeChange(e, key) { |
|
|
formatTimeValue(value) { |
|
|
this.shop[key] = e.detail.value |
|
|
if (!value) return '' |
|
|
|
|
|
if (typeof value === 'string') { |
|
|
|
|
|
return value.length >= 5 ? value.substring(0, 5) : value |
|
|
|
|
|
} |
|
|
|
|
|
const date = value instanceof Date ? value : new Date(value) |
|
|
|
|
|
if (isNaN(date.getTime())) return '' |
|
|
|
|
|
const h = date.getHours() |
|
|
|
|
|
const m = date.getMinutes() |
|
|
|
|
|
return (h < 10 ? '0' + h : h) + ':' + (m < 10 ? '0' + m : m) |
|
|
|
|
|
}, |
|
|
|
|
|
parseBusinessHourPeriods(takeaway) { |
|
|
|
|
|
if (!takeaway) { |
|
|
|
|
|
return [{ |
|
|
|
|
|
begin: '', |
|
|
|
|
|
end: '' |
|
|
|
|
|
}] |
|
|
|
|
|
} |
|
|
|
|
|
let list = takeaway.businessHourList |
|
|
|
|
|
if ((!list || !list.length) && takeaway.businessHours) { |
|
|
|
|
|
try { |
|
|
|
|
|
list = typeof takeaway.businessHours === 'string' ? JSON.parse(takeaway.businessHours) : takeaway.businessHours |
|
|
|
|
|
} catch (e) { |
|
|
|
|
|
list = [] |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
if (list && list.length) { |
|
|
|
|
|
return list.map(item => ({ |
|
|
|
|
|
begin: this.formatTimeValue(item.begin), |
|
|
|
|
|
end: this.formatTimeValue(item.end) |
|
|
|
|
|
})) |
|
|
|
|
|
} |
|
|
|
|
|
if (takeaway.businessHourBegin || takeaway.businessHourEnd) { |
|
|
|
|
|
return [{ |
|
|
|
|
|
begin: this.formatTimeValue(takeaway.businessHourBegin), |
|
|
|
|
|
end: this.formatTimeValue(takeaway.businessHourEnd) |
|
|
|
|
|
}] |
|
|
|
|
|
} |
|
|
|
|
|
return [{ |
|
|
|
|
|
begin: '', |
|
|
|
|
|
end: '' |
|
|
|
|
|
}] |
|
|
|
|
|
}, |
|
|
|
|
|
addBusinessHour() { |
|
|
|
|
|
this.businessHourPeriods.push({ |
|
|
|
|
|
begin: '', |
|
|
|
|
|
end: '' |
|
|
|
|
|
}) |
|
|
|
|
|
}, |
|
|
|
|
|
removeBusinessHour(index) { |
|
|
|
|
|
if (this.businessHourPeriods.length <= 1) return |
|
|
|
|
|
this.businessHourPeriods.splice(index, 1) |
|
|
|
|
|
}, |
|
|
|
|
|
bindBusinessTimeChange(e, index, key) { |
|
|
|
|
|
this.$set(this.businessHourPeriods[index], key, e.detail.value) |
|
|
}, |
|
|
}, |
|
|
statusChange(e) { |
|
|
statusChange(e) { |
|
|
const item = this.statusList[e.detail.value] |
|
|
const item = this.statusList[e.detail.value] |
|
|
if (item) this.shop.status = item.value |
|
|
if (item) this.shop.status = item.value |
|
|
}, |
|
|
}, |
|
|
validateForm() { |
|
|
buildBusinessHoursPayload() { |
|
|
if (!this.shop.businessHourBegin) return '请选择营业开始时间' |
|
|
const periods = [] |
|
|
if (!this.shop.businessHourEnd) return '请选择营业结束时间' |
|
|
for (let i = 0; i < this.businessHourPeriods.length; i++) { |
|
|
return '' |
|
|
const begin = this.formatTimeValue(this.businessHourPeriods[i].begin) |
|
|
}, |
|
|
const end = this.formatTimeValue(this.businessHourPeriods[i].end) |
|
|
submit(){ |
|
|
if (!begin || !end) { |
|
|
const error = this.validateForm() |
|
|
uni.showToast({ |
|
|
if (error) { |
|
|
title: '请完善第' + (i + 1) + '个营业时段', |
|
|
|
|
|
icon: 'none' |
|
|
|
|
|
}) |
|
|
|
|
|
return null |
|
|
|
|
|
} |
|
|
|
|
|
periods.push({ |
|
|
|
|
|
begin, |
|
|
|
|
|
end |
|
|
|
|
|
}) |
|
|
|
|
|
} |
|
|
|
|
|
if (!periods.length) { |
|
|
uni.showToast({ |
|
|
uni.showToast({ |
|
|
title: error, |
|
|
title: '请至少设置一个营业时段', |
|
|
icon: 'none' |
|
|
icon: 'none' |
|
|
}) |
|
|
}) |
|
|
return |
|
|
return null |
|
|
} |
|
|
} |
|
|
|
|
|
return periods |
|
|
|
|
|
}, |
|
|
|
|
|
submit(){ |
|
|
|
|
|
const periods = this.buildBusinessHoursPayload() |
|
|
|
|
|
if (!periods) return |
|
|
const payload = { |
|
|
const payload = { |
|
|
id: this.shop.id, |
|
|
id: this.shop.id, |
|
|
shopId: this.shop.shopId || uni.getStorageSync('shopId'), |
|
|
shopId: this.shop.shopId || uni.getStorageSync('shopId'), |
|
|
businessHourBegin: this.shop.businessHourBegin, |
|
|
businessHours: JSON.stringify(periods), |
|
|
businessHourEnd: this.shop.businessHourEnd, |
|
|
businessHourBegin: periods[0].begin, |
|
|
|
|
|
businessHourEnd: periods[0].end, |
|
|
status: Number(this.shop.status) |
|
|
status: Number(this.shop.status) |
|
|
} |
|
|
} |
|
|
this.submitLoading = true |
|
|
this.submitLoading = true |
|
|
this.NB.sendRequest('/app/shoptakeaway/update', payload, false, 'POST', 'application/x-www-form-urlencoded').then(res => { |
|
|
this.NB.sendRequest('/app/shoptakeaway/update', payload, false, 'POST', 'application/x-www-form-urlencoded').then(res => { |
|
|
|
|
|
this.submitLoading = false |
|
|
if (res.code == 200) { |
|
|
if (res.code == 200) { |
|
|
uni.showModal({ |
|
|
uni.showModal({ |
|
|
title: '提示', |
|
|
title: '提示', |
|
|
@ -171,6 +251,8 @@ |
|
|
} else { |
|
|
} else { |
|
|
uni.showToast(res.message) |
|
|
uni.showToast(res.message) |
|
|
} |
|
|
} |
|
|
|
|
|
}).catch(() => { |
|
|
|
|
|
this.submitLoading = false |
|
|
}) |
|
|
}) |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
@ -274,6 +356,92 @@ |
|
|
border-top: none; |
|
|
border-top: none; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
.business-hour-block { |
|
|
|
|
|
padding: 0 28rpx 28rpx; |
|
|
|
|
|
border-top: 1rpx solid #edf3f0; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
.section-title + .business-hour-block { |
|
|
|
|
|
border-top: none; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
.business-hour-title { |
|
|
|
|
|
height: 80rpx; |
|
|
|
|
|
line-height: 80rpx; |
|
|
|
|
|
font-size: 28rpx; |
|
|
|
|
|
font-weight: 800; |
|
|
|
|
|
color: #153c34; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
.period-card { |
|
|
|
|
|
margin-bottom: 20rpx; |
|
|
|
|
|
padding: 22rpx; |
|
|
|
|
|
border-radius: 22rpx; |
|
|
|
|
|
background: #f7fbf9; |
|
|
|
|
|
border: 1rpx solid #edf3f0; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
.period-header { |
|
|
|
|
|
display: flex; |
|
|
|
|
|
align-items: center; |
|
|
|
|
|
justify-content: space-between; |
|
|
|
|
|
margin-bottom: 18rpx; |
|
|
|
|
|
font-size: 26rpx; |
|
|
|
|
|
font-weight: 800; |
|
|
|
|
|
color: #153c34; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
.period-delete { |
|
|
|
|
|
color: #ff5a5f; |
|
|
|
|
|
font-size: 24rpx; |
|
|
|
|
|
font-weight: 700; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
.period-times { |
|
|
|
|
|
display: flex; |
|
|
|
|
|
align-items: center; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
.period-times picker { |
|
|
|
|
|
flex: 1; |
|
|
|
|
|
min-width: 0; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
.time-picker { |
|
|
|
|
|
height: 72rpx; |
|
|
|
|
|
line-height: 72rpx; |
|
|
|
|
|
text-align: center; |
|
|
|
|
|
border-radius: 16rpx; |
|
|
|
|
|
background: #fff; |
|
|
|
|
|
border: 1rpx solid #e4ece8; |
|
|
|
|
|
font-size: 26rpx; |
|
|
|
|
|
color: #263f39; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
.time-picker.placeholder { |
|
|
|
|
|
color: #9aa7a3; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
.time-split { |
|
|
|
|
|
width: 66rpx; |
|
|
|
|
|
text-align: center; |
|
|
|
|
|
color: #7b8b86; |
|
|
|
|
|
font-size: 24rpx; |
|
|
|
|
|
font-weight: 700; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
.add-period { |
|
|
|
|
|
height: 76rpx; |
|
|
|
|
|
line-height: 76rpx; |
|
|
|
|
|
text-align: center; |
|
|
|
|
|
border-radius: 18rpx; |
|
|
|
|
|
border: 1rpx dashed #9adfcd; |
|
|
|
|
|
color: #0d7f69; |
|
|
|
|
|
font-size: 26rpx; |
|
|
|
|
|
font-weight: 800; |
|
|
|
|
|
background: rgba(166, 255, 234, 0.2); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
.name { |
|
|
.name { |
|
|
width: 210rpx; |
|
|
width: 210rpx; |
|
|
font-size: 28rpx; |
|
|
font-size: 28rpx; |
|
|
|