learningNew.vue 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303
  1. <template>
  2. <view class="content">
  3. <u-sticky offsetTop="0" customNavHeight="0">
  4. <view class="tab-bar">
  5. <view v-for="(item, index) in tabs" :key="index" class="tab-item"
  6. :class="{active: tabIndex === item.value}" @click="tabChange(item)">
  7. {{ item.name }}
  8. </view>
  9. </view>
  10. </u-sticky>
  11. <view class="item_content">
  12. <view class="myjt-box" v-if="dataList.length>0">
  13. <view class="collection-list">
  14. <view class="item" v-for="(item,index) in dataList" :key="index" @tap="detail(item)">
  15. <view class="top">
  16. <view class="img-box">
  17. <image :src="item.imgUrl" mode="aspectFill"></image>
  18. <view class="playIcon">
  19. <image src="../../static/image/course/play_icon.png"></image>
  20. </view>
  21. <view v-if="item.isIntegral!=1" class="vip">VIP</view>
  22. </view>
  23. <view class="info-box">
  24. <view class="title ellipsis2">{{item.courseName}}</view>
  25. <view class="tips ellipsis2">{{item.videoName}}</view>
  26. <view class="time es-fs-24 es-c-66">{{ $formatDate(item.studyTime) }}</view>
  27. </view>
  28. <view class="arrow">
  29. <image src="/static/images/more_icon_12.png" mode=""></image>
  30. </view>
  31. </view>
  32. <view class="progress-bar">
  33. <view class="focus-bar" :style="{width:getProgress(item)+'%'}"></view>
  34. <view class="number">{{ getProgress(item)+'%' }}</view>
  35. </view>
  36. </view>
  37. </view>
  38. </view>
  39. <view class="u-f-ajc flex-1" v-else>
  40. <u-empty class="u-f-ajc" mode="data"></u-empty>
  41. </view>
  42. </view>
  43. </view>
  44. </template>
  45. <script>
  46. import {
  47. getAppCourseList,
  48. getLinkData
  49. } from '@/api/course'
  50. export default {
  51. data() {
  52. return {
  53. tabs: [{
  54. name: '待看课',
  55. value: 3,
  56. }, {
  57. name: '已完课',
  58. value: 2,
  59. }],
  60. tabIndex: 3,
  61. dataList: []
  62. }
  63. },
  64. onShow() {
  65. this.upCallback()
  66. },
  67. methods: {
  68. tabChange(e) {
  69. this.tabIndex = e.value;
  70. this.upCallback()
  71. },
  72. async detail(e) {
  73. const res = await getLinkData({
  74. linkId: e.linkId
  75. })
  76. if (res.code == 200) {
  77. uni.navigateTo({
  78. url: '/pages_im/pages/common/webH5/index?url=' + res.data.url
  79. })
  80. } else {
  81. uni.showToast({
  82. icon: 'none',
  83. title: res.msg
  84. })
  85. }
  86. },
  87. upCallback(page) {
  88. //联网加载数据
  89. let that = this;
  90. let params = {
  91. logType: this.tabIndex
  92. };
  93. getAppCourseList(params, 1).then(res => {
  94. if (res.code == 200) {
  95. that.dataList = res.data
  96. } else {
  97. uni.showToast({
  98. icon: 'none',
  99. title: "请求失败",
  100. });
  101. that.dataList = null;
  102. }
  103. });
  104. },
  105. getProgress(item) {
  106. if (!item.videoDuration || !item.duration) {
  107. return 0
  108. }
  109. let value = (item.duration / item.videoDuration * 1.0 * 100).toFixed(2);
  110. return value;
  111. },
  112. }
  113. }
  114. </script>
  115. <style lang="scss" scoped>
  116. .tab-bar {
  117. display: flex;
  118. background: #fff;
  119. border-bottom: 1px solid #eee;
  120. }
  121. .tab-item {
  122. flex: 1;
  123. text-align: center;
  124. padding: 24rpx 0;
  125. font-size: 30rpx;
  126. color: #666;
  127. border-bottom: 4rpx solid transparent;
  128. }
  129. .tab-item.active {
  130. color: #007AFF;
  131. border-bottom-color: #007AFF;
  132. font-weight: 500;
  133. }
  134. .myjt-box {
  135. margin: 0 20rpx;
  136. margin-top: 20rpx;
  137. border-radius: 20rpx;
  138. padding-right: 0rpx;
  139. background-color: #fff;
  140. .title-inner {
  141. margin-left: 20rpx;
  142. height: 60rpx;
  143. line-height: 80rpx;
  144. font-size: 28rpx;
  145. color: #666;
  146. }
  147. .collection-list {
  148. display: flex;
  149. flex-wrap: wrap;
  150. border-radius: 8rpx;
  151. margin: 0 16rpx;
  152. margin-top: 20rpx;
  153. .item {
  154. display: flex;
  155. flex-direction: column;
  156. // align-items: center;
  157. justify-content: center;
  158. width: calc(100%);
  159. margin-bottom: 20rpx;
  160. .top {
  161. display: flex;
  162. flex: 1;
  163. flex-direction: row;
  164. .img-box {
  165. position: relative;
  166. width: 40%;
  167. /* 或者任何你想要的宽度 */
  168. padding-bottom: 25%;
  169. /* 高度等于宽度 */
  170. overflow: hidden;
  171. /* 防止图片溢出 */
  172. image {
  173. position: absolute;
  174. width: 100%;
  175. height: 100%;
  176. top: 50%;
  177. left: 50%;
  178. transform: translate(-50%, -50%);
  179. border-radius: 20rpx;
  180. }
  181. }
  182. .playIcon {
  183. position: absolute;
  184. width: 50rpx;
  185. height: 50rpx;
  186. background: rgba(0, 0, 0, 0.28);
  187. border-radius: 50%;
  188. top: 50%;
  189. left: 50%;
  190. transform: translate(-50%, -50%);
  191. image {
  192. width: 20rpx;
  193. height: 24rpx;
  194. border-radius: 0 !important;
  195. }
  196. }
  197. .vip {
  198. position: absolute;
  199. width: 49rpx;
  200. height: 28rpx;
  201. background: linear-gradient(94deg, #FFE9D0 0%, #E9BD97 100%);
  202. border-radius: 6rpx;
  203. top: 16rpx;
  204. right: 16rpx;
  205. color: #333;
  206. font-size: 18rpx;
  207. text-align: center;
  208. font-weight: 500;
  209. font-style: italic;
  210. }
  211. }
  212. .info-box {
  213. width: calc(60%);
  214. padding: 0 20rpx;
  215. padding-right: 0rpx;
  216. position: relative;
  217. .title {
  218. font-size: 26rpx;
  219. font-family: PingFang SC;
  220. font-weight: 470;
  221. color: #333;
  222. line-height: 40rpx;
  223. margin-top: 10rpx;
  224. }
  225. .tips,
  226. .time {
  227. font-size: 26rpx;
  228. color: #666;
  229. line-height: 40rpx;
  230. margin-top: 10rpx;
  231. }
  232. .time {
  233. position: absolute;
  234. left: 20rpx;
  235. // bottom: 20rpx;
  236. }
  237. }
  238. .arrow {
  239. width: 30rpx;
  240. height: 100%;
  241. display: flex;
  242. align-items: center;
  243. justify-content: center;
  244. margin-right: 10rpx;
  245. image {
  246. width: 26rpx;
  247. height: 22rpx;
  248. }
  249. }
  250. }
  251. .progress-bar {
  252. border-radius: 20rpx;
  253. background: #ebebeb;
  254. height: 20rpx;
  255. margin: 20rpx 0rpx;
  256. display: flex;
  257. flex-direction: row;
  258. align-items: center;
  259. .focus-bar {
  260. background: #2583EB;
  261. border-radius: 20rpx;
  262. height: 100%;
  263. }
  264. .number {
  265. font-size: 22rpx;
  266. color: #fff;
  267. background: #2583EB;
  268. border-radius: 10rpx;
  269. border-left: 2rpx solid #fff;
  270. padding: 0rpx 12rpx;
  271. margin-left: -2rpx;
  272. }
  273. }
  274. }
  275. }
  276. </style>