product.vue 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. <template>
  2. <view class="coupon-product-container">
  3. <JHeader title="可用商品" width="50" height="50" style="padding: 24upx 0 0;"></JHeader>
  4. <view class="productList">
  5. <view class="couponTit flex-items">
  6. <tui-icon name="coupon" :size="66" unit="upx" color="#c83732" margin=" 0 15upx 0 0"></tui-icon>
  7. <text v-if="currentCoupon.discountMode === 1" class="fs24 font-color-C83732">
  8. 以下商品使用满{{ currentCoupon.fullMoney }}元减{{ currentCoupon.reduceMoney }}元的优惠券
  9. </text>
  10. <text v-else class="fs24 font-color-C83732">
  11. 以下商品使用满{{ currentCoupon.fullMoney }}打{{ currentCoupon.reduceMoney }}折
  12. </text>
  13. </view>
  14. <view class="productListBox">
  15. <view v-if="productList && productList.length" class="productItemBox mar-top-30">
  16. <view
  17. v-for="(item, index) in productList" :key="item.productId" class="productItem"
  18. @click="go(`/another-tf/another-serve/goodsDetails/index?shopId=${item.shopId}&productId=${item.productId}&skuId=${item.skuId}`)"
  19. >
  20. <view class="productImg">
  21. <image :src="common.seamingImgUrl(item.image)"></image>
  22. </view>
  23. <view class="productTit fs28 font-color-333">{{ item.productName }}</view>
  24. <view class="productPrice font-color-C83732 fs40">¥{{ item.price }}</view>
  25. </view>
  26. </view>
  27. <view style="padding-bottom: 45upx;">
  28. <LoadingMore
  29. :status="!isEmpty && !productList.length
  30. ? 'loading' : !isEmpty && productList.length && (productList.length >= productTotal) ? 'no-more' : ''"
  31. >
  32. </LoadingMore>
  33. <tui-no-data v-if="isEmpty" :fixed="false" style="margin-top: 60upx;">暂无可用商品~</tui-no-data>
  34. </view>
  35. </view>
  36. </view>
  37. </view>
  38. </template>
  39. <script>
  40. import { getCanvasCouponsApi, getCouponProductsApi } from '../../../api/anotherTFInterface'
  41. export default {
  42. name: 'Product',
  43. data() {
  44. return {
  45. couponId: 0,
  46. isEmpty: false,
  47. productList: [],
  48. productTotal: 0,
  49. queryInfo: {
  50. page: 1,
  51. pageSize: 20
  52. },
  53. currentCoupon: {
  54. fullMoney: 0,
  55. reduceMoney: 0
  56. }
  57. }
  58. },
  59. onLoad(options) {
  60. this.couponId = options.id
  61. this.getCouponData()
  62. this.getProductList()
  63. },
  64. methods: {
  65. getCouponData() {
  66. getCanvasCouponsApi({
  67. page: 1,
  68. pageSize: 1,
  69. ids: this.couponId
  70. }).then((res) => {
  71. if (res.data) {
  72. this.currentCoupon = res.data.list[0]
  73. }
  74. })
  75. },
  76. getProductList(isLoadmore) {
  77. uni.showLoading()
  78. getCouponProductsApi(this.queryInfo).then((res) => {
  79. this.productTotal = res.data.total
  80. if (isLoadmore) {
  81. this.productList.push(...res.data.list)
  82. } else {
  83. this.productList = res.data.list
  84. }
  85. this.isEmpty = this.productList.length === 0
  86. uni.hideLoading()
  87. })
  88. .catch((e) => {
  89. uni.hideLoading()
  90. })
  91. }
  92. },
  93. onReachBottom() {
  94. if (this.productList.length < this.productTotal) {
  95. ++this.queryInfo.page
  96. this.getProductList(true)
  97. }
  98. }
  99. }
  100. </script>
  101. <style lang="less" scoped>
  102. .coupon-product-container {
  103. padding: 0 20rpx;
  104. min-height: 100%;
  105. background-color: #ffffff;
  106. box-sizing: border-box;
  107. .productList {
  108. .couponTit {
  109. padding: 0 20rpx;
  110. height: 86rpx;
  111. background: #F9F6F1;
  112. }
  113. .productListBox {
  114. .productItemBox {
  115. display: flex;
  116. flex-wrap: wrap;
  117. justify-content: space-between;
  118. width: 100%;
  119. .productItem {
  120. box-sizing: border-box;
  121. width: 49%;
  122. padding: 0 20rpx;
  123. height: 420rpx;
  124. margin: 0 0 20rpx 0;
  125. &:nth-child(2n) {
  126. margin-right: 0;
  127. }
  128. .productImg {
  129. width: 282rpx;
  130. height: 282rpx;
  131. image {
  132. width: 100%;
  133. height: 100%;
  134. }
  135. }
  136. .productTit {
  137. overflow: hidden;
  138. text-overflow: ellipsis;
  139. white-space: nowrap;
  140. }
  141. .productPrice {
  142. margin-top: 15rpx;
  143. }
  144. }
  145. }
  146. }
  147. }
  148. }
  149. </style>