| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303 |
- <template>
- <view class="content">
- <u-sticky offsetTop="0" customNavHeight="0">
- <view class="tab-bar">
- <view v-for="(item, index) in tabs" :key="index" class="tab-item"
- :class="{active: tabIndex === item.value}" @click="tabChange(item)">
- {{ item.name }}
- </view>
- </view>
- </u-sticky>
- <view class="item_content">
- <view class="myjt-box" v-if="dataList.length>0">
- <view class="collection-list">
- <view class="item" v-for="(item,index) in dataList" :key="index" @tap="detail(item)">
- <view class="top">
- <view class="img-box">
- <image :src="item.imgUrl" mode="aspectFill"></image>
- <view class="playIcon">
- <image src="../../static/image/course/play_icon.png"></image>
- </view>
- <view v-if="item.isIntegral!=1" class="vip">VIP</view>
- </view>
- <view class="info-box">
- <view class="title ellipsis2">{{item.courseName}}</view>
- <view class="tips ellipsis2">{{item.videoName}}</view>
- <view class="time es-fs-24 es-c-66">{{ $formatDate(item.studyTime) }}</view>
- </view>
- <view class="arrow">
- <image src="/static/images/more_icon_12.png" mode=""></image>
- </view>
- </view>
- <view class="progress-bar">
- <view class="focus-bar" :style="{width:getProgress(item)+'%'}"></view>
- <view class="number">{{ getProgress(item)+'%' }}</view>
- </view>
- </view>
- </view>
- </view>
- <view class="u-f-ajc flex-1" v-else>
- <u-empty class="u-f-ajc" mode="data"></u-empty>
- </view>
- </view>
- </view>
- </template>
- <script>
- import {
- getAppCourseList,
- getLinkData
- } from '@/api/course'
- export default {
- data() {
- return {
- tabs: [{
- name: '待看课',
- value: 3,
- }, {
- name: '已完课',
- value: 2,
- }],
- tabIndex: 3,
- dataList: []
- }
- },
- onShow() {
- this.upCallback()
- },
- methods: {
- tabChange(e) {
- this.tabIndex = e.value;
- this.upCallback()
- },
- async detail(e) {
- const res = await getLinkData({
- linkId: e.linkId
- })
- if (res.code == 200) {
- uni.navigateTo({
- url: '/pages_im/pages/common/webH5/index?url=' + res.data.url
- })
- } else {
- uni.showToast({
- icon: 'none',
- title: res.msg
- })
- }
- },
- upCallback(page) {
- //联网加载数据
- let that = this;
- let params = {
- logType: this.tabIndex
- };
- getAppCourseList(params, 1).then(res => {
- if (res.code == 200) {
- that.dataList = res.data
- } else {
- uni.showToast({
- icon: 'none',
- title: "请求失败",
- });
- that.dataList = null;
- }
- });
- },
- getProgress(item) {
- if (!item.videoDuration || !item.duration) {
- return 0
- }
- let value = (item.duration / item.videoDuration * 1.0 * 100).toFixed(2);
- return value;
- },
- }
- }
- </script>
- <style lang="scss" scoped>
- .tab-bar {
- display: flex;
- background: #fff;
- border-bottom: 1px solid #eee;
- }
- .tab-item {
- flex: 1;
- text-align: center;
- padding: 24rpx 0;
- font-size: 30rpx;
- color: #666;
- border-bottom: 4rpx solid transparent;
- }
- .tab-item.active {
- color: #007AFF;
- border-bottom-color: #007AFF;
- font-weight: 500;
- }
- .myjt-box {
- margin: 0 20rpx;
- margin-top: 20rpx;
- border-radius: 20rpx;
- padding-right: 0rpx;
- background-color: #fff;
- .title-inner {
- margin-left: 20rpx;
- height: 60rpx;
- line-height: 80rpx;
- font-size: 28rpx;
- color: #666;
- }
- .collection-list {
- display: flex;
- flex-wrap: wrap;
- border-radius: 8rpx;
- margin: 0 16rpx;
- margin-top: 20rpx;
- .item {
- display: flex;
- flex-direction: column;
- // align-items: center;
- justify-content: center;
- width: calc(100%);
- margin-bottom: 20rpx;
- .top {
- display: flex;
- flex: 1;
- flex-direction: row;
- .img-box {
- position: relative;
- width: 40%;
- /* 或者任何你想要的宽度 */
- padding-bottom: 25%;
- /* 高度等于宽度 */
- overflow: hidden;
- /* 防止图片溢出 */
- image {
- position: absolute;
- width: 100%;
- height: 100%;
- top: 50%;
- left: 50%;
- transform: translate(-50%, -50%);
- border-radius: 20rpx;
- }
- }
- .playIcon {
- position: absolute;
- width: 50rpx;
- height: 50rpx;
- background: rgba(0, 0, 0, 0.28);
- border-radius: 50%;
- top: 50%;
- left: 50%;
- transform: translate(-50%, -50%);
- image {
- width: 20rpx;
- height: 24rpx;
- border-radius: 0 !important;
- }
- }
- .vip {
- position: absolute;
- width: 49rpx;
- height: 28rpx;
- background: linear-gradient(94deg, #FFE9D0 0%, #E9BD97 100%);
- border-radius: 6rpx;
- top: 16rpx;
- right: 16rpx;
- color: #333;
- font-size: 18rpx;
- text-align: center;
- font-weight: 500;
- font-style: italic;
- }
- }
- .info-box {
- width: calc(60%);
- padding: 0 20rpx;
- padding-right: 0rpx;
- position: relative;
- .title {
- font-size: 26rpx;
- font-family: PingFang SC;
- font-weight: 470;
- color: #333;
- line-height: 40rpx;
- margin-top: 10rpx;
- }
- .tips,
- .time {
- font-size: 26rpx;
- color: #666;
- line-height: 40rpx;
- margin-top: 10rpx;
- }
- .time {
- position: absolute;
- left: 20rpx;
- // bottom: 20rpx;
- }
- }
- .arrow {
- width: 30rpx;
- height: 100%;
- display: flex;
- align-items: center;
- justify-content: center;
- margin-right: 10rpx;
- image {
- width: 26rpx;
- height: 22rpx;
- }
- }
- }
- .progress-bar {
- border-radius: 20rpx;
- background: #ebebeb;
- height: 20rpx;
- margin: 20rpx 0rpx;
- display: flex;
- flex-direction: row;
- align-items: center;
- .focus-bar {
- background: #2583EB;
- border-radius: 20rpx;
- height: 100%;
- }
- .number {
- font-size: 22rpx;
- color: #fff;
- background: #2583EB;
- border-radius: 10rpx;
- border-left: 2rpx solid #fff;
- padding: 0rpx 12rpx;
- margin-left: -2rpx;
- }
- }
- }
- }
- </style>
|