learningPage.vue 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321
  1. <template>
  2. <view class="item_content">
  3. <mescroll-body @init="mescrollInit" top="0" bottom="0" :down="downOption" @down="downCallback" :up="upOption"
  4. @up="upCallback" @emptyclick="emptyClick">
  5. <view class="myjt-box" v-for="(citem,index) in dataList" :key="index" >
  6. <view class="title-inner">{{citem.date}}</view>
  7. <view class="collection-list">
  8. <view class="item" v-for="(item,index) in citem.courses" @tap="goToInfo(item)" :key="index">
  9. <view class="top">
  10. <view class="img-box">
  11. <image :src="item.imgUrl" mode="aspectFill"></image>
  12. <view class="playIcon">
  13. <image src="../../static/image/course/play_icon.png"></image>
  14. </view>
  15. <view v-if="item.isIntegral!=1" class="vip">VIP</view>
  16. </view>
  17. <view class="info-box">
  18. <view class="title ellipsis2">{{item.courseName}}</view>
  19. <view class="tips ellipsis2">{{item.videoName}}</view>
  20. <view class="time es-fs-24 es-c-66">{{ $formatDate(item.studyTime) }}</view>
  21. </view>
  22. <view class="arrow">
  23. <image src="/static/images/more_icon_12.png" mode=""></image>
  24. </view>
  25. </view>
  26. <view class="progress-bar">
  27. <view class="focus-bar" :style="{width:getProgress(item)+'%'}"></view>
  28. <view class="number">{{ getProgress(item)+'%' }}</view>
  29. </view>
  30. </view>
  31. </view>
  32. </view>
  33. </mescroll-body>
  34. </view>
  35. </template>
  36. <script>
  37. import MescrollMixin from "@/uni_modules/mescroll-uni/components/mescroll-uni/mescroll-mixins.js";
  38. import MescrollMoreItemMixin from "@/uni_modules/mescroll-uni/components/mescroll-uni/mixins/mescroll-more-item.js";
  39. import { getCourseStudyList } from '@/api/course'
  40. export default {
  41. mixins: [MescrollMixin,MescrollMoreItemMixin],
  42. props: {
  43. cataType:Number,
  44. i:Number,
  45. index:Number,
  46. itemData: {
  47. type: Object,
  48. default() {
  49. return { };
  50. }
  51. },
  52. },
  53. watch:{
  54. },
  55. onLoad() {
  56. },
  57. onUnload() {
  58. },
  59. onShow() {
  60. this.refreshPage();
  61. },
  62. data() {
  63. return {
  64. bottomBlackLineHeight: uni.getStorageSync('bottomBlackLineHeight'),
  65. downOption: {
  66. auto: false // 不自动加载 (mixin已处理第一个tab触发downCallback)
  67. },
  68. upOption: {
  69. auto: false, // 不自动加载
  70. page: {
  71. num: 0, // 当前页码,默认0,回调之前会加1,即callback(page)会从1开始
  72. size: 10 // 每页数据的数量
  73. },
  74. noMoreSize: 4, //如果列表已无数据,可设置列表的总数量要大于半页才显示无更多数据;避免列表数据过少(比如只有一条数据),显示无更多数据会不好看; 默认5
  75. toTop:{
  76. width:0,
  77. }
  78. },
  79. keyword:"",
  80. dataList: [] //列表数据
  81. }
  82. },
  83. mounted() {
  84. //this.refreshPage();
  85. },
  86. methods: {
  87. /*下拉刷新的回调 */
  88. downCallback() {
  89. // 下拉刷新的回调,默认重置上拉加载列表为第一页 (自动执行 page.num=1, 再触发upCallback方法 )
  90. this.mescroll.resetUpScroll(true);
  91. },
  92. /*上拉加载的回调 */
  93. upCallback(page) {
  94. //联网加载数据
  95. var that = this;
  96. var params = {"keyword":this.keyword};
  97. getCourseStudyList(params,page.num).then(res => {
  98. if(res.code==200){
  99. setTimeout(()=>{
  100. this.mescroll.endByPage(res.data.list.length, res.data.pages);
  101. if(page.num == 1) this.dataList = []; //如果是第一页需手动制空列表
  102. this.dataList=this.dataList.concat(res.data.list); //追加新数据
  103. },400);
  104. }else{
  105. uni.showToast({
  106. icon:'none',
  107. title: "请求失败",
  108. });
  109. that.dataList = null;
  110. that.mescroll.endErr();
  111. }
  112. });
  113. },
  114. getProgress(item){
  115. let value=(item.currentTimes/item.times*1.0*100).toFixed(2);
  116. return value;
  117. },
  118. goToInfo(item){
  119. let url='./info?courseId='+item.courseId+'&times='+item.currentTimes+'&videoId='+item.videoId+'&isLearning=true';
  120. this.$navTo(url);
  121. },
  122. //点击空布局按钮的回调
  123. emptyClick() {
  124. },
  125. hasPrimession(){
  126. let primession=this.isMyCts;
  127. return primession;
  128. },
  129. refreshPage(){
  130. this.mescroll.hideTopBtn();
  131. this.mescroll.resetUpScroll(true);
  132. }
  133. },
  134. created(){
  135. let that = this;
  136. uni.$on('refreshStudyTime', function(data) {
  137. that.refreshPage();
  138. });
  139. uni.$on('refreshFollowLog', function(data){
  140. //that.refreshPage();
  141. that.$emit('resetUpScroll');
  142. });
  143. },
  144. destroyed() {
  145. // 注销全局配置监听
  146. uni.$off("refreshFollowLog");
  147. uni.$off('refreshStudyTime');
  148. }
  149. }
  150. </script>
  151. <style lang="scss" scoped>
  152. .item_content .content:last-child .sline{
  153. height: 100%;
  154. }
  155. .item_content{
  156. background-color: #f7f7f7;
  157. margin-top: 10rpx;
  158. }
  159. .myjt-box{
  160. margin:0 20rpx;
  161. margin-top: 20rpx;
  162. border-radius: 20rpx;
  163. padding-right: 0rpx;
  164. background-color: #fff;
  165. .title-inner{
  166. margin-left: 20rpx;
  167. height: 60rpx;
  168. line-height: 80rpx;
  169. font-size: 28rpx;
  170. color: #666;
  171. }
  172. .collection-list{
  173. display: flex;
  174. flex-wrap: wrap;
  175. border-radius: 8rpx;
  176. margin: 0 16rpx;
  177. margin-top:20rpx;
  178. .item{
  179. display: flex;
  180. flex-direction: column;
  181. // align-items: center;
  182. justify-content: center;
  183. width: calc(100%);
  184. margin-bottom: 20rpx;
  185. .top{
  186. display: flex;
  187. flex: 1;
  188. flex-direction: row;
  189. .img-box{
  190. position: relative;
  191. width: 40%; /* 或者任何你想要的宽度 */
  192. padding-bottom: 25%; /* 高度等于宽度 */
  193. overflow: hidden; /* 防止图片溢出 */
  194. image{
  195. position: absolute;
  196. width: 100%;
  197. height: 100%;
  198. top: 50%;
  199. left: 50%;
  200. transform: translate(-50%, -50%);
  201. border-radius: 20rpx;
  202. }
  203. }
  204. .playIcon{
  205. position: absolute;
  206. width: 50rpx;
  207. height: 50rpx;
  208. background: rgba(0, 0, 0, 0.28);
  209. border-radius: 50%;
  210. top: 50%;
  211. left: 50%;
  212. transform: translate(-50%, -50%);
  213. image{
  214. width:20rpx ;
  215. height: 24rpx;
  216. border-radius: 0 !important;
  217. }
  218. }
  219. .vip{
  220. position: absolute;
  221. width: 49rpx;
  222. height: 28rpx;
  223. background: linear-gradient(94deg, #FFE9D0 0%, #E9BD97 100%);
  224. border-radius: 6rpx;
  225. top: 16rpx;
  226. right: 16rpx;
  227. color:#333;
  228. font-size:18rpx ;
  229. text-align: center;
  230. font-weight: 500;
  231. font-style: italic;
  232. }
  233. }
  234. .info-box{
  235. width: calc(60%);
  236. padding:0 20rpx;
  237. padding-right: 0rpx;
  238. position: relative;
  239. .title{
  240. font-size: 26rpx;
  241. font-family: PingFang SC;
  242. font-weight: 470;
  243. color: #333;
  244. line-height: 40rpx;
  245. margin-top: 10rpx;
  246. }
  247. .tips,.time{
  248. font-size: 26rpx;
  249. color: #666;
  250. line-height: 40rpx;
  251. margin-top: 10rpx;
  252. }
  253. .time{
  254. position: absolute;
  255. left: 20rpx;
  256. // bottom: 20rpx;
  257. }
  258. }
  259. .arrow{
  260. width: 30rpx;
  261. height: 100%;
  262. display: flex;
  263. align-items: center;
  264. justify-content: center;
  265. margin-right: 10rpx;
  266. image{
  267. width: 26rpx;
  268. height: 22rpx;
  269. }
  270. }
  271. }
  272. .progress-bar{
  273. border-radius: 20rpx;
  274. background: #ebebeb;
  275. height: 20rpx;
  276. margin:20rpx 0rpx;
  277. display: flex;
  278. flex-direction: row;
  279. align-items: center;
  280. .focus-bar{
  281. background:#FF5C03;
  282. border-radius: 20rpx;
  283. height: 100%;
  284. }
  285. .number{
  286. font-size: 22rpx;
  287. color: #fff;
  288. background:#FF5C03;
  289. border-radius: 10rpx;
  290. border-left: 2rpx solid #fff;
  291. padding: 0rpx 12rpx;
  292. margin-left: -2rpx;
  293. }
  294. }
  295. }
  296. }
  297. </style>