joinGroup.vue 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. <template>
  2. <view class="wrapper">
  3. <u-navbar :border-bottom="false" :background="background" class="unavbar" :title="title">
  4. <!-- 中间 -->
  5. <view class="slot-wrap container-wrap">
  6. <view v-if="search">
  7. <u-search @search="searchFun()" @custom="searchFun()" v-model="params.goodsName"></u-search>
  8. </view>
  9. </view>
  10. <!-- 右侧 -->
  11. <view slot="right">
  12. <view style="margin-right: 24rpx;" @click="searchFlag()">
  13. <view v-if="search">取消</view>
  14. <u-icon v-if="!search" size="44rpx" name="search"></u-icon>
  15. </view>
  16. </view>
  17. </u-navbar>
  18. <!-- 顶部栏 -->
  19. <!-- 商品栏 -->
  20. <div class="swiper">
  21. <view class="view-item" v-for="(groupItem, groupIndex) in groupBuy" :key="groupIndex">
  22. <view class="view-left">
  23. <u-image border-radius="10" shape="square" :src="groupItem.goodsImage" width="186rpx" height="186rpx">
  24. <view slot="error" style="font-size: 24rpx;">加载失败</view>
  25. </u-image>
  26. </view>
  27. <view class="view-content">
  28. <view class="view-content-name">
  29. {{ groupItem.goodsName }}
  30. </view>
  31. <view class="view-content-bottom">
  32. <view>
  33. <view class="view-content-price">
  34. <!-- ¥{{groupItem.sales_price | unitPrice }} <span v-if="groupItem.point">+{{groupItem.point}}积分</span> -->
  35. ¥{{groupItem.price | unitPrice }}
  36. </view>
  37. <view class="view-content-original_price">
  38. ¥{{ groupItem.originPrice | unitPrice }}
  39. </view>
  40. </view>
  41. <view>
  42. <view class="btn-group" @click="toHref(groupItem)"> 去拼团 </view>
  43. <view class="buy-content">已售{{groupItem.num || 0}}件</view>
  44. </view>
  45. </view>
  46. </view>
  47. </view>
  48. <u-loadmore bg-color='#f8f8f8' :status="status" />
  49. </div>
  50. </view>
  51. </template>
  52. <script>
  53. import * as API_Promotions from "@/api/promotions";
  54. import * as API_Goods from "@/api/goods";
  55. export default {
  56. components: {},
  57. data() {
  58. return {
  59. status: "loadmore",
  60. is_empty: false,
  61. search: false,
  62. title: "拼团活动",
  63. background: {
  64. backgroundColor: "#fff",
  65. },
  66. empty: false,
  67. params: {
  68. pageNumber: 1,
  69. pageSize: 10,
  70. categoryPath: "",
  71. goodsName: "",
  72. },
  73. groupBuy: [],
  74. };
  75. },
  76. mounted() {},
  77. watch: {
  78. search(val) {
  79. val ? (this.title = "") : (this.title = "拼团活动");
  80. },
  81. },
  82. onReachBottom(){
  83. this.loadMore()
  84. },
  85. // 点击搜索按钮
  86. onNavigationBarButtonTap(e) {
  87. this.popupFlag = !this.popupFlag;
  88. },
  89. async onLoad() {
  90. this.GET_AssembleGoods();
  91. },
  92. methods: {
  93. loadMore() {
  94. this.params.pageNumber++;
  95. this.GET_AssembleGoods();
  96. },
  97. searchFlag() {
  98. this.search = !this.search;
  99. },
  100. toHref(goods) {
  101. uni.navigateTo({
  102. url: `/pages/product/goods?id=${goods.skuId}&goodsId=${goods.goodsId}`,
  103. });
  104. },
  105. searchFun() {
  106. this.groupBuy = [];
  107. this.GET_AssembleGoods();
  108. },
  109. // 请求拼团数据
  110. GET_AssembleGoods() {
  111. this.status = "loading";
  112. const params = JSON.parse(JSON.stringify(this.params));
  113. if (params.category_id === 0) delete params.category_id;
  114. API_Promotions.getAssembleList(params)
  115. .then((response) => {
  116. const data = response.data.result.records;
  117. if (!data || !data.length) {
  118. this.is_empty = true;
  119. this.status = "nomore";
  120. } else {
  121. if (data.length <= this.params.pageSize) {
  122. this.status = "nomore";
  123. } else {
  124. this.status = "loadmore";
  125. }
  126. this.is_empty = false;
  127. this.groupBuy.push(...(data || []));
  128. }
  129. })
  130. .catch(() => {});
  131. },
  132. },
  133. };
  134. </script>
  135. <style lang="scss" scoped>
  136. @import "./style.scss";
  137. </style>