myLike.vue 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. <template>
  2. <!-- #ifdef H5 -->
  3. <zj-page-layout
  4. :hasFooter="false"
  5. :isScroll="true"
  6. :refresherTriggered="refresherTriggered"
  7. @refresherrefresh="refresherrefresh"
  8. @scrolltolower="scrolltolower">
  9. <view class="common-goods-list">
  10. <view class="item" v-for="(item, index) in dataList" :key="index" @tap="toDetail(item.id)">
  11. <view class="top">
  12. <image src="@/static/common/logo.png"></image>
  13. <view class="user">
  14. <view class="name">{{item.userName}}</view>
  15. <view class="time">{{item.createTime | timeFilter}}</view>
  16. </view>
  17. <view class="price">{{item.amount | priceFilter2}}</view>
  18. </view>
  19. <view class="title">{{item.title}}</view>
  20. <view class="des">{{item.content}}</view>
  21. <view class="imgs">
  22. <image :src="imgUrl + it.imgUrl" v-for="(it, idx) in item.goodsFiles" :key="idx" mode="aspectFill"></image>
  23. </view>
  24. <view class="bottom">
  25. <view class="left-location"><text class="iconfont icon-dingwei"></text>{{item.city}} {{item.area}}</view>
  26. <view class="right-btn" @tap.stop>
  27. <u-button text="取消点赞" shape="circle" @click="handelCancel(item.id)"></u-button>
  28. </view>
  29. </view>
  30. </view>
  31. </view>
  32. <Loading :loadStatus="loadStatus" :dataList="dataList" />
  33. </zj-page-layout>
  34. <!-- #endif -->
  35. <!-- #ifndef H5 -->
  36. <web-view :src="webViewHref('/pages/mine/myLike')" @message="crossPage.$listener"></web-view>
  37. <!-- #endif -->
  38. </template>
  39. <script>
  40. // #ifdef H5
  41. export default {
  42. data() {
  43. return {
  44. imgUrl: this.$imageUrl,
  45. dataList: [],
  46. pageNum: 1,
  47. loadStatus: 0,
  48. refresherTriggered: false,
  49. }
  50. },
  51. async onLoad() {
  52. await this.getList()
  53. },
  54. methods: {
  55. //获取列表数据
  56. async getList() {
  57. this.$api.get('/likeOrCollect/list', {
  58. userId: this.$store.state.user.userId,
  59. type: 1,
  60. pageNum: this.pageNum,
  61. pageSize: 10,
  62. }).then(res => {
  63. this.loadStatus = 0;
  64. let list = res.data.records;
  65. if(list.length < 10){
  66. this.loadStatus = 2;
  67. }
  68. this.dataList = this.dataList.concat(list);
  69. }).catch(() => {
  70. this.loadStatus = 2;
  71. }).finally(res => {
  72. this.refresherTriggered = false;
  73. })
  74. },
  75. // 滚动到底部
  76. scrolltolower(e) {
  77. if (this.loadStatus === 0) {
  78. this.pageNum++;
  79. this.getList();
  80. }
  81. },
  82. // 触发下拉刷新
  83. refresherrefresh(e) {
  84. this.refresherTriggered = true;
  85. this.refreshList();
  86. },
  87. refreshList() {
  88. this.dataList = [];
  89. this.pageNum = 1;
  90. this.getList();
  91. },
  92. toDetail(id) {
  93. this.$navToPage({
  94. url: `/pages/goods/detail?id=${id}`
  95. })
  96. },
  97. handelCancel(id) {
  98. this.$modal({
  99. content: '确定要取消点赞吗?'
  100. }).then(() => {
  101. this.$api.postJson('/likeOrCollect/likeOrCollect', {
  102. userId: this.$store.state.user.userId,
  103. goodsId: id,
  104. type: 1,
  105. operate: 'NO'
  106. }).then(res => {
  107. this.refreshList();
  108. })
  109. }).catch(() => {})
  110. },
  111. }
  112. }
  113. // #endif
  114. // #ifndef H5
  115. // #endif
  116. </script>
  117. <style lang="scss" scoped>
  118. </style>