index.vue 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  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">
  17. <image src="../../static/logo.png" mode=""></image>
  18. <view>x{{ item.exchangePrice }}</view>
  19. </view>
  20. </navigator>
  21. <view class="core-list-item"></view>
  22. </view>
  23. <view class="flex empty" v-if="!list.length">
  24. <u-empty text="数据为空" mode="order" />
  25. </view>
  26. </view>
  27. <custom-tab-bar :activeValue="'core'" />
  28. </view>
  29. </template>
  30. <script>
  31. import env from '../../config/env.js'
  32. import CustomTabBar from '../../components/custom-tab-bar/custom-tab-bar.vue'
  33. import $http from '@/utils/request.js'
  34. export default {
  35. components: {
  36. CustomTabBar,
  37. },
  38. data() {
  39. return {
  40. pageNum: 1,
  41. total: 0,
  42. list: [],
  43. };
  44. },
  45. onLoad(opthios) {
  46. this.getList()
  47. },
  48. onShow() {
  49. },
  50. methods: {
  51. getList() {
  52. uni.showLoading({
  53. title: '加载中'
  54. });
  55. let data = {
  56. categoryId: '',
  57. }
  58. $http.post(`/api/v1/mp/user/exchange/goods/list?pageNum=${this.pageNum}&pageSize=20`, data).then(
  59. res => {
  60. uni.hideLoading();
  61. if (res.code == 0) {
  62. res.rows.forEach(item => {
  63. let picUrlArr = item.picUrl.split(',')
  64. item.picUrl = env.filePublic + picUrlArr[0]
  65. })
  66. this.total = res.total
  67. this.list = this.list.concat(res.rows)
  68. }
  69. }).catch(() => {
  70. uni.hideLoading();
  71. })
  72. },
  73. },
  74. onReachBottom() {
  75. // 判断是否有数据
  76. if (this.total > this.pageNum * 20) {
  77. setTimeout(() => {
  78. ++this.pageNum
  79. this.getList()
  80. }, 500)
  81. } else {
  82. uni.$u.toast('没有更多数据了')
  83. }
  84. },
  85. }
  86. </script>
  87. <style lang="scss" scoped>
  88. </style>
  89. <style lang="scss" scoped>
  90. .core {
  91. margin: 20rpx 0;
  92. &-list {
  93. justify-content: space-around;
  94. flex-wrap: wrap;
  95. &-item {
  96. width: 320rpx;
  97. box-sizing: border-box;
  98. padding: 0 14rpx;
  99. background-color: #FFFFFF;
  100. padding-bottom: 24rpx;
  101. border-radius: 10rpx;
  102. margin-bottom: 40rpx;
  103. .iamge-wrap {
  104. image {
  105. width: 150rpx;
  106. height: 200rpx;
  107. padding: 50rpx 0;
  108. }
  109. }
  110. .title {
  111. font-size: 24rpx;
  112. line-height: 40rpx;
  113. overflow: hidden;
  114. text-overflow: ellipsis;
  115. display: -webkit-box;
  116. -webkit-box-orient: vertical;
  117. -webkit-line-clamp: 2;
  118. }
  119. .bean {
  120. display: flex;
  121. align-items: center;
  122. font-size: 32rpx;
  123. line-height: 44rpx;
  124. color: rgba(235, 112, 9, 100);
  125. margin-top: 12rpx;
  126. image {
  127. width: 42rpx;
  128. height: 42rpx;
  129. margin-right: 16rpx;
  130. }
  131. }
  132. }
  133. &-item:last-child {
  134. padding: 0;
  135. }
  136. }
  137. .empty {
  138. height: 60vh;
  139. }
  140. }
  141. </style>