123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342 |
- <template>
- <view class="container">
- <view class="top">
- <image class="bg" src="/static/assets/learn-bg.png" mode="widthFix"></image>
- <view class="top-box">
- <view class="title">《健康生活方式指导》</view>
- <view class="txt">
- <image src="/static/assets/learn1.png"></image>
- <text>共5节课</text>
- </view>
- </view>
- </view>
- <view class="container-body">
- <!-- <view class="center-box">
- <u-tabs lineColor="#f56c6c" :scrollable="false"
- :activeStyle="{color: '#fd694f',fontWeight: 'bold',fontSize:'34rpx'}"
- :inactiveStyle="{color: '#787878',fontSize:'34rpx'}" :list="tabList" @click="ontabList">
- </u-tabs>
- <view class="progress-box">
- <image src="/static/assets/learn2.png"></image>
- <text class="title">听课进度</text>
- <text class="txt">已学习<text style="color: #f74d3a;">0</text>/5节课</text>
- </view>
- <view class="progress">
- <u-line-progress inactiveColor="#f0f4f7" activeColor="#3c9cff" :percentage="0"
- :showText="false"></u-line-progress>
- <text>0%</text>
- </view>
- </view> -->
- <!-- <view class="list">
- <view class="img-box">
- <view class="sub">第一课</view>
- <image src="/static/assets/learn-img.png"></image>
- </view>
- <view class="right">
- <view class="title">第一课 如何防控烦人的慢性病</view>
- <view class="bottom">
- <view class="tip">
- <image src="/static/assets/learn3.png" mode="widthFix"></image>
- <text>答题送金币+200</text>
- </view>
- <view class="btn">已学习4%</view>
- </view>
- </view>
- </view> -->
- <view class="list" v-for="(item,index) in learnList" :key="index">
- <view class="img-box">
- <view class="sub">第一课</view>
- <image :src="item.videoImgUrl || '/static/assets/no-img.png'"></image>
- </view>
- <view class="right">
- <view class="title">{{item.title}}</view>
- <view class="bottom">
- <view class="tip">
- <image src="/static/assets/learn3.png" mode="widthFix"></image>
- <text>答题送金币+200</text>
- </view>
- <view @click="goLive(item)" class="btn" v-if="item.stauts==0">已学习4%</view>
- <view @click="goLive(item)" class="btn-red" v-else>去学习</view>
- </view>
- </view>
- </view>
- </view>
- </view>
- </template>
- <script>
- import { compile } from "vue";
- import {
- courseList
- } from '@/api/class.js'
-
- export default {
- data() {
- return {
- courseId: null,
- tabList: [{
- name: '详情'
- }, {
- name: '课程目录'
- }],
- learnList: []
- }
- },
- computed: {
- },
- onLoad(options) {
- // 接收传递的课程 ID
- if (options.courseId) {
- this.courseId = options.courseId;
- }
- },
- mounted() {
- this.getCourseList()
- },
- methods: {
- goLive(item) {
- console.log("id",item)
- const id=item.videoId
- uni.navigateTo({
- url: '/pages_course/videovip?videoitem='+JSON.stringify(item)
- })
- },
- getCourseList() {
- courseList().then(res => {
- console.log("课程列表", res)
- if (res.code == 200) {
- // 1. 根据 courseId 找到对应的课程
- const course = res.data.find(item => item.courseId == this.courseId);
- if (course && course.fsUserCourseVideoList) {
- // 2. 映射数据到 learnList 格式
- this.learnList = course.fsUserCourseVideoList
- console.log("learnList是多少》》", this.learnList)
- } else {
- console.warn("未找到课程或视频列表");
- this.learnList = [];
- }
- } else {
- uni.hideLoading();
- uni.showToast({
- title: res.msg,
- icon: 'none'
- });
- }
- })
- }
- // getCourseDetails() {
- // var data={
- // courseId:courseId
- // }
- // courseDetails(data).then(res => {
- // console.log("课程详情", res)
- // if (res.code == 200) {
- // } else {
- // uni.hideLoading();
- // uni.showToast({
- // title: res.msg,
- // icon: 'none'
- // });
- // }
- // })
- // }
- }
- }
- </script>
- <style lang="scss" scoped>
- .container {
- padding: 0 0 30rpx;
- background-color: #f0f4f7;
- .top {
- position: relative;
- .bg {
- width: 100%;
- }
- .top-box {
- position: absolute;
- bottom: -90rpx;
- width: 100%;
- padding: 30rpx;
- background: linear-gradient(to bottom,
- rgba(255, 255, 255, 0.5) 0%,
- rgba(255, 255, 255, 0.9) 20%,
- rgba(255, 255, 255, 1) 100%);
- border-radius: 16rpx;
- .title {
- font-size: 34rpx;
- }
- .txt {
- margin-top: 20rpx;
- display: flex;
- align-items: center;
- image {
- width: 36rpx;
- height: 36rpx;
- margin: 0 8rpx;
- }
- text {
- font-size: 28rpx;
- color: #595959;
- }
- }
- }
- }
- .container-body {
- margin-top: 110rpx;
- padding: 0 24rpx;
- .center-box {
- background-color: #ffffff;
- padding: 10rpx 24rpx 50rpx;
- border-radius: 16rpx;
- .progress-box {
- display: flex;
- align-items: center;
- margin: 50rpx 0 30rpx;
- image {
- width: 38rpx;
- height: 38rpx;
- }
- .title {
- margin: 0 10rpx 0 4rpx;
- font-size: 34rpx;
- }
- .txt {
- font-size: 28rpx;
- color: #595959;
- }
- }
- .progress {
- display: flex;
- align-items: center;
- text {
- font-size: 26rpx;
- margin-left: 12rpx;
- }
- }
- }
- .list {
- padding: 20rpx;
- background-color: #ffffff;
- border-radius: 16rpx;
- display: flex;
- justify-content: space-between;
- align-items: center;
- box-sizing: border-box;
- margin-top: 20rpx;
- .img-box {
- width: 240rpx;
- height: 150rpx;
- border-radius: 16rpx;
- overflow: hidden;
- position: relative;
- flex-shrink: 0;
- .sub {
- background-color: rgba(0, 0, 0, 0.8);
- padding: 4rpx 16rpx;
- color: #ffffff;
- position: absolute;
- top: 0;
- left: 0;
- font-size: 24rpx;
- border-radius: 8rpx;
- }
- image {
- width: 100%;
- height: 100%;
- }
- }
- .right {
- height: 150rpx;
- margin-left: 20rpx;
- flex: 1;
- display: flex;
- flex-direction: column;
- justify-content: space-between;
- min-width: 0;
- .title {
- font-size: 30rpx;
- font-weight: 500;
- overflow: hidden;
- text-overflow: ellipsis;
- display: -webkit-box;
- -webkit-line-clamp: 2;
- /* 控制显示行数 */
- -webkit-box-orient: vertical;
- word-break: break-all;
- /* 允许单词内换行 */
- max-height: 80rpx;
- /* 根据字体大小调整 */
- line-height: 40rpx;
- /* 行高与字体大小匹配 */
- width: 100%;
- /* 确保宽度占满容器 */
- }
- .bottom {
- display: flex;
- // flex-direction: column;
- justify-content: space-between;
- align-items: center;
- font-size: 26rpx;
- .tip {
- background: linear-gradient(to right, #fcecd0, #ffffff);
- padding: 8rpx 12rpx;
- border-radius: 22rpx;
- color: #f2931d;
- image {
- width: 36rpx;
- height: 36rpx;
- margin-right: 4rpx;
- }
- text {}
- }
- .btn {
- background-color: #fdf0e7;
- padding: 8rpx 16rpx;
- color: #f38600;
- border-radius: 12rpx;
- }
- .btn-red {
- background-color: #ff512f;
- padding: 8rpx 18rpx;
- color: #ffffff;
- border-radius: 12rpx;
- }
- }
- }
- }
- }
- }
- </style>
|