contentList.vue 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. <template>
  2. <view>
  3. <!-- <view class="ban">
  4. <swiper class="swiper" @change="swiperChange" autoplay="true" interval="5000" duration="300">
  5. <block v-for="(item, index) in bannerList" :key="index">
  6. <swiper-item @click="clickBanner(item)"><image lazy-load="true" :src="item.pic" mode="aspectFill"></image></swiper-item>
  7. </block>
  8. </swiper>
  9. <view class="dots ddflex">
  10. <block v-for="(item, index) in bannerList" :key="index"><view :class="['dot', index == swiperCurrent ? 'active' : '']"></view></block>
  11. </view>
  12. </view> -->
  13. <view class="box">
  14. <!-- <view class="title dflex">{{title}}</view> -->
  15. <view class="rec">
  16. <navigator :url="'/topic/content/content?id=' + item.id" hover-class="none" class="li dflex" v-for="(item,index) in contentList" :key="index">
  17. <view class="flex">
  18. <view class="rec-tit tovers">{{item.title}}</view>
  19. <view class="dflex">
  20. <!-- <view class="author ddflex"><image src="../../static/pages/images/zbgw.png" mode="aspectFill"></image>欧衡</view> -->
  21. <view class="rec-time">{{item.createDate}}</view>
  22. </view>
  23. </view>
  24. <image :src="item.pic" mode="aspectFill" class="rec-img"></image>
  25. </navigator>
  26. </view>
  27. </view>
  28. </view>
  29. </template>
  30. <script>
  31. const req = require('../../utils/request.js');
  32. const api = require('../../utils/api.js');
  33. const util = require('../../utils/util.js');
  34. const app = getApp();
  35. export default {
  36. data() {
  37. return {
  38. title: '',
  39. swiperCurrent: 0,
  40. bannerList: [],
  41. form: {
  42. page: 1,
  43. limit: 10
  44. },
  45. contentList: [],
  46. isLoad: true,
  47. code:null,
  48. };
  49. },
  50. onLoad(options) {
  51. this.title = options.title;
  52. this.code = options.code;
  53. uni.setNavigationBarTitle({
  54. title: options.title
  55. })
  56. },
  57. onShow() {
  58. this.getBannerList();
  59. this.getContentList();
  60. },
  61. onReachBottom(){
  62. this.form.page++;
  63. this.getContentList();
  64. },
  65. methods: {
  66. swiperChange(e) {
  67. this.swiperCurrent = e.detail.current;
  68. },
  69. getBannerList() {
  70. let that = this;
  71. req.getRequest('/api/banner', {
  72. groupId: '1196269897935630415'
  73. }, data => {
  74. that.bannerList = data;
  75. });
  76. },
  77. //为您推荐
  78. getContentList() {
  79. if (!this.isLoad) return false;
  80. this.isLoad = false;
  81. let form = this.form;
  82. form.code = this.code;
  83. req.getRequest('/api/content/list', form,res => {
  84. res = res?res.list:null
  85. if (res && res.length == 10) {
  86. this.isLoad = true;
  87. }
  88. if (this.form.page > 1) {
  89. res = this.contentList.concat(res);
  90. }
  91. this.contentList = res;
  92. });
  93. },
  94. clickBanner(item) {
  95. let url = '';
  96. if (item.type * 1 == 2 && item.content != "") {
  97. url = "product/detail/detail?id=" + item.content;
  98. } else if (item.type * 1 == 5) {
  99. url = "product/coupon/coupon";
  100. } else if (item.type * 1 == 6) {
  101. url = "pages/live/live";
  102. } else if (item.type * 1 == 9 && item.content != "") {
  103. url = "product/list/list?id=" + item.content;
  104. } else if (item.type * 1 == 10) {
  105. url = "plugin-private://wx2b03c6e691cd7370/pages/live-player-plugin?room_id=" + item.content;
  106. // console.log(
  107. // url); // url=`plugin-private://wx2b03c6e691cd7370/pages/live-player-plugin?room_id=${dt.content}`
  108. } else if (item.type * 1 == 19 && item.content != "") {//文章内容
  109. url = "topic/content/content?id=" + item.content;//1为普通文章内容
  110. } else {
  111. url = "";
  112. }
  113. if (item.type * 1 == 6) app.globalData.switchTab(url);
  114. else app.globalData.openPage(url);
  115. },
  116. }
  117. };
  118. </script>
  119. <style>
  120. @import "./contentList.css";
  121. </style>