index.vue 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  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. item.picUrl = env.filePublic + item.picUrl
  61. })
  62. this.total = res.total
  63. this.list = this.list.concat(res.rows)
  64. }
  65. }).catch(() => {
  66. uni.hideLoading();
  67. })
  68. },
  69. },
  70. onReachBottom() {
  71. // 判断是否有数据
  72. if (this.total > this.pageNum * 20) {
  73. setTimeout(() => {
  74. ++this.pageNum
  75. this.getList()
  76. }, 500)
  77. } else {
  78. uni.$u.toast('没有更多数据了')
  79. }
  80. },
  81. }
  82. </script>
  83. <style lang="scss" scoped>
  84. </style>
  85. <style lang="scss" scoped>
  86. .core {
  87. margin: 20rpx 0;
  88. &-list {
  89. justify-content: space-around;
  90. flex-wrap: wrap;
  91. &-item {
  92. width: 320rpx;
  93. box-sizing: border-box;
  94. padding: 0 14rpx;
  95. background-color: #FFFFFF;
  96. padding-bottom: 24rpx;
  97. border-radius: 10rpx;
  98. margin-bottom: 40rpx;
  99. .iamge-wrap {
  100. image {
  101. width: 150rpx;
  102. height: 200rpx;
  103. padding: 50rpx 0;
  104. }
  105. }
  106. .title {
  107. font-size: 24rpx;
  108. line-height: 40rpx;
  109. overflow: hidden;
  110. text-overflow: ellipsis;
  111. display: -webkit-box;
  112. -webkit-box-orient: vertical;
  113. -webkit-line-clamp: 2;
  114. }
  115. .bean {
  116. display: flex;
  117. align-items: center;
  118. font-size: 32rpx;
  119. line-height: 44rpx;
  120. color: rgba(235, 112, 9, 100);
  121. margin-top: 12rpx;
  122. image {
  123. width: 42rpx;
  124. height: 42rpx;
  125. margin-right: 16rpx;
  126. }
  127. }
  128. }
  129. &-item:last-child {
  130. padding: 0;
  131. }
  132. }
  133. }
  134. </style>