金诚优选前端代码
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.
 
 
 
 
 

240 lines
5.4 KiB

<template>
<view>
<lf-nav :showIcon="true" bgColor="transparent" :spreadOut="false"></lf-nav>
<view class="head">
<image class="img" mode="aspectFill" :src="activity_content.topic.image"></image>
<view class="title">{{activity_content.topic.name}}</view>
</view>
<scroll-view :style="{height: autoHeight}" :scroll-y="true" :refresher-enabled="true"
:refresher-triggered="isRefresher" @scrolltolower="onScrolltolower" @refresherrefresh="onRefresherrefresh">
<view class="content">
<view class="card" v-for="(item, index) in list" :key="index" @click="$url('/pages/shop/goodsdetail?id='+ item.goods.id)">
<view class="goods-img">
<image class="img" :src="item.goods.img"></image>
<!-- <view class="ranking">
<view class="top">{{ item+1 }}</view>
<view class="down"></view>
</view> -->
</view>
<view class="goods-info">
<view>
<view class="lf-line-2 title">{{item.goods.name}}</view>
<view class="desc">月销量:{{item.goods.sale_count}}</view>
</view>
<view class="lf-row-between">
<view class="price">
<text>¥{{item.goods.sell_price}}</text>
</view>
</view>
</view>
</view>
<!-- 空数据的情况 -->
<view class="loading-more">
<text v-if="list.length != 0" :class="{'loading-more-text': loadingClass}">{{ loadingText }}</text>
<lf-nocontent src="/static/images/empty.png" v-else></lf-nocontent>
</view>
</view>
</scroll-view>
</view>
</template>
<script>
export default {
data(){
return {
page: 1,
topic_id: 1,
activity_content: '',
list: [],
isPage: true,
loadingClass: true,
loadingText: '正在加载中',
scrollH: 0,
nav_height: 0,
isRefresher: true,
}
},
onLoad(){
let info = uni.getSystemInfoSync();
this.scrollH = info.screenHeight;
this.getActivityList();
},
computed: {
autoHeight() {
return `calc(${this.scrollH}px - ${this.nav_height}px - 430rpx)`;
}
},
methods: {
// 页面触底,加载下一页
onScrolltolower() {
if (this.isPage) {
this.page = this.page + 1;
this.getActivityList();
}
},
// 下拉刷新处理
refreshFn(options) {
this.page = 1;
this.isPage = true;
this.loadingClass = true;
this.list = []
this.loadingText = '正在加载中';
this.getActivityList(options);
},
// scroll-view 下拉刷新
onRefresherrefresh() {
this.isRefresher = true;
this.refreshFn({
type: 'scrollRefresh'
});
},
getActivityList(options = {}){
this.$http.get({
api: 'api/topic/list',
data: {
topic_id: this.topic_id,
page: this.page
},
header: {
Authorization: this.$cookieStorage.get('user_token')
}
}).then(res => {
this.activity_content = res.data.data
console.log('====',res.data.data)
let isPage = this.page < res.data.data.goods.total ? true : false;
this.isPage = isPage;
if (!isPage) {
this.loadingClass = false;
this.loadingText = '没有更多数据啦~';
}
if (options.type == 'pageRefresh') {
uni.stopPullDownRefresh();
} else if (options.type == 'scrollRefresh') {
this.isRefresher = false;
}
if (this.page == 1) {
this.list = res.data.data.goods.data;
} else {
this.list.push(...res.data.data.goods.data);
}
})
},
}
}
</script>
<style>
page{
background-color: #F8F8F8;
}
</style>
<style lang="scss" scoped="scoped">
.head{
width: 750rpx;
height: 430rpx;
position: relative;
.img{
width: 100%;
height: 100%;
}
.title{
position: absolute;
left: 0;
top: 0;
width: 100%;
height: 100%;
display: flex;
justify-content: center;
align-items: center;
font-size: 60rpx;
color: #FFFFFF;
font-weight: bold;
font-family: '楷体';
}
}
.content{
padding: 30rpx 32rpx;
.card{
width: 686rpx;
height: 260rpx;
background: #FFFFFF;
border-radius: 20rpx;
box-sizing: border-box;
padding: 30rpx;
display: flex;
&:nth-child(n+2){
margin-top: 30rpx;
}
.goods-img{
width: 200rpx;
height: 200rpx;
border-radius: 10rpx;
overflow: hidden;
position: relative;
margin-right: 15rpx;
.img{
width: 100%;
height: 100%;
background-color: #EEEEEE;
}
.ranking{
position: absolute;
top: 0;
left: 0;
width: 36rpx;
height: 56rpx;
overflow: hidden;
.top{
width: 36rpx;
height: 36rpx;
background-color: #15716E;
position: relative;
z-index: 3;
text-align: center;
color: #FFFFFF;
font-size: 28rpx;
}
.down{
width: 36rpx;
height: 36rpx;
background-color: #15716E;
transform: rotate(45deg);
margin-top: -26rpx;
position: relative;
z-index: 1;
}
}
}
.goods-info{
width: 410rpx;
height: 200rpx;
display: flex;
flex-direction: column;
justify-content: space-between;
.title{
font-size: 28rpx;
color: #222222;
}
.desc{
width: max-content;
height: 35rpx;
border-radius: 18rpx;
background-color: #E9F2F2;
font-size: 24rpx;
color: #15716E;
display: flex;
justify-content: center;
align-items: center;
margin-top: 10rpx;
padding: 0 10rpx;
}
.price>text:nth-child(1){
font-size: 32rpx;
color: #222222;
font-weight: bold;
}
}
}
}
</style>