learn.vue 7.1 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="https://bjczwh.oss-cn-beijing.aliyuncs.com/app/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://bjczwh.oss-cn-beijing.aliyuncs.com/app/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://bjczwh.oss-cn-beijing.aliyuncs.com/app/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. background-color: #fff;
  156. border-radius: 16rpx;
  157. .title {
  158. font-size: 34rpx;
  159. }
  160. .txt {
  161. margin-top: 20rpx;
  162. display: flex;
  163. align-items: center;
  164. image {
  165. width: 36rpx;
  166. height: 36rpx;
  167. margin: 0 8rpx;
  168. }
  169. text {
  170. font-size: 28rpx;
  171. color: #595959;
  172. }
  173. }
  174. }
  175. }
  176. .container-body {
  177. margin-top: 110rpx;
  178. padding: 0 24rpx;
  179. .center-box {
  180. background-color: #ffffff;
  181. padding: 10rpx 24rpx 50rpx;
  182. border-radius: 16rpx;
  183. .progress-box {
  184. display: flex;
  185. align-items: center;
  186. margin: 50rpx 0 30rpx;
  187. image {
  188. width: 38rpx;
  189. height: 38rpx;
  190. }
  191. .title {
  192. margin: 0 10rpx 0 4rpx;
  193. font-size: 34rpx;
  194. }
  195. .txt {
  196. font-size: 28rpx;
  197. color: #595959;
  198. }
  199. }
  200. .progress {
  201. display: flex;
  202. align-items: center;
  203. text {
  204. font-size: 26rpx;
  205. margin-left: 12rpx;
  206. }
  207. }
  208. }
  209. .list {
  210. padding: 20rpx;
  211. background-color: #ffffff;
  212. border-radius: 16rpx;
  213. display: flex;
  214. justify-content: space-between;
  215. align-items: center;
  216. box-sizing: border-box;
  217. margin-top: 20rpx;
  218. .img-box {
  219. width: 240rpx;
  220. height: 150rpx;
  221. border-radius: 16rpx;
  222. overflow: hidden;
  223. position: relative;
  224. flex-shrink: 0;
  225. .sub {
  226. background-color: rgba(0, 0, 0, 0.8);
  227. padding: 4rpx 16rpx;
  228. color: #ffffff;
  229. position: absolute;
  230. top: 0;
  231. left: 0;
  232. font-size: 24rpx;
  233. border-radius: 8rpx;
  234. }
  235. image {
  236. width: 100%;
  237. height: 100%;
  238. }
  239. }
  240. .right {
  241. height: 150rpx;
  242. margin-left: 20rpx;
  243. flex: 1;
  244. display: flex;
  245. flex-direction: column;
  246. justify-content: space-between;
  247. min-width: 0;
  248. .title {
  249. font-size: 30rpx;
  250. font-weight: 500;
  251. overflow: hidden;
  252. text-overflow: ellipsis;
  253. display: -webkit-box;
  254. -webkit-line-clamp: 2;
  255. /* 控制显示行数 */
  256. -webkit-box-orient: vertical;
  257. word-break: break-all;
  258. /* 允许单词内换行 */
  259. max-height: 80rpx;
  260. /* 根据字体大小调整 */
  261. line-height: 40rpx;
  262. /* 行高与字体大小匹配 */
  263. width: 100%;
  264. /* 确保宽度占满容器 */
  265. }
  266. .bottom {
  267. display: flex;
  268. // flex-direction: column;
  269. justify-content: flex-end;
  270. align-items: center;
  271. font-size: 26rpx;
  272. .tip {
  273. background: linear-gradient(to right, #fcecd0, #ffffff);
  274. padding: 8rpx 12rpx;
  275. border-radius: 22rpx;
  276. color: #f2931d;
  277. image {
  278. width: 36rpx;
  279. height: 36rpx;
  280. margin-right: 4rpx;
  281. }
  282. text {}
  283. }
  284. .btn {
  285. background-color: #fdf0e7;
  286. padding: 8rpx 16rpx;
  287. color: #f38600;
  288. border-radius: 12rpx;
  289. }
  290. .btn-red {
  291. background-color: #ff512f;
  292. padding: 8rpx 18rpx;
  293. color: #ffffff;
  294. border-radius: 12rpx;
  295. }
  296. }
  297. }
  298. }
  299. }
  300. }
  301. </style>