learn.vue 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342
  1. <template>
  2. <view class="container">
  3. <view class="top">
  4. <image class="bg" src="/static/assets/learn-bg.png" mode="widthFix"></image>
  5. <view class="top-box">
  6. <view class="title">《健康生活方式指导》</view>
  7. <view class="txt">
  8. <image src="/static/assets/learn1.png"></image>
  9. <text>共5节课</text>
  10. </view>
  11. </view>
  12. </view>
  13. <view class="container-body">
  14. <!-- <view class="center-box">
  15. <u-tabs lineColor="#f56c6c" :scrollable="false"
  16. :activeStyle="{color: '#fd694f',fontWeight: 'bold',fontSize:'34rpx'}"
  17. :inactiveStyle="{color: '#787878',fontSize:'34rpx'}" :list="tabList" @click="ontabList">
  18. </u-tabs>
  19. <view class="progress-box">
  20. <image src="/static/assets/learn2.png"></image>
  21. <text class="title">听课进度</text>
  22. <text class="txt">已学习<text style="color: #f74d3a;">0</text>/5节课</text>
  23. </view>
  24. <view class="progress">
  25. <u-line-progress inactiveColor="#f0f4f7" activeColor="#3c9cff" :percentage="0"
  26. :showText="false"></u-line-progress>
  27. <text>0%</text>
  28. </view>
  29. </view> -->
  30. <!-- <view class="list">
  31. <view class="img-box">
  32. <view class="sub">第一课</view>
  33. <image src="/static/assets/learn-img.png"></image>
  34. </view>
  35. <view class="right">
  36. <view class="title">第一课 如何防控烦人的慢性病</view>
  37. <view class="bottom">
  38. <view class="tip">
  39. <image src="/static/assets/learn3.png" mode="widthFix"></image>
  40. <text>答题送金币+200</text>
  41. </view>
  42. <view class="btn">已学习4%</view>
  43. </view>
  44. </view>
  45. </view> -->
  46. <view class="list" v-for="(item,index) in learnList" :key="index">
  47. <view class="img-box">
  48. <view class="sub">第一课</view>
  49. <image :src="item.videoImgUrl || '/static/assets/no-img.png'"></image>
  50. </view>
  51. <view class="right">
  52. <view class="title">{{item.title}}</view>
  53. <view class="bottom">
  54. <view class="tip">
  55. <image src="/static/assets/learn3.png" mode="widthFix"></image>
  56. <text>答题送金币+200</text>
  57. </view>
  58. <view @click="goLive(item)" class="btn" v-if="item.stauts==0">已学习4%</view>
  59. <view @click="goLive(item)" class="btn-red" v-else>去学习</view>
  60. </view>
  61. </view>
  62. </view>
  63. </view>
  64. </view>
  65. </template>
  66. <script>
  67. import { compile } from "vue";
  68. import {
  69. courseList
  70. } from '@/api/class.js'
  71. export default {
  72. data() {
  73. return {
  74. courseId: null,
  75. tabList: [{
  76. name: '详情'
  77. }, {
  78. name: '课程目录'
  79. }],
  80. learnList: []
  81. }
  82. },
  83. computed: {
  84. },
  85. onLoad(options) {
  86. // 接收传递的课程 ID
  87. if (options.courseId) {
  88. this.courseId = options.courseId;
  89. }
  90. },
  91. mounted() {
  92. this.getCourseList()
  93. },
  94. methods: {
  95. goLive(item) {
  96. console.log("id",item)
  97. const id=item.videoId
  98. uni.navigateTo({
  99. url: '/pages_course/videovip?videoitem='+JSON.stringify(item)
  100. })
  101. },
  102. getCourseList() {
  103. courseList().then(res => {
  104. console.log("课程列表", res)
  105. if (res.code == 200) {
  106. // 1. 根据 courseId 找到对应的课程
  107. const course = res.data.find(item => item.courseId == this.courseId);
  108. if (course && course.fsUserCourseVideoList) {
  109. // 2. 映射数据到 learnList 格式
  110. this.learnList = course.fsUserCourseVideoList
  111. console.log("learnList是多少》》", this.learnList)
  112. } else {
  113. console.warn("未找到课程或视频列表");
  114. this.learnList = [];
  115. }
  116. } else {
  117. uni.hideLoading();
  118. uni.showToast({
  119. title: res.msg,
  120. icon: 'none'
  121. });
  122. }
  123. })
  124. }
  125. // getCourseDetails() {
  126. // var data={
  127. // courseId:courseId
  128. // }
  129. // courseDetails(data).then(res => {
  130. // console.log("课程详情", res)
  131. // if (res.code == 200) {
  132. // } else {
  133. // uni.hideLoading();
  134. // uni.showToast({
  135. // title: res.msg,
  136. // icon: 'none'
  137. // });
  138. // }
  139. // })
  140. // }
  141. }
  142. }
  143. </script>
  144. <style lang="scss" scoped>
  145. .container {
  146. padding: 0 0 30rpx;
  147. background-color: #f0f4f7;
  148. .top {
  149. position: relative;
  150. .bg {
  151. width: 100%;
  152. }
  153. .top-box {
  154. position: absolute;
  155. bottom: -90rpx;
  156. width: 100%;
  157. padding: 30rpx;
  158. background: linear-gradient(to bottom,
  159. rgba(255, 255, 255, 0.5) 0%,
  160. rgba(255, 255, 255, 0.9) 20%,
  161. rgba(255, 255, 255, 1) 100%);
  162. border-radius: 16rpx;
  163. .title {
  164. font-size: 34rpx;
  165. }
  166. .txt {
  167. margin-top: 20rpx;
  168. display: flex;
  169. align-items: center;
  170. image {
  171. width: 36rpx;
  172. height: 36rpx;
  173. margin: 0 8rpx;
  174. }
  175. text {
  176. font-size: 28rpx;
  177. color: #595959;
  178. }
  179. }
  180. }
  181. }
  182. .container-body {
  183. margin-top: 110rpx;
  184. padding: 0 24rpx;
  185. .center-box {
  186. background-color: #ffffff;
  187. padding: 10rpx 24rpx 50rpx;
  188. border-radius: 16rpx;
  189. .progress-box {
  190. display: flex;
  191. align-items: center;
  192. margin: 50rpx 0 30rpx;
  193. image {
  194. width: 38rpx;
  195. height: 38rpx;
  196. }
  197. .title {
  198. margin: 0 10rpx 0 4rpx;
  199. font-size: 34rpx;
  200. }
  201. .txt {
  202. font-size: 28rpx;
  203. color: #595959;
  204. }
  205. }
  206. .progress {
  207. display: flex;
  208. align-items: center;
  209. text {
  210. font-size: 26rpx;
  211. margin-left: 12rpx;
  212. }
  213. }
  214. }
  215. .list {
  216. padding: 20rpx;
  217. background-color: #ffffff;
  218. border-radius: 16rpx;
  219. display: flex;
  220. justify-content: space-between;
  221. align-items: center;
  222. box-sizing: border-box;
  223. margin-top: 20rpx;
  224. .img-box {
  225. width: 240rpx;
  226. height: 150rpx;
  227. border-radius: 16rpx;
  228. overflow: hidden;
  229. position: relative;
  230. flex-shrink: 0;
  231. .sub {
  232. background-color: rgba(0, 0, 0, 0.8);
  233. padding: 4rpx 16rpx;
  234. color: #ffffff;
  235. position: absolute;
  236. top: 0;
  237. left: 0;
  238. font-size: 24rpx;
  239. border-radius: 8rpx;
  240. }
  241. image {
  242. width: 100%;
  243. height: 100%;
  244. }
  245. }
  246. .right {
  247. height: 150rpx;
  248. margin-left: 20rpx;
  249. flex: 1;
  250. display: flex;
  251. flex-direction: column;
  252. justify-content: space-between;
  253. min-width: 0;
  254. .title {
  255. font-size: 30rpx;
  256. font-weight: 500;
  257. overflow: hidden;
  258. text-overflow: ellipsis;
  259. display: -webkit-box;
  260. -webkit-line-clamp: 2;
  261. /* 控制显示行数 */
  262. -webkit-box-orient: vertical;
  263. word-break: break-all;
  264. /* 允许单词内换行 */
  265. max-height: 80rpx;
  266. /* 根据字体大小调整 */
  267. line-height: 40rpx;
  268. /* 行高与字体大小匹配 */
  269. width: 100%;
  270. /* 确保宽度占满容器 */
  271. }
  272. .bottom {
  273. display: flex;
  274. // flex-direction: column;
  275. justify-content: space-between;
  276. align-items: center;
  277. font-size: 26rpx;
  278. .tip {
  279. background: linear-gradient(to right, #fcecd0, #ffffff);
  280. padding: 8rpx 12rpx;
  281. border-radius: 22rpx;
  282. color: #f2931d;
  283. image {
  284. width: 36rpx;
  285. height: 36rpx;
  286. margin-right: 4rpx;
  287. }
  288. text {}
  289. }
  290. .btn {
  291. background-color: #fdf0e7;
  292. padding: 8rpx 16rpx;
  293. color: #f38600;
  294. border-radius: 12rpx;
  295. }
  296. .btn-red {
  297. background-color: #ff512f;
  298. padding: 8rpx 18rpx;
  299. color: #ffffff;
  300. border-radius: 12rpx;
  301. }
  302. }
  303. }
  304. }
  305. }
  306. }
  307. </style>