Jelajahi Sumber

版本更新

liuguofeng 6 bulan lalu
induk
melakukan
00be865260

+ 22 - 76
jiaoyu_mp/pages/product/index.vue

@@ -284,8 +284,8 @@
 					if( re.code == 'success' ) {
 						// 刷新数据
 						this.productInfo = re.data;
-						//设置默认sku
-						this.setDefaultSpec();
+						// //设置默认sku
+						// this.setDefaultSpec();
 					}
 				});		
 			};
@@ -362,6 +362,14 @@
 			createOrder(){
 				// 不可预约
 				if( !this.$checkAccess.alertCity() ) return;
+				// 如果有SKU,但是没有选择
+				if( this.productInfo.product_sku.length && !this.sku_id ){
+					uni.showToast({
+						title:"请选择规格",
+						icon:"none"
+					})
+					return;
+				}
 				// 下单数量小于0
 				if( this.quantity < 1 ) {
 					uni.showToast({
@@ -415,6 +423,14 @@
 			createCart(){
 				// 不可预约
 				if( !this.$checkAccess.alertCity() ) return;
+				// 如果有SKU,但是没有选择
+				if( this.productInfo.product_sku.length && !this.sku_id ){
+					uni.showToast({
+						title:"请选择规格",
+						icon:"none"
+					})
+					return;
+				}
 				// 下单数量小于0
 				if( this.quantity < 1 ) {
 					uni.showToast({
@@ -630,80 +646,6 @@
 					},
 				})
 			},
-			// 设置默认sku
-			setDefaultSpec(){
-				// 如果列表存在
-				if( this.productInfo.product_sku.length ){
-					//如果列表大于1
-					if(this.productInfo.product_sku.length > 1){
-						//循环sku列表
-						for(var k = 0 ; k < this.productInfo.product_sku.length;k++ ){
-							//全部规格都已经下架
-							if(k === this.productInfo.product_sku.length){
-								uni.showToast({
-									title:"当前商品已全部下架",
-									icon:"error"
-								})
-								this.productInfo.stock = 0;
-								return;
-							}
-							// 获取第一个没有下架的sku作为默认值
-							if(this.productInfo.product_sku[k].status === 0){
-								var attr_ids = this.productInfo.product_sku[k].attr_ids.split(",");
-								break;
-							}
-						}
-						// 循环规格列表
-						for ( let i in this.productInfo.product_attr ) {
-							// 再循环属性
-							for (let j in this.productInfo.product_attr[i].attr_list) {
-								// 如果不等于id
-								if( attr_ids.includes(this.productInfo.product_attr[i].attr_list[j].id + '') ){
-									// 设置选中
-									this.productInfo.product_attr[i].attr_list[j].active = 1;
-								}else{
-									this.productInfo.product_attr[i].attr_list[j].active = 0;
-								}
-							}
-						}
-						// 产品价格修改
-						this.productInfo.price = this.productInfo.product_sku[k].price;
-						// 产品规格修改
-						this.productInfo.spec = this.productInfo.product_sku[k].attr_names;
-						// 产品库存
-						this.productInfo.stock = this.productInfo.product_sku[k].stock;
-						// 产品SKU
-						this.sku_id 		= this.productInfo.product_sku[k].id;
-						// 计算价格
-						this.priceHandler();
-					}else{
-						var attr_ids = this.productInfo.product_sku[0].attr_ids.split(",");
-						// 循环规格列表
-						for ( let i in this.productInfo.product_attr ) {
-							// 再循环属性
-							for (let j in this.productInfo.product_attr[i].attr_list) {
-								// 如果不等于id
-								if( attr_ids.includes(this.productInfo.product_attr[i].attr_list[j].id + '') ){
-									// 设置选中
-									this.productInfo.product_attr[i].attr_list[j].active = 1;
-								}else{
-									this.productInfo.product_attr[i].attr_list[j].active = 0;
-								}
-							}
-						}
-						// 产品价格修改
-						this.productInfo.price = this.productInfo.product_sku[0].price;
-						// 产品规格修改
-						this.productInfo.spec = this.productInfo.product_sku[0].attr_names;
-						// 产品库存
-						this.productInfo.stock = this.productInfo.product_sku[0].stock;
-						// 产品SKU
-						this.sku_id = this.productInfo.product_sku[0].id;
-						// 计算价格
-						this.priceHandler();
-					}
-				}
-			},
 			// 属性变更
 			attrChange(spec_index,attr_index){
 				// 判断当前属性是否选择。选择的跳过
@@ -734,6 +676,10 @@
 				}
 				// 转成字符串
 				var attrids	= attr_ids.join(",");
+				
+				// 如果选项不足的话
+				if( attr_ids.length != this.productInfo.product_attr.length) return ;
+				
 				// 如果当前点击的属性对应的SKU状态为未下架(初始化为0)
 				let currentSKUStatus = 0;
 				// 匹配规格

+ 1 - 1
jiaoyu_mp/pages/score/product.vue

@@ -102,7 +102,7 @@
 						<text>{{productInfo.name}}</text>
 					</view>
 					<view class="product_subtitle">
-						<text>我是副标题</text>
+						<text>{{productInfo.spec}}</text>
 					</view>
 					<view class="product_spec">
 						<view class="spec_name">{{productInfo.score}}积分</view> 

+ 18 - 32
jiaoyu_mp/pagesA/course/reservation.vue

@@ -70,10 +70,10 @@
 				type: Boolean,
 				default: false
 			},
-			isSection: { //预约时间段
-				type: Boolean,
-				default: false
-			},
+			// isSection: { //预约时间段
+			// 	type: Boolean,
+			// 	default: false
+			// },
 			disableText:{ //禁用显示的文本
 				type: String,
 				default: "已预约"
@@ -86,10 +86,10 @@
 				type: String,
 				default: "可预约"
 			},
-			timeInterval: { // 时间间隔,小时为单位
-				type: Number,
-				default: 1
-			},
+			// timeInterval: { // 时间间隔,小时为单位
+			// 	type: Number,
+			// 	default: 1
+			// },
 			selectedTabColor: { // 日期栏选中的颜色
 				type: String,
 				default: "#51bf81"
@@ -98,28 +98,23 @@
 				type: String,
 				default: "#51bf81"
 			},
-			beginTime: {
-				type: String,
-				default: "08:30"
-			},
-			endTime: {
-				type: String,
-				default: "19:30"
-			},
+			// beginTime: {
+			// 	type: String,
+			// 	default: "08:30"
+			// },
+			// endTime: {
+			// 	type: String,
+			// 	default: "19:30"
+			// },
 			appointTime: { // 预约的时间
 				type: Array,
 				default () {
 					return []
 				}
 			},
-			disableTimeSlot: { // 预约开始和结束时间,来禁用时间段
-				type: Array,
-				default () {
-					return []
-				}
-			}
 		},
 		watch: {
+			//监控appointTime变化,去控制预约时间的状态
 			appointTime: {
 				handler(val) {
 					if (val && val.length) {
@@ -127,13 +122,7 @@
 					}
 				}
 			},
-			// disableTimeSlot: {
-			// 	handler(val) {
-			// 		if (val && val.length) {
-			// 			this.initOnload()
-			// 		}
-			// 	}
-			// },
+			//监控排课列表的里面的属性reservation_status的值,从而保持前后端预约时间状态的一致性。
 			shcedule_list:{
 				handler(val) {
 					if(val && val.length){
@@ -230,7 +219,6 @@
 				selectDate: "", //选择的日期
 				timeQuanBegin: "", //时间段开始时间
 				timeQuanEnd: "", //时间段结束时间
-				// isTime:[],
 				
 			}
 		},
@@ -242,7 +230,6 @@
 			this.course_id = course_id
 		},
 		onShow() {
-
 			 if(this.orders_product_id > 0 && this.course_id > 0){
 				
 				this.$http.request('api/course/get_schedule_list',{orders_product_id:this.orders_product_id,course_id:this.course_id},'post').then((res)=>{
@@ -477,7 +464,6 @@
 			},
 			
 			//时间数组
-		// this.shcedule_list[{"start_time":1732060800,"end_time":1732063500}];
 			 initTime( isQuantum) {
 				const time = []
 				this.shcedule_list.forEach((cruTiem)=>{

+ 16 - 52
jiaoyu_mp/unpackage/dist/dev/mp-weixin/pages/product/index.js

@@ -79,7 +79,6 @@ const _sfc_main = {
       this.$http.request("api/product/get_detail", this.requestParam).then((re) => {
         if (re.code == "success") {
           this.productInfo = re.data;
-          this.setDefaultSpec();
         }
       });
     }
@@ -137,6 +136,13 @@ const _sfc_main = {
     createOrder() {
       if (!this.$checkAccess.alertCity())
         return;
+      if (this.productInfo.product_sku.length && !this.sku_id) {
+        common_vendor.index.showToast({
+          title: "请选择规格",
+          icon: "none"
+        });
+        return;
+      }
       if (this.quantity < 1) {
         common_vendor.index.showToast({
           title: "至少购买1个"
@@ -176,6 +182,13 @@ const _sfc_main = {
     createCart() {
       if (!this.$checkAccess.alertCity())
         return;
+      if (this.productInfo.product_sku.length && !this.sku_id) {
+        common_vendor.index.showToast({
+          title: "请选择规格",
+          icon: "none"
+        });
+        return;
+      }
       if (this.quantity < 1) {
         common_vendor.index.showToast({
           title: "至少购买1个"
@@ -335,57 +348,6 @@ const _sfc_main = {
         }
       });
     },
-    // 设置默认sku
-    setDefaultSpec() {
-      if (this.productInfo.product_sku.length) {
-        if (this.productInfo.product_sku.length > 1) {
-          for (var k = 0; k < this.productInfo.product_sku.length; k++) {
-            if (k === this.productInfo.product_sku.length) {
-              common_vendor.index.showToast({
-                title: "当前商品已全部下架",
-                icon: "error"
-              });
-              this.productInfo.stock = 0;
-              return;
-            }
-            if (this.productInfo.product_sku[k].status === 0) {
-              var attr_ids = this.productInfo.product_sku[k].attr_ids.split(",");
-              break;
-            }
-          }
-          for (let i in this.productInfo.product_attr) {
-            for (let j in this.productInfo.product_attr[i].attr_list) {
-              if (attr_ids.includes(this.productInfo.product_attr[i].attr_list[j].id + "")) {
-                this.productInfo.product_attr[i].attr_list[j].active = 1;
-              } else {
-                this.productInfo.product_attr[i].attr_list[j].active = 0;
-              }
-            }
-          }
-          this.productInfo.price = this.productInfo.product_sku[k].price;
-          this.productInfo.spec = this.productInfo.product_sku[k].attr_names;
-          this.productInfo.stock = this.productInfo.product_sku[k].stock;
-          this.sku_id = this.productInfo.product_sku[k].id;
-          this.priceHandler();
-        } else {
-          var attr_ids = this.productInfo.product_sku[0].attr_ids.split(",");
-          for (let i in this.productInfo.product_attr) {
-            for (let j in this.productInfo.product_attr[i].attr_list) {
-              if (attr_ids.includes(this.productInfo.product_attr[i].attr_list[j].id + "")) {
-                this.productInfo.product_attr[i].attr_list[j].active = 1;
-              } else {
-                this.productInfo.product_attr[i].attr_list[j].active = 0;
-              }
-            }
-          }
-          this.productInfo.price = this.productInfo.product_sku[0].price;
-          this.productInfo.spec = this.productInfo.product_sku[0].attr_names;
-          this.productInfo.stock = this.productInfo.product_sku[0].stock;
-          this.sku_id = this.productInfo.product_sku[0].id;
-          this.priceHandler();
-        }
-      }
-    },
     // 属性变更
     attrChange(spec_index, attr_index) {
       if (this.productInfo.product_attr[spec_index].attr_list[attr_index].active)
@@ -407,6 +369,8 @@ const _sfc_main = {
         }
       }
       var attrids = attr_ids.join(",");
+      if (attr_ids.length != this.productInfo.product_attr.length)
+        return;
       let currentSKUStatus = 0;
       if (this.productInfo.product_sku.length) {
         let haveSku = 0;

+ 34 - 33
jiaoyu_mp/unpackage/dist/dev/mp-weixin/pages/score/product.js

@@ -193,42 +193,43 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
     d: common_vendor.o((...args) => $options.goBack && $options.goBack(...args)),
     e: $data.productInfo.thumb,
     f: common_vendor.t($data.productInfo.name),
-    g: common_vendor.t($data.productInfo.score),
-    h: common_vendor.t($data.productInfo.stock),
-    i: common_assets._imports_0$1,
-    j: common_assets._imports_1$1,
-    k: common_assets._imports_2$1,
-    l: common_vendor.o(($event) => $options.showSpecPopup(2)),
-    m: !$data.checkedAddr.id
+    g: common_vendor.t($data.productInfo.spec),
+    h: common_vendor.t($data.productInfo.score),
+    i: common_vendor.t($data.productInfo.stock),
+    j: common_assets._imports_0$1,
+    k: common_assets._imports_1$1,
+    l: common_assets._imports_2$1,
+    m: common_vendor.o(($event) => $options.showSpecPopup(2)),
+    n: !$data.checkedAddr.id
   }, !$data.checkedAddr.id ? {} : {}, {
-    n: common_vendor.t($data.checkedAddr.contact_name),
-    o: common_vendor.t($data.checkedAddr.contact_phone),
-    p: common_vendor.t($data.checkedAddr.contact_province),
-    q: common_vendor.t($data.checkedAddr.contact_city),
-    r: common_vendor.t($data.checkedAddr.contact_area),
-    s: common_vendor.t($data.checkedAddr.contact_addr),
-    t: common_vendor.o(($event) => $options.showAddrPopup()),
-    v: $data.productInfo.thumb,
-    w: common_vendor.t($data.productInfo.name),
-    x: common_vendor.t($data.productInfo.score),
-    y: common_assets._imports_3,
-    z: common_vendor.o(($event) => $options.changeQuantity(-1)),
-    A: common_vendor.o(($event) => $options.changeQuantity(0)),
-    B: $data.quantity,
-    C: common_vendor.o(($event) => $data.quantity = $event.detail.value),
-    D: common_assets._imports_4,
-    E: common_vendor.o(($event) => $options.changeQuantity(1)),
-    F: common_vendor.t($data.productInfo.stock),
-    G: common_vendor.t($data.priceTotal),
-    H: common_vendor.o(($event) => $options.createOrder()),
-    I: common_vendor.sr("specPopup", "f81ec0bc-1"),
-    J: common_vendor.o($options.popupChange),
-    K: common_vendor.p({
+    o: common_vendor.t($data.checkedAddr.contact_name),
+    p: common_vendor.t($data.checkedAddr.contact_phone),
+    q: common_vendor.t($data.checkedAddr.contact_province),
+    r: common_vendor.t($data.checkedAddr.contact_city),
+    s: common_vendor.t($data.checkedAddr.contact_area),
+    t: common_vendor.t($data.checkedAddr.contact_addr),
+    v: common_vendor.o(($event) => $options.showAddrPopup()),
+    w: $data.productInfo.thumb,
+    x: common_vendor.t($data.productInfo.name),
+    y: common_vendor.t($data.productInfo.score),
+    z: common_assets._imports_3,
+    A: common_vendor.o(($event) => $options.changeQuantity(-1)),
+    B: common_vendor.o(($event) => $options.changeQuantity(0)),
+    C: $data.quantity,
+    D: common_vendor.o(($event) => $data.quantity = $event.detail.value),
+    E: common_assets._imports_4,
+    F: common_vendor.o(($event) => $options.changeQuantity(1)),
+    G: common_vendor.t($data.productInfo.stock),
+    H: common_vendor.t($data.priceTotal),
+    I: common_vendor.o(($event) => $options.createOrder()),
+    J: common_vendor.sr("specPopup", "f81ec0bc-1"),
+    K: common_vendor.o($options.popupChange),
+    L: common_vendor.p({
       show: true,
       type: "bottom",
       ["background-color"]: "#FFFFFF"
     }),
-    L: common_vendor.f($data.addrList, (item, index, i0) => {
+    M: common_vendor.f($data.addrList, (item, index, i0) => {
       return common_vendor.e({
         a: item.id == $data.checkedAddr.id ? "../../static/icon/radioed.png" : "../../static/icon/radio.png",
         b: common_vendor.t(item.contact_name),
@@ -243,8 +244,8 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
         j: common_vendor.o(($event) => $options.checkedAddrItem(item), index)
       });
     }),
-    M: common_vendor.sr("addrPopup", "f81ec0bc-2"),
-    N: common_vendor.p({
+    N: common_vendor.sr("addrPopup", "f81ec0bc-2"),
+    O: common_vendor.p({
       type: "bottom",
       ["background-color"]: "#FFFFFF"
     })

File diff ditekan karena terlalu besar
+ 0 - 0
jiaoyu_mp/unpackage/dist/dev/mp-weixin/pages/score/product.wxml


+ 18 - 34
jiaoyu_mp/unpackage/dist/dev/mp-weixin/pagesA/course/reservation.js

@@ -11,11 +11,10 @@ const _sfc_main = {
       type: Boolean,
       default: false
     },
-    isSection: {
-      //预约时间段
-      type: Boolean,
-      default: false
-    },
+    // isSection: { //预约时间段
+    // 	type: Boolean,
+    // 	default: false
+    // },
     disableText: {
       //禁用显示的文本
       type: String,
@@ -30,11 +29,10 @@ const _sfc_main = {
       type: String,
       default: "可预约"
     },
-    timeInterval: {
-      // 时间间隔,小时为单位
-      type: Number,
-      default: 1
-    },
+    // timeInterval: { // 时间间隔,小时为单位
+    // 	type: Number,
+    // 	default: 1
+    // },
     selectedTabColor: {
       // 日期栏选中的颜色
       type: String,
@@ -45,30 +43,24 @@ const _sfc_main = {
       type: String,
       default: "#51bf81"
     },
-    beginTime: {
-      type: String,
-      default: "08:30"
-    },
-    endTime: {
-      type: String,
-      default: "19:30"
-    },
+    // beginTime: {
+    // 	type: String,
+    // 	default: "08:30"
+    // },
+    // endTime: {
+    // 	type: String,
+    // 	default: "19:30"
+    // },
     appointTime: {
       // 预约的时间
       type: Array,
       default() {
         return [];
       }
-    },
-    disableTimeSlot: {
-      // 预约开始和结束时间,来禁用时间段
-      type: Array,
-      default() {
-        return [];
-      }
     }
   },
   watch: {
+    //监控appointTime变化,去控制预约时间的状态
     appointTime: {
       handler(val) {
         if (val && val.length) {
@@ -76,13 +68,7 @@ const _sfc_main = {
         }
       }
     },
-    // disableTimeSlot: {
-    // 	handler(val) {
-    // 		if (val && val.length) {
-    // 			this.initOnload()
-    // 		}
-    // 	}
-    // },
+    //监控排课列表的里面的属性reservation_status的值,从而保持前后端预约时间状态的一致性。
     shcedule_list: {
       handler(val) {
         if (val && val.length) {
@@ -195,7 +181,6 @@ const _sfc_main = {
       //时间段开始时间
       timeQuanEnd: ""
       //时间段结束时间
-      // isTime:[],
     };
   },
   onLoad(e) {
@@ -399,7 +384,6 @@ const _sfc_main = {
       return time;
     },
     //时间数组
-    // this.shcedule_list[{"start_time":1732060800,"end_time":1732063500}];
     initTime(isQuantum) {
       const time = [];
       this.shcedule_list.forEach((cruTiem) => {

Beberapa file tidak ditampilkan karena terlalu banyak file yang berubah dalam diff ini