添加loading

master
xcw 2023-03-28 14:09:31 +08:00
parent ce5e3b7d80
commit 4e6e74c462
3 changed files with 69 additions and 11 deletions

View File

@ -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);
},

View File

@ -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
}
}
}

View File

@ -216,4 +216,6 @@
}
</script>
<style></style>
<style>
.rich-text [alt]{width: 100%;}
</style>