diff --git a/App.vue b/App.vue index 04b1661..77ce04e 100644 --- a/App.vue +++ b/App.vue @@ -150,7 +150,7 @@ this.onPlayAudio(10) } else if (content.includes('您有一笔配送中订单用户申请退款')) { this.onPlayAudio(11) - } else if (content.includes('抢单大厅来新单啦')) { + } else if (content.includes('抢单大厅来新单啦') || content.includes('有新的中转配送单啦,请及时接单')) { this.onPlayAudio(12) } else if (content.includes('您有中转配送订单超时未送达中转点')) { this.onPlayAudio(7) diff --git a/components/print/index.js b/components/print/index.js index c19d33a..0a1b4ea 100644 --- a/components/print/index.js +++ b/components/print/index.js @@ -89,7 +89,7 @@ export default { data1.deliveryType == 1 && data1.orderType == 3 ? data1.deliveryInfo.numberCode : data1.numberCode ); printerJobs.setAlign('ct').setSize(2, 2).setLineSpacing(60).print( - (data1.deliveryInfo && data1.deliveryInfo.appointmentDelivery == 1 && data1.status != 7 && data1.status == 11) ? '预约单' : + (data1.deliveryInfo && data1.deliveryInfo.appointmentDelivery == 1 && data1.status != 7 && data1.status != 11 && data1.status != 8 && data1.status != 12) ? '预约单' : (data1.deliveryInfo && data1.deliveryInfo.transferDelivery == 1 && data1.status != 7 && data1.status != 11) ? '取餐码(' + data1.deliveryInfo.transferPickupCode +')' : (data1.status == 7 || data1.status == 11) ? '申请退款' : (data1.deliveryType == 1 && data1.orderType == 3) ? '面对面配送' : @@ -110,7 +110,11 @@ export default { ); } printerJobs.setSize(1, 1).setLineSpacing(40); - printerJobs.setAlign('lt').print(data1.shopName + ((data1.deliveryType == 1 && data1.orderType == 3) ? '(' + + if (this.isFaceToFaceDelivery(data1)) { + printerJobs.setAlign('lt').setSize(2, 2).setLineSpacing(60).print('本单编号:' + (data1.numberCode || '')); + printerJobs.setSize(1, 1).setLineSpacing(40); + } + printerJobs.setAlign('lt').print(data1.shopName + (this.isFaceToFaceDelivery(data1) ? '(' + data1.numberCode + ')' : '')); printerJobs.setAlign('lt').print( @@ -190,7 +194,7 @@ export default { printerJobs.print('锦鲤免单:-' + data1.freeAmount); } printerJobs.print('合计金额:' + ((data1.goodsAmount + data1.deliveryFee + data1.packageFee).toFixed(2))); - if (data1.mallRefundRecord != null) { + if (data1.mallRefundRecord != null && data1.deliveryType != 2) { printerJobs.print('应退金额:' + data1.totalAmount); } else { printerJobs.print('实付金额:' + data1.totalAmount); @@ -247,6 +251,9 @@ export default { } return '平台退款'; }, + isFaceToFaceDelivery(order) { + return order && order.deliveryType == 1 && (order.orderType == 3 || (order.deliveryInfo && order.deliveryInfo.numberCode)); + }, // 去除字符串中的 Emoji 表情 removeEmojis(str) { if (!str) return ''; diff --git a/pages/index/index.vue b/pages/index/index.vue index 7c7001f..a04d41d 100644 --- a/pages/index/index.vue +++ b/pages/index/index.vue @@ -269,6 +269,7 @@ import tabBar from "@/components/tab-bar/tab-bar.vue"; import deLivery from "@/components/tab-bar/delivery.vue"; import myCenter from "@/components/tab-bar/myCenter.vue"; + import printer from '@/components/print/index.js'; export default { data() { return { @@ -471,6 +472,7 @@ break; default: } + if (!url) return; uni.navigateTo({ url: url }) @@ -546,6 +548,7 @@ title: '核销成功', icon: 'none' }) + that.printAfterComplete(productId) } else { uni.showModal({ title: '提示', @@ -576,6 +579,38 @@ } }) }, + printAfterComplete(orderId) { + if (!orderId) return; + if (uni.getStorageSync('printingMethod') == 'cloud') { + this.NB.sendRequest("/mall/order/cloudPrint/" + orderId, {}, false, 'post', + 'application/x-www-form-urlencoded').then((res) => { + if (res.code != 200) { + uni.showToast({ + title: res.message || '云打印失败', + icon: 'none' + }); + } + }).catch(() => {}); + return; + } + getApp().globalData.printData.push({ + order_id: orderId + }); + if (!getApp().globalData.isPrinting) { + this.processPrintQueue(); + } + }, + processPrintQueue() { + if (getApp().globalData.printData.length === 0) { + getApp().globalData.isPrinting = false; + return; + } + getApp().globalData.isPrinting = true; + printer.getData(() => { + getApp().globalData.printData.shift(); + this.processPrintQueue(); + }); + }, //底部tab切换组件状态改变 changeIndex(index, type) { let that = this; diff --git a/pages/myCenter/businessInfo.vue b/pages/myCenter/businessInfo.vue index 34bbaa9..bc685c9 100644 --- a/pages/myCenter/businessInfo.vue +++ b/pages/myCenter/businessInfo.vue @@ -8,29 +8,32 @@ 营业设置 - - 营业开始时间 - - - - {{shop.businessHourBegin || '请选择开始时间'}} - - - - - - - 营业结束时间 - - - - {{shop.businessHourEnd || '请选择结束时间'}} - - - + + 营业时段 + + + 时段{{index + 1}} + 删除 + + + + + {{item.begin || '开始时间'}} + + + + + + + {{item.end || '结束时间'}} + + + + + + 添加营业时段 营业状态 @@ -89,8 +92,13 @@ virtualGroupCommissionRate: '', type: '', isDelivery: 0, - cookingTime: '' + cookingTime: '', + businessHours: '' }, + businessHourPeriods: [{ + begin: '', + end: '' + }], submitLoading: false, statusList: [{ value: 0, @@ -117,48 +125,120 @@ shopId: uni.getStorageSync('shopId') }, false, 'get', 'application/x-www-form-urlencoded').then(res => { if (res.code == 200) { - this.shop = res.result - for (let key in this.shop) { - if (this.shop[key] === null) { - delete this.shop[key]; - } + const result = Object.assign({}, res.result || {}) + for (let key in result) { + if (result[key] === null) { + delete result[key] + } } + this.shop = Object.assign({}, this.shop, result) + this.businessHourPeriods = this.parseBusinessHourPeriods(this.shop) } else { uni.showToast(res.message) } }) }, - bindTimeChange(e, key) { - this.shop[key] = e.detail.value + formatTimeValue(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) { const item = this.statusList[e.detail.value] if (item) this.shop.status = item.value }, - validateForm() { - if (!this.shop.businessHourBegin) return '请选择营业开始时间' - if (!this.shop.businessHourEnd) return '请选择营业结束时间' - return '' - }, - submit(){ - const error = this.validateForm() - if (error) { + buildBusinessHoursPayload() { + const periods = [] + for (let i = 0; i < this.businessHourPeriods.length; i++) { + const begin = this.formatTimeValue(this.businessHourPeriods[i].begin) + const end = this.formatTimeValue(this.businessHourPeriods[i].end) + if (!begin || !end) { + uni.showToast({ + title: '请完善第' + (i + 1) + '个营业时段', + icon: 'none' + }) + return null + } + periods.push({ + begin, + end + }) + } + if (!periods.length) { uni.showToast({ - title: error, + title: '请至少设置一个营业时段', icon: 'none' }) - return + return null } + return periods + }, + submit(){ + const periods = this.buildBusinessHoursPayload() + if (!periods) return const payload = { id: this.shop.id, shopId: this.shop.shopId || uni.getStorageSync('shopId'), - businessHourBegin: this.shop.businessHourBegin, - businessHourEnd: this.shop.businessHourEnd, + businessHours: JSON.stringify(periods), + businessHourBegin: periods[0].begin, + businessHourEnd: periods[0].end, status: Number(this.shop.status) } this.submitLoading = true this.NB.sendRequest('/app/shoptakeaway/update', payload, false, 'POST', 'application/x-www-form-urlencoded').then(res => { + this.submitLoading = false if (res.code == 200) { uni.showModal({ title: '提示', @@ -171,6 +251,8 @@ } else { uni.showToast(res.message) } + }).catch(() => { + this.submitLoading = false }) } } @@ -273,6 +355,92 @@ .section-title + .value { 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 { width: 210rpx; diff --git a/pages/worker/workerOrderList.vue b/pages/worker/workerOrderList.vue index 7748f23..c0f8742 100644 --- a/pages/worker/workerOrderList.vue +++ b/pages/worker/workerOrderList.vue @@ -27,7 +27,7 @@ - + @@ -110,7 +110,8 @@ 暂无已完成订单 - + + @@ -144,7 +145,6 @@ - @@ -174,9 +174,7 @@ } }, onReachBottom() { - if (this.searchForm.pageNum >= this.totalPages) return; - this.searchForm.pageNum++; - this.getList(); + this.loadMore(); }, filters: { formatHourMinute(value) { @@ -260,6 +258,12 @@ uni.hideLoading(); }) }, + loadMore() { + if (this.loadStatus == 'loading') return; + if (this.searchForm.pageNum >= this.totalPages) return; + this.searchForm.pageNum++; + this.getList(); + }, deliveryTypeText(type) { if (type == 1) return '外卖'; if (type == 2) return '代取快递'; @@ -318,10 +322,10 @@ .page1 { width: 100%; - height: 100%; + height: 100vh; font-size: 24rpx; position: relative; - padding-bottom: 40rpx; + overflow: hidden; } .worker-order-fixed { @@ -402,9 +406,11 @@ .list-wrap { width: 92%; + height: calc(100vh - 462rpx); margin: 0 auto; position: relative; z-index: 1; + box-sizing: border-box; } .search-card {