ソースを参照

feat:收藏集新增取消收藏功能和活动模考去考试的限制

xuqiaoying 2 年 前
コミット
167cccf96b

+ 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

+ 9 - 3
pages2/bank/collectById.vue

@@ -27,10 +27,10 @@
 					<view class="bt">
 						<view class="left">收藏数<text class="num">{{item.questionNum}}</text></view>
 						<view class="right">
-							<navigator  hover-class="none" :url="'/pages2/subject/collectBank?orderGoodsId='+orderGoodsId+'&id='+item.examId">
+							<navigator  hover-class="none" :url="'/pages2/subject/collectBank?orderGoodsId='+orderGoodsId+'&examId='+item.examId + '&distinction=1'">
 								<view class="btn">重做</view>
 							</navigator>
-							<navigator  hover-class="none" :url="'/pages2/subject/collectBank?orderGoodsId='+orderGoodsId+'&id='+item.examId+'&explain=1'">
+							<navigator  hover-class="none" :url="'/pages2/subject/collectBank?orderGoodsId='+orderGoodsId+'&examId='+item.examId+'&explain=1' + '&distinction=1'">
 								<view class="btn">解析</view>
 							</navigator>
 							<!-- <view class="btn">解析</view> -->
@@ -51,11 +51,17 @@
 					<view class="bt">
 						<view class="left">收藏数<text class="num">{{item.num}}</text></view>
 						<view class="right">
-							<navigator  hover-class="none" :url="'/pages2/subject/collectTypeBank?orderGoodsId='+orderGoodsId+'&type='+item.type">
+							<!-- <navigator  hover-class="none" :url="'/pages2/subject/collectTypeBank?orderGoodsId='+orderGoodsId+'&type='+item.type">
 								<view class="btn">重做</view>
 							</navigator>
 							<navigator  hover-class="none" :url="'/pages2/subject/collectTypeBank?orderGoodsId='+orderGoodsId+'&type='+item.type+'&explain=1'">
 								<view class="btn">解析</view>
+							</navigator> -->
+							<navigator  hover-class="none" :url="'/pages2/subject/collectTypeBank?orderGoodsId='+orderGoodsId+'&type='+item.type + '&distinction=2'">
+								<view class="btn">重做</view>
+							</navigator>
+							<navigator  hover-class="none" :url="'/pages2/subject/collectTypeBank?orderGoodsId='+orderGoodsId+'&type='+item.type+'&explain=1'+ '&distinction=2'">
+								<view class="btn">解析</view>
 							</navigator>
 						</view>
 					</view>

+ 15 - 6
pages2/subject/collect.vue

@@ -39,10 +39,10 @@
 					<view class="bt">
 						<view class="left">收藏数<text class="num">{{item.questionNum}}</text></view>
 						<view class="right">
-							<navigator  hover-class="none" :url="'/pages2/subject/collectBank?id='+item.examId">
+							<navigator  hover-class="none" :url="'/pages2/subject/collectBank?examId='+item.examId + '&distinction=1'">
 								<view class="btn">重做</view>
 							</navigator>
-							<navigator  hover-class="none" :url="'/pages2/subject/collectBank?id='+item.examId+'&explain=1'">
+							<navigator  hover-class="none" :url="'/pages2/subject/collectBank?examId='+item.examId+'&explain=1' + '&distinction=1'">
 								<view class="btn">解析</view>
 							</navigator>
 							<!-- <view class="btn">解析</view> -->
@@ -63,12 +63,18 @@
 					<view class="bt">
 						<view class="left">收藏数<text class="num">{{item.num}}</text></view>
 						<view class="right">
-							<navigator  hover-class="none" :url="'/pages2/subject/collectTypeBank?type='+item.type">
+							<navigator  hover-class="none" :url="'/pages2/subject/collectBank?type='+item.type + '&distinction=2'">
 								<view class="btn">重做</view>
 							</navigator>
-							<navigator  hover-class="none" :url="'/pages2/subject/collectTypeBank?type='+item.type+'&explain=1'">
+							<navigator  hover-class="none" :url="'/pages2/subject/collectBank?type='+item.type+'&explain=1' + '&distinction=2'">
 								<view class="btn">解析</view>
 							</navigator>
+							<!-- <navigator  hover-class="none" :url="'/pages2/subject/collectTypeBank?type='+item.type + '&distinction=2'">
+								<view class="btn">重做</view>
+							</navigator>
+							<navigator  hover-class="none" :url="'/pages2/subject/collectTypeBank?type='+item.type+'&explain=1' + '&distinction=2'">
+								<view class="btn">解析</view>
+							</navigator> -->
 						</view>
 					</view>
 				</view>
