whj il y a 1 jour
Parent
commit
20a691e7ce

+ 1 - 0
.cool/types/user.ts

@@ -3,4 +3,5 @@ export type UserInfo = {
 	sysRoles: any[]
 	roles: string[]
 	permissions: string[]
+	studyCourseNum: number
 };

+ 13 - 0
components/lock.uvue

@@ -0,0 +1,13 @@
+<script setup lang='ts'>
+
+</script>
+<template>
+  <view class="absolute top-0 left-0 w-full h-full flex items-center justify-center bg1">
+    <cl-image src="https://oss.xiaoxiongcode.com/static/home/lock.png" mode="widthFix" width="30%" height="auto" />
+  </view>
+</template>
+<style lang="scss" scoped>
+.bg1 {
+  background-color: rgba(255, 255, 255, 0.5);
+}
+</style>

+ 3 - 1
pages/catalog/index.uvue

@@ -2,6 +2,7 @@
 import { ref, onMounted } from 'vue'
 import { fetchSubjectConfigInfo } from '@/services/subject/info'
 import type { SubjectCatalogResult } from '@/services/subject/catalog'
+import Lock from '@/components/lock.uvue'
 import Progress from './components/progress.uvue'
 import Back from '@/components/back.uvue'
 import Loading from '@/components/loading.uvue'
