浏览代码

活动模考和商品多规则

xuqiaoying 3 年之前
父节点
当前提交
13840ffca3

+ 9 - 9
pages/learn/index.vue

@@ -718,16 +718,16 @@ export default {
 				title: '拼命加载中...',
 				mask:true,
 			})
-			var confirmDetail = true;
-			if (item.educationName == '继续教育') { 
-				if(item.officialName && item.businessName == '二级' && item.projectName == '建造师') { 
-					confirmDetail = await this.userConfirmInfoDetail()
-				}
-			}
+			// var confirmDetail = true;
+			// if (item.educationName == '继续教育') { 
+			// 	if(item.officialName && item.businessName == '二级' && item.projectName == '建造师') { 
+			// 		confirmDetail = await this.userConfirmInfoDetail()
+			// 	}
+			// }
 			
-			if(!confirmDetail) {
-				return;
-			}
+			// if(!confirmDetail) {
+			// 	return;
+			// }
 
 			this.itemIndex = index
 			if (item.gradeStatus == 1 && item.status == 1 && (item.serviceEndTime > this.sysTime) && (item

+ 29 - 17
pages2/bank/detail.vue

@@ -356,7 +356,7 @@ export default {
 			// 判断有没有规格选择
 			if (this.goodsData.specTemplateId) {
 				this.isCarOrBuy = 2
-				this.toggleSkuShow = true
+				this.getSpecDetail()
 				return
 			}
 			this.$navTo.togo('/pages2/order/confirm_list?id=' + this.id);
@@ -370,13 +370,13 @@ export default {
 			// 判断有没有规格选择
 			if (this.goodsData.specTemplateId) {
 				this.isCarOrBuy = 1
-				this.toggleSkuShow = true
+				this.getSpecDetail()
 				return
 			}
-			this.addShopCart()
+			this.addShopCart(this.id)
 		},
-		addShopCart() {
-			this.$api.addCart({ goodsId: this.id }).then(res => {
+		addShopCart(goodsId) {
+			this.$api.addCart({ goodsId: goodsId }).then(res => {
 				if (res.data.code == 200) {
 					uni.setStorageSync('updateCart', 1); //提醒刷新购物车
 					uni.showToast({
@@ -393,19 +393,22 @@ export default {
 				method: 'get',
 				noToken: true
 			}).then((res) => {
-				if (res.data.code == 200) {
+				let data = res.data.data
+				if (data) {
 					this.toggleSkuShow = true
-					let data = res.data.data
-					if (data) {
-						this.specList = data && (data.specList || [])
-						this.specList.forEach((item, index) => {
-							item.specAttrList.forEach((child, i_index) => {
-								this.$set(this.specList[index].specAttrList[i_index], 'check', false)
-							})
+					this.specList = data && (data.specList || [])
+					this.specList.forEach((item, index) => {
+						item.specAttrList.forEach((child, i_index) => {
+							this.$set(this.specList[index].specAttrList[i_index], 'check', false)
 						})
-					}
+					})
 				} else {
-					this.$u.toast('暂无数据')
+					if (this.isCarOrBuy == 1) { // 加入购物车
+						this.addShopCart(this.id)
+					} else {
+						this.$navTo.togo('/pages2/order/confirm_list?id='+this.id);
+					}
+					this.closePop()
 				}
 			})
 		},
@@ -530,10 +533,19 @@ export default {
 				this.$u.toast('请先选择所有的规格')
 				return
 			}
+			if (this.skuItem.goodsStatus == 0) {
+				this.$message.warning('商品已下架, 请重新选择')
+				return
+			}
+			let sysTime = this.$method.timest()
+			if (sysTime <= this.skuItem.validityStartTime || sysTime >= this.skuItem.validityEndTime) {
+				this.$message.warning('商品不在有效期, 请重新选择')
+				return
+			}
             if (this.isCarOrBuy == 1) { // 加入购物车
-				this.addShopCart()
+				this.addShopCart(this.skuItem.goodsId)
 			} else {
-				this.$navTo.togo('/pages2/order/confirm_list?id='+this.id);
+				this.$navTo.togo('/pages2/order/confirm_list?id='+this.skuItem.goodsId);
 			}
 			this.closePop()
         }

+ 31 - 18
pages3/course/detail.vue

@@ -423,8 +423,9 @@ export default {
 				this.getMenuList(item)
 			}
 		},
-		addShopCart() {
-			this.$api.addCart({goodsId:this.id}).then(res => {
+		addShopCart(goodsId) {
+			// this.id
+			this.$api.addCart({goodsId: goodsId}).then(res => {
 				if(res.data.code==200){
 					uni.setStorageSync('updateCart',1) //提醒刷新购物车
 					uni.showToast({
@@ -627,14 +628,12 @@ export default {
 			// 判断有没有规格选择
 			if (this.detail.specTemplateId) {
 				this.isCarOrBuy = 2
-				this.toggleSkuShow = true
+				this.getSpecDetail()
 				return
 			}
 			this.$navTo.togo('/pages2/order/confirm_list?id='+this.id);
 		},
 		addCart(){
-			// this.getSpecDetail()
-			// return
 			if(this.$method.isGoLogin()){
 				return
 			}
@@ -644,7 +643,7 @@ export default {
 				this.getSpecDetail()
 				return
 			}
-			this.addShopCart()
+			this.addShopCart(this.id)
 		},
 		getSpecDetail() {
 			// || 35
@@ -653,19 +652,22 @@ export default {
 				method: 'get',
 				noToken: true
 			}).then((res) => {
-				if (res.data.code == 200) {
+				let data = res.data.data
+				if (data) {
 					this.toggleSkuShow = true
-					let data = res.data.data
-					if (data) {
-						this.specList = data && (data.specList || [])
-						this.specList.forEach((item, index) => {
-							item.specAttrList.forEach((child, i_index) => {
-								this.$set(this.specList[index].specAttrList[i_index], 'check', false)
-							})
+					this.specList = data && (data.specList || [])
+					this.specList.forEach((item, index) => {
+						item.specAttrList.forEach((child, i_index) => {
+							this.$set(this.specList[index].specAttrList[i_index], 'check', false)
 						})
-					}
+					})
 				} else {
-					this.$u.toast('暂无数据')
+					if (this.isCarOrBuy == 1) { // 加入购物车
+						this.addShopCart(this.id)
+					} else {
+						this.$navTo.togo('/pages2/order/confirm_list?id='+this.id);
+					}
+					this.closePop()
 				}
 			})
 		},
@@ -858,10 +860,21 @@ export default {
 				this.$u.toast('请先选择所有的规格')
 				return
 			}
+			if (this.skuItem.goodsStatus == 0) {
+				this.$message.warning('商品已下架, 请重新选择')
+				return
+			}
+			
+			let sysTime = this.$method.timest()
+			if (sysTime <= this.skuItem.validityStartTime || sysTime >= this.skuItem.validityEndTime) {
+				this.$message.warning('商品不在有效期, 请重新选择')
+				return
+			}
+
             if (this.isCarOrBuy == 1) { // 加入购物车
-				this.addShopCart()
+				this.addShopCart(this.skuItem.goodsId)
 			} else {
-				this.$navTo.togo('/pages2/order/confirm_list?id='+this.id);
+				this.$navTo.togo('/pages2/order/confirm_list?id='+this.skuItem.goodsId);
 			}
 			this.closePop()
         }

+ 0 - 1
pages5/exam/index.vue

@@ -109,7 +109,6 @@ export default {
 			this.$navTo.togo('/pages5/examList/index?state='+state);
 		},
 		goResult(){
-			console.log(111)
 			this.$navTo.togo('/pages5/liveList/index');
 		}
 	},

+ 12 - 1
pages5/examList/index.vue

@@ -16,6 +16,7 @@
 		
 		<view class="record">
 			<template v-if=" param.mockStatus == 0">
+				<view v-if="recordList.length">
 				<view class="examList" v-for="(item,index) in recordList" :key="index">
 					<view class="main">
 						<view class="top" @click="showDetails(item)">
@@ -55,9 +56,12 @@
 						</view>
 					</view>
 				</view>
+				</view>
+				<view v-else class="nodata">暂无相关数据</view>
 			</template>
 			
 			<template v-if=" param.mockStatus == 1">
+				<view v-if="recordList.length">
 				<view class="examList" v-for="(item,index) in recordList" :key="index">
 					<view class="main">
 						<view class="top" @click="showDetails(item)">
@@ -107,6 +111,8 @@
 						
 					</view>
 				</view>
+				</view>
+				<view v-else class="nodata">暂无相关数据</view>
 			</template>
 			
 		</view>
@@ -185,7 +191,6 @@ export default {
 		...mapGetters(['userInfo'])
 	},
 	onLoad(option) {
-		console.log('查看返回的onloaddddd')
 		this.param.mockStatus = option.state || 0
 		
 		this.endDate = this.$method.timestampToTime(new Date().getTime() / 1000).replace(/-/g,'/');
@@ -656,4 +661,10 @@ page {
 	background: #007aff !important;
 	color: #fff !important;
 }
+.nodata {
+	text-align: center;
+    margin-top: 100rpx;
+    font-size: 32rpx;
+    color: #222;
+}
 </style>

+ 129 - 33
pages5/mockExam/examApply.vue

@@ -63,7 +63,7 @@
                     </u-form-item>
                 </view> -->
 
-                <view class="items">
+                <!-- <view class="items">
                     <view class="item_title">
                         <text class="star_red">*</text>
                         <text class="number">04</text>
@@ -74,8 +74,25 @@
                             <input v-model.trim="examform.userPhone" class="uni-input" placeholder="请输入" />
                         </view>
                     </u-form-item>
+                </view> -->
+                <view class="items">
+                    <view class="item_title">
+                        <text class="star_red">*</text>
+                        <text class="number">04</text>
+                        <text class="category">报考专业</text>
+                    </view>
+                    <u-form-item label=" " label-width="74" prop="majorId" :border-bottom='false'>
+                        <view class="inputs">
+                            <view class="item_box">
+                                <picker class="picker" mode="selector" :range="majorList" range-key="majorName" :value="examform.majorId"
+                                 @change="majorChange">
+                                    <view class="pick_con" style="fontSize: 40rpx">{{ majorName }}</view>
+                                </picker>
+                                <u-icon class="icon" name="arrow-down"></u-icon>
+                            </view>
+                        </view>
+                    </u-form-item>
                 </view>
-
                 <view class="items">
                     <view class="item_title">
                         <text class="star_red">*</text>
@@ -84,7 +101,7 @@
                     </view>
                     <u-form-item label=" " label-width="74" prop="userMajors" :border-bottom='false'>
                         <u-checkbox-group :wrap='true' @change="checkboxGroupChange">
-                            <u-checkbox v-model="item.checked" v-for="(item, index) in checkboxList" :key="index" :name="item.name">
+                            <u-checkbox v-model="item.checked" v-for="(item, index) in subjectLists" :key="index" :name="item.subjectId">
                                 {{ item.name }}
                             </u-checkbox>
                         </u-checkbox-group>
@@ -113,27 +130,39 @@ export default {
                 callback(new Error("请选择报考科目"))
             }
         }
+        var validatorMajorId = (rule, value, callback) => {
+            if (value) {
+                callback()
+            } else {
+                callback(new Error("请选择专业"))
+            }
+        }
         return {
             examform: {
                 userName: '',
                 userSex: '',
                 companyName: '',
-                userIdCard: '',
-                userPhone: '',
+                // userIdCard: '',
+                // userPhone: '',
                 userMajors: [],
+                majorId: '',
             },
             rules: {
                 userName: [{ required: true, message: '请输入姓名', trigger: ['blur', 'change']}],
                 userSex: [{ required: true, message: '请选择性别', trigger: ['blur', 'change']}],
                 companyName: [{ required: true, message: '请输入企业名称', trigger: ['blur', 'change']}],
                 // userIdCard: [{ required: true, message: '请输入身份证号', trigger: ['blur', 'change']}],
-                userPhone: [{ required: true, message: '请输入手机号码', trigger: ['blur', 'change']}],
-                userMajors: [{ validator: validatorMajor, trigger: ['blur', 'change']},
-                            ],
+                majorId: [{ validator: validatorMajorId, trigger: ['change','blur']}],
+                userMajors: [{ validator: validatorMajor, trigger: ['blur', 'change']}],
             },
             checkboxList: [],
             activityId: '', // 活动id
             subLoading: true,
+            majorList: [], // 专业
+            subjectLists: [], // 科目
+            majorName: '',
+            startTime: '',
+            endTime: '',
         }
     },
     onLoad(option) {
@@ -141,21 +170,25 @@ export default {
         if (option.scene) {
             let tid = decodeURIComponent(option.scene)
             this.activityId = tid.split('=')[1]
-            console.log('activityId: ', this.activityId)
-            this.getActivity()
+            // this.getActivity()
         } else {
             this.activityId = option.tid
-            this.getActivity()
+            // this.getActivity()
         }
     },
     onShow() {
-        // console.log('222222222222222')
-        // if (!uni.getStorageSync('user_account')) {
-		// 	uni.navigateTo({
-		// 		url: '/pages4/login/login?isBack=true'
-		// 	})
-		// 	return
-		// }
+        console.log('activityId: ', this.activityId)
+        if (!uni.getStorageSync('user_account')) { // 未登录
+            console.log('未登录')
+			uni.navigateTo({
+				url: '/pages4/login/login?isBack=true'
+			})
+			return
+		} else {
+            // 已登录
+            console.log('已登录')
+            this.getActivity()
+        }
         
     },
     // 必须要在onReady生命周期,因为onLoad生命周期组件可能尚未创建完毕
@@ -163,26 +196,46 @@ export default {
 		this.$refs.uForm.setRules(this.rules)
 	},
     methods: {
-        // 获取活动信息
+        // 获取活动信息(专业和科目)
         getActivity() {
             this.$http({
-                url: `/app/common/detail/${this.activityId}`,
+                url: `/apply/activity/detail/${this.activityId}`,
                 method: 'get',
-                noToken: true,
             }).then((res) => {
                 if (res.data.code == 200) {
-                    if (res.data.data.majors) {
-                        let majors = res.data.data.majors.split(',')
-                        this.checkboxList = majors.map((item) => {
+                    this.hadCheck()
+                    let data = res.data.data || {}
+                    const { majorList, subjectList, endTime, startTime} = data
+                    this.majorList = majorList || []
+                    this.startTime = startTime
+                    this.endTime = endTime
+                    if (subjectList) {
+                        this.checkboxList = subjectList.map((item) => {
                             return {
-                                name: '《' + item + '》',
-                                checked: false
+                                name: '《' + item.subjectName + '》',
+                                checked: false,
+                                ...item
                             }
                         })
                         console.log('checkboxList:', this.checkboxList)
                     }
                 }
             })
+        },
+        // 校验用户是否已报名
+        hadCheck() {
+            this.$http({
+                url: `/apply/activity/check/${this.activityId}`,
+                method: 'get',
+            }).then((res) => {
+                if (res.data.data) {
+                    // 已经报名
+                    uni.navigateTo({
+                        url: '/pages5/mockExam/registrationSuccess?endTime=' + this.endTime + '&startTime=' + this.startTime 
+                        + '&activityId=' + this.activityId
+                    })
+                }
+            })
         },
 		checkboxGroupChange(e) {
             this.examform.userMajors = e
@@ -190,27 +243,55 @@ export default {
 		radioGroupChange(e) {
 			console.log(e, this.examform.userSex);
 		},
+        majorChange(e) {
+            this.examform.userMajors = []
+            let index = e.detail.value
+            const { majorName, majorId, mockMajorId } = this.majorList[index]
+            this.majorName = majorName
+            this.examform.majorId = majorId
+            // console.log('1111majorId', this.examform.majorId)
+            this.subjectLists = this.checkboxList.filter(e => e.mockMajorId == mockMajorId)
+            this.subjectLists = this.subjectLists.map((item) => {
+                return {
+                    name: '《' + item.subjectName + '》',
+                    checked: false,
+                    ...item
+                }
+            })
+        },
         submit() {
             this.$refs.uForm.validate(valid => {
 				if (valid) {
-					console.log('验证通过');
                     if (!this.subLoading) {
                         return
                     }
                     this.subLoading = false
+                    const { userName, userSex, companyName, majorId, userMajors} = this.examform
+                    let arrs = []
+                    userMajors.forEach((item, index) => {
+                        let findItem = this.subjectLists.find(e => e.subjectId == item)
+                        if (findItem) {
+                            arrs.push(findItem)
+                        }
+                    })
+                    let mockSubjectIds = arrs.map(e => e.subjectId).join(',')
+                    let mockMajorSubjectIds = arrs.map(e => e.mockMajorSubjectId).join(',')
                     let params = {
                         activityId: this.activityId,
-                        ...this.examform,
+                        userName: userName,
+                        userSex: userSex,
+                        companyName: companyName,
+                        mockMajorId: majorId,
+                        mockSubjectIds: mockSubjectIds,
+                        mockMajorSubjectIds: mockMajorSubjectIds, 
                     }
-                    params.userMajors = this.examform.userMajors.join(',')
-                    console.log('eret', params)
+                    // console.log('eret', params)
                     this.$http({
-                        url: '/app/common/launch',
+                        url: '/apply/activity/launch',
                         method: 'post',
                         data: params,
-                        noToken: true,
+                        // noToken: true,
                     }).then((res) => {
-                        console.log('提交', res)
                         this.subLoading = true
                         if (res.data.code == 200) {
                             let data = res.data.data
@@ -284,6 +365,21 @@ page {
             align-items: center;
             padding-left: 24rpx;
         }
+        .item_box {
+            height: 86rpx;
+            display: flex;
+            align-items: center;
+            .pick_con {
+                width: 500rpx;
+                height: 86rpx;
+                // font-size: 32rpx;
+            }
+            .text {
+                flex:1;
+                display: flex;
+                align-items: center;
+            }
+        }
     }
     .btns {
         width: 100%;

+ 56 - 47
pages5/mockExam/registrationSuccess.vue

@@ -8,20 +8,25 @@
             </view>
         </view>
         <view class="exam_times">
-            <view class="start_time all_time">
-                <view class="time_left">
-                    <text class="numbers">{{ startTime | getLastDay }}</text>
-                    <text class="days">天</text>
+            <view class="time_up">
+                <view class="start_time all_time">
+                    <view class="time_left">
+                        <text class="numbers">{{ startTime | getLastDay }}</text>
+                        <text class="days">天</text>
+                    </view>
+                    <view class="words">距模考开始时间</view>
                 </view>
-                <view class="words">距模考开始时间</view>
-            </view>
-            <view class="lines"></view>
-            <view class="end_time all_time">
-                <view class="time_left">
-                    <text class="numbers">{{ endTime | getLastDay }}</text>
-                    <text class="days">天</text>
+                <view class="lines"></view>
+                <view class="end_time all_time">
+                    <view class="time_left">
+                        <text class="numbers">{{ endTime | getLastDay }}</text>
+                        <text class="days">天</text>
+                    </view>
+                    <view class="words">距模考结束时间</view>
                 </view>
-                <view class="words">距模考结束时间</view>
+            </view>
+            <view class="time_down">
+                <view class="look_mock" @click="toLookMock()">立即查看模考</view>
             </view>
         </view>
         <view class="mains">
@@ -58,32 +63,12 @@
                 </view>
             </view>
         </view>
-        <!-- <view class="distance_time">
-            <view class="time_item">
-                距模考开始时间还有:
-                <u-count-down v-if="sDay > 1" :timestamp="lastStartDay" :show-days="true" separator="zh" 
-					:show-hours="false" :show-minutes="false" :show-seconds="false" font-size="28"
-					bg-color="#DFECFD" separator-color="#222222" color="#222222" separator-size="28">
-				</u-count-down>
-                <text v-else>0天</text>
-            </view>
-            <view class="time_item">
-                距模考结束时间还有:
-                <u-count-down v-if="eDay > 1" :timestamp="lastEndDay" :show-days="true" separator="zh" 
-					:show-hours="false" :show-minutes="false" :show-seconds="false" font-size="28"
-					bg-color="#DFECFD" separator-color="#222222" color="#222222" separator-size="28">
-				</u-count-down>
-                <text v-else>0天</text>
-            </view>
-            <view class="time_item">活动详情请咨询业务人员或致电020-87085982/87085983</view>
-        </view> -->
         <view class="activity_phone">
             <view class="titles">活动咨询电话</view>
             <view class="phone_num">020-87085982 / 020-87085983 / 18565459156</view>
         </view>
         <view class="exam_entry">
             参加本次活动,请添加此次活动专属微信号
-            <!-- <text class="entrys">考试入口:</text>请进入祥粤云学堂小程序或者网站, 在个人中心找到模考功能进行考试。 -->
         </view>
 
         <view v-if="courseList.length" class="course_list">
@@ -111,7 +96,6 @@
                                 </view>
                             </view>
                             <view v-if="item.buyUserNum" class="joins">
-                                <!-- <image class="people" src="/static/index/people.png"></image> -->
                                 <!-- 为0时,不显示 -->
                                 <view class="people">{{ item.buyUserNum }}人参与</view>
                             </view>
@@ -133,10 +117,10 @@ export default {
         return {
             startTime: '',
             endTime: '',
-            lastStartDay: '',
-            lastEndDay: '',
-            sDay: '',
-            eDay: '',
+            // lastStartDay: '',
+            // lastEndDay: '',
+            // sDay: '',
+            // eDay: '',
             activityId: '',
             courseList: [],
             pageNum: 1,
@@ -167,13 +151,11 @@ export default {
     },
     computed: { ...mapGetters(['hideBuyState']) },
     onLoad(option) {
-        console.log('option: ', option)
+        // console.log('option: ', option)
+        // endTime=1663084800&startTime=1662998400&activityId=13
         this.startTime = option.startTime
         this.endTime = option.endTime
         this.activityId = option.activityId
-        // this.getAct()
-        // this.startTime = "1663041599"
-        // this.endTime = "1663127999"
     },
     onShow() {
 		this.courseList = []
@@ -221,6 +203,12 @@ export default {
                 })
             }
         },
+        // 查看模考
+        toLookMock(){
+            uni.navigateTo({
+                url: '/pages5/examList/index?state=0'
+            })
+        }
     }
 }
 </script>
@@ -272,14 +260,35 @@ page {
 }
 .exam_times {
     margin-top: 28rpx;
-    display: flex;
-    align-items: center;
-    justify-content: space-between;
     width: 670rpx;
-    height: 178rpx;
+    // height: 178rpx;
     background: #FFFFFF;
     border-radius: 24rpx;
     padding: 0rpx 64rpx;
+    .time_up {
+        display: flex;
+        align-items: center;
+        justify-content: space-between;
+        width: 100%;
+        height: 178rpx;
+    }
+    .time_down {
+        display: flex;
+        align-items: center;
+        justify-content: center;
+        margin-bottom: 40rpx;
+        .look_mock {
+            width: 288rpx;
+            height: 80rpx;
+            line-height: 80rpx;
+            text-align: center;
+            background: #FFFFFF;
+            border-radius: 160rpx;
+            border: 2rpx solid #F67205;
+            font-size: 32rpx;
+            color: #F67205;
+        }
+    }
     .all_time {
         .time_left {
             text-align: center;
@@ -467,9 +476,9 @@ page {
 }
 .activity_phone {
     margin: 40rpx 0rpx 56rpx 0rpx;
-    padding: 32rpx 0rpx 0rpx 44rpx;
+    padding: 32rpx 0rpx 32rpx 44rpx;
     width: 670rpx;
-    height: 148rpx;
+    // height: 148rpx;
     background: #FFFFFF;
     border-radius: 24rpx;
     .titles {