Browse Source

refactor: 优化站点配置、主题逻辑与付费校验逻辑

1. 更新站点配置为根路径,关闭自定义 tabbar 和返回顶部按钮
2. 简化主题获取逻辑,固定使用浅色主题
3. 新增全局付费状态变量,统一替换页面内硬编码的付费校验逻辑
4. 调整目录页面进度条样式,修复布局溢出问题
5. 完善 Lock 组件参数,新增 payFlag 属性和关闭回调
408249787@qq.com 1 week ago
parent
commit
ebfa4dfb7f

+ 1 - 23
.cool/theme/index.ts

@@ -76,29 +76,7 @@ export function getConfig(key: string): string {
  */
 const getTheme = () => {
 	let value: string | null;
-
-	// #ifdef APP
-	const appInfo = uni.getAppBaseInfo();
-	// @ts-ignore
-	const appTheme = appInfo.appTheme as string;
-	const osTheme = uni.getSystemInfoSync().osTheme!;
-
-	// 如果 appTheme 为 auto,则跟随系统主题,否则使用 appTheme
-	value = appTheme == "auto" ? osTheme : appTheme;
-	isAuto.value = appTheme == "auto";
-	// #endif
-
-	// #ifdef H5 || MP
-	const hostTheme = uni.getAppBaseInfo().hostTheme;
-	if (hostTheme) {
-		// 如果有 hostTheme,则使用 hostTheme
-		value = hostTheme;
-	} else {
-		// 默认使用 light 主题
-		value = "light";
-	}
-	// #endif
-
+	value = "light";
 	return value as Theme;
 };
 

+ 11 - 2
components/lock.uvue

@@ -1,6 +1,7 @@
 <script setup lang='ts'>
 import { wechatPay, wechatPayRequest, wechatPayQuery, wechatPayCancel } from '@/services/user'
 import { ref } from 'vue'
+const emit = defineEmits(['close'])
 const props = defineProps({
   record: {
     type: Object,
@@ -13,14 +14,19 @@ const props = defineProps({
   platFormLock: {
     type: Boolean,
     default: true
+  },
+  payFlag: {
+    type: Boolean,
+    default: false
   }
 })
 const visible = ref(false)
 function handleOpen() {
-  if (!props.isPay || props.platFormLock) {
+  if (!props.isPay) {
     return
   }
-  if (!props.record.isPay && !props.record.trialPlay) {
+  console.log(2)
+  if (!props.payFlag && !props.record.trialPlay) {
     visible.value = true
   }
   else {
@@ -33,6 +39,8 @@ async function getPayStatus(outTradeNo: string) {
   })
   if (res.code !== 1000) {
     getPayStatus(outTradeNo)
+  }else{
+    emit('close',true)
   }
 }
 
@@ -74,6 +82,7 @@ const handlePay = async () => {
               title: "订单已取消",
               icon: 'success'
             });
+            emit('close',false)
           }
         })
       }

+ 3 - 3
config/index.ts

@@ -12,10 +12,10 @@ export const ignoreTokens: string[] = [];
 export const config = {
 	name: "Cool Unix",
 	locale: "zh-tw",
-	website: "https://cool-js.com",
+	website: "/",
 	showDarkButton: false,
-	isCustomTabBar: true,
-	backTop: true,
+	isCustomTabBar: false,
+	backTop: false,
 	wx: {
 		debug: false
 	},

+ 8 - 3
pages/catalog/detail.uvue

@@ -268,7 +268,7 @@ onUnmounted(() => {
         <view class="control-progress">
           <view class="before"></view>
           <view v-for="(item, i) in menu2Items" :key="item.id"
-            class="py-2 px-3 flex items-center flex-row justify-center gap-[5px] relative z-[1]"
+            class="py-2 px-3 flex items-center flex-row justify-center ov gap-[5px]  relative z-[1]"
             :class="{ '!bg-[#fff] rounded-l-full': progress2 == i + 1 }" @tap="progress2 = i + 1">
             <cl-image :src="item.icon" mode="heightFix" class="!h-[28px] !w-[50px]"></cl-image>
             <text class="text-[12px]  font-bold" :class="{ '!text-[#2BA0F3]': progress2 == i + 1 }">{{ item.name
@@ -355,13 +355,18 @@ onUnmounted(() => {
   color: #fff;
 
   .control-progress {
-    @apply fixed top-1/2 right-[0px] flex flex-col gap-[3px] z-[100] h-[280px];
+    @apply fixed top-1/2 right-[0px] flex flex-col gap-[3px] z-[100] h-[280px] w-[105px];
     transform: translateY(-50%);
-
+    view{
+      overflow: initial !important;
+    }
     .before {
       @apply absolute top-0 right-0 h-full w-full bg-[#2BA0F3];
       border-radius: 25px 0 0 25px;
     }
+    .ov{
+      overflow: initial !important;
+    }
   }
 }
 

+ 9 - 2
pages/catalog/index.uvue

@@ -16,9 +16,11 @@ const visible = ref<boolean>(false)
 const dataList = ref<SubjectCatalogResult[]>([])
 const catalog = ref<SubjectCatalogResult>()
 const courseList = ref<SubjectCourseResult>()
+const record = ref<any>()
 async function getDataList() {
   const id = dict.getValueByLabelMapByType('index_subject_id')['物理']
   const res = await fetchSubjectAppInfo({ id })
+   record.value = res
   dataList.value = res.catalogList || []
   catalog.value = res?.catalogList?.[0]
   courseList.value = res?.courseList || []
@@ -97,6 +99,11 @@ function debouncedOnScroll(e: any) {
     })
   })
 }
+function handleClose(val: boolean) {
+  if (val) {
+    getDataList()
+  }
+}
 </script>
 
 <template>
@@ -133,8 +140,8 @@ function debouncedOnScroll(e: any) {
             <Progress :num="6" size="12px"
               :percentage="course.courseUserProgress ? course.courseUserProgress?.status == 1 ? 6 : course.courseUserProgress?.assistantProgress : 0" />
           </view>
-          <Lock v-if="!course.trialPlay && !course.payFlag || !course.platFormLock" :record="course" isPay
-            :platFormLock="course.platFormLock" />
+          <Lock v-if="(!course.trialPlay && !record.payFlag) || !course.platFormLock" :record="course" isPay
+            :platFormLock="course.platFormLock" :payFlag="record.payFlag" @close="handleClose" />
         </view>
       </scroll-view>
     </view>

+ 3 - 1
pages/chinese/index.uvue

@@ -13,9 +13,11 @@ const isLoading = ref(true)
 const visible = ref<boolean>(false)
 const dataList = ref<SubjectCatalogResult[]>([])
 const catalog = ref<SubjectCatalogResult>()
+const record = ref<any>()
 async function getDataList() {
   const id = dict.getValueByLabelMapByType('index_subject_id')['语文']
   const res = await fetchSubjectConfigInfo({ id })
+  record.value = res
   dataList.value = res.catalogList || []
   catalog.value = res?.catalogList?.[0]
 }
@@ -80,7 +82,7 @@ function handleDetail(item: SubjectCatalogResult) {
           <!-- <view>
             <Progress :progress="30" />
           </view> -->
-          <Lock v-if="!course.trialPlay && !course.payFlag" :record="course" />
+          <Lock v-if="!course.trialPlay && !record.payFlag" :record="course" :payFlag="record.payFlag" />
         </view>
       </scroll-view>
     </view>

+ 3 - 1
pages/english/index.uvue

@@ -12,8 +12,10 @@ const isLoading = ref(true)
 const visible = ref<boolean>(false)
 const dataList = ref<SubjectCatalogResult[]>([])
 const catalog = ref<SubjectCatalogResult>()
+const record = ref<any>()
 async function getDataList() {
   const res = await fetchSubjectConfigInfo({ id: router.query().id })
+  record.value = res
   dataList.value = res.catalogList || []
   catalog.value = res?.catalogList?.[0]
 }
@@ -79,7 +81,7 @@ function handleDetail(item: SubjectCatalogResult) {
           <!-- <view>
             <Progress :progress="30" />
           </view> -->
-          <Lock v-if="!course.trialPlay && !course.payFlag" :record="course" />
+          <Lock v-if="!course.trialPlay && !record.payFlag" :record="course" :payFlag="record.payFlag" />
         </view>
       </scroll-view>
     </view>

+ 3 - 1
pages/game/index.uvue

@@ -13,9 +13,11 @@ const isLoading = ref(true)
 const visible = ref<boolean>(false)
 const dataList = ref<SubjectCatalogResult[]>([])
 const catalog = ref<SubjectCatalogResult>()
+const record = ref<any>()
 async function getDataList() {
   const id = dict.getValueByLabelMapByType('index_subject_id')['娱乐']
   const res = await fetchSubjectConfigInfo({ id })
+  record.value = res
   dataList.value = res.catalogList || []
   catalog.value = res?.catalogList?.[0]
 }
@@ -80,7 +82,7 @@ function handleDetail(item: SubjectCatalogResult) {
           <!-- <view>
             <Progress :progress="30" />
           </view> -->
-          <Lock v-if="!course.trialPlay && !course.payFlag" :record="course" />
+          <Lock v-if="!course.trialPlay && !record.payFlag" :record="course" :payFlag="record.payFlag" />
         </view>
       </scroll-view>
     </view>

+ 3 - 1
pages/mix/index.uvue

@@ -12,8 +12,10 @@ const isLoading = ref(true)
 const visible = ref<boolean>(false)
 const dataList = ref<SubjectCatalogResult[]>([])
 const catalog = ref<SubjectCatalogResult>()
+const record = ref<any>()
 async function getDataList() {
   const res = await fetchSubjectConfigInfo({ id: router.query().id })
+  record.value = res
   dataList.value = res.catalogList || []
   catalog.value = res?.catalogList?.[0]
 }
@@ -79,7 +81,7 @@ function handleDetail(item: SubjectCatalogResult) {
           <!-- <view>
             <Progress :progress="30" />
           </view> -->
-          <Lock v-if="!course.trialPlay && !course.payFlag" :record="course" />
+          <Lock v-if="!course.trialPlay && !record.payFlag" :record="course" :payFlag="record.payFlag" />
         </view>
       </scroll-view>
     </view>