فهرست منبع

Merge branch 'main' of https://gogs.mtavip.com/wangguoyu/uniProject into main

tanxue 1 ماه پیش
والد
کامیت
cea46b1c90
6فایلهای تغییر یافته به همراه244 افزوده شده و 79 حذف شده
  1. 12 0
      api/course.js
  2. 84 0
      components/scroll-list-card-kecheng/scroll-list-card-kecheng.vue
  3. 7 0
      pages.json
  4. 32 15
      pages/course/index.vue
  5. 27 0
      pages/course/kechengInfo.vue
  6. 82 64
      utils/request.js

+ 12 - 0
api/course.js

@@ -0,0 +1,12 @@
+import request from '@/utils/request'
+export function getKechengList(data = {}) {
+  return request({
+    'url': '/app/kecheng/list',
+    headers: {
+      isToken: true
+    },
+    method: 'post',
+    data,
+    timeout: 20000
+  })
+}

+ 84 - 0
components/scroll-list-card-kecheng/scroll-list-card-kecheng.vue

@@ -0,0 +1,84 @@
+<template>
+  <view class="scroll-list-card mobile-card-box">
+		<view>
+			<img style="width: 100rpx;height: 100rpx;;" :src="data.pic" alt="" />
+		</view>
+		<text>{{data.name}}</text>
+		<view>讲师:{{data.lecturerName ? data.lecturerName:'无讲师'}}</view>
+		<view>时间:{{data.startTime}}</view>
+  </view>
+</template>
+
+<script setup>
+import { toRefs, ref, computed } from "vue";
+
+const props = defineProps({
+  data: {
+    type: Object,
+  },
+});
+const { data } = toRefs(props);
+</script>
+
+<style lang="scss" scoped>
+.mobile-card-box {
+  box-sizing: border-box;
+  margin: 0 30rpx 10rpx;
+  border-bottom: 2rpx solid #f2f1f2;
+  padding-bottom: 30rpx;
+}
+
+.mobile-card-title {
+  color: #333;
+  font-size: 32rpx;
+  font-weight: 500;
+  margin: 24rpx 0 24rpx 0;
+  text-overflow: ellipsis;
+  -o-text-overflow: ellipsis;
+  overflow: hidden;
+  word-wrap: break-word;
+  display: -webkit-box;
+  white-space: normal;
+  -webkit-box-orient: vertical;
+  text-align: justify;
+  -webkit-line-clamp: 2;
+  line-clamp: 2;
+  line-height: 48rpx;
+}
+
+// 行
+.mobile-card-row {
+  margin-bottom: 32rpx;
+  display: flex;
+  justify-content: space-between;
+  align-items: flex-end;
+
+  text {
+    font-size: 28rpx;
+    line-height: 40rpx;
+  }
+
+  // 得分
+  .mobile-card-score {
+    font-size: 40rpx;
+    color: #f10a0a;
+  }
+
+  // 分数(有最小宽度)
+  .card-score-box {
+    min-width: 240rpx;
+    text-align: left;
+  }
+}
+
+// 按钮
+.mobile-card-btn {
+  width: 60%;
+  height: 80rpx;
+  line-height: 80rpx;
+  margin: 50rpx auto;
+  background: linear-gradient(0deg, #436aff 0%, #234ff7 100%);
+  border-radius: 80rpx;
+  display: block;
+}
+</style>

+ 7 - 0
pages.json

@@ -47,6 +47,13 @@
 				"navigationBarTitleText" : "课程"
 			}
 		},
