contentList.vue 3.7 KB

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