learn.vue 7.1 KB

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