contentList.vue 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  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. };
  48. },
  49. onLoad(options) {
  50. this.title = options.title;
  51. uni.setNavigationBarTitle({
  52. title: options.title
  53. })
  54. },
  55. onShow() {
  56. this.getBannerList();
  57. this.getContentList();
  58. },
  59. onReachBottom(){
  60. this.form.page++;
  61. this.getContentList();
  62. },
  63. methods: {
  64. swiperChange(e) {
  65. this.swiperCurrent = e.detail.current;
  66. },
  67. getBannerList() {
  68. let that = this;
  69. req.getRequest('/api/banner', {
  70. groupId: '1196269897935630415'
  71. }, data => {
  72. that.bannerList = data;
  73. });
  74. },
  75. //为您推荐
  76. getContentList() {
  77. if (!this.isLoad) return false;
  78. this.isLoad = false;
  79. let form = this.form;
  80. form.code = '001';
  81. req.getRequest('/api/content/list', form,res => {
  82. if (res && res.length == 10) {
  83. this.isLoad = true;
  84. }
  85. if (this.form.page > 1) {
  86. res = this.contentList.concat(res);
  87. }
  88. this.contentList = res;
  89. });
  90. },
  91. clickBanner(item) {
  92. let url = '';
  93. if (item.type * 1 == 2 && item.content != "") {
  94. url = "product/detail/detail?id=" + item.content;
  95. } else if (item.type * 1 == 5) {
  96. url = "product/coupon/coupon";
  97. } else if (item.type * 1 == 6) {
  98. url = "pages/live/live";
  99. } else if (item.type * 1 == 9 && item.content != "") {
  100. url = "product/list/list?id=" + item.content;
  101. } else if (item.type * 1 == 10) {
  102. url = "plugin-private://wx2b03c6e691cd7370/pages/live-player-plugin?room_id=" + item.content;
  103. // console.log(
  104. // url); // url=`plugin-private://wx2b03c6e691cd7370/pages/live-player-plugin?room_id=${dt.content}`
  105. } else if (item.type * 1 == 19 && item.content != "") {//文章内容
  106. url = "topic/content/content?id=" + item.content;//1为普通文章内容
  107. } else {
  108. url = "";
  109. }
  110. if (item.type * 1 == 6) app.globalData.switchTab(url);
  111. else app.globalData.openPage(url);
  112. },
  113. }
  114. };
  115. </script>
  116. <style>
  117. @import "./contentList.css";
  118. </style>