index.vue 3.0 KB

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