فهرست منبع

优化营业时间

lishanshan 1 ماه پیش
والد
کامیت
ac4654b72e
1فایلهای تغییر یافته به همراه12 افزوده شده و 9 حذف شده
  1. 12 9
      pages/store/addHours.vue

+ 12 - 9
pages/store/addHours.vue

@@ -269,15 +269,18 @@ export default {
             return hours * 60 + minutes
         },
         sumbit() {
-            let data = {
-                merchantId: this.merchantId,
-                timeType: this.timeType.length > 0 ? 1 : 2,
-                period: this.selectedIndices.length > 0 ? this.selectedIndices.join('、') : null,
-                middleTime: this.timeArr.length >= 1 ? this.timeArr[0].value : null,
-                beginTime: this.timeArr.length >= 2 ? this.timeArr[1].value : null,
-                endTime: this.timeArr.length >= 3 ? this.timeArr[2].value : null,
-                id:this.arrData.index==1 || this.arrData.index==0?this.arrData.arr[this.arrData.index].id:null
-            }
+          // 按照周一至周日的顺序排序选中的营业日
+          const weekOrder = ['周一', '周二', '周三', '周四', '周五', '周六', '周日' ,'整周'];
+          const sortedPeriod = this.selectedIndices.sort((a, b) => weekOrder.indexOf(a) - weekOrder.indexOf(b));
+          let data = {
+              merchantId: this.merchantId,
+              timeType: this.timeType.length > 0 ? 1 : 2,
+              period: this.selectedIndices.length > 0 ? sortedPeriod.join('、') : null,
+              middleTime: this.timeArr.length >= 1 ? this.timeArr[0].value : null,
+              beginTime: this.timeArr.length >= 2 ? this.timeArr[1].value : null,
+              endTime: this.timeArr.length >= 3 ? this.timeArr[2].value : null,
+              id:this.arrData.index==1 || this.arrData.index==0?this.arrData.arr[this.arrData.index].id:null
+          }
             if(this.selectedIndices.length==0){
 				this.$tip.toast('请选择营业日');
                 return