wangxy 5 hónapja
szülő
commit
13bd37d96b

+ 23 - 16
components/catalogue/catalogue.vue

@@ -13,7 +13,7 @@
 								<!-- 章名 -->
 								<text class="collapse-name">{{item.zhangName}}</text>
 								<!-- 锁 -->
-								<template>
+								<template v-if="AuthCode !== 'VIP'">
 									<view class="collapse-lock" v-if="index!=0"></view>
 								</template>
 							</view>
@@ -26,6 +26,7 @@
 					</view>
 				</uni-collapse-item>
 			</uni-collapse>
+			<tip-small-dialog ref="confirmDialogRef" @confirm-btn="handleConfirmPay" :content="Message"></tip-small-dialog>
 		</view>
 	</uni-popup>
 </template>
@@ -40,25 +41,25 @@
 	import {
 		toast
 	} from "@/utils/common.js"
+	import {getUserIdentity} from "@/utils/common.js"
+	import {MESSAGE_VISITER_TO_LOGIN,MESSAGE_BEFORE_PAY} from "@/utils/constant.js"
+    import tipSmallDialog from '@/components/dialog/tipSmallDialog.vue'
+	
 
 	const $emit = defineEmits(['change-zhang'])
 
-	const props = defineProps({
-		nianji: {
-			type: [String, Number],
-		},
-		xueke: {
-			type: [String, Number],
-		}
-	})
-
 	const {
+		nianji,
+		xueke,
 		getCatalogue,
 	} = useCatalogue(props);
 
 	const popupRef = ref(null); // 索引
+	const confirmDialogRef = ref(null);
 	const list = ref([]); // 章节
 	const activeCollapse = ref('');
