123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205 |
- <template>
- <view class='recommend'>
- <block v-if="tempArr.length">
- <title-box v-if="isShowTitle" title="热门推荐"></title-box>
- <view class='recommendList borderPad' :class="isShowTitle?'':'mt30'">
- <WaterfallsFlow :isDynamics="dynamics" :userFair="dynamics" :wfList='tempArr' :type="1" :isStore="1">
- <template slot-scope="{item}">{{item.name}}
- <WaterfallsFlowItem :item="item" :type="1" :isStore="1"/>
- </template>
- </WaterfallsFlow>
- </view>
- <view class='loadingicon acea-row row-center-wrapper' :hidden='loading==false'>
- <text class='loading iconfont icon-jiazai'></text>
- </view>
- <view class="mores-txt flex" v-if="goodScroll">
- <text>我是有底线的</text>
- </view>
- </block>
- </view>
- </template>
- <script>
- // +----------------------------------------------------------------------
- // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
- // +----------------------------------------------------------------------
- // | Copyright (c) 2016~2025 https://www.crmeb.com All rights reserved.
- // +----------------------------------------------------------------------
- // | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
- // +----------------------------------------------------------------------
- // | Author: CRMEB Team <admin@crmeb.com>
- // +----------------------------------------------------------------------
- import {
- mapGetters
- } from "vuex";
- import animationType from '@/utils/animationType.js'
- import {
- getProductHot,
- getSecondHandHot
- } from '@/api/product.js';
- import WaterfallsFlow from '@/components/WaterfallsFlow/WaterfallsFlow.vue';
- import WaterfallsFlowItem from '@/components/WaterfallsFlowItem/WaterfallsFlowItem.vue';
- import TitleBox from '@/components/titleBox/index.vue';
- let app = getApp();
- export default {
- name: 'recommend',
- computed: mapGetters(['uid']),
- components: {
- WaterfallsFlow,
- TitleBox
- },
- props: {
- categoryId: {
- type: Number,
- default: function() {
- return 0;
- }
- },
- //是否显示头部
- isShowTitle: {
- type: Boolean,
- default: function() {
- return true;
- }
- },
- //是否使用本页面的请求数据
- isDefault: {
- type: Boolean,
- default: function() {
- return true;
- }
- },
- //使用的页面中调用数据传来的商品列表,isDefault为false时使用
- recommendList: {
- type: Array,
- default: function() {
- return [];
- }
- },
- dynamics: {
- type: Boolean,
- default: false
- },
- tabActive: {
- type: Number,
- default: 0
- }
- },
- data() {
- return {
- urlDomain: this.$Cache.get("imgHost"),
- theme: app.globalData.theme,
- goodScroll: false,
- params: { //精品推荐分页
- page: 1,
- limit: 10,
- cid: 0
- },
- loading: false,
- tempArr: []
- };
- },
- watch: {
- categoryId: function(val) { //监听props中的属性
- if (!this.isDefault) {
- this.params.page = 1;
- this.tempArr = [];
- this.goodScroll = false;
- this.get_host_product()
- }
- }
- },
- mounted() {
- if (this.isDefault) {
- this.params.page = 1;
- this.goodScroll = false;
- this.tempArr = [];
- this.get_host_product()
- }else{
- this.tempArr = this.recommendList
- };
- },
- methods: {
- /**
- * 获取我的推荐
- */
- get_host_product: function() {
- if (this.goodScroll) return;
- this.loading = true
- this.params.cid = this.categoryId;
- console.log(this.tabActive, '子组件响应0000000000000000000000')
- if (this.tabActive == 0 && this.dynamics) {
- this.params.range = 'school'
- } else if (this.tabActive == 1 && this.dynamics) {
- this.params.range = 'city'
- this.params.city = uni.getStorageSync('cityName')
- } else if (this.tabActive == 2 && this.dynamics) {
- this.params.range = 'all'
- }
- let api = this.dynamics ? getSecondHandHot : getProductHot;
- console.log(this.params, '推荐')
- api(this.params).then((res) => {
- this.$set(this.params, 'page', this.params.page + 1);
- this.goodScroll = this.params.page > res.data.totalPage;
- this.tempArr = this.tempArr.concat(res.data.list || []);
- this.$emit('getRecommendLength', this.tempArr.length);
- this.loading = false
- }).catch(err => {
- this.loading = false
- });
- },
- initParams(text) {
- this.params = { //精品推荐分页
- page: 1,
- limit: 10,
- cid: 0,
- keywords: text || ''
- };
- this.tempArr = [];
- this.goodScroll = false;
- this.get_host_product()
- }
- },
- onReachBottom() {
- if (this.isDefault) this.get_host_product();
- }
- }
- </script>
- <style scoped lang="scss">
-
- .mores-txt {
- width: 100%;
- align-items: center;
- justify-content: center;
- height: 70rpx;
- color: #999;
- font-size: 24rpx;
- .iconfont {
- margin-top: 2rpx;
- font-size: 20rpx;
- }
- }
- .recommend {
- .title {
- height: 120rpx;
- line-height: 120rpx;
- font-size: 32rpx;
- color: #333333;
- .iconfont {
- font-size: 170rpx;
- color: #454545;
- }
- }
- .name {
- margin: 0 28rpx;
- }
- }
- .recommendList{
- background-color: #f5f5f5;
- }
- </style>
|