<template>
|
<view class="category-wrap" :data-theme='theme()' :class="theme() || ''">
|
<!-- #ifdef APP-PLUS -->
|
<header-bar></header-bar>
|
<!-- #endif -->
|
<!-- 搜索框 -->
|
<view class="index-search-box-cate d-b-c" id="searchBox"
|
:style="topBarHeight() == 0 ? '': 'height:'+topBarHeight()+'px;padding-top:'+topBarTop()+'px'">
|
<view class="index-search-cate flex-1 t-c" @click="gotoSearch">
|
<span class="icon iconfont icon-sousuo"></span>
|
<text class="ml10">{{ searchName }}</text>
|
</view>
|
<!-- #ifdef MP-WEIXIN -->
|
<view class="wx-top-right"></view>
|
<!-- #endif -->
|
</view>
|
<!--类别列表-->
|
<view class="category-content">
|
<!--一级分类 大图-->
|
<view class="cotegory-type cotegory-type-1" v-if="show_type==10">
|
<scroll-view scroll-y="true" class="scroll-Y" :style="'height:'+scrollviewHigh+'px;'">
|
<view class="list">
|
<view class="item" v-for="(item,index) in listData" :key="index"
|
@click="gotoList(item.category_id)">
|
<view class="pic">
|
<image :src="hasImages(item)" mode="widthFix"></image>
|
</view>
|
<view class="p-20-0 fb tc f34">
|
{{item.name}}
|
</view>
|
</view>
|
</view>
|
</scroll-view>
|
</view>
|
|
<!--一级分类 小图-->
|
<view class="cotegory-type cotegory-type-2" v-if="show_type==20">
|
<scroll-view scroll-y="true" class="scroll-Y" :style="'height:'+scrollviewHigh+'px;'">
|
<view class="list">
|
<view class="item" v-for="(item,index) in listData" :key="index"
|
@click="gotoList(item.category_id)">
|
<image :src="hasImages(item)" mode="aspectFit"></image>
|
<text>{{item.name}}</text>
|
</view>
|
</view>
|
</scroll-view>
|
</view>
|
|
<!--一级分类 列表-->
|
<view class="cotegory-type cotegory-type-3" v-if="show_type==40">
|
<view class="category-tab">
|
<scroll-view scroll-y="true" class="scroll-Y" :style="'height:'+scrollviewHigh+'px;'">
|
<view :class="index==select_index?'item active':'item'" v-for="(item,index) in listData"
|
:key="index" @click="getProductData(index)">
|
<text>{{item.name}}</text>
|
</view>
|
</scroll-view>
|
</view>
|
<view class="category-content pr">
|
<scroll-view scroll-y="true" class="scroll-Y scroll-3" :style="'height:'+scrollviewHigh+'px;'">
|
<view class="shop_body">
|
<view class="shop_body_l_item" :class="index==productData.length-1?'noborder':''" v-for="(item,index) in productData"
|
:key="index" @click="gotoList2(item.product_id)" v-if="index_open_city==0 || (index_open_city==1 && isInArray2(city_supplier_ids,item.shop_supplier_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>
|
<view class="shop_body_l_item_info_others f22">
|
<view class="shop_body_l_item_info_others_sales">累计成交:{{item.product_sales}}笔</view>
|
</view>
|
</view>
|
</view>
|
</view>
|
</view>
|
<!-- 没有记录 -->
|
<view class="d-c-c p30" v-if="productData.length==0 && !isloadding">
|
<text class="iconfont icon-wushuju"></text>
|
<text class="cont">亲,暂无相关记录哦</text>
|
</view>
|
</scroll-view>
|
</view>
|
</view>
|
|
<!--二级分类-->
|
<view class="cotegory-type cotegory-type-3" v-if="show_type==30">
|
<view class="category-tab">
|
<scroll-view scroll-y="true" class="scroll-Y" :style="'height:'+scrollviewHigh+'px;'">
|
<view :class="index==select_index?'item active':'item'" v-for="(item,index) in listData"
|
:key="index" @click="selectCategory(index)">
|
<text>{{item.name}}</text>
|
</view>
|
</scroll-view>
|
</view>
|
<view class="category-content pr">
|
<scroll-view scroll-y="true" class="scroll-Y scroll-3" :style="'height:'+scrollviewHigh+'px;'">
|
<view class="f26 catename">{{catename}}</view>
|
<view class="list">
|
<view class="item" v-for="(item,index) in childlist" :key="index"
|
@click="gotoList(item.category_id)">
|
<image :src="hasImages(item)" mode="aspectFit"></image>
|
<text class="type-name">{{item.name}}</text>
|
</view>
|
</view>
|
</scroll-view>
|
</view>
|
</view>
|
|
</view>
|
<tabBar></tabBar>
|
<request-loading :loadding='isloadding'></request-loading>
|
</view>
|
</template>
|
|
<script>
|
export default {
|
components: {},
|
data() {
|
return {
|
isloadding: true,
|
searchName: '搜索商品',
|
/*展示方式*/
|
show_type: 3,
|
/*手机高度*/
|
phoneHeight: 0,
|
/*可滚动视图区域高度*/
|
scrollviewHigh: 0,
|
/*数据*/
|
listData: [],
|
/*子类数据*/
|
childlist: [],
|
/*当前选中的分类*/
|
select_index: 0,
|
productData:[],
|
catename:'',
|
/*底部加载*/
|
loading: true,
|
index_open_city:0,
|
city_supplier_ids:[],
|
};
|
},
|
mounted() {
|
this.init();
|
this.getData();
|
},
|
onShow(){
|
this.getData();
|
this.getTabBarLinks();
|
},
|
methods: {
|
/*初始化*/
|
init() {
|
let _this = this;
|
uni.getSystemInfo({
|
success(res) {
|
_this.phoneHeight = res.windowHeight;
|
// 计算组件的高度
|
let view = uni.createSelectorQuery().select('#searchBox');
|
view.boundingClientRect(data => {
|
let h = _this.phoneHeight - data.height;
|
_this.scrollviewHigh = h;
|
}).exec();
|
}
|
});
|
},
|
|
isInArray2(arr,value){
|
value=parseInt(value);
|
var index = arr.indexOf(value);
|
if(index >= 0){
|
return true;
|
}
|
return false;
|
},
|
|
/*判断是否有图片*/
|
hasImages(e) {
|
if (e.images != null && e.images.file_path != null) {
|
return e.images.file_path;
|
} else {
|
return '';
|
}
|
},
|
|
/*获取数据*/
|
getData() {
|
let _this = this;
|
_this.select_index = 0;
|
|
var city_supplier_ids = '';
|
if(uni.getStorageSync('citySupplierRes')){
|
let resData=uni.getStorageSync('citySupplierRes');
|
_this.city_supplier_ids=resData.supplier_ids;
|
city_supplier_ids = _this.city_supplier_ids.join(",")
|
}
|
_this.isloadding = true;
|
_this._get('product.category/index', {city_supplier_ids:city_supplier_ids}, function(res) {
|
_this.listData = res.data.list;
|
_this.show_type = res.data.template.category_style;
|
if(_this.listData.length>0){
|
if (_this.listData[0].child) {
|
_this.childlist = _this.listData[0].child;
|
}
|
}
|
_this.catename = _this.listData[0].name;
|
_this.background = res.data.background;
|
_this.productData=res.data.productList.data;
|
_this.index_open_city=res.data.store.index_open_city;
|
_this.isloadding = false;
|
});
|
},
|
|
/*选择分类*/
|
selectCategory(e) {
|
if (this.listData[e].child) {
|
this.childlist = this.listData[e].child;
|
this.select_index = e;
|
}
|
},
|
/*获取商品数据*/
|
getProductData(e) {
|
this.select_index = e;
|
this.productData=[];
|
let self = this;
|
var city_supplier_ids = '';
|
if(uni.getStorageSync('citySupplierRes')){
|
let resData=uni.getStorageSync('citySupplierRes');
|
self.city_supplier_ids=resData.supplier_ids;
|
city_supplier_ids = self.city_supplier_ids.join(",")
|
}
|
let page = 1;
|
let list_rows = 10;
|
let category_id =this.listData[e].category_id;
|
let search = '';
|
let sortType = '';
|
let sortPrice = 0;
|
self.isloadding = true;
|
self._get('product.product/lists', {
|
page: page || 1,
|
category_id: category_id,
|
search: search,
|
sortType: sortType,
|
sortPrice: sortPrice,
|
list_rows: list_rows,
|
city_supplier_ids:city_supplier_ids
|
}, function(res) {
|
self.isloadding = false;
|
self.productData = res.data.list.data;
|
self.index_open_city=res.data.store.index_open_city;
|
});
|
},
|
/*跳转产品列表*/
|
gotoList2(e) {
|
let url = 'pages/product/detail/detail?product_id=' + e
|
this.gotoPage(url);
|
},
|
/*跳转产品列表*/
|
gotoList(e) {
|
let category_id = e;
|
let sortType = 'all';
|
let search = '';
|
let sortPrice = 0;
|
this.gotoPage('/pages/product/list/list?category_id=' + category_id + '&sortType=' + sortType +
|
'&search=' + search +
|
'&sortPrice=' + sortPrice);
|
},
|
|
wxGetUserInfo: function(res) {
|
if (!res.detail.iv) {
|
uni.showToast({
|
title: "您取消了授权,登录失败",
|
icon: "none"
|
});
|
return false;
|
}
|
},
|
|
/*跳转搜索页面*/
|
gotoSearch() {
|
this.gotoPage('/pages/product/search/search');
|
},
|
/**
|
* 设置分享内容
|
*/
|
onShareAppMessage() {
|
let self = this;
|
return {
|
title: self.templet.share_title,
|
path: '/pages/product/category?' + self.getShareUrlParams()
|
};
|
},
|
}
|
};
|
</script>
|
|
<style lang="scss">
|
@import '@/common/mixin.scss';
|
|
.foot_ {
|
height: 98rpx;
|
width: 100%;
|
}
|
|
.cotegory-type {
|
line-height: 40rpx;
|
background: #ffffff;
|
}
|
|
.cotegory-type image {
|
width: 100%;
|
}
|
|
.cotegory-type-1 .list {
|
padding: 20rpx;
|
}
|
|
.cotegory-type-1 .list .item {
|
margin-top: 30rpx;
|
}
|
|
.cotegory-type-1 .list .item .pic {
|
border: 1px solid #e3e3e3;
|
width: 710rpx;
|
height: auto;
|
overflow: hidden;
|
border-radius: 8px;
|
}
|
|
.cotegory-type-1 .list .item image {
|
width: 100%;
|
height: 100%;
|
}
|
|
.cotegory-type-2 .list,
|
.cotegory-type-3 .list {
|
padding: 0 20rpx;
|
display: flex;
|
flex-wrap: wrap;
|
justify-content: flex-start;
|
}
|
|
.cotegory-type-2 .list .item,
|
.cotegory-type-3 .list .item {
|
display: flex;
|
flex-direction: column;
|
justify-content: center;
|
align-items: center;
|
}
|
|
.cotegory-type-2 .list .item {
|
padding: 0 16rpx;
|
width: 200rpx;
|
height: 300rpx;
|
font-size: 28rpx;
|
}
|
|
.cotegory-type-2 .list .item image {
|
width: 180rpx;
|
height: 180rpx;
|
margin-bottom: 20rpx;
|
}
|
|
.cotegory-type-3 {
|
display: flex;
|
}
|
|
.cotegory-type-3 .category-tab {
|
width: 200rpx;
|
background: #FFFFFF;
|
// border-right: 1px solid #e3e3e3;
|
}
|
|
.cotegory-type-3 .category-tab .item {
|
padding: 40rpx 0;
|
font-size: 26rpx;
|
text-align: center;
|
color: #666666;
|
font-weight: bold;
|
}
|
|
.cotegory-type-3 .category-tab .item.active {
|
position: relative;
|
background: #ffffff;
|
|
color: #333333;
|
}
|
|
.cotegory-type-3 .category-tab .item.active::after {
|
position: absolute;
|
content: '';
|
top: 40rpx;
|
bottom: 40rpx;
|
left: 0;
|
width: 6rpx;
|
height: 22rpx;
|
margin: auto;
|
@include background_linear('titleft1', 'titleft2', 180deg, 0%, 100%);
|
}
|
|
.cotegory-type-3 .category-content {
|
flex: 1;
|
margin: 0 20rpx;
|
}
|
|
.cotegory-type-3 .list .item {
|
width: 140rpx;
|
height: 200rpx;
|
margin-top: 40rpx;
|
margin-right: 20rpx;
|
font-size: 24rpx;
|
}
|
|
.cotegory-type-3 .list .item:nth-child(3n) {
|
margin-right: 0;
|
}
|
|
.cotegory-type-3 .list .item image {
|
width: 140rpx;
|
height: 140rpx;
|
}
|
|
.cotegory-type-3 .list .item .type-name {
|
display: block;
|
margin-top: 20rpx;
|
height: 80rpx;
|
line-height: 60rpx;
|
text-overflow: ellipsis;
|
width: 100%;
|
color: #818181;
|
font-size: 26rpx;
|
white-space: nowrap;
|
overflow: hidden;
|
text-align: center;
|
}
|
|
.scroll-3 {
|
position: absolute;
|
background: #ffffff;
|
border-radius: 12px;
|
}
|
.catename{
|
padding-top: 10rpx;
|
line-height: 60rpx;
|
border-bottom: 1rpx solid #D9D9D9;
|
}
|
.shop_body {
|
width: 100%;
|
background-color: #ffffff;
|
padding: 0rpx 20rpx;
|
box-sizing: border-box;
|
}
|
|
.shop_body_l_item {
|
// width: 90%;
|
// height: 250rpx;
|
margin: 0 auto;
|
background-color: white;
|
// border-radius: 15rpx;
|
// margin-top: 20rpx;
|
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 {
|
// width: 70%;
|
// height: 100%;
|
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 {
|
// width: 100%;
|
height: 30rpx;
|
display: flex;
|
justify-content: space-between;
|
}
|
|
.shop_body_l_item_info_others_activity {
|
width: 150rpx;
|
height: 30rpx;
|
line-height: 30rpx;
|
border: 1rpx #E22319 solid;
|
border-radius: 30rpx;
|
/* font-size: 16rpx; */
|
color: #E22319;
|
text-align: center;
|
box-sizing: border-box;
|
}
|
|
.shop_body_l_item_info_others_sales {
|
color: #333333;
|
}
|
|
.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;
|
}
|
|
.inner-tab .item .icon-sanjiao2 {
|
font-size: 13rpx;
|
}
|
|
.inner-tab .item .icon-sanjiao1 {
|
font-size: 13rpx;
|
}
|
|
.noborder {
|
border: none;
|
}
|
</style>
|