favoritePage.vue 6.6 KB

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