You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

183 lines
4.2 KiB

3 months ago
  1. <template>
  2. <view class='recommend'>
  3. <block v-if="tempArr.length">
  4. <view v-if="isShowTitle" class="flex-center recommend-box mt-20 mb-24">
  5. <image :src="`${urlDomain}crmebimage/presets/haowuzuo.png`"></image>
  6. <view class="f-s-32 lh-44rpx ml-4">热门推荐</view>
  7. <image class="ml-6" :src="`${urlDomain}crmebimage/presets/haowuyou.png`"></image>
  8. </view>
  9. <view class='recommendList borderPad' :class="isShowTitle?'':'mt30'">
  10. <WaterfallsFlow :wfList='tempArr' :type="1" :isStore="1">
  11. </WaterfallsFlow>
  12. </view>
  13. <view class='loadingicon acea-row row-center-wrapper' :hidden='loading==false'>
  14. <text class='loading iconfont icon-jiazai'></text>
  15. </view>
  16. <view class="mores-txt flex" v-if="goodScroll">
  17. <text>我是有底线的</text>
  18. </view>
  19. </block>
  20. </view>
  21. </template>
  22. <script>
  23. // +----------------------------------------------------------------------
  24. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  25. // +----------------------------------------------------------------------
  26. // | Copyright (c) 2016~2025 https://www.crmeb.com All rights reserved.
  27. // +----------------------------------------------------------------------
  28. // | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
  29. // +----------------------------------------------------------------------
  30. // | Author: CRMEB Team <admin@crmeb.com>
  31. // +----------------------------------------------------------------------
  32. import {
  33. mapGetters
  34. } from "vuex";
  35. import animationType from '@/utils/animationType.js'
  36. import {
  37. getProductslist
  38. } from '@/api/store.js';
  39. import WaterfallsFlow from '@/components/WaterfallsFlow/WaterfallsFlow.vue';
  40. let app = getApp();
  41. export default {
  42. name: 'recommend',
  43. computed: mapGetters(['uid']),
  44. components: {
  45. WaterfallsFlow
  46. },
  47. props: {
  48. categoryId: {
  49. type: Number,
  50. default: function() {
  51. return 0;
  52. }
  53. },
  54. //是否显示头部
  55. isShowTitle: {
  56. type: Boolean,
  57. default: function() {
  58. return true;
  59. }
  60. },
  61. //是否使用本页面的请求数据
  62. isDefault: {
  63. type: Boolean,
  64. default: function() {
  65. return true;
  66. }
  67. },
  68. //使用的页面中调用数据传来的商品列表,isDefault为false时使用
  69. recommendList: {
  70. type: Array,
  71. default: function() {
  72. return [];
  73. }
  74. }
  75. },
  76. data() {
  77. return {
  78. urlDomain: this.$Cache.get("imgHost"),
  79. theme: app.globalData.theme,
  80. goodScroll: false,
  81. params: { //精品推荐分页
  82. page: 1,
  83. limit: 10,
  84. cid: 0
  85. },
  86. loading: false,
  87. tempArr: []
  88. };
  89. },
  90. computed:{
  91. myCategoryId(){
  92. return this.categoryId
  93. }
  94. },
  95. watch: {
  96. myCategoryId: function(val) { //监听props中的属性
  97. this.params.page = 1;
  98. this.tempArr = [];
  99. this.goodScroll = false;
  100. this.get_host_product()
  101. }
  102. },
  103. mounted() {
  104. if (this.isDefault) {
  105. this.params.page = 1;
  106. this.goodScroll = false;
  107. this.tempArr = [];
  108. this.get_host_product()
  109. } else {
  110. this.tempArr = this.recommendList
  111. };
  112. },
  113. methods: {
  114. /**
  115. * 获取我的推荐
  116. */
  117. get_host_product: function() {
  118. if (this.goodScroll) return;
  119. this.loading = true
  120. this.params.cid = this.categoryId;
  121. getProductslist(
  122. this.params
  123. ).then((res) => {
  124. this.$set(this.params, 'page', this.params.page + 1);
  125. this.goodScroll = this.params.page > res.data.totalPage;
  126. this.tempArr = this.tempArr.concat(res.data.list || []);
  127. // this.$emit('getRecommendLength', this.tempArr.length);
  128. this.loading = false
  129. }).catch(err => {
  130. this.loading = false
  131. });
  132. }
  133. },
  134. onReachBottom() {
  135. if (this.isDefault) this.get_host_product();
  136. }
  137. }
  138. </script>
  139. <style scoped lang="scss">
  140. .recommend-box {
  141. image {
  142. width: 42rpx;
  143. height: 36rpx;
  144. }
  145. view {
  146. font-weight: 600;
  147. }
  148. }
  149. .mores-txt {
  150. width: 100%;
  151. align-items: center;
  152. justify-content: center;
  153. height: 70rpx;
  154. color: #999;
  155. font-size: 24rpx;
  156. .iconfont {
  157. margin-top: 2rpx;
  158. font-size: 20rpx;
  159. }
  160. }
  161. .recommend {
  162. .title {
  163. height: 120rpx;
  164. line-height: 120rpx;
  165. font-size: 32rpx;
  166. color: #333333;
  167. .iconfont {
  168. font-size: 170rpx;
  169. color: #454545;
  170. }
  171. }
  172. .name {
  173. margin: 0 28rpx;
  174. }
  175. }
  176. </style>