learn.vue 7.0 KB

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