Преглед изворни кода

点击购买时,添加判断是否在营业时间

shizhongqi пре 10 месеци
родитељ
комит
9676b510c5

+ 1 - 1
ghsApp/src/admin/home/member.vue

@@ -18,7 +18,7 @@
       <block v-for="(item, index) in list.data" :key="index">
         <tui-list-cell :arrow="true" @click="pageTo({url: '/pagesClient/member/detail?id='+item.id})">
           <div class="tui-msg-box">
-            <img :src="item.avatar" class="tui-msg-pic" mode="widthFix" />
+            <img :src="item.smallAvatar" class="tui-msg-pic" mode="widthFix" />
             <div class="tui-msg-item">
               <div class="tui-msg-name">
                 <div class="tui-user-name">

+ 27 - 0
mallApp/src/pages/goods/detail.vue

@@ -327,6 +327,33 @@ export default {
       });
     },
     showPopup() {
+      const currentShop = uni.getStorageSync('currentShop');
+
+      if (this.$util.isEmpty(currentShop)) {
+        console.error("当前所在门店数据异常");
+      } else if (currentShop.openStartTime !='' && currentShop.openEndTime !='') {
+        // 当前小时与分钟是否在营业时间范围内
+        const currentTime = new Date();
+        const currentHour = currentTime.getHours();
+        const currentMinute = currentTime.getMinutes();
+
+        const openTime = currentShop.openStartTime; //营业开始时间,例如:3:30
+        const openHour = parseInt(openTime.split(':')[0]);
+        const openMinute = parseInt(openTime.split(':')[1]);
+        const closeTime = currentShop.openEndTime; //营业结束时间,例如:18:30
+        const closeHour = parseInt(closeTime.split(':')[0]);
+        const closeMinute = parseInt(closeTime.split(':')[1]);
+
+        if (currentHour < openHour || (currentHour === openHour && currentMinute < openMinute)) {
+          this.$msg("当前时间不在营业时间范围内");
+          return;
+        }
+        if (currentHour > closeHour || (currentHour === closeHour && currentMinute > closeMinute)) {
+          this.$msg("当前时间不在营业时间范围内");
+          return;
+        }
+      }
+
       this.popupShow = true;
     },
     hidePopup() {

+ 2 - 0
mallApp/src/pages/home/category.vue

@@ -209,6 +209,8 @@ export default {
 						}
 					}
 
+					//保存当前所在门店信息
+					uni.setStorageSync('currentShop', res.data.info)
 				}
 			})
     },

+ 3 - 0
mallApp/src/pages/home/mall.vue

@@ -238,6 +238,9 @@ export default {
             this.shopName = name;
             this.shopImg = res.data.info.avatar;
             this.shopInfo = res.data.info;
+
+            //保存当前所在门店信息
+            uni.setStorageSync('currentShop', this.shopInfo)
           }
 
           if (res.data.hd && Number(res.data.hd.id) > 0) {

+ 3 - 0
mallApp/src/pages/item/item.vue

@@ -343,6 +343,9 @@ export default {
 							this.hdId = res.data.hd.id
 						}
 					}
+
+					//保存当前所在门店信息
+					uni.setStorageSync('currentShop', res.data.info)
 				}
 			})
 			this.initData()