Quellcode durchsuchen

feat: 多规格弹窗

xuqiaoying vor 3 Jahren
Ursprung
Commit
4103230bd3

+ 2 - 2
common/request.js

@@ -6,11 +6,11 @@ var num = 1
 //接口api   
 // export const BASE_URL = 'https://api.xyyxt.net'   //release
 // export const BASE_URL = 'https://test.xyyxt.net'   //预发布
-export const BASE_URL = 'http://120.79.166.78:19012' // 测试环境
+// export const BASE_URL = 'http://120.79.166.78:19012' // 测试环境
 // export const BASE_URL = 'http://42.192.164.187:19005'    //test(后端本地)
 // export const BASE_URL = 'http://192.168.1.222:5055'    //后端本地更新到222
 // export const BASE_URL = 'http://192.168.1.24:5055'    //后端本地
-// export const BASE_URL = 'http://192.168.1.7:5055'    //后端本地
+export const BASE_URL = 'http://192.168.1.7:5055'    //后端本地
 
  //图片上传api
 // export const BASE_IMG_URL = 'https://file.xyyxt.net/'     //release

+ 1 - 1
pages/webview/index.vue

@@ -184,7 +184,7 @@ export default {
     toAuth() {
       if (this.goodsStatus == 1) { //已上架
         uni.navigateTo({
-          url:'/pages3/course/detail?id='+this.goodsId
+          url:'/pages3/course/detail?id='+this.goodsId + '&goodsType=6'
         })
       } else {
         uni.switchTab({

+ 75 - 2
pages2/bank/detail.vue

@@ -132,6 +132,44 @@
 				</view>
 			</view>
 		</u-popup>
+
+		<!-- 选择规格弹窗 -->
+        <u-popup v-model="toggleSkuShow" mode="bottom" border-radius="40">
+			<view class="popup_box">
+                <view class="check_head">
+                    <view class="headers">
+                    	<view class="grade">选择规格</view>
+                        <u-icon name="close" color="#9C9C9C" size="40" @click="closePop()"></u-icon>
+                    </view>
+                </view>
+                <view class="pop_prices">
+                    <view class="lefts">
+						<!-- <image :src="$method.splitImgHost(item.coverUrl, true)" class="imgs"></image> -->
+						<image src="" class="imgs"></image>
+					</view>
+					<view class="rights">
+						<view class="goods_titles">【建筑全科】2022年一建精华 2022年一建精华班</view>
+						<view class="goods_price">¥154.00</view>
+					</view>
+                </view>
+				<view class="lines"></view>
+                <view class="check_con">
+					<view class="grades">班级</view>
+					<view class="grade_names">
+						<view class="course_items" v-for="(item, index) in courseSku" :key="index" :class="{nactive: skuIndex == index}" @click="selectSku(item, index)">
+							{{ item }}
+						</view>
+					</view>
+					<view class="areas">地区</view>
+					<view class="grade_names">
+						<view class="course_items" v-for="(item, index) in courseSku" :key="index" :class="{nactive: skuIndex == index}" @click="selectSku(item, index)">
+							{{ item }}
+						</view>
+					</view>
+                </view>
+                <view class="right_now" @click="rightNowBuy()">确 定</view>
+			</view>
+		</u-popup>
 	</view>
 </template>
 
@@ -156,6 +194,10 @@ export default {
 			goodsExamConfig: [],
 			bugCourseModel: false, // 弹窗
 			hadBuyCourse: {}, // 已购买课程信息
+			toggleSkuShow: false,
+			courseSku: ['基础班', '钻石班', '基础班', '钻石班', '基础班', '钻石班'],
+			skuItem: {},
+            skuIndex: -1,
 		};
 	},
 	filters: {
@@ -298,14 +340,27 @@ export default {
 			if (this.$method.isGoLogin()) {
 				return;
 			}
+			// 判断有没有规格选择
+			if (this.goodsData.specTemplateId) {
+				this.isCarOrBuy = 2
+				this.toggleSkuShow = true
+				return
+			}
 			this.$navTo.togo('/pages2/order/confirm_list?id=' + this.id);
 		},
 		addCart() {
 			if (this.$method.isGoLogin()) {
 				return;
 			}
-
-			let self = this;
+			// 判断有没有规格选择
+			if (this.goodsData.specTemplateId) {
+				this.isCarOrBuy = 1
+				this.toggleSkuShow = true
+				return
+			}
+			this.addShopCart()
+		},
+		addShopCart() {
 			this.$api.addCart({ goodsId: this.id }).then(res => {
 				if (res.data.code == 200) {
 					uni.setStorageSync('updateCart', 1); //提醒刷新购物车
@@ -393,6 +448,24 @@ export default {
 			})
 			this.bugCourseModel = false
 		},
+		closePop() {
+            this.toggleSkuShow = false
+        },
+		selectSku(item, index) {
+            console.log('defhd', item, index)
+            this.skuItem = item
+            this.skuIndex = index
+        },
+        rightNowBuy() {
+            // if (Object.keys(this.skuItem).length == 0) {
+            //     this.$u.toast('请选择科目')
+            //     return
+            // }
+            // if(this.$method.isGoLogin()){
+			// 	return
+			// }
+			// this.$navTo.togo('/pages2/order/confirm_list?id='+this.skuItem.goodsId)
+        }
 	}
 };
 </script>

+ 0 - 5
pages2/bank/question_report.vue

@@ -317,11 +317,6 @@ export default {
             })
         },
 		toBuy(item) {
-            // if (item.goodsType == 1) {
-            //     uni.navigateTo({
-            //         url: '/pages3/course/detail?id='+item.goodsId
-            //     })
-            // } else 
 			if (item.goodsType == 2) {
                 uni.navigateTo({
                     url: '/pages2/bank/detail?id='+item.goodsId

+ 2 - 1
pages2/msg/detail.vue

@@ -300,7 +300,8 @@ export default {
 					break;
 				case 20:
 					this.$navTo.togo('/pages3/course/detail', {
-						id: item.goodsId
+						id: item.goodsId,
+						goodsType: item.goodsType
 					});
 					break;
 				default:

+ 163 - 7
pages3/course/detail.vue

@@ -144,8 +144,8 @@
 				</view>
 			</view>
 			<view style="display: flex;color: #FFFFFF;align-items: center;">
-				<view class="btn1" @click="addCart">加购物车</view>
-				<view class="btn2" @click="buy">立即购买 </view>
+				<view class="btn1" @click="addCart()">加购物车</view>
+				<view class="btn2" @click="buy()">立即购买 </view>
 			</view>
 		</view>
 
@@ -164,6 +164,41 @@
 				</view>
 			</view>
 		</u-popup>
+
+		<!-- 选择规格弹窗 -->
+        <u-popup v-model="toggleSkuShow" mode="bottom" border-radius="40">
+			<view class="popup_box">
+                <view class="check_head">
+                    <view class="headers">
+                    	<view class="grade">选择规格</view>
+                        <u-icon name="close" color="#9C9C9C" size="40" @click="closePop()"></u-icon>
+                    </view>
+                </view>
+                <view class="pop_prices">
+                    <view class="lefts">
+						<!-- <image :src="$method.splitImgHost(item.coverUrl, true)" class="imgs"></image> -->
+						<!-- <image src="" class="imgs"></image> -->
+					</view>
+					<view class="rights">
+						<view class="goods_titles">【建筑全科】2022年一建精华 2022年一建精华班</view>
+						<view class="goods_price">¥154.00</view>
+					</view>
+                </view>
+				<view class="lines"></view>
+                <view class="check_con">
+					<view v-for="(item, index) in specList" :key="index" class="check_items">
+						<view class="grades">{{ item.name }}</view>
+						<view class="grade_names">
+							<!-- :class="{nactive: skuIndex == index}"   -->
+							<view class="course_items" v-for="(child, c_index) in item.specAttrList" :key="c_index" @click="selectSku(child, index, c_index)">
+								{{ child.name }}
+							</view>
+						</view>
+					</view>
+                </view>
+                <view class="right_now" @click="rightNowBuy()">确 定</view>
+			</view>
+		</u-popup>
 	</view>
 </template>
 
@@ -205,6 +240,65 @@ export default {
 			teaIndex: 0,
 			States: {0: 0},
 			goodsType: 1, // 1视频2题库 3补考 4前培 6直播
+			toggleSkuShow: false,
+			courseSku: ['基础班', '钻石班', '基础班', '钻石班', '基础班', '钻石班'],
+			skuItem: {},
+            skuIndex: -1,
+			isCarOrBuy: 1, // 1加入购物车 2立即购买
+			specList: [
+						{
+							"specId":62,
+							"specTemplateId":28,
+							name:"一建规格-001",
+							"code":null,
+							"sort":null,
+							"status":1,
+							specAttrList: [
+								{
+									"specAttributeId":115,
+									"specId":62,
+									name:"一建规格属性0011",
+									"code":null,
+									"sort":null,
+									"status":1
+								},
+								{
+									"specAttributeId":116,
+									"specId":62,
+									name:"一建规格属性0012",
+									"code":null,
+									"sort":null,
+									"status":1
+								}
+							]
+						},
+						{
+							"specId":63,
+							"specTemplateId":28,
+							name:"一建规格-002",
+							"code":null,
+							"sort":null,
+							"status":1,
+							specAttrList: [
+								{
+									"specAttributeId":117,
+									"specId":63,
+									name:"一建规格属性0021",
+									"code":null,
+									"sort":null,
+									"status":1
+								},
+								{
+									"specAttributeId":118,
+									"specId":63,
+									name:"一建规格属性0022",
+									"code":null,
+									"sort":null,
+									"status":1
+								}
+							]
+						}
+					], // 规格列表
 		};
 	},
 	computed: { ...mapGetters(['userInfo','goodsAuditionConfigIdList','playSectionId','hideBuyState']) },
@@ -238,7 +332,7 @@ export default {
 	onShareAppMessage() {
 		return {
 			title: this.detail.goodsName,
-			path: `/pages3/course/detail?id=` + this.id,
+			path: `/pages3/course/detail?id=` + this.id + '&goodsType=' + this.goodsType,
 			imageUrl: this.$method.splitImgHost(this.detail.coverUrl)
 		}
 	},
@@ -367,10 +461,8 @@ export default {
 			if(!item.down&&item.menuList.length==0){
 				this.getMenuList(item)
 			}
-			
 		},
 		addShopCart() {
-			let self = this
 			this.$api.addCart({goodsId:this.id}).then(res => {
 				if(res.data.code==200){
 					uni.setStorageSync('updateCart',1) //提醒刷新购物车
@@ -571,16 +663,60 @@ export default {
 			if(this.$method.isGoLogin()){
 				return
 			}
+			// 判断有没有规格选择
+			if (this.detail.specTemplateId) {
+				this.isCarOrBuy = 2
+				this.toggleSkuShow = true
+				return
+			}
 			this.$navTo.togo('/pages2/order/confirm_list?id='+this.id);
 		},
 		addCart(){
+			// this.getSpecDetail()
+			this.toggleSkuShow = true
+			this.specList.forEach((item, index) => {
+				item.specAttrList.forEach((child) => {
+					child['check'] = false
+				})
+			})
+			console.log('000', this.specList)
+			return
 			if(this.$method.isGoLogin()){
 				return
 			}
+			// 判断有没有规格选择
+			if (this.detail.specTemplateId) {
+				this.isCarOrBuy = 1
+				this.getSpecDetail()
+				return
+			}
 			this.addShopCart()
 		},
-		open(item){
-			item.showChildren = !item.showChildren
+		getSpecDetail() {
+			// ${this.detail.specTemplateId}
+			// 这里id到时候需要改回来
+			console.log('1111111111')
+			this.$http({
+				url: `/app/common/spec/28`,
+				method: 'get',
+				noToken: true
+			}).then((res) => {
+				if (res.data.code == 200) {
+					this.toggleSkuShow = true
+					let data = res.data.data
+					if (data) {
+						this.specList = data && (data.specList || [])
+						this.specList.forEach((item, index) => {
+							item.specAttrList.forEach((child) => {
+								child['check'] = false
+							})
+						})
+						console.log('this.specList', this.specList)
+					}
+				} else {
+					this.$u.toast('暂无数据')
+				}
+			})
 		},
 		change(index){
 			this.current = index;
@@ -723,6 +859,26 @@ export default {
 				})
 			})
 		},
+		closePop() {
+            this.toggleSkuShow = false
+        },
+		selectSku(item, index, c_index) {
+            console.log('defhd', item, index, c_index)
+			this.$set(this.specList[index].specAttrList[c_index], '')
+			// this.specList
+            // this.skuItem = item
+            // this.skuIndex = index
+        },
+        rightNowBuy() {
+            // if (Object.keys(this.skuItem).length == 0) {
+            //     this.$u.toast('请选择科目')
+            //     return
+            // }
+            // if(this.$method.isGoLogin()){
+			// 	return
+			// }
+			// this.$navTo.togo('/pages2/order/confirm_list?id='+this.skuItem.goodsId)
+        }
 	}
 };
 </script>

+ 93 - 0
pages3/course/index.scss

@@ -121,4 +121,97 @@
 			background-color: #F0F0F0;
 		}
 	}
+}
+
+// 选择规格弹窗
+.popup_box {
+    width: 100%;
+    height: 938rpx;
+    padding: 56rpx 56rpx 0rpx;
+    .headers {
+      width: 100%;
+      display: flex;
+      align-items: center;
+      justify-content: space-between;
+      .grade {
+        font-size: 40rpx;
+        font-weight: bold;
+        color: #222222;
+      }
+    }
+	.pop_prices {
+		width: 100%;
+		display: flex;
+		align-items: center;
+		justify-content: space-between;
+		margin: 48rpx 0rpx 40rpx 0rpx;
+		.imgs {
+			width: 204rpx;
+			height: 120rpx;
+			border-radius: 16rpx;
+			margin-right: 24rpx;
+		}
+		.goods_titles {
+			font-size: 28rpx;
+			font-weight: 500;
+			color: #222222;
+		}
+		.goods_price {
+			font-size: 28rpx;
+			font-weight: 500;
+			color: #FC3F3F;
+		}
+	}
+	.lines {
+		width: 100%;
+		height: 2rpx;
+		background: #F0F0F0;
+	}
+	.check_con {
+		width: 100%;
+		height: 500rpx;
+		overflow-y: auto;
+		.check_items {
+			width: 100%;
+			// height: 500rpx;
+		}
+		.grades {
+			font-size: 28rpx;
+			font-weight: 400;
+			color: #969696;
+			margin-bottom: 24rpx;
+		}
+		.grades {
+			margin-top: 40rpx;
+		}
+		.grade_names {
+			display: flex;
+			flex-wrap: wrap;
+		}
+		.course_items {
+			height: 56rpx;
+			background: #F8F8F8;
+			border-radius: 66rpx;
+			padding: 12rpx 30rpx;
+			font-size: 24rpx;
+			color: #222222;
+			margin-bottom: 24rpx;
+			margin-right: 32rpx;
+			&.nactive {
+				background: #D5E4FF;
+				color: #3F8DFD;
+			}
+		}
+	}
+    .right_now {
+        width: 100%;
+        height: 92rpx;
+        line-height: 92rpx;
+        text-align: center;
+        background: #3F8DFD;
+        border-radius: 120rpx;
+        font-size: 32rpx;
+        font-weight: 500;
+        color: #FFFFFF;
+    }
 }

+ 0 - 5
pages4/courseTopic/goodsTopic.vue

@@ -173,11 +173,6 @@ export default {
             uni.navigateBack()
         },
         toDetail() {
-            // if (this.goodsInfo.goodsType == 1) {
-            //     uni.navigateTo({
-            //         url: '/pages3/course/detail?id='+this.goodsInfo.goodsId
-            //     })
-            // } else 
             if (this.goodsInfo.goodsType == 2) {
                 uni.navigateTo({
                     url: '/pages2/bank/detail?id='+this.goodsInfo.goodsId

+ 0 - 5
pages5/examReport/index.vue

@@ -360,11 +360,6 @@ export default {
             })
         },
 		toBuy(item) {
-            // if (item.goodsType == 1) {
-            //     uni.navigateTo({
-            //         url: '/pages3/course/detail?id='+item.goodsId
-            //     })
-            // } else 
 			if (item.goodsType == 2) {
                 uni.navigateTo({
                     url: '/pages2/bank/detail?id='+item.goodsId

+ 0 - 5
pages5/mockExam/registrationSuccess.vue

@@ -210,11 +210,6 @@ export default {
             })
         },
         toBuy(item) {
-            // if (item.goodsType == 1) {
-            //     uni.navigateTo({
-            //         url: '/pages3/course/detail?id='+item.goodsId
-            //     })
-            // } else 
             if (item.goodsType == 2) {
                 uni.navigateTo({
                     url: '/pages2/bank/detail?id='+item.goodsId