gift.vue 3.7 KB

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