Просмотр исходного кода

学习中心-直播提醒对接

xuqiaoying 3 лет назад
Родитель
Сommit
f3701f750f
5 измененных файлов с 92 добавлено и 16 удалено
  1. 8 1
      common/httpList/course.js
  2. 2 2
      common/request.js
  3. 4 0
      main.js
  4. 4 0
      pages/learn/index.scss
  5. 74 13
      pages/learn/index.vue

+ 8 - 1
common/httpList/course.js

@@ -182,5 +182,12 @@ export default {
 			data:data
 		})
 	},
-	
+	// 学习中心的直播课列表
+	getgoodsLiveList (data) {
+		return myRequest({
+			url: '/goods/getLiveList',
+			method: 'get',
+			data:data
+		})
+	},
 }

+ 2 - 2
common/request.js

@@ -5,9 +5,9 @@ import api from './api.js'
 var num = 1
 //接口api   
 // export const BASE_URL = 'https://api.xyyxt.net'   //release
-export const BASE_URL = 'https://test.xyyxt.net'   //预发布
+// export const BASE_URL = 'https://test.xyyxt.net'   //预发布
 // export const BASE_URL = 'http://42.192.164.187:19005'    //test
-// export const BASE_URL = 'http://192.168.1.222:5055'    //后端本地更新到222
+export const BASE_URL = 'http://192.168.1.222:5055'    //后端本地更新到222
 // export const BASE_URL = 'http://192.168.1.24:5055'    //后端本地
 
  //图片上传api

+ 4 - 0
main.js

@@ -65,6 +65,10 @@ Vue.filter('formate', function(time, formate = 'yyyy-mm-dd hh:mm:ss') {
                 res = year + '年' + month + '月'
                 break
             }
+            case 'hh:mm': {
+                res = hour + ':' + minutes
+                break
+            }
             case 'yyyy-mm-dd hh:mm': {
                 res = year + '-' + month + '-' + day + ' ' + hour + ':' + minutes
                 break

+ 4 - 0
pages/learn/index.scss

@@ -37,6 +37,7 @@
 		height: 150rpx;
 		border-radius: 16rpx;
 		padding: 14rpx 0rpx 0rpx 43rpx;
+		margin-bottom: 15rpx;
 		.my_bg {
 			position:absolute;
 			left:0;
@@ -81,6 +82,9 @@
 			font-size: 20rpx;
 			color: #fff;
 			margin-top: 17rpx;
+			.timeR {
+				margin-right: 15rpx;
+			}
 		}
 		.liv_title {
 			font-size: 28rpx;

+ 74 - 13
pages/learn/index.vue

@@ -15,23 +15,26 @@
 			<view class="had_courses">
 				<!-- 直播 -->
 				<view class="lives">
-					<view class="live_item">
+					<view v-for="(live, l_index) in livingLists" :key="l_index" class="live_item">
 						<view class="live_con">
 							<view class="live_status">
-								<image src="/static/learn/living.png" class="liv_icon"></image>
-								<!-- <image src="/static/learn/wlive.png" class="my_bg"></image> -->
-								<text class="status_s">正在直播中...</text>
-								<view class="look_bt">点击观看</view>
+								<image v-if="bgShow(live.liveStartTime, live.watchStatus)" src="/static/learn/living.png" class="liv_icon"></image>
+								<image v-else src="/static/learn/wlive.png" class="liv_icon"></image>
+								<text class="status_s">{{ live.liveStartTime | liveStatus(live.watchStatus)}}</text>
+								<view class="look_bt" :class="{}">{{ lookTimeStatus(live.liveStartTime, live.watchStatus) }}</view>
 							</view>
 							<view class="liv_time">
-								7月19日 15:00
+								<text class="timeR">{{ live.liveStartTime | formate('mm月dd日')}}</text>
+								<text>{{ live.liveStartTime | formate('hh:mm')}}</text>
 							</view>
-							<view class="liv_title">一级建造师《水利实务》拔高训练直播</view>
+							<view class="liv_title">{{ live.name }}</view>
 						</view>
-						<!-- <image src="/static/learn/wlive_bg.png" class="my_bg"></image> -->
-						<image src="/static/learn/living_bg.png" class="my_bg"></image>
+						<image v-if="bgShow(live.liveStartTime, live.watchStatus)" src="/static/learn/living_bg.png" class="my_bg"></image>
+						<image v-else src="/static/learn/wlive_bg.png" class="my_bg"></image>
+						
 					</view>
 				</view>
+
 				<!-- 我的课程 -->
 				<view class="my_courses">
 					<text class="titles">我的课程</text>
@@ -162,7 +165,6 @@ export default {
 			gradeList: [],
 			gradeValue: -1,
 			sysTime: 0,
-			// totalC: 0,
 			courseLists: [],
 			questionLists: [], // 题库
 			paramQ: {
@@ -170,11 +172,22 @@ export default {
 				pageSize: 50
 			},
 			queitemIndex:'',
+			livingLists: [],
         }
     },
-	onLoad(option) {
-		this.getcourseList()
-		this.getlistQuestion()
+	filters: {
+		liveStatus(liveTime, watchStatus) {
+			let curTime = new Date().getTime() // 当前时间的时间戳
+			let value = liveTime * 1000
+			if (curTime < value) { // 判断当前时间和直播开始时间
+				return ' 未开播'
+			} else {
+				return watchStatus == 'live' ? '正在直播中...' : '即将开播'
+			}
+		}
+	},
+	onLoad() {
+		this.getCourseLiveQues()
 	},
 	async onShow() {
 		await this.commonSystemTime()
@@ -182,11 +195,59 @@ export default {
 		console.log('this.sysTime', this.sysTime)
 	},
 	methods: {
+		bgShow(liveTime, watchStatus) {
+			let curTime = new Date().getTime() // 当前时间的时间戳
+			let value = liveTime * 1000
+			if (curTime > value) { // 判断当前时间和直播开始时间
+				return watchStatus == 'live' ? true : false
+			}
+		},
+		lookTimeStatus(liveTime, watchStatus) {
+			let curTime = new Date().getTime() // 当前时间的时间戳
+			let value = liveTime * 1000
+			if (curTime > value) { // 判断当前时间和直播开始时间
+				if (watchStatus == 'live') { // 
+					return '点击观看'
+				} else {
+					return '即将开播'
+				}
+			} else {
+				return '剩余:'
+			}
+		},
 		toChoose() {
 			uni.switchTab({
 				url:'/pages/course/index'
 			})
 		},
+		// 查询直播课
+		getCourseLiveQues() {
+			let arrs = [
+				this.$api.courseGoodsList(this.paramC), // 查询用户拥有的商品/课程列表/course/goodsList
+				this.$api.listGoodsUserQuestion(this.paramQ), // 题库列表
+				this.$api.getgoodsLiveList({
+					pageNum: 1,
+					pageSize: 3 // 默认3条
+				})
+			]
+			Promise.all(arrs).then((res) => {
+				// if (res.data.code == 200) {
+					console.log('ewds========', res)
+					const [{ data: res1}, { data: res2}, {data: res3}] = res
+					if (res1.code == 200) {
+						this.courseLists = res1.rows || []
+					}
+					if (res2.code == 200) {
+						this.questionLists = res2.rows || []
+					}
+					if (res3.code == 200) {
+						this.livingLists = res3.rows || []
+					}
+				// }
+			}).catch(err => {
+				// this.$u.toast('请重新刷新请求')
+			})
+		},
 		// 查询用户拥有的商品/课程列表/course/goodsList
 		getcourseList() {
 			this.$api.courseGoodsList(this.paramC).then(res => {