goods.vue 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  1. <!-- 推广商品 -->
  2. <template>
  3. <view class="promotion-goods-wrap">
  4. <view class="goods-list u-flex" v-for="(item, index) in goodsList" :key="item.goods_id" @tap="jump('/pages/goods/detail', { id: item.id })">
  5. <view class="img-box"><image class="goods-img" :src="item.image" mode=""></image></view>
  6. <view class="goods-info u-flex-col u-row-between">
  7. <view class="goods-title u-ellipsis-1">{{ item.title }}</view>
  8. <view class="goods-des u-ellipsis-1">{{ item.subtitle }}</view>
  9. <view class="goods-price u-flex font-OPPOSANS">
  10. <view class="price">¥{{ item.price }}</view>
  11. <view class="origin-price">¥{{ item.original_price }}</view>
  12. </view>
  13. <view class="commission-num">预计佣金:¥{{ item.commission_money }}</view>
  14. </view>
  15. <button class="share-btn u-reset-button" @tap.stop="toShare(index)">分享赚</button>
  16. </view>
  17. <!-- 分享组件 -->
  18. <shopro-share v-model="showShare" :posterInfo="posterInfo" :posterType="'goods'"></shopro-share>
  19. <!-- 缺省页 -->
  20. <shopro-empty v-if="isEmpty" :image="$IMG_URL + '/imgs/empty/no_data.png'" tipText="暂无数据"></shopro-empty>
  21. <!-- 更多 -->
  22. <u-loadmore v-if="goodsList.length" height="80rpx" :status="loadStatus" icon-type="flower" color="#ccc" />
  23. </view>
  24. </template>
  25. <script>
  26. import share from '@/shopro/share';
  27. export default {
  28. components: {},
  29. data() {
  30. return {
  31. showShare: false, //是否分享
  32. posterInfo: {}, //分享信息
  33. goodsList: [], //分销商品
  34. loadStatus: 'loadmore', //loadmore-加载前的状态,loading-加载中的状态,nomore-没有更多的状态
  35. currentPage: 1,
  36. lastPage: 1,
  37. isEmpty: false
  38. };
  39. },
  40. computed: {},
  41. onLoad() {
  42. this.getGoodList();
  43. },
  44. onUnload() {
  45. share.setShareInfo();
  46. },
  47. onReachBottom() {
  48. if (this.currentPage < this.lastPage) {
  49. this.currentPage += 1;
  50. this.getGoodList();
  51. }
  52. },
  53. methods: {
  54. jump(path, parmas) {
  55. this.$Router.push({
  56. path: path,
  57. query: parmas
  58. });
  59. },
  60. // 去分享
  61. toShare(index) {
  62. const that = this;
  63. let goodsInfo = this.goodsList[index];
  64. this.posterInfo = goodsInfo;
  65. share.setShareInfo({
  66. title: goodsInfo.title,
  67. desc: goodsInfo.subtitle,
  68. image: goodsInfo.image,
  69. params: {
  70. page: 2,
  71. pageId: goodsInfo.id
  72. }
  73. });
  74. this.showShare = true;
  75. },
  76. getGoodList() {
  77. let that = this;
  78. that.loadStatus = 'loading';
  79. that.$http('commission.goods', {
  80. page: that.currentPage
  81. }).then(res => {
  82. if (res.code === 1) {
  83. that.goodsList = [...that.goodsList, ...res.data.data];
  84. that.lastPage = res.data.last_page;
  85. that.isEmpty = !that.goodsList.length;
  86. that.loadStatus = that.currentPage < res.data.last_page ? 'loadmore' : 'nomore';
  87. }
  88. });
  89. }
  90. }
  91. };
  92. </script>
  93. <style lang="scss">
  94. page {
  95. background-color: #fff;
  96. }
  97. // 推广商品列表
  98. .goods-list {
  99. padding: 30rpx;
  100. border-bottom: 1rpx solid rgba(#dfdfdf, 0.5);
  101. position: relative;
  102. .share-btn {
  103. position: absolute;
  104. bottom: 30rpx;
  105. right: 30rpx;
  106. width: 160rpx;
  107. line-height: 60rpx;
  108. background: linear-gradient(90deg, #a36fff, #5336ff);
  109. box-shadow: 0px 7rpx 11rpx 2rpx rgba(124, 103, 214, 0.34);
  110. border-radius: 30rpx;
  111. font-size: 28rpx;
  112. color: #fff;
  113. font-weight: 500;
  114. }
  115. .img-box {
  116. border: 1rpx solid rgba(223, 223, 223, 0.43);
  117. margin-right: 30rpx;
  118. .goods-img {
  119. width: 200rpx;
  120. height: 200rpx;
  121. }
  122. }
  123. .goods-info {
  124. align-items: flex-start;
  125. height: 200rpx;
  126. .goods-title {
  127. width: 400rpx;
  128. font-size: 28rpx;
  129. font-weight: 500;
  130. color: #333333;
  131. margin-bottom: 10rpx;
  132. }
  133. .goods-des {
  134. width: 400rpx;
  135. font-size: 22rpx;
  136. font-weight: 500;
  137. color: #a8700d;
  138. margin-bottom: 10rpx;
  139. }
  140. .goods-price {
  141. margin-bottom: 10rpx;
  142. .price {
  143. font-size: 28rpx;
  144. font-weight: 500;
  145. color: #333333;
  146. margin-right: 16rpx;
  147. }
  148. .origin-price {
  149. font-size: 24rpx;
  150. font-weight: 400;
  151. text-decoration: line-through;
  152. color: #999999;
  153. }
  154. }
  155. .commission-num {
  156. font-size: 24rpx;
  157. font-weight: 500;
  158. color: #5e4ddf;
  159. }
  160. }
  161. }
  162. </style>