famousHallPageItem.vue 7.8 KB

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