<template>
|
<view>
|
<view class="top-box">
|
<view class="inner-tab">
|
<view class="scroll_box" v-if="categoryData[0]">
|
<scroll-view class="scroll" scroll-x="true" upper-threshode="50">
|
<view class="flex">
|
<view :class="category_id==0?'scroll-view-item_H active':'scroll-view-item_H'" @click="getProduct(0)">最新</view>
|
<view v-for="(item,index) in categoryData" :key="index" :class="category_id==item.category_id?'scroll-view-item_H active':'scroll-view-item_H'" @click="getProduct(item.category_id)">{{item.name}}</view>
|
</view>
|
</scroll-view>
|
</view>
|
</view>
|
</view>
|
<view class="prodcut-list-wrap">
|
<scroll-view scroll-y="true" class="scroll-Y" :style="'height:' + scrollviewHigh + 'px;'" lower-threshold="50"
|
@scrolltolower="scrolltolowerFunc">
|
<view :class="topRefresh?'top-refresh open':'top-refresh'">
|
<view class="circle" v-for="(circle,n) in 3" :key="n"></view>
|
</view>
|
<view class="shop_body">
|
<view class="shop_body_l_item" :class="index==listData.length-1?'noborder':''" v-for="(item,index) in listData"
|
:key="index" @click="gotoDetail(item.product_id)">
|
<view>
|
<image :src="item.product_image" mode=""></image>
|
</view>
|
<view class="shop_body_l_item_info">
|
<view class="shop_body_l_item_info_title gray3 f32">{{item.product_name}}</view>
|
<view class="d-b-c pb10">
|
<view class="shop_body_l_item_info_price">
|
<view class="f24 shop_red">¥<text class="f32 fb">{{item.product_price}}</text></view>
|
<view class="f20 huaxianjia">¥<text class="24">{{item.line_price}}</text></view>
|
</view>
|
<view class="shop_body_l_item_info_others f22">
|
<view class="shop_body_l_item_info_others_sales">抢购</view>
|
</view>
|
</view>
|
</view>
|
</view>
|
</view>
|
|
<!-- 没有记录 -->
|
<view class="d-c-c p30" v-if="listData.length==0 && !loading">
|
<text class="iconfont icon-wushuju"></text>
|
<text class="cont">亲,暂无相关记录哦</text>
|
</view>
|
<uni-load-more v-else :loadingType="loadingType"></uni-load-more>
|
</scroll-view>
|
</view>
|
</view>
|
</template>
|
|
<script>
|
import uniLoadMore from "@/components/uni-load-more.vue";
|
export default {
|
components: {
|
uniLoadMore
|
},
|
data() {
|
return {
|
/*手机高度*/
|
phoneHeight: 0,
|
/*可滚动视图区域高度*/
|
scrollviewHigh: 0,
|
/*顶部刷新*/
|
topRefresh: false,
|
/*底部加载*/
|
loading: true,
|
/*没有更多*/
|
no_more: false,
|
categoryData: [],
|
/*商品列表*/
|
listData: [],
|
/*当前页面*/
|
page: 1,
|
category_id: 0,
|
list_rows: 10,
|
last_page: 0,
|
};
|
},
|
computed: {
|
|
/*加载中状态*/
|
loadingType() {
|
if (this.loading) {
|
return 1;
|
} else {
|
if (this.listData.length != 0 && this.no_more) {
|
return 2;
|
} else {
|
return 0;
|
}
|
}
|
}
|
},
|
onLoad(e) {
|
},
|
mounted() {
|
this.init();
|
/*获取分类列表*/
|
this.getCategoryData();
|
this.getProductData();
|
},
|
onPullDownRefresh() {
|
/*下拉到顶,页面值还原初始化*/
|
this.restoreData();
|
this.getProductData();
|
},
|
methods: {
|
/*初始化*/
|
init() {
|
let _this = this;
|
uni.getSystemInfo({
|
success(res) {
|
_this.phoneHeight = res.windowHeight;
|
// 计算组件的高度
|
let view = uni.createSelectorQuery().select('.top-box');
|
view.boundingClientRect(data => {
|
let h = _this.phoneHeight - data.height;
|
_this.scrollviewHigh = h;
|
}).exec();
|
}
|
});
|
},
|
/*还原初始化*/
|
restoreData() {
|
this.listData = [];
|
this.category_id = 0;
|
},
|
|
/*获取数据*/
|
getCategoryData() {
|
let self = this;
|
self.loading = true;
|
self._get('plus.goodcoupon.category/index', {
|
|
}, function(res) {
|
self.categoryData = res.data.category_list;
|
self.loading = false;
|
});
|
},
|
|
/*点击二级分类*/
|
getProduct(category_id){
|
let self = this;
|
self.listData = [];
|
self.page = 1;
|
self.no_more = false;
|
self.loading = true;
|
self.category_id = category_id;
|
self.getProductData();
|
},
|
|
/*获取商品数据*/
|
getProductData() {
|
let self = this;
|
self.loading = true;
|
self._get('plus.goodcoupon.coupon/lists', {
|
page: self.page,
|
list_rows: self.list_rows,
|
category_id: self.category_id,
|
}, function(res) {
|
self.loading = false;
|
self.listData = self.listData.concat(res.data.list.data);
|
self.last_page = res.data.list.last_page;
|
if (res.data.list.last_page <= 1) {
|
self.no_more = true;
|
}
|
});
|
},
|
|
/*跳转详情*/
|
gotoDetail(e) {
|
let url = 'pages/product/detail/detail?product_id=' + e
|
this.gotoPage(url);
|
},
|
|
|
/*可滚动视图区域到底触发*/
|
scrolltolowerFunc() {
|
let self = this;
|
self.bottomRefresh = true;
|
self.page++;
|
self.loading = true;
|
if (self.page > self.last_page) {
|
self.loading = false;
|
self.no_more = true;
|
return;
|
}
|
self.getData();
|
},
|
|
/** 设置分享内容*/
|
onShareAppMessage() {
|
// 构建分享参数
|
return {
|
title: "领好券",
|
path: "/pages2/goodcoupon/coupon"
|
};
|
},
|
}
|
};
|
</script>
|
|
<style lang="scss" scoped>
|
.inner-tab {
|
position: fixed;
|
width: 100%;
|
height: 80rpx;
|
background: #ffffff;
|
left:0px;
|
top:0px;
|
z-index: 9;
|
|
}
|
.scroll_box{
|
height:80rpx;
|
}
|
.scroll{
|
width: 100%;
|
overflow: hidden;
|
background: #fff;
|
white-space: nowrap;
|
position: absolute;
|
left: 0px;
|
top:0px;
|
z-index: 999;
|
}
|
.scroll-view-item_H{
|
height:80rpx;
|
line-height: 80rpx;
|
padding-left: 20rpx;
|
margin-right: 50rpx;
|
display: inline-block;
|
font-size: 30rpx;
|
}
|
.scroll-view-item_H.active{
|
color: red;
|
}
|
|
.prodcut-list-wrap {
|
padding-top: 100rpx;
|
}
|
|
.prodcut-list-wrap .list {
|
background: #FFFFFF;
|
}
|
|
.prodcut-list-wrap .list .item {
|
padding: 20rpx;
|
display: flex;
|
border-bottom: 1rpx solid #f6f6f6;
|
}
|
|
.prodcut-list-wrap .product-cover,
|
.prodcut-list-wrap .product-cover image {
|
width: 150rpx;
|
height: 150rpx;
|
}
|
|
.prodcut-list-wrap .product-info {
|
flex: 1;
|
margin-left: 30rpx;
|
display: flex;
|
flex-direction: column;
|
justify-content: space-around;
|
}
|
|
.prodcut-list-wrap .product-title {
|
display: -webkit-box;
|
line-height: 36rpx;
|
overflow: hidden;
|
-webkit-line-clamp: 2;
|
-webkit-box-orient: vertical;
|
font-size: 26rpx;
|
}
|
|
.prodcut-list-wrap .price {
|
color: $dominant-color;
|
font-size: 24rpx;
|
}
|
|
.prodcut-list-wrap .price .num {
|
margin-left: 6rpx;
|
padding: 0 4rpx;
|
font-size: 32rpx;
|
font-weight: bold;
|
}
|
|
.shop_body {
|
width: 100%;
|
background-color: #ffffff;
|
padding: 0rpx 20rpx;
|
box-sizing: border-box;
|
}
|
|
.shop_body_l_item {
|
margin: 0 auto;
|
background-color: white;
|
display: flex;
|
padding: 40rpx 0;
|
box-sizing: border-box;
|
border-bottom: 1rpx solid #D9D9D9;
|
|
}
|
|
.shop_body_l_item image {
|
width: 150rpx;
|
height: 150rpx;
|
border-radius: 12rpx;
|
background-color: rgba(0, 0, 0, 0.1);
|
}
|
|
.shop_body_l_item_info {
|
flex: 1;
|
display: flex;
|
justify-content: space-between;
|
flex-direction: column;
|
padding-left: 20rpx;
|
box-sizing: border-box;
|
}
|
|
.shop_body_l_item_info_title {
|
display: -webkit-box;
|
-webkit-box-orient: vertical;
|
-webkit-line-clamp: 2;
|
text-overflow: ellipsis;
|
-webkit-box-orient: vertical;
|
word-wrap: break-word;
|
word-break: break-all;
|
overflow: hidden;
|
}
|
|
.shop_body_l_item_info_price {
|
display: flex;
|
align-items: flex-end;
|
}
|
|
.shop_body_l_item_info_price view {
|
margin-right: 15rpx;
|
}
|
|
.shop_body_l_item_info_others {
|
height: 30rpx;
|
display: flex;
|
justify-content: space-between;
|
}
|
|
|
.shop_body_l_item_info_others_sales {
|
font-size: 24rpx;
|
color: #fff;
|
background: red;
|
padding: 10rpx 20rpx;
|
border-radius: 40%;
|
text-align: center;
|
height: 30rpx;
|
line-height: 30rpx;
|
}
|
|
.shop_body2 {
|
width: 100%;
|
display: flex;
|
justify-content: flex-start;
|
flex-wrap: wrap;
|
background-color: #f2f2f2;
|
}
|
|
.shop_body_t_item {
|
width: 345rpx;
|
// margin: 0 2.5%;
|
margin-bottom: 20rpx;
|
height: 520rpx;
|
overflow: hidden;
|
background-color: white;
|
border-radius: 12rpx;
|
}
|
|
.collect text {
|
color: #FFFFFF;
|
}
|
|
.shop_body_t_item image {
|
width: 100%;
|
height: 337.5rpx;
|
background-color: rgba(0, 0, 0, 0.1);
|
}
|
|
.shop_body_t_item_info {
|
// height: 182.5rpx;
|
display: flex;
|
flex-direction: column;
|
justify-content: flex-start;
|
padding: 20rpx;
|
box-sizing: border-box;
|
}
|
|
.shop_body_t_item_info_title {
|
display: -webkit-box;
|
-webkit-box-orient: vertical;
|
-webkit-line-clamp: 1;
|
text-overflow: ellipsis;
|
-webkit-box-orient: vertical;
|
word-wrap: break-word;
|
word-break: break-all;
|
overflow: hidden;
|
margin-bottom: 30rpx;
|
}
|
|
.shop_body_t_item_info_price {
|
display: flex;
|
align-items: flex-end;
|
|
}
|
|
.shop_body_t_item_info_others {
|
display: flex;
|
justify-content: space-between;
|
margin-bottom: 8rpx;
|
}
|
|
.shop_body_t_item_info_others_activity {}
|
|
.shop_body_t_item_info_others_sales {
|
color: #999999;
|
}
|
|
.huaxianjia {
|
text-decoration: line-through;
|
color: #999;
|
margin-left: 5rpx;
|
}
|
|
.shop_red {
|
color: #F6220C;
|
}
|
|
.noborder {
|
border: none;
|
}
|
</style>
|