添加loading
parent
ce5e3b7d80
commit
4e6e74c462
|
@ -106,13 +106,15 @@ const request = (method, url, options) => {
|
|||
break;
|
||||
}
|
||||
return new Promise((resolve, reject) => {
|
||||
console.log(`${url}的参数===>`,options);
|
||||
uni.showLoading({title: '加载中',mask:true});
|
||||
uni.request({
|
||||
url: `${getApp().globalData.hostapi}${url}`,
|
||||
method: methods,
|
||||
data: options,
|
||||
header: headers,
|
||||
success: res => {
|
||||
uni.hideLoading();
|
||||
console.log(`${url}的参数===>`,options);
|
||||
if (res.statusCode == 200) {
|
||||
if (res.data.code == 0) {
|
||||
// 接口调用成功
|
||||
|
@ -123,11 +125,13 @@ const request = (method, url, options) => {
|
|||
checkError(res);
|
||||
}
|
||||
} else {
|
||||
uni.hideLoading();
|
||||
// 接口返回错误信息
|
||||
checkError(res);
|
||||
}
|
||||
},
|
||||
fail: e => {
|
||||
uni.hideLoading();
|
||||
// 接口请求错误
|
||||
checkError(e, reject);
|
||||
},
|
||||
|
|
|
@ -1,14 +1,14 @@
|
|||
<template>
|
||||
<view>
|
||||
<status-container titlet="观影记录" returnc="#FFFFFF">
|
||||
<status-container titlet="观看记录" returnc="#FFFFFF">
|
||||
<view slot="content" style="margin-top: -20rpx;">
|
||||
<view class="pad-zy30 bacf pad-x30" v-if="total">
|
||||
<view class="pad-sx30 disac fon24 bbot" v-for="(item,index) in dataList" :key="index">
|
||||
<image class="flexs" :src="hostapi + item.course_video_cover" mode="aspectFill" style="width: 228rpx;height: 160rpx;"></image>
|
||||
<view class="disjbac fc width100 mar-z20" style="height: 160rpx;">
|
||||
<view class="fon26 col26 width100">
|
||||
<view class="fon28 col26 width100">
|
||||
<view class="clips2">{{item.course_video_title}}</view>
|
||||
<view class="fon20 mar-s10" style="color: #7f7f7f;">{{item.course_video_summary}}</view>
|
||||
<view class="fon24 mar-s10" style="color: #7f7f7f;">观看时长:{{item.duration}}</view>
|
||||
</view>
|
||||
<view class="disjbac width100">
|
||||
<view class="fon24"></view>
|
||||
|
@ -64,13 +64,19 @@
|
|||
size:this.size
|
||||
}
|
||||
this.$requst.post('/api/course/course-browse-records',params).then(res=>{
|
||||
this.total = res.data.total;
|
||||
if(this.page==1){this.dataList=[];}
|
||||
this.dataList = [...this.dataList,...res.data.list];
|
||||
if(this.total==this.dataList.length && this.page!=1){
|
||||
this.noMore = true;
|
||||
if(res.code == 0) {
|
||||
this.total = res.data.total;
|
||||
if(this.page==1){this.dataList=[];}
|
||||
this.dataList = [...this.dataList,...res.data.list];
|
||||
this.dataList.forEach((item,index)=>{
|
||||
item.duration = this.formatSeconds(item.duration)
|
||||
})
|
||||
if(this.total==this.dataList.length && this.page!=1){
|
||||
this.noMore = true;
|
||||
}
|
||||
this.loading = true;
|
||||
|
||||
}
|
||||
this.loading = true;
|
||||
})
|
||||
},
|
||||
|
||||
|
@ -89,6 +95,52 @@
|
|||
}
|
||||
|
||||
})
|
||||
},
|
||||
|
||||
// 秒数转化为时分秒
|
||||
formatSeconds(value) {
|
||||
// 秒
|
||||
let second = parseInt(value)
|
||||
// 分
|
||||
let minute = 0
|
||||
// 小时
|
||||
let hour = 0
|
||||
// 天
|
||||
// let day = 0
|
||||
// 如果秒数大于60,将秒数转换成整数
|
||||
if (second > 60) {
|
||||
// 获取分钟,除以60取整数,得到整数分钟
|
||||
minute = parseInt(second / 60)
|
||||
// 获取秒数,秒数取佘,得到整数秒数
|
||||
second = parseInt(second % 60)
|
||||
// 如果分钟大于60,将分钟转换成小时
|
||||
if (minute > 60) {
|
||||
// 获取小时,获取分钟除以60,得到整数小时
|
||||
hour = parseInt(minute / 60)
|
||||
// 获取小时后取佘的分,获取分钟除以60取佘的分
|
||||
minute = parseInt(minute % 60)
|
||||
// 如果小时大于24,将小时转换成天
|
||||
// if (hour > 23) {
|
||||
// // 获取天数,获取小时除以24,得到整天数
|
||||
// day = parseInt(hour / 24)
|
||||
// // 获取天数后取余的小时,获取小时除以24取余的小时
|
||||
// hour = parseInt(hour % 24)
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
let result = '' + parseInt(second) + '秒'
|
||||
if (minute > 0) {
|
||||
result = '' + parseInt(minute) + '分' + result
|
||||
}
|
||||
if (hour > 0) {
|
||||
result = '' + parseInt(hour) + '小时' + result
|
||||
}
|
||||
// if (day > 0) {
|
||||
// result = '' + parseInt(day) + '天' + result
|
||||
// }
|
||||
console.log('result:', result)
|
||||
return result
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -216,4 +216,6 @@
|
|||
}
|
||||
</script>
|
||||
|
||||
<style></style>
|
||||
<style>
|
||||
.rich-text [alt]{width: 100%;}
|
||||
</style>
|
||||
|
|
Loading…
Reference in New Issue