index.vue 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  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/icon/bean.png" mode="aspectFill"></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() {
  46. this.pageList()
  47. },
  48. methods: {
  49. getList() {
  50. uni.showLoading({
  51. title: '加载中'
  52. });
  53. let data = {
  54. categoryId: '',
  55. noToken: true
  56. }
  57. $http.post(`/api/v1/mp/user/exchange/goods/list?pageNum=${this.pageNum}&pageSize=20`, data).then(
  58. res => {
  59. uni.hideLoading();
  60. if (res.code == 0) {
  61. res.rows.forEach(item => {
  62. let picUrlArr = item.picUrl.split(',')
  63. item.picUrl = env.filePublic + picUrlArr[0]
  64. })
  65. this.total = res.total
  66. this.list = this.list.concat(res.rows)
  67. }
  68. }).catch(() => {
  69. uni.hideLoading();
  70. })
  71. },
  72. pageList(){
  73. this.pageNum = 1
  74. this.total = 0
  75. this.list = []
  76. this.getList()
  77. }
  78. },
  79. onReachBottom() {
  80. // 判断是否有数据
  81. if (this.total > this.pageNum * 20) {
  82. setTimeout(() => {
  83. ++this.pageNum
  84. this.getList()
  85. }, 500)
  86. } else {
  87. uni.$u.toast('没有更多数据了')
  88. }
  89. },
  90. }
  91. </script>
  92. <style lang="scss" scoped>
  93. </style>
  94. <style lang="scss" scoped>
  95. .core {
  96. margin: 20rpx 0;
  97. &-list {
  98. justify-content: space-around;
  99. flex-wrap: wrap;
  100. &-item {
  101. width: 320rpx;
  102. box-sizing: border-box;
  103. padding: 0 14rpx;
  104. background-color: #FFFFFF;
  105. padding-bottom: 24rpx;
  106. border-radius: 10rpx;
  107. margin-bottom: 40rpx;
  108. .iamge-wrap {
  109. image {
  110. width: 150rpx;
  111. height: 200rpx;
  112. padding: 50rpx 0;
  113. }
  114. }
  115. .title {
  116. font-size: 24rpx;
  117. line-height: 40rpx;
  118. overflow: hidden;
  119. text-overflow: ellipsis;
  120. display: -webkit-box;
  121. -webkit-box-orient: vertical;
  122. -webkit-line-clamp: 2;
  123. }
  124. .bean {
  125. display: flex;
  126. align-items: center;
  127. font-size: 32rpx;
  128. line-height: 44rpx;
  129. color: rgba(235, 112, 9, 100);
  130. margin-top: 12rpx;
  131. image {
  132. width: 42rpx;
  133. height: 42rpx;
  134. margin-right: 16rpx;
  135. }
  136. }
  137. }
  138. &-item:last-child {
  139. padding: 0;
  140. }
  141. }
  142. .empty {
  143. height: 60vh;
  144. }
  145. }
  146. </style>