travelGuide.vue 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. <template>
  2. <!-- 旅游向导列表 -->
  3. <view class="container">
  4. <view class="rnwdList">
  5. <view class="list" @tap="goDetails(item.id)" v-for="(item, index1) in dataSource" :key="index1">
  6. <span class="listTitle">{{ item.titleName }}</span>
  7. <view class="onePic" v-if="item.pictureList != null && item.pictureList.length == 1">
  8. <image :src="loadImgSrcLocalhost(item2)" v-for="(item2, index2) in item.pictureList" :key="index2">
  9. </image>
  10. </view>
  11. <view class="twoPic" v-if="item.pictureList != null && item.pictureList.length == 2">
  12. <image :src="loadImgSrcLocalhost(item2)" v-for="(item2, index2) in item.pictureList" :key="index2">
  13. </image>
  14. </view>
  15. <view class="threePic" v-if="item.pictureList != null && item.pictureList.length == 3">
  16. <image :src="loadImgSrcLocalhost(item2)" v-for="(item2, index2) in item.pictureList" :key="index2">
  17. </image>
  18. </view>
  19. <view class="threePic" v-if="item.pictureList != null && item.pictureList.length > 3">
  20. <image :src="loadImgSrcLocalhost(item2)" v-for="(item2, index2) in item.pictureList"
  21. v-if="index2 < 3" :key="index2"></image>
  22. </view>
  23. <view class="jlSj" style="height: 2vh;display: flex;margin-top: 10px;">
  24. <span style="color: #07c160;font-size: 24rpx;">
  25. {{ item.createTime }}
  26. <!-- <em class="iconfont icon-jifen"></em> -->
  27. </span>
  28. <view class="ck">
  29. <span>
  30. <em class="iconfont icon-chakan"></em>
  31. {{ item.likeNum }}
  32. </span>
  33. <!-- <span>-->
  34. <!-- <em class="iconfont icon-shoucang"></em>-->
  35. <!-- {{ item.watchNum }}-->
  36. <!-- </span>-->
  37. </view>
  38. </view>
  39. </view>
  40. </view>
  41. </view>
  42. </template>
  43. <script>
  44. import {
  45. list,
  46. getDetails
  47. } from '@/api/travelGuide/travelGuide.js';
  48. export default {
  49. data() {
  50. return {
  51. dataSource: [],
  52. // 数据总量
  53. total: 0,
  54. queryParams: {
  55. // 当前页
  56. pageNum: 1,
  57. // 每页数据量
  58. pageSize: 10,
  59. },
  60. loading: false,
  61. }
  62. },
  63. /**
  64. * 生命周期函数--监听页面加载
  65. */
  66. onLoad(options) {
  67. this.getList(1)
  68. },
  69. onReachBottom(){
  70. let pageNum = this.queryParams.pageNum
  71. let pageSize = this.queryParams.pageSize
  72. let total = this.total
  73. if(pageNum * pageSize >= total){
  74. uni.showToast({
  75. title:'暂无更多数据'
  76. })
  77. return
  78. } else {
  79. this.queryParams.pageNum += 1;
  80. this.getList()
  81. }
  82. },
  83. methods: {
  84. goDetails(id) {
  85. getDetails(id).then(res => {
  86. let data = res.data
  87. data.urls = data.pictureList
  88. uni.navigateTo({
  89. url: `/pages/common/articleDetail/articleDetail?data=${this.encodify(data)}`
  90. });
  91. })
  92. },
  93. // 分页触发
  94. change(e) {
  95. this.getList(e.current);
  96. },
  97. // 获取数据
  98. getList(pageNum) {
  99. let params = {
  100. pageSize: this.queryParams.pageSize,
  101. pageNum: pageNum,
  102. }
  103. list(params).then(res => {
  104. if (res.code == 200) {
  105. this.dataSource = [...this.dataSource,...res.rows]
  106. this.total = res.total
  107. }
  108. })
  109. },
  110. }
  111. }
  112. </script>
  113. <style>
  114. @import './travelGuide.css';
  115. </style>