gift.vue 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. <template>
  2. <view class="hot-list">
  3. <view class="good" v-for="item in goodList" @click="navto('/pages/product/product?id=' + item.id)">
  4. <image :src="item.image" mode="" class="good-img"></image>
  5. <view class="good-tit">
  6. {{item.store_name}}
  7. </view>
  8. <view class="good-cz flex">
  9. <view class="price">
  10. <text class="xy">¥</text> <text>{{item.price}}</text><text class="old-price">¥{{item.ot_price}}</text>
  11. </view>
  12. <view class="cz-btn">
  13. 立即抢购
  14. </view>
  15. </view>
  16. </view>
  17. <uni-load-more :status="loadingType"></uni-load-more>
  18. </view>
  19. </template>
  20. <script>
  21. import {
  22. getBargainList,
  23. getProducts,
  24. goodsDetail,
  25. poster
  26. } from '@/api/product.js';
  27. export default {
  28. data() {
  29. return {
  30. goodList: [], //商品列表
  31. loadingType: 'more',
  32. page: 1,
  33. limit: 10
  34. }
  35. },
  36. onShow() {
  37. this.getGoodList()
  38. },
  39. onReachBottom() {
  40. this.getGoodList()
  41. },
  42. onPullDownRefresh() {
  43. this.getGoodList('down')
  44. },
  45. methods: {
  46. navto(url) {
  47. uni.navigateTo({
  48. url,
  49. fail() {
  50. uni.switchTab({
  51. url
  52. })
  53. }
  54. })
  55. },
  56. getGoodList(type) {
  57. let obj = this
  58. if(type == 'down') {
  59. obj.loadingType = 'more'
  60. obj.page = 1
  61. }
  62. if (obj.loadingType == 'loading' || obj.loadingType == 'noMore') {
  63. return
  64. }
  65. obj.loadingType = 'loading'
  66. getProducts({
  67. is_pack: 1,
  68. page: obj.page,
  69. limit:obj.limit,
  70. }).then(res => {
  71. if(type == 'down') {
  72. obj.goodList = []
  73. uni.stopPullDownRefresh();
  74. }
  75. obj.goodList = obj.goodList.concat(res.data)
  76. if (obj.limit == res.data.length) {
  77. obj.loadingType = 'more'
  78. obj.page++
  79. } else {
  80. obj.loadingType = 'noMore'
  81. }
  82. }).catch(err => {
  83. obj.loadingType = 'more'
  84. uni.stopPullDownRefresh();
  85. })
  86. },
  87. }
  88. }
  89. </script>
  90. <style lang="scss" scoped>
  91. .hot-list {
  92. // margin-top: -70rpx;
  93. padding-top: 20rpx;
  94. .good {
  95. width: 704rpx;
  96. background: #FFFFFF;
  97. border-radius: 20rpx;
  98. margin:0 auto 30rpx;
  99. .good-img {
  100. width: 704rpx;
  101. height: 330rpx;
  102. background: #D4D4E1;
  103. border-radius: 20rpx 20rpx 0rpx 0rpx;
  104. }
  105. .good-tit {
  106. padding:10rpx 20rpx;
  107. font-size: 30rpx;
  108. font-weight: bold;
  109. color: #000000;
  110. }
  111. .good-cz {
  112. padding: 0 20rpx 23rpx 23rpx;
  113. .price {
  114. font-size: 42rpx;
  115. font-weight: bold;
  116. color: $base-color;
  117. .xy {
  118. font-size: 24rpx;
  119. }
  120. .old-price {
  121. font-size: 26rpx;
  122. font-weight: 500;
  123. text-decoration: line-through;
  124. color: #999999;
  125. margin-left: 18rpx;
  126. }
  127. }
  128. .cz-btn {
  129. width: 172rpx;
  130. line-height: 60rpx;
  131. background: $base-color;
  132. border-radius: 10rpx;
  133. font-size: 26rpx;
  134. font-weight: 500;
  135. color: #FFFFFF;
  136. text-align: center;
  137. }
  138. }
  139. }
  140. }
  141. </style>