@@ -73,6 +74,7 @@ function handleDetail(item: SubjectCatalogResult) {
           <view>
             <Progress :num="2" :percentage="course.sortNum" />
           </view>
+          <Lock v-if="!course.trialPlay" />
         </view>
       </scroll-view>
     </view>
@@ -125,7 +127,7 @@ function handleDetail(item: SubjectCatalogResult) {
 }
 
 .scroll-view-item_H {
-  @apply w-[40vh] h-[50vh] mr-[20px] rounded-2xl border-[5px] border-[#1D4BD9] border-solid border-b-[10px] p-1 flex items-center;
+  @apply w-[40vh] h-[50vh] mr-[20px] rounded-2xl border-[5px] border-[#1D4BD9] border-solid border-b-[10px] p-1 flex items-center relative;
 }
 
 .light-tag {

+ 5 - 2
pages/english/detail.uvue

@@ -10,7 +10,7 @@ const showControls = ref(true)
 const showVideo = ref(true)
 
 const data = ref({
-  videoSrc: 'https://oss.xiaoxiongcode.com/course-1/animate/第1集_观察.mp4',
+  videoSrc: '',
 })
 //当前进度
 
@@ -18,7 +18,10 @@ const course = ref<SubjectCourseResult>()
 //通过路由参数获取课程id
 async function fetchCatalog() {
   course.value = await fetchSubjectCourseApp({ id: router.query().id })
-  data.value.videoSrc = course.value?.videoPath || ''
+  if (!course.value?.videoPath) {
+    return
+  }
+  data.value.videoSrc = course.value?.videoPath.includes('http') ? course.value?.videoPath : ('https://oss.xiaoxiongcode.com' + course.value?.videoPath)
 }
 onMounted(async () => {
   await fetchCatalog()

+ 2 - 2
pages/index/home.uvue

@@ -89,8 +89,8 @@ const userInfo = computed(() => user.info.value?.userInfo)
 				<view class="text-[26px] font-bold">学习进度</view>
 				<view class=" w-full flex flex-row items-center justify-center gap-2">
 
-					<cl-progress class="flex-1" color="linear-gradient(0deg, #1FA5F5 37%, #A2D8FF 100%)" :value="50"
-						:show-text="false" :strokeWidth="16"
+					<cl-progress class="flex-1" color="linear-gradient(0deg, #1FA5F5 37%, #A2D8FF 100%)"
+						:value="user.info.value?.studyCourseNum" :show-text="false" :strokeWidth="16"
 						:pt="{ outer: { className: '!rounded-full' }, inner: { className: '!rounded-full' } }"></cl-progress>
 
 					<view class="text-[12px] w-[100px] rounded-full text-black font-bold text-center check

+ 23 - 7
pages/user/components/set.uvue

@@ -2,7 +2,7 @@
 import { ref } from 'vue'
 import { useUi, type ClFormRule, useForm } from "@/uni_modules/cool-ui";
 import { encryptPassword, user, router } from '@/.cool';
-import { changeUserPwd } from "@/services/user";
+import { changeUserPwd, bindWechatOpenId } from "@/services/user";
 const ui = useUi();
 const formData = ref({
   oldPassword: '',
@@ -65,6 +65,21 @@ const handleLogout = () => {
     },
   });
 }
+const loading = ref(false)
+const handleBind = () => {
+  loading.value = true
+  uni.login({
+    provider: 'weixin',
+    success(res) {
+      bindWechatOpenId({ code: res.code }).then(res => {
+        uni.showToast({
+          title: '授权成功,请重新登录'
+        })
+        user.logout()
+      })
+    }
+  })
+}
 </script>
 <template>
   <view class=" w-full bg-[#fff] shadow rounded-xl mt-[20px] text-[#00A9FF] sidebar flex  items-center">
@@ -79,15 +94,16 @@ const handleLogout = () => {
       </cl-form>
     </view>
     <uni-button
-      class="h-[30px] rounded-2xl flex flex-row items-center justify-center  w-[200px] text-[14px] active:bg-[#045bb9]"
+      class="h-[30px] rounded-2xl px-[10px] py-[5px] flex flex-row items-center !text-[#fff] justify-center bg-[#007aff] w-[200px] text-[14px] active:bg-[#045bb9]"
       type="primary" block @tap="handleEdit">修改密码</uni-button>
     <uni-button
-      class="flex flex-row w-[200px] items-center justify-center gap-2 h-[30px] bg-[#09BA07] rounded-2xl px-[10px] py-[5px] text-[14px] !text-[#fff] active:bg-[#099508] my-[10px]"><cl-image
-        src="https://oss.xiaoxiongcode.com/static/个人中心/微信.png" mode="heightFix" height="20px" width="auto"></cl-image>
-      微信账号快捷登录</uni-button>
+      class="flex flex-row w-[200px] items-center justify-center gap-2 h-[30px] bg-[#09BA07] rounded-2xl px-[10px] py-[5px] text-[14px] !text-[#fff] active:bg-[#099508] my-[10px]"
+      @tap="handleBind"><cl-image src="https://oss.xiaoxiongcode.com/static/个人中心/微信.png" mode="heightFix" height="20px"
+        width="auto"></cl-image>
+      绑定微信</uni-button>
     <uni-button
-      class="h-[30px] rounded-2xl flex flex-row items-center justify-center text-[14px]  w-[200px] active:bg-[#045bb9]"
-      type="primary" block @tap="handleLogout">退出登录</uni-button>
+      class="h-[30px] rounded-2xl px-[10px] py-[5px] flex flex-row items-center !text-[#fff] justify-center text-[14px] bg-[#007aff] w-[200px] active:bg-[#045bb9]"
+      :loading="loading" type="primary" block @tap="handleLogout">退出登录</uni-button>
   </view>
 </template>
 <style lang="scss" scoped>

+ 68 - 6
pages/user/login.uvue

@@ -16,12 +16,31 @@
 					<view v-else>
 						<password :form="formData" />
 					</view>
-					<cl-button :pt="{ className: '!h-[45px] !rounded-full w-[200px] mx-auto' }" :loading="loading" @tap="toLogin">
-						登录
-					</cl-button>
+					<view class="flex flex-row items-center justify-center gap-4">
+						<cl-button :pt="{ className: '!h-[45px] !rounded-full w-[140px] mx-auto' }" :loading="loading"
+							@tap="toLogin">
+							登录
+						</cl-button>
+						<cl-button type="success" :pt="{ className: '!h-[45px] !rounded-full w-[140px] mx-auto ' }"
+							:loading="loading" @tap="toWechatLogin">
+							<view class="flex flex-row items-center justify-center gap-2">
+								<cl-image src="https://oss.xiaoxiongcode.com/static/个人中心/微信.png" mode="heightFix" height="20px"
+									width="auto"></cl-image> 登录
+							</view>
+						</cl-button>
+					</view>
 				</cl-form>
 			</view>
 		</view>
+		<cl-action-sheet ref="actionSheetRef">
+			<template #prepend>
+				<view class=" mb-3 font-bold text-center">
+					<cl-text :size="20" color="#666">
+						选择登录账号
+					</cl-text>
+				</view>
+			</template>
+		</cl-action-sheet>
 	</cl-page>
 </template>
 
@@ -33,7 +52,11 @@ import password from './components/password.uvue';
 import { ref } from 'vue'
 import type { ClTabsItem } from "@/uni_modules/cool-ui";
 import { encryptPassword, user, router } from '@/.cool';
-import { loginApi } from "@/services/user";
+import { loginApi, wechatLogin } from "@/services/user";
+import type { ClActionSheetOptions } from "@/uni_modules/cool-ui";
+
+const actionSheetRef = ref<ClActionSheetComponentPublicInstance | null>(null);
+
 const val = ref('quickly_login')
 const list: ClTabsItem[] = [
 	{
@@ -46,8 +69,8 @@ const list: ClTabsItem[] = [
 	},
 ]
 const formData = ref<LoginForm>({
-	username: 'xiongchao',
-	password: '123456',
+	username: '',
+	password: '',
 	randomStr: 0,
 	grant_type: 'quickly_login',
 	scope: 'server',
@@ -84,6 +107,45 @@ function toLogin() {
 	})
 
 }
+function toWechatLogin() {
+	uni.login({
+		provider: 'weixin',
+		success(res) {
+			wechatLogin({
+				code: res.code,
+			}).then(res => {
+				console.log(res);
+				const list = res.map(item => ({
+					label: item,
+					icon: "user-line",
+					callback() {
+						handleSelect(item)
+					}
+				}))
+				actionSheetRef.value!.open({
+					list: list
+				} as ClActionSheetOptions);
+			})
+		}
+	})
+}
+function handleSelect(item: string) {
+	formData.value.username = item
+	formData.value.password = 'quickly_login'
+	formData.value.grant_type = 'quickly_login'
+	formData.value.loginType = 88
+	loginApi({
+		...formData.value,
+	}).then(res => {
+		user.setToken(res)
+		uni.showToast({
+			title: '登录成功',
+			icon: 'success'
+		})
+		router.nextLogin();
+	})
+
+}
 </script>
 
 <style lang="scss" scoped>

+ 6 - 0
services/user.ts

@@ -57,4 +57,10 @@ export function updateUserInfo(parameter: any) {
 }
 export function changeUserPwd(parameter: any) {
   return usePut(`/upms/users/change-pwd`, parameter) as Promise<any>
+}
+export function bindWechatOpenId(parameter: any) {
+  return useGet(`/wechat/bind/small/program`, parameter) as Promise<any>
+}
+export function wechatLogin(parameter: any) {
+  return useGet(`/wechat/quickly/login/oauth`, parameter) as Promise<any>
 }