gift.vue 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218
  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. is_pack: 0,
  39. goodList: [], //商品列表
  40. loadingType: 'more',
  41. page: 1,
  42. limit: 10,
  43. type: 0,
  44. loaded: false,
  45. pUser: {},
  46. is_zero: 0,
  47. }
  48. },
  49. onLoad(opt) {
  50. if (opt.type) {
  51. this.type = opt.type
  52. }
  53. if(opt.tit) {
  54. uni.setNavigationBarTitle({
  55. title: opt.tit
  56. })
  57. }
  58. if(opt.is_pack) {
  59. this.is_pack = opt.is_pack
  60. }
  61. if(opt.is_zero) {
  62. this.is_zero = opt.is_zero
  63. }
  64. this.getGoodList()
  65. },
  66. onShow() {
  67. this.passUser()
  68. },
  69. onReachBottom() {
  70. this.getGoodList()
  71. },
  72. onPullDownRefresh() {
  73. this.getGoodList('down')
  74. },
  75. methods: {
  76. passUser() {
  77. passUser().then(res => {
  78. this.pUser = res.data
  79. })
  80. },
  81. navto(url) {
  82. uni.navigateTo({
  83. url,
  84. fail() {
  85. uni.switchTab({
  86. url
  87. })
  88. }
  89. })
  90. },
  91. getGoodList(type) {
  92. let obj = this
  93. if (type == 'down') {
  94. obj.loadingType = 'more'
  95. obj.page = 1
  96. }
  97. if (obj.loadingType == 'loading' || obj.loadingType == 'noMore') {
  98. return
  99. }
  100. obj.loadingType = 'loading'
  101. if (obj.type) {
  102. getProducts({
  103. page: obj.page,
  104. limit: obj.limit,
  105. cid: obj.type
  106. }).then(res => {
  107. if (type == 'down') {
  108. obj.goodList = []
  109. uni.stopPullDownRefresh();
  110. }
  111. obj.goodList = obj.goodList.concat(res.data)
  112. if (obj.limit == res.data.length) {
  113. obj.loadingType = 'more'
  114. obj.page++
  115. } else {
  116. obj.loadingType = 'noMore'
  117. }
  118. obj.loaded = true
  119. }).catch(err => {
  120. obj.loadingType = 'more'
  121. uni.stopPullDownRefresh();
  122. })
  123. } else {
  124. getProducts({
  125. is_pack: obj.is_pack,
  126. is_zero: obj.is_zero,
  127. page: obj.page,
  128. limit: obj.limit,
  129. }).then(res => {
  130. if (type == 'down') {
  131. obj.goodList = []
  132. uni.stopPullDownRefresh();
  133. }
  134. obj.goodList = obj.goodList.concat(res.data)
  135. if (obj.limit == res.data.length) {
  136. obj.loadingType = 'more'
  137. obj.page++
  138. } else {
  139. obj.loadingType = 'noMore'
  140. }
  141. obj.loaded = true
  142. }).catch(err => {
  143. obj.loadingType = 'more'
  144. uni.stopPullDownRefresh();
  145. })
  146. }
  147. },
  148. }
  149. }
  150. </script>
  151. <style lang="scss" scoped>
  152. .hot-list {
  153. // margin-top: -70rpx;
  154. padding-top: 20rpx;
  155. .good {
  156. width: 704rpx;
  157. background: #FFFFFF;
  158. border-radius: 20rpx;
  159. margin: 0 auto 30rpx;
  160. .good-img {
  161. width: 704rpx;
  162. height: 330rpx;
  163. background: #D4D4E1;
  164. border-radius: 20rpx 20rpx 0rpx 0rpx;
  165. }
  166. .good-tit {
  167. padding: 10rpx 20rpx;
  168. font-size: 30rpx;
  169. font-weight: bold;
  170. color: #000000;
  171. }
  172. .good-cz {
  173. padding: 0 20rpx 23rpx 23rpx;
  174. .price {
  175. font-size: 42rpx;
  176. font-weight: bold;
  177. color: $base-color;
  178. .xy {
  179. font-size: 24rpx;
  180. }
  181. .old-price {
  182. font-size: 26rpx;
  183. font-weight: 500;
  184. // text-decoration: line-through;
  185. // color: #999999;
  186. color: $base-color;
  187. margin-left: 18rpx;
  188. }
  189. }
  190. .cz-btn {
  191. width: 172rpx;
  192. line-height: 60rpx;
  193. background: $base-color;
  194. border-radius: 10rpx;
  195. font-size: 26rpx;
  196. font-weight: 500;
  197. color: #FFFFFF;
  198. text-align: center;
  199. }
  200. }
  201. }
  202. }
  203. </style>