123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261 |
- <template>
- <view>
- <view class="video_list">
- <view class="video_item" v-for="(item, index) in videoList">
- <view class="video_info">
- <image class="thumb_img" :src="item.thumb" mode="aspectFit"></image>
- <view>
- <view class="video_type">
- <text class="type_name">{{ item.type_name }}</text>
- </view>
- <view class="video_title">{{ item.name }}</view>
- <view class="video_time">
- <text class="time_info">{{ item.end_time }} </text>
- </view>
- </view>
- </view>
- <view class="video_btn">
- <button class="after_exam" @click="goExam(item.id, item.report_id, item.learn_status)">
- {{ item.report_id > 0 ? "查看报告" : "课后评测" }}
- </button>
- <button class="to_learn" @click.stop="goDetail(item.id)">开始学习</button>
- </view>
- </view>
- </view>
- <view class="to_bottom" v-if="!videoList.length"> -----您还没有可学习课程-----</view>
- <view class="contact_follow">
- <button class="contact_btn" open-type="contact">
- <uni-icons type="headphones" size="30" color="#FFFFFF"></uni-icons>
- </button>
- </view>
- </view>
- </template>
- <script>
- export default {
- data() {
- return {
- // 产品列表
- videoList: [],
- // 请求参数
- requestParam: {
- page: 1,
- status: 0,
- },
- // 是否最后一页
- isLast: false,
- // 是否请求中
- isReqing: false,
- };
- },
- onLoad() {},
- onShow() {
- // 没有数据的话,或者请求中,不允许刷新
- if (this.isReqing) return;
- // 初始化页码为1
- this.requestParam.page = 1;
- // 是否是最后一页
- this.isLast = false;
- // 设置请求中
- this.isReqing = true;
- // 请求列表
- this.$http.request("api/video_course/get_list", this.requestParam).then((re) => {
- // 设置非请求中
- this.isReqing = false;
- // 成功结果
- if (re.code == "success") {
- if (re.data.last_page <= this.requestParam.page) this.isLast = true;
- this.videoList = re.data.data;
- }
- });
- },
- onPullDownRefresh() {
- // 如果请求中,不允许请求,
- if (this.isReqing) return false;
- // 初始化页码为1
- this.requestParam.page = 1;
- // 是否是最后一页
- this.isLast = false;
- // 设置请求中
- this.isReqing = true;
- // 请求列表
- this.$http.request("api/video_course/get_list", this.requestParam).then((re) => {
- // 设置非请求中
- this.isReqing = false;
- // 成功结果
- if (re.code == "success") {
- if (re.data.last_page <= this.requestParam.page) this.isLast = true;
- this.videoList = re.data.data;
- }
- });
- uni.stopPullDownRefresh();
- },
- onReachBottom() {
- // 如果页码是0,避免第一页重复
- if (this.requestParam.page < 1) return;
- // 最后一页不请求
- if (this.isLast) return;
- // 请求中,不再请求
- if (this.isReqing) return;
- // 增加一页
- this.requestParam.page = this.requestParam.page + 1;
- // 设置请求中
- this.isReqing = true;
- // 请求列表
- this.$http.request("api/video_course/get_list", this.requestParam).then((re) => {
- // 设置非请求中
- this.isReqing = false;
- // 成功结果
- if (re.code == "success") {
- // 数据
- if (re.data.last_page <= this.requestParam.page) this.isLast = true;
- // 追加数据
- this.videoList.push(...re.data.data);
- }
- });
- },
- methods: {
- goDetail(id) {
- uni.navigateTo({
- url: "/pages/video/detail?id=" + id,
- });
- },
- goExam(id, report_id, status) {
- if (status < 0) {
- uni.showToast({
- title: "请先完成课程再来答题吧",
- icon: "none",
- duration: 2000,
- });
- return;
- }
- if (report_id > 0) {
- uni.navigateTo({
- url: "/pages/video/record?type=exam&record_id=" + report_id,
- });
- return;
- }
- uni.navigateTo({
- url: "/pages/video/exam?id=" + id,
- });
- },
- },
- };
- </script>
- <style lang="less">
- .video_list {
- float: left;
- width: 750rpx;
- display: block;
- overflow: hidden;
- .video_item {
- display: block;
- width: 700rpx;
- overflow: hidden;
- margin-bottom: 10rpx;
- padding: 20rpx 25rpx;
- border-radius: 10rpx;
- background-color: #ffffff;
- .video_btn {
- display: flex;
- align-items: center;
- justify-content: flex-end;
- gap: 20rpx;
- margin-top: 10rpx;
- .to_learn {
- margin: 0;
- color: #fff;
- border: none;
- width: 140rpx;
- height: 50rpx;
- font-size: 26rpx;
- line-height: 50rpx;
- padding: 0rpx 0rpx;
- text-align: center;
- border-radius: 10rpx;
- background-color: #5045e6;
- }
- .to_learn::after {
- border: none;
- }
- .after_exam {
- margin: 0;
- color: #5045e6;
- border: none;
- width: 140rpx;
- height: 50rpx;
- font-size: 26rpx;
- line-height: 50rpx;
- padding: 0rpx 0rpx;
- text-align: center;
- border-radius: 10rpx;
- background-color: #fff;
- border: 1px solid #5045e6;
- }
- }
- .video_info {
- width: 100%;
- display: flex;
- .thumb_img {
- width: 200rpx;
- height: 200rpx;
- border-radius: 10rpx;
- margin-right: 20rpx;
- }
- .video_type {
- color: #999999;
- width: 480rpx;
- display: block;
- height: 60rpx;
- font-size: 26rpx;
- line-height: 60rpx;
- }
- .video_title {
- width: 480rpx;
- display: block;
- height: 80rpx;
- font-size: 32rpx;
- overflow: hidden;
- font-weight: bold;
- line-height: 40rpx;
- text-overflow: ellipsis;
- }
- .video_time {
- color: #999999;
- width: 480rpx;
- display: block;
- height: 60rpx;
- font-size: 26rpx;
- line-height: 60rpx;
- }
- }
- }
- }
- .contact_follow {
- bottom: 30%;
- right: 20rpx;
- width: 100rpx;
- height: 100rpx;
- display: block;
- position: fixed;
- border-radius: 50%;
- background-color: #1296db;
- .contact_btn {
- border: none;
- width: 100rpx;
- color: #ffffff;
- height: 100rpx;
- padding: 0rpx 0rpx;
- line-height: 100rpx;
- text-align: center;
- border-radius: 50%;
- background-color: #1296db;
- }
- .contact_btn::after {
- border: none;
- }
- }
- </style>
|