learn.vue 7.0 KB

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