Vipgift.vue 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  1. <template>
  2. <view class="content padding-t-20">
  3. <view class="flex item padding-v-20 padding-c-20" v-for="(item,index) in goodsList">
  4. <view class="imgbox">
  5. <image class="img" src="" mode="scaleToFill"></image>
  6. </view>
  7. <view class="contentbox padding-l-20 flex">
  8. <view class="clamp2 title">
  9. 法国空运高端82年拉菲陈酿 红葡萄酒...
  10. </view>
  11. <view class="oldMoneyBox ">
  12. <view class="flex-start padding-b-10">
  13. <text class="oldMoney">¥200</text>
  14. <image class="icon padding-l-10" src="../../static/img/domIcon.png" mode="scaleToFill"></image>
  15. <text class="domMoney font-size-sm">
  16. 直降40元
  17. </text>
  18. </view>
  19. <view class="flex">
  20. <view class="money">¥200</view>
  21. <view class="buttomPay" @click="navto('/')">立即购买</view>
  22. </view>
  23. </view>
  24. </view>
  25. </view>
  26. <uni-load-more :status="loadingType"></uni-load-more>
  27. </view>
  28. </template>
  29. <script>
  30. import {
  31. getProducts
  32. } from '@/api/product.js';
  33. export default {
  34. data() {
  35. return {
  36. // 列表
  37. goodsList: [],
  38. limit: 6, //每次加载数据条数
  39. page: 1, //当前页数
  40. loadingType: 'more', //加载更多状态
  41. };
  42. },
  43. onLoad() {
  44. this.getProducts();
  45. },
  46. onShow() {},
  47. onPullDownRefresh() {
  48. this.getProducts('refresh');
  49. },
  50. methods: {
  51. navto(url) {
  52. // #ifdef H5
  53. console.log(url.indexOf('http'), 'banner');
  54. if (url.indexOf('http') >= 0) {
  55. window.location.href = url;
  56. }
  57. // #endif
  58. //测试数据没有写id,用title代替
  59. uni.navigateTo({
  60. url: url
  61. });
  62. },
  63. async getProducts(type) {
  64. let obj = this;
  65. // 判断是否为重新加载数据
  66. if (type !== 'refresh') {
  67. //没有更多数据直接跳出方法
  68. if (obj.loadingType === 'nomore') {
  69. return;
  70. }
  71. if (obj.loadingType === 'loading') {
  72. //防止重复加载
  73. return;
  74. }
  75. // 设置当前为数据载入中
  76. obj.loadingType = 'loading';
  77. } else {
  78. this.page = 1;
  79. obj.goodsList = [];
  80. //当重新加载数据时更新状态为可继续添加数据
  81. obj.loadingType = 'more';
  82. }
  83. let data = {
  84. page: obj.page,
  85. limit: obj.limit,
  86. };
  87. getProducts(data).then(e => {
  88. obj.goodsList = obj.goodsList.concat(e.data);
  89. //判断是否还有下一页,有是more 没有是nomore
  90. if (obj.limit == e.data.length) {
  91. obj.page++;
  92. obj.loadingType = 'more';
  93. } else {
  94. obj.loadingType = 'nomore';
  95. }
  96. });
  97. },
  98. }
  99. };
  100. </script>
  101. <style lang="scss">
  102. page,
  103. .content {
  104. min-height: 100%;
  105. height: auto;
  106. }
  107. .item {
  108. border-radius: 10rpx;
  109. background-color: #FFFFFF;
  110. width: 690rpx;
  111. margin: 0 30rpx 20rpx 30rpx;
  112. align-items: stretch;
  113. line-height: 1;
  114. .imgbox {
  115. background-color: #EE2F72;
  116. border-radius: 10rpx;
  117. .img {
  118. height: 246rpx;
  119. width: 246rpx;
  120. }
  121. }
  122. .contentbox {
  123. flex-wrap: wrap;
  124. .title {
  125. width: 100%;
  126. align-self: flex-start;
  127. font-size: $font-lg;
  128. color: $font-color-dark;
  129. line-height: 1.5;
  130. }
  131. .money {
  132. font-size: $font-lg + 4rpx;
  133. font-weight: bold;
  134. color: #EE2F72;
  135. }
  136. .oldMoneyBox {
  137. align-self: flex-end;
  138. width: 100%;
  139. .oldMoney {
  140. font-size: $font-sm;
  141. text-decoration: line-through;
  142. color: $font-color-light;
  143. }
  144. .domMoney {
  145. color: #B59467;
  146. }
  147. .icon {
  148. width: 14rpx;
  149. height: 16rpx;
  150. }
  151. .buttomPay {
  152. padding: 14rpx 26rpx;
  153. font-size: $font-base;
  154. color: #fff;
  155. background: linear-gradient(90deg, #FF4A8A, #FF77A7);
  156. border-radius: 26px;
  157. }
  158. }
  159. }
  160. }
  161. </style>