+			{
+			"path" : "pages/course/kechengInfo",
+			"style" :
+			{
+				"navigationBarTitleText" : "课程详情"
+			}
+		},
 		{
 			"path" : "pages/score/index",
 			"style" :

+ 32 - 15
pages/course/index.vue

@@ -1,22 +1,39 @@
 <template>
-	<view class="lli-develop-expect-page">
-		开发中,敬请期侍!
-	</view>
+	<custom-scroll-list :refreshFn="getKechengList" :tabList="tabData" :defaultTab="1">
+		<template #default="{list}">
+			<scroll-list-card-kecheng @click="kechengClick(item)" v-for="(item,index) in list" :key="item.ksId"
+				:data="item"></scroll-list-card-kecheng>
+		</template>
+	</custom-scroll-list>
 </template>
 
-<script>
-	export default {
-		data() {
-			return {
-				
-			}
-		},
-		methods: {
-			
-		}
+<script setup>
+	import {
+		getKechengList
+	} from "@/api/course.js";
+	import {
+		onLoad,
+		onReady,
+
+	} from "@dcloudio/uni-app"
+	import {
+		reactive,
+		ref
+	} from "vue";
+	const tabData = [{
+		label: "可以学习",
+		value: 1,
+	}, {
+		label: "已结束",
+		value: 4
+	}]
+	const kechengClick = (data) => {
+		uni.navigateTo({
+			url: '/pages/course/kechengInfo?kcId=' + data.kcId + '&name=' + data.name
+		});
 	}
 </script>
 
-<style>
+<style lang="scss">
 
-</style>
+</style>

+ 27 - 0
pages/course/kechengInfo.vue

@@ -0,0 +1,27 @@
+<template>
+		<view>asdfsdfas</view>
+</template>
+
+<script setup>
+	import {
+		getKechengList
+	} from "@/api/course.js";
+	import {
+		onLoad,
+		onReady
+	} from "@dcloudio/uni-app"
+	import {
+		reactive,
+		ref
+	} from "vue";
+	onLoad((options) => {
+		console.log('options',options);
+	});
+	const kechengClick = ()=>{
+		
+	}
+</script>
+
+<style lang="scss">
+
+</style>

+ 82 - 64
utils/request.js

@@ -1,76 +1,94 @@
 //import store from '@/store'
 import config from '../config.js'
-import { getAuth } from '@/utils/auth'
-import { Md5 }   from 'ts-md5/dist/md5';
+import {
+	getAuth
+} from '@/utils/auth'
+import {
+	Md5
+} from 'ts-md5/dist/md5';
 import errorCode from '@/utils/errorCode'
-import { toast, showConfirm, tansParams } from '@/utils/common'
+import {
+	toast,
+	showConfirm,
+	tansParams
+} from '@/utils/common'
 
 let timeout = 10000
 const baseUrl = config.baseUrl
 const request = config => {
 
-  // 是否需要设置 token
- // const isToken = (config.headers || {}).isToken === false
-  config.header = config.header || {}
-  
-  
- //  if (getToken() && !isToken) {
+	// 是否需要设置 token
+	// const isToken = (config.headers || {}).isToken === false
+	config.header = config.header || {}
+
+
+	//  if (getToken() && !isToken) {
 	// config.headers['X-AUTH-SIGN'] = Md5.hashStr(JSON.stringify(config.data) +auth.secret);
 	// config.headers['X-AUTH-TOKEN'] = auth.token;
- //  }
-  if (getAuth()) {
-	config.headers['X-AUTH-SIGN'] = Md5.hashStr(JSON.stringify(config.data) +JSON.parse(getAuth()).secret);
-	config.headers['X-AUTH-TOKEN'] = JSON.parse(getAuth()).token;
-  }
-  return new Promise((resolve, reject) => {
-	//  debugger
-    uni.request({
-        method: config.method || 'get',
-        timeout: config.timeout ||  timeout,
-        url: config.baseUrl || baseUrl + config.url,
-        data: config.data,
-        header: config.headers,
-        dataType: 'json'
-      }).then(response => {
-         const res = response.data;
-        // if (error) {
-        //   toast('后端接口连接异常')
-        //   reject('后端接口连接异常')
-        //   return
-        // }
-        const code = res.code 
-       // const msg = errorCode[code] || res.data.msg || errorCode['default']
-        if (code === 401) {
-          showConfirm('登录状态已过期,您可以继续留在该页面,或者重新登录?').then(res => {
-            // if (res.confirm) {
-            //   store.dispatch('LogOut').then(res => {
-            //     uni.reLaunch({ url: '/pages/login' })
-            //   })
-            // }
-			  uni.reLaunch({ url: '/pages/login' })
-          })
-          reject('无效的会话,或者会话已过期,请重新登录。')
-        } else if (code === 500) {
-          reject('500')
-        } else if (code !== 0) {
-       //   toast(msg)
-          reject(code)
-        }
-        resolve(res)
-      })
-      .catch(error => {
-        let { message } = error
-        if (message === 'Network Error') {
-          message = '后端接口连接异常'
-        } else if (message.includes('timeout')) {
-          message = '系统接口请求超时'
-        } else if (message.includes('Request failed with status code')) {
-          message = '系统接口' + message.substr(message.length - 3) + '异常'
-        }
-        toast(message)
-        reject(error)
-      })
-  })
+	//  }
+	if (getAuth()) {
+		config.headers['X-AUTH-SIGN'] = Md5.hashStr(JSON.stringify(config.data) + JSON.parse(getAuth()).secret);
+		config.headers['X-AUTH-TOKEN'] = JSON.parse(getAuth()).token;
+	}
+	return new Promise((resolve, reject) => {
+		//  debugger
+		uni.request({
+				method: config.method || 'get',
+				timeout: config.timeout || timeout,
+				url: config.baseUrl || baseUrl + config.url,
+				data: config.data,
+				header: config.headers,
+				dataType: 'json'
+			}).then(response => {
+				const res = response.data;
+				// if (error) {
+				//   toast('后端接口连接异常')
+				//   reject('后端接口连接异常')
+				//   return
+				// }
+				const code = res.code
+				// const msg = errorCode[code] || res.data.msg || errorCode['default']
+				if (code === 401) {
+					showConfirm('登录状态已过期,您可以继续留在该页面,或者重新登录?').then(res => {
+						// if (res.confirm) {
+						//   store.dispatch('LogOut').then(res => {
+						//     uni.reLaunch({ url: '/pages/login' })
+						//   })
+						// }
+						uni.reLaunch({
+							url: '/pages/login'
+						})
+					})
+					reject('无效的会话,或者会话已过期,请重新登录。')
+				} else if (code === 405) {
+					showConfirm('帐号已在其他设备登录').then(res => {
+						uni.reLaunch({
+							url: '/pages/login'
+						})
+					})
+				} else if (code === 500) {
+					reject('500')
+				} else if (code !== 0) {
+					//   toast(msg)
+					reject(code)
+				}
+				resolve(res)
+			})
+			.catch(error => {
+				let {
+					message
+				} = error
+				if (message === 'Network Error') {
+					message = '后端接口连接异常'
+				} else if (message.includes('timeout')) {
+					message = '系统接口请求超时'
+				} else if (message.includes('Request failed with status code')) {
+					message = '系统接口' + message.substr(message.length - 3) + '异常'
+				}
+				toast(message)
+				reject(error)
+			})
+	})
 }
 
-export default request
+export default request