+	const Message = MESSAGE_BEFORE_PAY;
+	const AuthCode = getUserIdentity(); // 用户身份
 
 	/**
 	 * @summary 展示弹窗 暴露函数
@@ -98,18 +99,24 @@
 	 * @param({zhangId:string}) data
 	 */
 	function handleSelectZhang(data,index) {
-		if(index!=0){
-			toast("付费章节");
+		if(index !=0 && AuthCode == 'Visitor'){
+			// 游客
+			toast(MESSAGE_VISITER_TO_LOGIN)
+			return;
+		}
+
+		if(index !=0 && AuthCode == 'Not-Vip'){
+			// 非VIP
+			popupRef.value.close();
+			confirmDialogRef.value.handleShow();
 			return;
 		}
 		$emit('change-zhang', Object.assign({}, data));
 		handleClose();
 	}
-
-	function handleExpand() {
-		console.log('zhankai')
+	function handleConfirmPay() {
+		uni.redirectTo({ url: '/pages/pay/svip' })
 	}
-
 	defineExpose({
 		showPopup
 	})

+ 7 - 2
components/catalogue/useCatalogue.js

@@ -10,15 +10,20 @@ import {
 	catchError
 } from "@/utils/common.js"
 import * as httpCatalogue from "@/api/catalogue.js"
+import {useXuekeNianji} from "@/utils/cacheManager.js"
 
 export function useCatalogue(props) {
+	const {getXueke} = useXuekeNianji();
+	
+	const { xueke = null, nianji = null } = getXueke()
+	
 	const data = reactive({
 		xueke: null,
 		nianji: null
 	})
 
-	data.nianji = props.nianji;
-	data.xueke = props.xueke;
+	data.nianji = xueke;
+	data.xueke = nianji;
 
 	async function getCatalogue() {
 		return await catchError(httpCatalogue.getCatalogue({

+ 6 - 0
pages/my/index.vue

@@ -141,4 +141,10 @@
 		const instance = getCurrentInstance();
 		// console.log(instance.appContext.config.globalProperties,'instance.appContext.config.globalProperties')
 	})
+
+  function checkWrong() {
+    uni.redirectTo({
+      url: '/pages/wrong/index'
+    })
+  }
 </script>

+ 2 - 6
pages/selectGradesTerms/index.vue

@@ -87,12 +87,8 @@
 		}) {
 			updateXueke(data.activeNianji, data.activeXueke)
 			// 数序
-			data.activeXueke == SHUXUE && uni.redirectTo({
-				url: `/pages/study/index?xueke=${data.activeXueke}&nianji=${data.activeNianji}&flag=selectGrades`
-			})
-			// 英语
-			data.activeXueke == YINGYU && uni.redirectTo({
-				url: `/pages/study/index?xueke=${data.activeXueke}&nianji=${data.activeNianji}&flag=selectGrades`
+			uni.redirectTo({
+				url: `/pages/study/index?flag=selectGrades`
 			})
 		}
 

+ 1 - 3
pages/study/index.vue

@@ -5,8 +5,7 @@
 		</shuxueZhangjie>
 		<!-- 蛋 -->
 		<egg-dialog ref="eggDialogRef" @eggBtn="eggBtn"></egg-dialog>
-		<catalogue ref="catalogueRef" :nianji="selectZhang.nianji" :cardId="selectZhang.cardId"
-			@change-zhang="handleChangeZhang"></catalogue>
+		<catalogue ref="catalogueRef" @change-zhang="handleChangeZhang"></catalogue>
 		<CustomTabBar></CustomTabBar>
 	</view>
 
@@ -154,7 +153,6 @@
 	}
 
 	function handleChangeZhang(data) {
-		console.log("章", data);
 		selectZhang.value = data;
 		getZhangInfo(true)
 	}

+ 4 - 13
pages/unitTest/index.vue

@@ -98,13 +98,8 @@
 			zhangId:  zhangId.value
 		}))
 		
-		// 数学	
-		xueke.value == SHUXUE && uni.redirectTo({
-			url: `/pages/study/index?nianji=${nianji.value}&xueke=${xueke.value}&zhangId=${data.zhangId}`
-		})
-		// 英语
-		xueke.value == YINGYU && uni.redirectTo({
-			url: `/pages/study/index?nianji=${nianji.value}&xueke=${xueke.value}&zhangId=${data.zhangId}`
+		uni.redirectTo({
+			url: `/pages/study/index?zhangId=${data.zhangId}`
 		})
 	}
 	
@@ -112,12 +107,8 @@
 	
 	function handleBack() {
 		// 数学
-		xueke.value == SHUXUE && uni.redirectTo({
-			url: `/pages/study/index?nianji=${nianji.value}&xueke=${xueke.value}&zhangId=${zhangId.value}`
-		})
-		// 英语
-		xueke.value == YINGYU && uni.redirectTo({
-			url: `/pages/study/index?nianji=${nianji.value}&xueke=${xueke.value}&zhangId=${zhangId.value}`
+		uni.redirectTo({
+			url: `/pages/study/index?zhangId=${zhangId.value}`
 		})
 	}
 	

+ 58 - 2
pages/wrong/index.vue

@@ -1,11 +1,67 @@
 <template>
 	<view>
-		
+    <uni-section title="实心标签" type="line">
+      <view class="uni-padding-wrap uni-common-mt">
+        <uni-segmented-control :current="data.current" :values="data.items" style-type="button"
+                               active-color="#007aff" @clickItem="onChangeTab" />
+      </view>
+      <view class="content">
+        <view v-if="data.current === 0">
+          <!--数学-->
+          <uni-list>
+            <uni-list-item v-for="item in data.ShuxueList">
+              <template v-slot:body>
+                <view class="slot-box">
+                  {{item}}
+                  <text class="slot-text">title</text>
+                  <text class="slot-text">date</text>
+                  <text class="slot-text">wrong</text>
+                  <button>查看错题</button>
+                </view>
+              </template>
+            </uni-list-item>
+            <uni-load-more :status="data.moreShuxue"></uni-load-more>
+          </uni-list>
+        </view>
+        <view v-if="data.current === 1">
+          <!--英语-->
+          <uni-list>
+            <uni-list-item v-for="item in data.YingyuList">
+              <template v-slot:body>
+                <view class="slot-box">
+                  {{item}}
+                  <text class="slot-text">title</text>
+                  <text class="slot-text">date</text>
+                  <text class="slot-text">wrong</text>
+                  <button>查看错题</button>
+                </view>
+              </template>
+            </uni-list-item>
+            <uni-load-more :status="data.moreYingyu"></uni-load-more>
+          </uni-list>
+        </view>
+      </view>
+    </uni-section>
 	</view>
 </template>
 
 <script setup>
-	
+	import {reactive, computed} from "vue";
+
+  const data = reactive({
+    items: ['选项卡1', '选项卡2', '选项卡3'],
+    current: 0,
+    ShuxueList: [],
+    YingyuList: [],
+    moreYingyu: 'more',
+    moreShuxue: 'more'
+  })
+
+  function onChangeTab(e) {
+    if (this.current !== e.currentIndex) {
+      this.current = e.currentIndex
+    }
+  }
 </script>
 
 <style>

+ 1 - 1
utils/cacheManager.js

@@ -110,7 +110,7 @@ export function useXuekeNianji() {
 	
 	// 获取学科年级
 	function getXueke() {
-		return cacheManager.get(NIANJI_XUEKE)
+		return cacheManager.get(NIANJI_XUEKE) || {}
 	}
 	
 	return {

+ 18 - 0
utils/common.js

@@ -1,3 +1,5 @@
+import cacheManager from "./cacheManager.js"
+
 /**
 * 显示消息提示框
 * @param content 提示的标题
@@ -50,3 +52,19 @@ export function catchError(promise) {
 		})
 	})
 }
+
+// 是否是会员
+export function getUserIdentity() {
+	const auth = cacheManager.get('auth');
+	if (auth) {
+		if (auth.cardList.some(item => item === auth.catdId)) {
+			// VIP
+			return 'VIP'
+		}
+		// 非VIP
+		return 'Not-Vip';
+	} else {
+		// 游客
+		return 'Visitor';
+	}
+}

+ 7 - 3
utils/constant.js

@@ -25,16 +25,20 @@
 	},
 ];
 export const SHUXUE = 1; // 数学
-export const YINGYU = 1; // 英语
+export const YINGYU = 2; // 英语
  
 export const xueke_list = [
 	{
 		label: "数学",
-		id: SHUXUE
+		id: SHUXUE,
+		cardId:1
 	},
 	{
 		label: "英语",
-		id: YINGYU
+		id: YINGYU,
+		cardId: 2
 	}
 ]
 
+export const MESSAGE_BEFORE_PAY = `当前为非会员模式请先购买!`;
+export const MESSAGE_VISITER_TO_LOGIN = `当前为游客模式请登录!`;