Jelajahi Sumber

fix: 收藏问题修复

huangziyang 2 hari lalu
induk
melakukan
72a7a01d27

+ 2 - 0
components/Topic/TopicPracticeEnd.vue

@@ -249,6 +249,8 @@ const isRight = (selectAns, rightAns) => {
 // 收藏方法
 const handleStar = (item) => {
   if (!props.onStar) return;
+  console.log(item);
+  
   props.onStar(item).then((res) => {
     uni.showToast({
       title: res ? "已加入收藏" : "已移除收藏",

+ 22 - 14
pages/challenge/index.vue

@@ -25,23 +25,33 @@ import { request } from "../../utils/request";
 import { router } from "../../utils/router";
 import { onShow } from "@dcloudio/uni-app";
 import { ref } from "vue";
+
 const isPay = ref(true);
 
 const p = ref(0);
 onShow(async () => {
-  isPay.value = true;
-  let res;
-  try {
-    res = await request(
-      "api/question_bank/question_reception/challenge_registration_log/detail",
-      {
-        showToast: false,
-      }
-    );
-  } catch (e) {
-    isPay.value = false;
+  const a = uni.getStorageSync("pages/challenge/index");
+  let res = {
+    data: false,
+  };
+  
+  isPay.value = a === "" ? true : a;
+  if (a === "") {
+    isPay.value = true;
+    try {
+      res = await request(
+        "api/question_bank/question_reception/challenge_registration_log/detail",
+        {
+          showToast: false,
+        }
+      );
+      isPay.value = res.data !== "";
+    } catch (e) {
+      isPay.value = false;
+    }
+    uni.setStorageSync("pages/challenge/index", isPay.value);
   }
-  request(
+  await request(
     "api/question_bank/question_reception/recharge_package/list",
     {
       package_type: 2,
@@ -50,8 +60,6 @@ onShow(async () => {
   ).then(async (res) => {
     p.value = res.data.data[0].id;
   });
-  if (res.data) return;
-  isPay.value = false;
 });
 
 const toRule = () => {

+ 3 - 2
pages/challenge/registration.vue

@@ -37,7 +37,7 @@ const rules = {
   pharmacist_type: [
     {
       required: true,
-      message: "请选择报考药师类型",
+      message: "请选择报考执业药师类型",
     },
   ],
 };
@@ -139,6 +139,7 @@ const onSubmit = async () => {
               type: formData.value.pharmacist_type,
             },
           });
+          uni.setStorageSync("pages/challenge/index", null);
         },
         fail(err) {
           console.log(err);
@@ -191,7 +192,7 @@ const onChange = (e) => {
             />
           </view>
           <view class="uni-form-item">
-            <view class="title required">报考药师类型(请选择)</view>
+            <view class="title required">报考执业药师类型(请选择)</view>
             <RadioBlock
               v-model="formData.pharmacist_type"
               name="pharmacist_type"

+ 18 - 13
pages/learn/index.vue

@@ -70,7 +70,11 @@
     </div>
     <div class="context">
       <template v-if="currentIndex === 0 && dataList.length">
-        <QuestionsItem :data="dataList" :isRight="isRight" :catalogue_id="currentTab" />
+        <QuestionsItem
+          :data="dataList"
+          :isRight="isRight"
+          :catalogue_id="currentTab"
+        />
       </template>
       <template v-else-if="currentIndex === 1 && examList.length">
         <div class="card" v-for="item in examList" :key="item.catalogue_id">
@@ -88,11 +92,7 @@
         </div>
       </template>
       <template v-else-if="currentIndex === 2 && favoriteList.length">
-        <QuestionsItem
-          :data="favoriteList"
-          isRight
-          :onClick="toFavorite"
-        />
+        <QuestionsItem :data="favoriteList" isRight :onClick="toFavorite" />
       </template>
       <Empty v-else text="暂无数据"></Empty>
     </div>
@@ -103,11 +103,12 @@
 import Container from "@/components/Container/Container.vue";
 import Empty from "@/components/Empty/Empty.vue";
 import { ref, watch } from "vue";
-import { onShow } from "@dcloudio/uni-app";
+import { onShow, onHide } from "@dcloudio/uni-app";
 import { request } from "../../utils/request";
 import QuestionsItem from "../../components/Topic/QuestionsItem.vue";
 import { router } from "../../utils/router";
 
+const show = ref(true);
 const currentIndex = ref(0);
 const currentTab = ref(0);
 const isRight = ref(1);
@@ -117,6 +118,7 @@ const errorTotal = ref(0);
 const dataList = ref([]);
 const examList = ref([]);
 const favoriteList = ref([]);
+
 const toHistory = (item) => {
   router.push({
     url: "/pages/real/history",
@@ -168,11 +170,11 @@ const toFavorite = () => {
     url: "/pages/learn/favorite",
     params: {
       chapter_id: currentTab.value,
-      title: '收藏'
+      title: "收藏",
     },
   });
 };
-watch(currentIndex, () => {
+watch([currentIndex, show], () => {
   switch (currentIndex.value) {
     case 1:
       requestExamList();
@@ -184,8 +186,7 @@ watch(currentIndex, () => {
       break;
   }
 });
-
-watch(currentTab, () => {
+watch([currentTab, show], () => {
   switch (currentIndex.value) {
     case 0:
       isRight.value = 1;
@@ -202,14 +203,14 @@ watch(currentTab, () => {
       break;
   }
 });
-watch(isRight, () => {
+watch([isRight, show], () => {
   dataList.value = [];
   requestTopic(isRight.value, (data) => {
     dataList.value = data;
   });
 });
-
 onShow(() => {
+  show.value = true;
   request(
     "api/question_bank/question_reception/study_book/get_study_record_title"
   ).then((res) => {
@@ -217,6 +218,10 @@ onShow(() => {
     currentTab.value = res.data.chapter_infos[0].id;
   });
 });
+
+onHide(() => {
+  show.value = false;
+});
 // 示例数据
 </script>
 

+ 1 - 1
pages/learn/rightPractice.vue

@@ -72,7 +72,7 @@ const onStar = (item) =>
         : "api/question_bank/question_reception/topic/cancel_favorite",
       {
         id: item.id,
-        chapter_id: getRoute().params.id,
+        chapter_id: item.chapter_id,
         user_exercise_paper_id: user_exercise_paper_id.value,
       }
     ).then(() => {

+ 1 - 1
pages/regulations/practice.vue

@@ -121,7 +121,7 @@ const onStar = (item) =>
         : "api/question_bank/question_reception/topic/cancel_favorite",
       {
         id: item.id,
-        chapter_id: getRoute().params.id,
+        chapter_id: item.chapter_id,
         user_exercise_paper_id: user_exercise_paper_id.value,
       }
     ).then(() => {

+ 142 - 139
pages/user/settings.vue

@@ -1,13 +1,13 @@
 <template>
-	<Container
-		title="设置"
-		:scrollStyle="{
-			padding: 0
-		}"
-		bgColor="#f8f8f8"
-	>
-	<view>
-<!-- 		<view class="user_box">
+  <Container
+    title="设置"
+    :scrollStyle="{
+      padding: 0,
+    }"
+    bgColor="#f8f8f8"
+  >
+    <view>
+      <!-- 		<view class="user_box">
 			<view class="box_left">
 				<image class="user_image" :src="userInfo.userpic"></image>
 			</view>
@@ -18,147 +18,150 @@
 			<view class="box_right"></view>
 		</view>
 		<view class="setting_list"></view> -->
-		<view class="setting_list">
-			<view class="setting_item_loginout" @click="outLogin()">
-				<text class="setting_title_loginout">退出登录</text>
-				<view class="setting_icon">&gt;</view>
-			</view>
-		</view>
-	</view>
-	</Container>
+      <view class="setting_list">
+        <view class="setting_item_loginout" @click="outLogin()">
+          <text class="setting_title_loginout">退出登录</text>
+          <view class="setting_icon">&gt;</view>
+        </view>
+      </view>
+    </view>
+  </Container>
 </template>
 
 <script>
-import Container from '../../components/Container/Container.vue';
-import CustomerService from '@/components/CustomerService/CustomerService.vue';
+import Container from "../../components/Container/Container.vue";
+import CustomerService from "@/components/CustomerService/CustomerService.vue";
 
 export default {
-	data() {
-		return {
-			userInfo: {
-				username: '',
-				userpic: '',
-				phone: '',
-				status: 0,
-				company_status: 0
-			}
-		};
-	},
-	onLoad() {
-		let userInfo = uni.getStorageSync('userInfo');
-		this.userInfo = userInfo;
-		if (!this.userInfo.userpic) this.userInfo.userpic = 'https://kailin-mp.oss-cn-shenzhen.aliyuncs.com/static/icon/doctor.png';
-	},
-	onShow() {},
-	methods: {
-		outLogin() {
-			uni.showModal({
-				title: '确认退出登录?',
-				success(re) {
-					if (re.confirm) {
-						// 清空登录标识
-						uni.setStorageSync('userLogin', null);
-						// 清空用户信息
-						uni.setStorageSync('userInfo', null);
-						// 跳转到登录页
-						uni.redirectTo({
-							url: '/pages/login/index'
-						});
-					}
-				}
-			});
-		}
-	}
+  data() {
+    return {
+      userInfo: {
+        username: "",
+        userpic: "",
+        phone: "",
+        status: 0,
+        company_status: 0,
+      },
+    };
+  },
+  onLoad() {
+    let userInfo = uni.getStorageSync("userInfo");
+    this.userInfo = userInfo;
+    if (!this.userInfo.userpic)
+      this.userInfo.userpic =
+        "https://kailin-mp.oss-cn-shenzhen.aliyuncs.com/static/icon/doctor.png";
+  },
+  onShow() {},
+  methods: {
+    outLogin() {
+      uni.showModal({
+        title: "确认退出登录?",
+        success(re) {
+          if (re.confirm) {
+            // 清空登录标识
+            uni.setStorageSync("userLogin", null);
+            // 清空用户信息
+            uni.setStorageSync("userInfo", null);
+            uni.setStorageSync("pages/challenge/index", null);
+            // 跳转到登录页
+            uni.redirectTo({
+              url: "/pages/login/index",
+            });
+          }
+        },
+      });
+    },
+  },
 };
 </script>
 
 <style lang="less">
 .user_box {
-	width: 680rpx;
-	height: 180rpx;
-	overflow: hidden;
-	background: #ffffff;
-	padding: 10rpx 35rpx;
-	.box_left {
-		float: left;
-		display: block;
-		width: 140rpx;
-		height: 140rpx;
-		.user_image {
-			display: block;
-			width: 120rpx;
-			height: 120rpx;
-			border-radius: 50%;
-			margin: 10rpx auto;
-		}
-	}
-	.box_center {
-		float: left;
-		width: 300rpx;
-		height: 140rpx;
-		margin-left: 35rpx;
-		.user_name {
-			font-size: 30rpx;
-			line-height: 80rpx;
-		}
-		.user_info {
-			color: #999999;
-			font-size: 24rpx;
-			line-height: 60rpx;
-		}
-	}
-	.box_right {
-		float: right;
-		width: 140rpx;
-		height: 140rpx;
-		font-size: 20rpx;
-		.setting_page {
-			width: 140rpx;
-			height: 140rpx;
-			display: block;
-			overflow: hidden;
-			.setting_icon {
-				width: 60rpx;
-				height: 60rpx;
-				display: block;
-				margin: 40rpx auto;
-			}
-		}
-	}
+  width: 680rpx;
+  height: 180rpx;
+  overflow: hidden;
+  background: #ffffff;
+  padding: 10rpx 35rpx;
+  .box_left {
+    float: left;
+    display: block;
+    width: 140rpx;
+    height: 140rpx;
+    .user_image {
+      display: block;
+      width: 120rpx;
+      height: 120rpx;
+      border-radius: 50%;
+      margin: 10rpx auto;
+    }
+  }
+  .box_center {
+    float: left;
+    width: 300rpx;
+    height: 140rpx;
+    margin-left: 35rpx;
+    .user_name {
+      font-size: 30rpx;
+      line-height: 80rpx;
+    }
+    .user_info {
+      color: #999999;
+      font-size: 24rpx;
+      line-height: 60rpx;
+    }
+  }
+  .box_right {
+    float: right;
+    width: 140rpx;
+    height: 140rpx;
+    font-size: 20rpx;
+    .setting_page {
+      width: 140rpx;
+      height: 140rpx;
+      display: block;
+      overflow: hidden;
+      .setting_icon {
+        width: 60rpx;
+        height: 60rpx;
+        display: block;
+        margin: 40rpx auto;
+      }
+    }
+  }
 }
 .setting_list {
-	overflow: hidden;
-	margin: 10rpx auto;
-	padding: 0rpx 0rpx;
-	.setting_item_loginout {
-		height: 80rpx;
-		display: block;
-		font-size: 26rpx;
-		line-height: 80rpx;
-		margin: 10rpx 40rpx;
-		padding: 0rpx 35rpx;
-		background: #ffffff;
-		background: #ffffff;
-		border-radius: 100rpx 100rpx 100rpx 100rpx;
-		text-align: center;
-	}
-	.setting_item {
-		height: 80rpx;
-		display: block;
-		font-size: 26rpx;
-		line-height: 80rpx;
-		margin: 10rpx auto;
-		padding: 0rpx 35rpx;
-		background: #ffffff;
-		.setting_title {
-		}
-		.setting_title_loginout{
-			color: #999999;
-		}
-		.setting_icon {
-			float: right;
-			color: #999999;
-		}
-	}
+  overflow: hidden;
+  margin: 10rpx auto;
+  padding: 0rpx 0rpx;
+  .setting_item_loginout {
+    height: 80rpx;
+    display: block;
+    font-size: 26rpx;
+    line-height: 80rpx;
+    margin: 10rpx 40rpx;
+    padding: 0rpx 35rpx;
+    background: #ffffff;
+    background: #ffffff;
+    border-radius: 100rpx 100rpx 100rpx 100rpx;
+    text-align: center;
+  }
+  .setting_item {
+    height: 80rpx;
+    display: block;
+    font-size: 26rpx;
+    line-height: 80rpx;
+    margin: 10rpx auto;
+    padding: 0rpx 35rpx;
+    background: #ffffff;
+    .setting_title {
+    }
+    .setting_title_loginout {
+      color: #999999;
+    }
+    .setting_icon {
+      float: right;
+      color: #999999;
+    }
+  }
 }
 </style>