@@ -105,7 +111,7 @@ export default {
 		this.orderGoodsId = option.orderGoodsId || '';
 		this.listGoodsUserQuestion();
 		this.examaperList();
-		this.getData();
+		
 		
 		uni.getSystemInfo({
 			success:(e) => {
@@ -122,6 +128,9 @@ export default {
 			}
 		})
 	},
+	onShow() {
+		this.getData()
+	},
 	methods: {
 		getData() {
 			if(this.type == 1) {
@@ -355,7 +364,7 @@ page {
 }
 .wrongList{
 	margin-top:20rpx;
-	.item{;
+	.item{
 		background: #FFFFFF;
 		border-radius: 16rpx;
 		padding: 0 30rpx;

+ 100 - 9
pages2/subject/collectBank.vue

@@ -659,6 +659,19 @@
           </template>
 
           <view class="footer_btn">
+            <view
+              class="collect show"
+              @click="collect(collectList[bankIndex], bankIndex, bank)"
+            >
+              <view v-if="collectList[bankIndex]">
+                <image src="/static/icon/collected.png" mode=""></image>
+                <view>取消收藏</view>
+              </view>
+              <view v-if="!collectList[bankIndex]">
+                <image src="/static/icon/collect.png" mode=""></image>
+                <view>收藏</view>
+              </view>
+            </view>
             <view class="flex_center" @click="openFooterTab">
               <view class="up-icon">
                 <image src="/static/up.png"></image>
@@ -709,7 +722,7 @@
 export default {
   data() {
     return {
-      id: "",
+      examId: "",
       current: 0,
       questionList: [],
       ast: ["A", "B", "C", "D", "E", "F", "G"],
@@ -721,13 +734,17 @@ export default {
       goodsId: "",
       explain: "",
       orderGoodsId: "",
+      distinction: 1, // 1试卷归类,2题型归类
+      subjectType: 0, // 题目类型
     };
   },
   onLoad(option) {
     this.orderGoodsId = option.orderGoodsId || "";
-    this.id = option.id;
-    this.explain = option.explain;
-
+    const { examId, explain, type, distinction} = option
+    this.examId = examId
+    this.explain = explain
+    this.distinction = distinction
+    this.subjectType = type
     let showDialog = uni.getStorageSync("showDialog");
 
     if (showDialog) {
@@ -736,8 +753,11 @@ export default {
       this.showDialog = true;
       uni.setStorageSync("showDialog", "1");
     }
-
+    if (this.distinction == 1) {
     this.collectQuestionExamQuestionList();
+    } else {
+      this.goodsCollectList()
+    }
   },
   onUnload() {},
   methods: {
@@ -750,10 +770,22 @@ export default {
     collectQuestionExamQuestionList() {
       this.$api
         .collectQuestionExamQuestionList({
-          examId: this.id,
+          examId: this.examId,
+        })
+        .then((res) => {
+          this.analysteData(res.data.rows)
+        });
+    },
+    goodsCollectList() {
+      this.$api.goodsCollectList({
+          type: this.subjectType,
         })
         .then((res) => {
-          res.data.rows.forEach((item, index) => {
+          this.analysteData(res.data.rows)
+        })
+    },
+    analysteData(rows) {
+      rows.forEach((item, index) => {
             if (typeof item.jsonStr == "string") {
               item.jsonStr = JSON.parse(item.jsonStr);
 
@@ -861,6 +893,12 @@ export default {
                     /<img/gi,
                     '<img style="max-width:100%;"'
                   ));
+                if (this.distinction == 2) {
+                  item.content && (item.content = item.content.replace(
+                    /<img/gi,
+                    '<img style="max-width:100%;"'
+                  ));
+                }
                 if (this.explain) {
                   item.ques = item.ans;
                 }
@@ -887,8 +925,61 @@ export default {
             }
           });
 
-          this.questionList = res.data.rows;
-        });
+          this.questionList = rows;
+          // new Array(12).fill(true)
+          this.collectList = new Array(this.questionList.length).fill(true)
+          console.log('this.collectList', this.collectList)
+    },
+    /**
+     * @param {Object} state
+     * @param {Object} index
+     * 收藏
+     */
+    collect(state, index, bank) {
+      console.log('0000', state, index, bank);
+      // return
+      if (!state) {
+        this.$api.collectQuestion({
+            examId: this.examId || bank.examId,
+            questionId: bank.questionId,
+            goodsId: bank.goodsId || "",
+            orderGoodsId: bank.orderGoodsId,
+          })
+          .then((res) => {
+            if (res.data.code == 200) {
+              this.$set(this.collectList, index, true);
+              uni.showToast({
+                title: "收藏成功",
+                duration: 2000,
+                icon: "none",
+              });
+            } else {
+              uni.showToast({
+                title: "收藏失败",
+                duration: 2000,
+                icon: "none",
+              });
+            }
+          });
+      } else {
+        this.$api.deleteCollectQuestion(bank.collectQuestionId).then((res) => {
+            if (res.data.code == 200) {
+              this.$set(this.collectList, index, false)
+              uni.showToast({
+                title: "取消收藏成功",
+                duration: 2000,
+                icon: "none",
+              });
+            } else {
+              uni.showToast({
+                title: "取消收藏失败",
+                duration: 2000,
+                icon: "none",
+              });
+            }
+          });
+      }
+      return;
     },
     /**
      * @param {Object} e单选点击

+ 15 - 7
pages5/examCount/index.vue

@@ -8,7 +8,8 @@
 				<view class="time">{{timeText}}</view>
 			</view>
 			
-			<view class="btn" @click="examBank()" :class="{disabled:!((nowTime > start) && (nowTime < end ))}">开始考试</view>
+			<view v-if="mockActivity == 1" class="btn" @click="examBank()">开始考试</view>
+			<view v-else class="btn" @click="examBank()" :class="{disabled:!((nowTime > start) && (nowTime < end ))}">开始考试</view>
 		</view>
 	</view>
 </template>
@@ -33,10 +34,10 @@ export default {
 			end:0,
 			percent:0,
 			examEndTime:0,
+			mockActivity: 0,
 		};
 	},
 	onLoad(option){
-		console.log('option', option)
 		this.examEndTime = option.examEndTime;
 		this.mockName = option.mockName || ''
 		this.subscribeId = option.subscribeId
@@ -44,6 +45,7 @@ export default {
 		this.examId = option.examId
 		this.timeLimit = +option.limit || 0
 		this.start = +option.start;
+		this.mockActivity = option.mockActivity
 		this.end = (this.timeLimit* 60) + this.start ;
 		this.timer = setInterval(() => {
 			this.timeText = this.getDuring()
@@ -76,15 +78,21 @@ export default {
 			
 		},
 		examBank() {
-			if(((this.nowTime > this.start) && (this.nowTime < this.end ))) {
+			if (this.mockActivity == 1) {
 				uni.redirectTo({
 					url:'../examBank/index?examId='+this.examId+'&eachExamId='+this.eachExamId+'&subscribeId='+this.subscribeId+'&examEndTime='+this.examEndTime+'&examStartTime='+this.start
 				})
 			} else {
-				uni.showToast({
-					icon:'none',
-					title:'不在考试时间'
-				})
+				if(((this.nowTime > this.start) && (this.nowTime < this.end ))) {
+					uni.redirectTo({
+						url:'../examBank/index?examId='+this.examId+'&eachExamId='+this.eachExamId+'&subscribeId='+this.subscribeId+'&examEndTime='+this.examEndTime+'&examStartTime='+this.start
+					})
+				} else {
+					uni.showToast({
+						icon:'none',
+						title:'不在考试时间'
+					})
+				}
 			}
 		}
 	},

+ 6 - 2
pages5/examList/index.vue

@@ -363,13 +363,14 @@ export default {
 					},
 				}).then((res) => {
 					if (res.data.code == 200) {
-						const { examTime, startTime, endTime, eachExamId} = res.data.data
+						const { examTime, startTime, endTime, eachExamId, mockActivity} = res.data.data
 						let o_item = {
 							...item,
 							applySiteExamTime: examTime,
 							applySiteStartTime: startTime,
 							applySiteEndTime: endTime,
 							eachExamId: eachExamId,
+							mockActivity: mockActivity
 						}
 						// item.applySiteExamTime = examTime // 当前时间的时间戳
 						// item.applySiteStartTime = startTime
@@ -399,7 +400,10 @@ export default {
 
 			this.itemIndex = index;
 			uni.navigateTo({
-				url:'../examCount/index?start='+this.$method.TimeTotimestamp(this.$method.timestampToTime(item.applySiteExamTime) + ' ' + item.applySiteStartTime)+'&limit='+item.timeLimit+'&examId='+item.examId+'&eachExamId='+item.eachExamId+'&subscribeId='+item.subscribeId+'&mockName='+item.applyName +'&examEndTime='+this.$method.TimeTotimestamp(this.$method.timestampToTime(item.applySiteExamTime) + ' ' + item.applySiteEndTime)
+				url:'../examCount/index?start='+this.$method.TimeTotimestamp(this.$method.timestampToTime(item.applySiteExamTime) + ' ' + 
+				item.applySiteStartTime)+'&limit='+item.timeLimit+'&examId='+item.examId+'&eachExamId='+item.eachExamId+'&subscribeId='
+				+item.subscribeId+'&mockName='+item.applyName +'&examEndTime='+this.$method.TimeTotimestamp(this.$method.timestampToTime(item.applySiteExamTime) 
+				+ ' ' + item.applySiteEndTime)+'&mockActivity=' + item.mockActivity
 			})
 		},