Huanyuyuehui/components/recommend/index.vue

107 lines
2.2 KiB
Vue

<template>
<view class='recommend'>
<view class="common-hd">
<view class="title" :style="{ 'background-image': `url(${domain}/static/images/index-title.png)`}">为你推荐</view>
</view>
<view class='recommendList' :class="indexP?'on':''">
<WaterfallsFlow :wfList='hostProduct' @itemTap="goDetail" :type="0" />
</view>
</view>
</template>
<script>
import {mapGetters} from "vuex";
import { goShopDetail } from '@/libs/order.js'
import {initiateAssistApi} from '@/api/activity.js';
import {toLogin} from '@/libs/login.js';
import WaterfallsFlow from '@/components/WaterfallsFlow/WaterfallsFlow.vue'
import { HTTP_REQUEST_URL } from '@/config/app';
export default {
components:{WaterfallsFlow},
computed: mapGetters(['uid']),
props: {
hostProduct: {
type: Array,
default: function() {
return [];
}
},
indexP:{
type: Boolean,
default: false
},
isLogin:{
type: Boolean,
default: false
}
},
data() {
return {
domain: HTTP_REQUEST_URL,
};
},
mounted() {
},
onPullDownRefresh(){
// 模拟上拉刷新
setTimeout(()=>{
const newList = this.hostProduct.reverse();
this.hostProduct = newList;
uni.stopPullDownRefresh();
},500)
},
methods: {
goDetail(item){
goShopDetail(item, this.uid).then(res => {
if (this.isLogin) {
initiateAssistApi(item.activity_id).then(res => {
let id = res.data.product_assist_set_id;
uni.hideLoading();
uni.navigateTo({
url: '/pages/activity/assist_detail/index?id=' + id
});
}).catch((err) => {
uni.showToast({
title: err,
icon: 'none'
})
});
} else {
toLogin();
}
})
}
}
}
</script>
<style scoped lang="scss">
.common-hd {
display: flex;
align-items: center;
justify-content: center;
height: 118rpx;
.title {
padding: 0 80rpx;
font-size: 34rpx;
color: $theme-color;
font-weight: bold;
background-repeat: no-repeat;
background-size: 100% auto;
background-position: left center;
}
}
.recommend .recommendList {
padding: 0 20rpx;
min-height: 100rpx;
}
.recommend .recommendList.on{
padding: 0;
}
/deep/.looming-gray{
border-radius: 16rpx 16rpx 0 0;
}
</style>