|
|
|
@ -8,11 +8,11 @@ |
|
|
|
|
<search :tips="options.search ? options.search : '搜索商品'" @event="handleSearch" /> |
|
|
|
|
</view> |
|
|
|
|
</view> |
|
|
|
|
<view class="store-sort"> |
|
|
|
|
<view class="store-sort" v-if="tabbar.length>0"> |
|
|
|
|
<view class="goodsType"> |
|
|
|
|
<scroll-view class="typeList" scroll-x="true"> |
|
|
|
|
<view v-for="(item,index) in banrdType" :key="index" class="typeItem" @click="onChage(item,1)" |
|
|
|
|
:style="{'color':item.id==isBanrdActive?'#F43B21':'#5A5A5A','background':item.id==isBanrdActive?'#FEF6F6':'#F7F8FA','border':item.id==isBanrdActive?'2rpx solid #F22029':'none'}"> |
|
|
|
|
<view v-for="(item,index) in tabbar" :key="index" class="typeItem" @click="onChage(item,1)" |
|
|
|
|
:style="{'color':item.category_id==isBanrdActive?'#F43B21':'#5A5A5A','background':item.category_id==isBanrdActive?'#FEF6F6':'#F7F8FA','border':item.category_id==isBanrdActive?'2rpx solid #F22029':'none'}"> |
|
|
|
|
{{item.name}} |
|
|
|
|
</view> |
|
|
|
|
</scroll-view> |
|
|
|
@ -20,7 +20,7 @@ |
|
|
|
|
<view class="goodsType"> |
|
|
|
|
<scroll-view class="typeList" scroll-x="true"> |
|
|
|
|
<view v-for="(item,index) in goodsType" :key="index" class="typeItem" @click="onChage(item,2)" |
|
|
|
|
:style="{'color':isActive==item.id?'#F43B21':'#5A5A5A','background':isActive==item.id?'#FEF6F6':'#F7F8FA','border':isActive==item.id?'2rpx solid #F22029':'none'}"> |
|
|
|
|
:style="{'color':isActive==item.category_id?'#F43B21':'#5A5A5A','background':isActive==item.category_id?'#FEF6F6':'#F7F8FA','border':isActive==item.category_id?'2rpx solid #F22029':'none'}"> |
|
|
|
|
{{item.name}} |
|
|
|
|
</view> |
|
|
|
|
</scroll-view> |
|
|
|
@ -143,7 +143,7 @@ |
|
|
|
|
|
|
|
|
|
const pageSize = 15 |
|
|
|
|
const showViewKey = 'GoodsList-ShowView'; |
|
|
|
|
|
|
|
|
|
import * as cstegory from '@/api/category' |
|
|
|
|
export default { |
|
|
|
|
components: { |
|
|
|
|
Search |
|
|
|
@ -152,40 +152,12 @@ |
|
|
|
|
data() { |
|
|
|
|
return { |
|
|
|
|
searchText: '', |
|
|
|
|
banrdType: [{ |
|
|
|
|
name: '长虹', |
|
|
|
|
id: 1, |
|
|
|
|
}, { |
|
|
|
|
name: '苹果', |
|
|
|
|
id: 2, |
|
|
|
|
}, { |
|
|
|
|
name: '联想', |
|
|
|
|
id: 3, |
|
|
|
|
}, { |
|
|
|
|
name: '小米', |
|
|
|
|
id: 4, |
|
|
|
|
}, { |
|
|
|
|
name: 'TCL', |
|
|
|
|
id: 5, |
|
|
|
|
}], |
|
|
|
|
banrdType: [], |
|
|
|
|
keyName1: '', |
|
|
|
|
isBanrdActive: '', |
|
|
|
|
isActive: '', |
|
|
|
|
goodsType: [{ |
|
|
|
|
name: '80英寸', |
|
|
|
|
id: 1, |
|
|
|
|
}, { |
|
|
|
|
name: '75英寸', |
|
|
|
|
id: 2, |
|
|
|
|
}, { |
|
|
|
|
name: '70英寸', |
|
|
|
|
id: 3, |
|
|
|
|
}, { |
|
|
|
|
name: '65英寸', |
|
|
|
|
id: 4, |
|
|
|
|
}, { |
|
|
|
|
name: '60英寸', |
|
|
|
|
id: 5, |
|
|
|
|
}, ], |
|
|
|
|
goodsType: [], |
|
|
|
|
keyName2: '', |
|
|
|
|
showView: false, // 列表显示方式 (true列表、false平铺) |
|
|
|
|
sortType: 'all', // 排序类型 |
|
|
|
|
sortPrice: false, // 价格排序 (true高到低 false低到高) |
|
|
|
@ -202,7 +174,8 @@ |
|
|
|
|
}, |
|
|
|
|
// 数量要大于4条才显示无更多数据 |
|
|
|
|
noMoreSize: 4, |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
tabbar: [] |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
|
|
|
|
@ -218,16 +191,40 @@ |
|
|
|
|
this.setShowView() |
|
|
|
|
// 设置微信公众号链接分享卡片内容 |
|
|
|
|
this.setWxofficialShareData() |
|
|
|
|
this.getGoodsTypeList(options.categoryId) |
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
methods: { |
|
|
|
|
getGoodsTypeList(category_id) { |
|
|
|
|
const that = this; |
|
|
|
|
that.goodsType = [] |
|
|
|
|
return new Promise((resolve, reject) => { |
|
|
|
|
cstegory.childrenList({ |
|
|
|
|
category_id: category_id |
|
|
|
|
}) |
|
|
|
|
.then(res => { |
|
|
|
|
if (res.data.list.length > 0) { |
|
|
|
|
that.tabbar = res.data.list; |
|
|
|
|
res.data.list.forEach(item => { |
|
|
|
|
item.children.forEach(item_1 => { |
|
|
|
|
that.goodsType.push(item_1) |
|
|
|
|
}) |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
|
.catch(reject) |
|
|
|
|
}) |
|
|
|
|
}, |
|
|
|
|
onChage(item, type) { |
|
|
|
|
if (type == 1) { |
|
|
|
|
this.isBanrdActive = item.id |
|
|
|
|
this.isBanrdActive = item.category_id; |
|
|
|
|
this.keyName1 = item.name |
|
|
|
|
} |
|
|
|
|
if (type == 2) { |
|
|
|
|
this.isActive = item.id |
|
|
|
|
this.isActive = item.category_id |
|
|
|
|
this.keyName2 = item.name |
|
|
|
|
} |
|
|
|
|
this.getGoodsList() |
|
|
|
|
}, |
|
|
|
|
/** |
|
|
|
|
* 上拉加载的回调 (页面初始化时也会执行一次) |
|
|
|
@ -257,13 +254,20 @@ |
|
|
|
|
*/ |
|
|
|
|
getGoodsList(pageNo = 1) { |
|
|
|
|
const app = this |
|
|
|
|
console.log(app.options) |
|
|
|
|
let keywords = [] |
|
|
|
|
if (this.keyName1) { |
|
|
|
|
keywords.push(this.keyName1) |
|
|
|
|
} |
|
|
|
|
if (this.keyName2) { |
|
|
|
|
keywords.push(this.keyName2) |
|
|
|
|
} |
|
|
|
|
const param = { |
|
|
|
|
sortType: app.sortType, |
|
|
|
|
sortPrice: Number(app.sortPrice), |
|
|
|
|
categoryId: app.options.categoryId || 0, |
|
|
|
|
goodsName: app.options.search || '', |
|
|
|
|
page: pageNo |
|
|
|
|
page: pageNo, |
|
|
|
|
keywords: keywords |
|
|
|
|
} |
|
|
|
|
return new Promise((resolve, reject) => { |
|
|
|
|
GoodsApi.list(param) |
|
|
|
@ -306,7 +310,7 @@ |
|
|
|
|
* 商品搜索 |
|
|
|
|
*/ |
|
|
|
|
handleSearch() { |
|
|
|
|
const searchPageUrl = 'pages/search/index' |
|
|
|
|
const searchPageUrl = 'pages/search/index?category_id=' + this.options.categoryId |
|
|
|
|
// 判断来源页面 |
|
|
|
|
let pages = getCurrentPages() |
|
|
|
|
if (pages.length > 1 && |
|
|
|
@ -363,9 +367,10 @@ |
|
|
|
|
|
|
|
|
|
// 搜索框 |
|
|
|
|
.search { |
|
|
|
|
width: 100%; |
|
|
|
|
width: 100%; |
|
|
|
|
padding: 0 30rpx; |
|
|
|
|
.search-wrapper{ |
|
|
|
|
|
|
|
|
|
.search-wrapper { |
|
|
|
|
padding: 0; |
|
|
|
|
width: 100%; |
|
|
|
|
} |
|
|
|
|