index.vue 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. <template>
  2. <view>
  3. <u-navbar leftIconSize="0" :placeholder="true" bgColor="#fff">
  4. <view class="u-nav-slot" slot="left">
  5. <text>兑换大厅</text>
  6. </view>
  7. </u-navbar>
  8. <view class="core">
  9. <view class="flex core-list">
  10. <navigator :url="`/pages/goods/detail?id=${ item.goodsId }`" class="core-list-item" hover-class="navigator-hover"
  11. v-for="(item, index) in list" :key="index">
  12. <view class="flex iamge-wrap">
  13. <image :src="item.picUrl" mode="aspectFill"></image>
  14. </view>
  15. <view class="title">{{ item.title }}</view>
  16. <view class="bean">{{ item.exchangePrice }}</view>
  17. </navigator>
  18. <view class="core-list-item"></view>
  19. </view>
  20. </view>
  21. <custom-tab-bar :activeValue="'core'" />
  22. </view>
  23. </template>
  24. <script>
  25. import env from '../../config/env.js'
  26. import CustomTabBar from '../../components/custom-tab-bar/custom-tab-bar.vue'
  27. import $http from '@/utils/request.js'
  28. export default {
  29. components: {
  30. CustomTabBar,
  31. },
  32. data() {
  33. return {
  34. pageNum: 1,
  35. total: 0,
  36. list: [],
  37. };
  38. },
  39. onLoad(opthios) {
  40. this.getList()
  41. },
  42. onShow() {
  43. },
  44. methods: {
  45. getList() {
  46. uni.showLoading({
  47. title: '加载中'
  48. });
  49. let data = {
  50. categoryId: '',
  51. }
  52. $http.post(`/api/v1/mp/user/exchange/goods/list?pageNum=${this.pageNum}&pageSize=20`, data).then(
  53. res => {
  54. uni.hideLoading();
  55. if (res.code == 0) {
  56. res.rows.forEach(item => {
  57. item.picUrl = env.filePublic + item.picUrl
  58. })
  59. this.total = res.total
  60. this.list = this.list.concat(res.rows)
  61. }
  62. }).catch(() => {
  63. uni.hideLoading();
  64. })
  65. },
  66. },
  67. onReachBottom() {
  68. // 判断是否有数据
  69. if (this.total > this.pageNum * 20) {
  70. setTimeout(() => {
  71. ++this.pageNum
  72. this.getList()
  73. }, 500)
  74. } else {
  75. uni.$u.toast('没有更多数据了')
  76. }
  77. },
  78. }
  79. </script>
  80. <style lang="scss" scoped>
  81. </style>
  82. <style lang="scss" scoped>
  83. .core {
  84. margin: 20rpx 0;
  85. &-list {
  86. justify-content: space-around;
  87. flex-wrap: wrap;
  88. &-item {
  89. width: 320rpx;
  90. box-sizing: border-box;
  91. padding: 0 14rpx;
  92. background-color: #FFFFFF;
  93. padding-bottom: 24rpx;
  94. border-radius: 10rpx;
  95. margin-bottom: 40rpx;
  96. .iamge-wrap {
  97. image {
  98. width: 150rpx;
  99. height: 200rpx;
  100. padding: 50rpx 0;
  101. }
  102. }
  103. .title {
  104. font-size: 24rpx;
  105. line-height: 40rpx;
  106. overflow: hidden;
  107. text-overflow: ellipsis;
  108. display: -webkit-box;
  109. -webkit-box-orient: vertical;
  110. -webkit-line-clamp: 2;
  111. }
  112. .bean {
  113. font-size: 24rpx;
  114. color: #EB7009;
  115. }
  116. }
  117. &-item:last-child {
  118. padding: 0;
  119. }
  120. }
  121. }
  122. </style>