gift.vue 4.0 KB

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