activity.vue 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. <template>
  2. <view class="content">
  3. <view class="main-item" v-for="(item, index) in list" @click="navToDetailPage(item)">
  4. <image class="main-image" :src="item.image" mode=""></image>
  5. <view class="main-title clamp2">{{ item.store_name }}</view>
  6. <view class="btn-box flex">
  7. <view class="price">
  8. <text>原价:¥{{ item.price }}</text>
  9. {{ item.price }}
  10. </view>
  11. <view class="buy-btn">去抢购</view>
  12. </view>
  13. </view>
  14. </view>
  15. </template>
  16. <script>
  17. import { getProducts } from '@/api/product.js';
  18. export default {
  19. data() {
  20. return {
  21. list: [],
  22. loadingType: 'more',
  23. page: 1, //当前页数
  24. limit: 10 //每次信息条数
  25. };
  26. },
  27. onLoad() {},
  28. onShow() {
  29. this.loadData();
  30. },
  31. methods: {
  32. loadData() {
  33. let obj = this;
  34. if (obj.loadingType === 'loading') {
  35. //防止重复加载
  36. return;
  37. }
  38. if (obj.loadingType === 'noMore') {
  39. //防止重复加载
  40. return;
  41. }
  42. obj.loadingType = 'loading';
  43. getProducts({ cid: 52, page: obj.page, limit: obj.limit }).then(({ data }) => {
  44. console.log(data);
  45. obj.list = obj.list.concat(data);
  46. obj.page++;
  47. if (obj.limit == data.length) {
  48. //判断是否还有数据, 有改为 more, 没有改为noMore
  49. obj.loadingType = 'more';
  50. return;
  51. } else {
  52. //判断是否还有数据, 有改为 more, 没有改为noMore
  53. obj.loadingType = 'noMore';
  54. }
  55. });
  56. },
  57. navToDetailPage(item) {
  58. let id = item.id;
  59. uni.navigateTo({
  60. url: '/pages/product/product?id=' + id + '&isVip=1'
  61. });
  62. }
  63. }
  64. };
  65. </script>
  66. <style lang="scss">
  67. page,
  68. .content {
  69. min-height: 100%;
  70. height: auto;
  71. }
  72. .main-item {
  73. width: 690rpx;
  74. background: #ffffff;
  75. box-shadow: 0px 0px 20rpx 0px rgba(50, 50, 52, 0.06);
  76. border-radius: 20rpx;
  77. margin: 20rpx auto 0;
  78. .main-image {
  79. width: 690rpx;
  80. height: 300rpx;
  81. border-radius: 20rpx 20rpx 0 0;
  82. }
  83. .main-title {
  84. padding: 18rpx 50rpx 0 22rpx;
  85. font-size: 32rpx;
  86. font-family: PingFang SC;
  87. font-weight: 500;
  88. color: #333333;
  89. }
  90. .btn-box {
  91. margin-top: 20rpx;
  92. padding: 0 15rpx 25rpx 22rpx;
  93. .price {
  94. font-size: 40rpx;
  95. font-family: PingFang SC;
  96. font-weight: bold;
  97. color: #ff4c4c;
  98. text {
  99. display: inline-block;
  100. margin-right: 10rpx;
  101. font-size: 26rpx;
  102. font-family: PingFang SC;
  103. font-weight: 500;
  104. text-decoration: line-through;
  105. color: #999999;
  106. }
  107. }
  108. .buy-btn {
  109. display: flex;
  110. justify-content: center;
  111. align-items: center;
  112. width: 170rpx;
  113. height: 53rpx;
  114. background: linear-gradient(30deg, #ff4c4c, #fe6238);
  115. border-radius: 27rpx;
  116. font-size: 28rpx;
  117. font-family: PingFang SC;
  118. font-weight: bold;
  119. color: #ffffff;
  120. }
  121. }
  122. }
  123. </style>