319 lines
7.7 KiB
Vue
319 lines
7.7 KiB
Vue
<template>
|
||
<view class="">
|
||
<u-sticky :enable="enableIos">
|
||
<view class="search-box-ios">
|
||
<u-search bg-color="#f2f2f2" style="width: 100%;" placeholder="搜索更多资源" v-model="keywordIos"
|
||
:show-action="false" :animation="true" @search="getCourseListIos()"></u-search>
|
||
</view>
|
||
</u-sticky>
|
||
<view class="swiper flex align-center justify-center">
|
||
<view class="swiper-box">
|
||
<swiper :indicator-dots="true" class="swiper " :autoplay="true" interval="5000" duration="500"
|
||
:circular="true" style="width: 100%;height: 350rpx;">
|
||
<swiper-item v-for="(item,index) in swiperListIos" :key='index' @tap="goPageIos(item.url)">
|
||
<image :src="item.imageUrl" mode="scaleToFill"
|
||
style="width: 100%;height: 100%;border-radius: 24rpx;"></image>
|
||
</swiper-item>
|
||
</swiper>
|
||
</view>
|
||
</view>
|
||
<view class="padding-lr">
|
||
<view class="" v-if="courseListIos.length">
|
||
<videoList @success="posterSuccessIos" :list="courseListIos" />
|
||
</view>
|
||
<empty title="暂无视频" :isShow='false' v-else></empty>
|
||
<u-loadmore v-if="courseListIos.length > 0" :status="statusIos" />
|
||
</view>
|
||
|
||
</view>
|
||
</template>
|
||
|
||
<script>
|
||
import videoList from '../../../components/videoList/videoList.vue'
|
||
import empty from '@/components/empty.vue'
|
||
export default {
|
||
components: {
|
||
empty,
|
||
videoList
|
||
},
|
||
data() {
|
||
return {
|
||
enableIos: true,
|
||
statusIos: 'loadmore',
|
||
swiperListIos: [], //轮播图列表
|
||
courseListIos: [], //资源列表
|
||
pageIos: 1,
|
||
limitIos: 10,
|
||
pagesIos: 0,
|
||
|
||
sortIos: '',
|
||
keywordIos: '',
|
||
isPriceIos: '', //是否免费 2:免费
|
||
}
|
||
},
|
||
onShow() {
|
||
this.enableIos = true
|
||
this.getCourseListIos()
|
||
},
|
||
onHide() {
|
||
this.enableIos = false
|
||
},
|
||
onLoad(option) {
|
||
this.asdxxx(1212,5)
|
||
this.jhjkhjk(1212.5)
|
||
this.kuuuuu(1212,5)
|
||
this.ytutyuty(1212,5)
|
||
this.tyutre(1212,5)
|
||
uni.setNavigationBarTitle({
|
||
title: option.title
|
||
})
|
||
this.getBannerListIos()
|
||
if (option.sort) {
|
||
this.sortIos = option.sort
|
||
}
|
||
if (option.isPrice) {
|
||
this.isPriceIos = option.isPrice
|
||
}
|
||
|
||
},
|
||
methods: {
|
||
|
||
//乘法函数,用来得到精确的乘法结果
|
||
//说明:javascript的乘法结果会有误差,在两个浮点数相乘的时候会比较明显。这个函数返回较为精确的乘法结果。
|
||
//调用:mul(arg1,arg2)
|
||
//返回值:arg1乘以arg2的精确结果
|
||
//
|
||
kuuuuu(arg1, arg2) {
|
||
var m = 0,
|
||
s1 = arg1.toString(),
|
||
s2 = arg2.toString();
|
||
try {
|
||
m += s1.split(".")[1].length;
|
||
} catch (e) {
|
||
m = 0;
|
||
}
|
||
try {
|
||
m += s2.split(".")[1].length;
|
||
} catch (e) {
|
||
m = m || 0;
|
||
}
|
||
return (
|
||
(Number(s1.replace(".", "")) * Number(s2.replace(".", ""))) /
|
||
Math.pow(10, m)
|
||
);
|
||
}, //除法函数,用来得到精确的除法结果
|
||
//说明:javascript的除法结果会有误差,在两个浮点数相除的时候会比较明显。这个函数返回较为精确的除法结果。
|
||
//调用:div(arg1,arg2)
|
||
//返回值:arg1除以arg2的精确结果
|
||
asdxxx(arg1, arg2) {
|
||
var r1, r2, m, n;
|
||
try {
|
||
r1 = arg1.toString().split(".")[1].length;
|
||
} catch (e) {
|
||
r1 = 0;
|
||
}
|
||
try {
|
||
r2 = arg2.toString().split(".")[1].length;
|
||
} catch (e) {
|
||
r2 = 0;
|
||
}
|
||
m = Math.pow(10, Math.max(r1, r2));
|
||
//动态控制精度长度
|
||
n = r1 >= r2 ? r1 : r2;
|
||
return ((arg1 * m - arg2 * m) / m).toFixed(n);
|
||
},
|
||
ytutyuty(arg1, arg2) {
|
||
var r1, r2, m, n;
|
||
try {
|
||
r1 = arg1.toString().split(".")[1].length;
|
||
} catch (e) {
|
||
r1 = 0;
|
||
}
|
||
try {
|
||
r2 = arg2.toString().split(".")[1].length;
|
||
} catch (e) {
|
||
r2 = 0;
|
||
}
|
||
m = Math.pow(10, Math.max(r1, r2));
|
||
n = r1 >= r2 ? r1 : r2;
|
||
return ((arg1 * m + arg2 * m) / m).toFixed(n);
|
||
},
|
||
tyutre(arg1, arg2) {
|
||
var t1 = 0,
|
||
t2 = 0,
|
||
r1,
|
||
r2;
|
||
try {
|
||
t1 = arg1.toString().split(".")[1].length;
|
||
} catch (e) {
|
||
t1 = 0;
|
||
}
|
||
try {
|
||
t2 = arg2.toString().split(".")[1].length;
|
||
} catch (e) {
|
||
t2 = 0;
|
||
}
|
||
r1 = Number(arg1.toString().replace(".", ""));
|
||
r2 = Number(arg2.toString().replace(".", ""));
|
||
|
||
},
|
||
/**
|
||
* 保留小数n位,不进行四舍五入
|
||
* num你传递过来的数字,
|
||
* decimal你保留的几位,默认保留小数后两位
|
||
* isInt 是否保留0。如:12.20 是否保留0
|
||
*/
|
||
jhjkhjk(num, decimal = 2, isInt = false) {
|
||
num = num.toFixed(3).toString();
|
||
const index = num.indexOf(".");
|
||
if (index !== -1) {
|
||
num = num.substring(0, decimal + index + 1);
|
||
} else {
|
||
num = num.substring(0);
|
||
}
|
||
//截取后保留两位小数
|
||
if (isInt) {
|
||
return parseFloat(num);
|
||
} else {
|
||
return parseFloat(num).toFixed(decimal);
|
||
}
|
||
},
|
||
|
||
//乘法函数,用来得到精确的乘法结果
|
||
//说明:javascript的乘法结果会有误差,在两个浮点数相乘的时候会比较明显。这个函数返回较为精确的乘法结果。
|
||
//调用:mul(arg1,arg2)
|
||
//返回值:arg1乘以arg2的精确结果
|
||
goPageIos(url) {
|
||
uni.navigateTo({
|
||
url: url
|
||
})
|
||
},
|
||
//点击回调
|
||
posterSuccessIos(item) {
|
||
uni.navigateTo({
|
||
url: '/me/detail/detail?id=' + item.courseId + '&courseDetailsId=' + item.courseDetailsId
|
||
})
|
||
},
|
||
//最新热播
|
||
getCourseListIos() {
|
||
let data = {
|
||
limit: this.limitIos,
|
||
page: this.pageIos,
|
||
sort: this.sortIos ? this.sortIos : '',
|
||
title: this.keywordIos,
|
||
}
|
||
// #ifdef MP-WEIXIN
|
||
data.wxShow = 1
|
||
// #endif
|
||
// #ifdef MP-TOUTIAO
|
||
data.dyShow = 1
|
||
// #endif
|
||
if (this.isPriceIos) {
|
||
data.isPrice = this.isPriceIos
|
||
}
|
||
this.$u.api.courseList(data).then(res => {
|
||
if (res.code == 0) {
|
||
this.pagesIos = res.data.totalPage
|
||
if (this.pageIos < this.pagesIos) {
|
||
this.statusIos = 'loadmore'
|
||
} else {
|
||
this.statusIos = 'nomore'
|
||
}
|
||
// res.data.list.forEach(ret => {
|
||
// ret.courseLabel = ret.courseLabel ? ret.courseLabel.split(',') : []
|
||
// })
|
||
if (this.pageIos == 1) {
|
||
this.courseListIos = res.data.list
|
||
} else {
|
||
this.courseListIos = [...this.courseListIos, ...res.data.list]
|
||
}
|
||
} else {
|
||
uni.showToast({
|
||
title: res.msg,
|
||
duration: 1000,
|
||
icon: 'none'
|
||
});
|
||
}
|
||
uni.stopPullDownRefresh();
|
||
|
||
})
|
||
},
|
||
// 获取轮播图列表
|
||
getBannerListIos() {
|
||
this.$u.api.bannerList({
|
||
classify: '1'
|
||
}).then(res => {
|
||
if (res.code == 0) {
|
||
res.data.forEach(d => {
|
||
if (d.state == 1) {
|
||
this.swiperListIos.push(d)
|
||
}
|
||
})
|
||
|
||
} else {
|
||
uni.showToast({
|
||
title: res.msg,
|
||
duration: 1000,
|
||
icon: 'none'
|
||
});
|
||
}
|
||
})
|
||
},
|
||
|
||
},
|
||
onReachBottom: function() {
|
||
if (this.pageIos < this.pagesIos) {
|
||
this.pageIos += 1
|
||
this.statusIos = 'loading'
|
||
this.getCourseListIos()
|
||
|
||
} else {
|
||
this.statusIos = 'nomore'
|
||
}
|
||
|
||
},
|
||
onPullDownRefresh: function() {
|
||
this.pageIos = 1;
|
||
this.getCourseListIos()
|
||
},
|
||
}
|
||
</script>
|
||
|
||
<style lang="scss" scoped>
|
||
.search-box-ios {
|
||
width: 100%;
|
||
padding: 15upx 2.5%;
|
||
display: flex;
|
||
justify-content: space-between;
|
||
background-color: #ffffff;
|
||
}
|
||
|
||
|
||
|
||
.swiper {
|
||
width: 100%;
|
||
height: auto;
|
||
margin-bottom: 10rpx;
|
||
margin-top: 10rpx;
|
||
|
||
.swiper-box {
|
||
width: 686rpx;
|
||
height: 100%;
|
||
}
|
||
}
|
||
|
||
.active {
|
||
color: #5074FF;
|
||
}
|
||
|
||
.btn {
|
||
width: 150upx;
|
||
height: 60upx;
|
||
background: #5074FF;
|
||
border-radius: 30upx;
|
||
color: #FFFFFF;
|
||
text-align: center;
|
||
line-height: 60rpx;
|
||
font-size: 26rpx;
|
||
}
|
||
</style> |