408249787@qq.com há 1 dia atrás
pai
commit
4d4687d3b9

+ 2 - 1
pages/catalog/index.uvue

@@ -38,7 +38,8 @@ onMounted(async () => {
 })
 const cardsScrollView = ref<any>(null)
 
-function handleDetail(item: SubjectCatalogResult) {
+function handleDetail(item: SubjectCourseResult) {
+  if ((!item.trialPlay && !item.payFlag) || !item.platFormLock || item.studyUnitLock) return
   // if (!item.payFlag && !item.trialPlay) {
   //   uni.showToast({
   //     title: '请先购买',

+ 1 - 0
pages/chinese/index.uvue

@@ -66,6 +66,7 @@ function handleDetail(item: SubjectCatalogResult) {
   //   })
   //   return
   // }
+  if (userInfo.value?.memberLevel === 'default') return
   router.push({
     path: "/pages/english/detail",
     query: {

+ 1 - 0
pages/english/index.uvue

@@ -65,6 +65,7 @@ function handleDetail(item: SubjectCatalogResult) {
   //   })
   //   return
   // }
+  if (userInfo.value?.memberLevel === 'default') return
   router.push({
     path: "/pages/english/detail",
     query: {

+ 92 - 9
pages/index/home.uvue

@@ -10,7 +10,10 @@ import Mix from './components/mix.uvue'
 import Game from './components/game.uvue'
 import Exchange from './components/exchange.uvue'
 import MathModal from './components/math.uvue'
-
+import { bindWechatOpenId } from "@/services/user";
+import { useUi } from "@/uni_modules/cool-ui";
+import { exchangeCode } from '@/services/user'
+const ui = useUi();
 const menuList = computed(() => {
 	return [
 		...dict.getChildrenList('index_subject_id'),
@@ -52,15 +55,38 @@ function handlePage(val: any) {
 	selected.value = val.code
 
 }
-onMounted(() => {
-	console.log(menuList.value)
-})
-function handleView(url) {
-	router.push({ path: url })
-}
 const userInfo = computed(() => user.info.value?.userInfo)
+
+
 const visible = ref(false)
 const visible2 = ref(false)
+const visible3 = ref(false)
+onMounted(async () => {
+	if (!userInfo.value.wxOpenId) {
+		ui.showConfirm({
+			title: "提示",
+			message: "您当前未绑定微信,是否绑定微信?",
+			confirmText: "绑定",
+			cancelText: "取消",
+			callback: async (action) => {
+				if (action === "confirm") {
+					await handleBind()
+				}
+				else {
+					userInfo.value.wxOpenId = true
+				}
+				if (userInfo.value.memberLevel === 'default') {
+					visible3.value = true
+				}
+			},
+		});
+		return
+	} else if (userInfo.value.memberLevel === 'default') {
+		visible3.value = true
+		return
+	}
+
+})
 function copyUrl() {
 	uni.setClipboardData({
 		data: 'www.xiaoxiongcode.com',
@@ -72,7 +98,46 @@ function copyUrl() {
 		}
 	});
 }
+const handleBind = async () => {
+	uni.login({
+		provider: 'weixin',
+		success: async (res) => {
+			await bindWechatOpenId({ code: res.code })
+			uni.showToast({
+				title: '授权成功,请重新登录'
+			})
+			await user.get()
+		}
+	})
+}
+const code = ref<string>('')
 
+async function handleExchange() {
+	if (!code.value) {
+		uni.showToast({
+			title: '请输入兑换码',
+			icon: 'none'
+		})
+		return
+	}
+	try {
+		await exchangeCode({
+			exchangeCode: code.value,
+			subjectId: dict.getValueByLabelMapByType('index_subject_id')['物理'],
+		})
+		await user.get()
+		uni.showToast({
+			title: '兑换成功',
+			icon: 'success'
+		})
+		visible3.value = false
+	} catch (err: any) {
+		uni.showToast({
+			title: err.message,
+			icon: 'error'
+		})
+	}
+}
 </script>
 <template>
 	<cl-page :backTop="false">
@@ -91,7 +156,7 @@ function copyUrl() {
 
 			</view>
 		</view>
-		<cl-float-view :left="20" :bottom="100">
+		<cl-float-view :left="20" :bottom="100" v-if="!userInfo.roleCodes?.includes('show_time')">
 			<view
 				class="flex flex-col items-center p-1 px-4 justify-center gap-1 w-[40px] h-[40px] transition-all duration-300"
 				@tap="visible = true">
@@ -124,7 +189,9 @@ function copyUrl() {
 				<view class="text-center " v-if="userInfo?.memberLevel !== 'default'">
 					<cl-text class="text-center" color="#999" :size="14">账号:小程序登录手机账号 </cl-text>
 					<cl-text class="text-center" color="#999" :size="14"> 密码:初始密码为123456 </cl-text>
-					<cl-text class="text-center" color="#999" :size="14">少儿编程网址: www.xiaoxiongcode.com </cl-text>
+					<cl-text class="text-center" v-if="!userInfo.roleCodes?.includes('show_time')" color="#999"
+						:size="14">少儿编程网址: www.xiaoxiongcode.com </cl-text>
+					<cl-text class="text-center" v-else color="#999" :size="14">少儿编程网址: ************* </cl-text>
 					<cl-button type="primary" size="small" @tap="copyUrl"> 复制网址 </cl-button>
 				</view>
 				<view class="text-center " v-else>
@@ -132,6 +199,18 @@ function copyUrl() {
 				</view>
 			</view>
 		</cl-popup>
+		<cl-popup v-model="visible3" showClose :size="400" :show-header="false" direction="center">
+			<view class="flex flex-col items-center justify-center gap-4 py-7 bg-slate-50">
+				<cl-text class="text-center " color="#333" :size="25"> ——激活会员—— </cl-text>
+
+				<input
+					class="w-[200px] h-[40px] bg-[#F5F5F5] border-[1px] border-[#333] border-solid rounded-[20px] px-[10px]"
+					v-model="code" placeholder="请输入兑换码"></input>
+
+				<cl-button class="mt-4" size="large" type="primary" block @tap="handleExchange"> 兑换 </cl-button>
+
+			</view>
+		</cl-popup>
 		<Physics v-if="selected === 'physics'" />
 		<Chinese v-else-if="selected === 'chinese'" />
 		<English v-else-if="selected === 'english'" />
@@ -158,4 +237,8 @@ function copyUrl() {
 		-1px 1px 0 #000,
 		1px 1px 0 #000;
 }
+
+.check {
+	background: linear-gradient(0deg, #FBD00E 0%, #FBEC92 100%);
+}
 </style>

+ 1 - 0
pages/math/index.uvue

@@ -65,6 +65,7 @@ function handleDetail(item: SubjectCatalogResult) {
   //   })
   //   return
   // }
+  if (userInfo.value?.memberLevel === 'default') return
   router.push({
     path: "/pages/english/detail",
     query: {

+ 1 - 0
pages/mix/index.uvue

@@ -65,6 +65,7 @@ function handleDetail(item: SubjectCatalogResult) {
   //   })
   //   return
   // }
+  if (userInfo.value?.memberLevel === 'default') return
   router.push({
     path: "/pages/english/detail",
     query: {

+ 1 - 0
pages/test/index.uvue

@@ -38,6 +38,7 @@ onMounted(async () => {
 const cardsScrollView = ref<any>(null)
 
 function handleDetail(item: SubjectCourseTestResult) {
+  if (item?.lockFlag) return
   router.push({
     path: "/pages/catalog/web-view",
     query: {

+ 26 - 0
pages/user/components/weixin.uvue

@@ -0,0 +1,26 @@
+<template>
+	<view class="flex flex-col w-[80vw]">
+		<cl-button type="success" @tap="wechatLogin">
+			<cl-image src="https://oss.xiaoxiongcode.com/static/个人中心/微信.png" mode="heightFix" height="20px"
+				width="auto"></cl-image>
+			成功按钮</cl-button>
+	</view>
+</template>
+
+<script setup lang="ts">
+import { type PropType } from "vue";
+import type { LoginForm } from "./types";
+import { useRefs, } from "@/.cool";
+
+const props = defineProps({
+	form: {
+		type: Object as PropType<LoginForm>,
+		default: () => ({})
+	}
+});
+
+const emit = defineEmits(["success"]);
+
+const refs = useRefs();
+
+</script>

+ 26 - 11
pages/user/login.uvue

@@ -13,33 +13,44 @@
 				</cl-text>
 			</view>
 			<view class="group">
-
 				<view class="w-[80vw]">
 					<!-- <cl-tabs v-model="val" :list="list" fill :form="formData" @change="tabsChange"></cl-tabs> -->
 					<cl-form v-model="formData" :pt="{ className: 'mt-1' }">
 						<view v-if="val === 'quickly_login'">
 							<phone :form="formData" />
 						</view>
-						<view v-else>
+						<view v-else-if="val === 'password'">
 							<password :form="formData" />
 						</view>
+
 						<view class="flex flex-row items-center justify-center mb-5">
-							<cl-button :disabled="!agree || !agree2"
+							<cl-button v-if="val === 'weixin'"
+								:pt="{ className: '!h-[45px] !rounded-full w-[200px] mx-auto' }" type="success"
+								@tap="toWechatLogin">
+								<view class="flex flex-row items-center justify-center">
+									<cl-image src="https://oss.xiaoxiongcode.com/static/个人中心/微信.png" mode="heightFix"
+										height="20px" width="auto"></cl-image>
+									<view class="ml-2">
+										微信快捷登录
+									</view>
+								</view>
+							</cl-button>
+							<cl-button v-else :disabled="!agree || !agree2"
 								:pt="{ className: '!h-[45px] !rounded-full w-[200px] mx-auto' }" :loading="loading"
 								@tap="toLogin">
 								登录
 							</cl-button>
 						</view>
-						<cl-checkbox v-model="agree">
+						<cl-checkbox v-model="agree" v-if="val !== 'weixin'">
 							<view class="flex flex-row items-center w-full text-[12px]">
 								同意并阅读
 								<cl-text :size="12" color="primary" @tap.stop="toAgreement">
 									《用户服务协议》
 								</cl-text>
-							
+
 							</view>
 						</cl-checkbox>
-							<cl-checkbox v-model="agree2">
+						<cl-checkbox v-model="agree2" v-if="val !== 'weixin'">
 							<view class="flex flex-row items-center w-full text-[12px]">
 								同意并阅读
 								<cl-text :size="12" color="primary" @tap.stop="toPrivacy">
@@ -51,9 +62,9 @@
 				</view>
 			</view>
 			<view class="absolute bottom-20 w-full flex flex-row  gap-4 items-center justify-center">
-				<view>
+				<view v-if="val !== 'weixin'">
 					<cl-button type="success" :pt="{ className: '!h-[40px] !rounded-full w-[40px] mx-auto !p-1' }"
-						:loading="loading" @tap="toWechatLogin">
+						:loading="loading" @tap="tabsChange('weixin')">
 						<cl-image src="https://oss.xiaoxiongcode.com/static/个人中心/微信.png" mode="heightFix" height="20px"
 							width="auto"></cl-image>
 					</cl-button>
@@ -63,7 +74,7 @@
 						</cl-text>
 					</view>
 				</view>
-				<view v-if="val === 'password'">
+				<view v-if="val !== 'quickly_login'">
 					<cl-button type="info" :pt="{ className: '!h-[40px] !rounded-full w-[40px] mx-auto !p-1' }"
 						:loading="loading" @tap="tabsChange('quickly_login')">
 						<cl-image src="https://oss.xiaoxiongcode.com/static/home/phone.svg" mode="heightFix"
@@ -75,7 +86,7 @@
 						</cl-text>
 					</view>
 				</view>
-				<view v-else>
+				<view v-if="val !== 'password'">
 					<cl-button type="info" :pt="{ className: '!h-[40px] !rounded-full w-[40px] mx-auto !p-1' }"
 						:loading="loading" @tap="tabsChange('password')">
 						<cl-image src="https://oss.xiaoxiongcode.com/static/home/password.svg" mode="heightFix"
@@ -114,7 +125,7 @@ import type { ClActionSheetOptions } from "@/uni_modules/cool-ui";
 
 const actionSheetRef = ref<ClActionSheetComponentPublicInstance | null>(null);
 
-const val = ref('quickly_login')
+const val = ref('weixin')
 const agree = ref(false)
 const agree2 = ref(false)
 const list: ClTabsItem[] = [
@@ -126,6 +137,10 @@ const list: ClTabsItem[] = [
 		label: '密码登录',
 		value: 'password'
 	},
+	{
+		label: '微信登录',
+		value: 'weixin'
+	},
 ]
 const formData = ref<LoginForm>({
 	username: '',