|
|
@ -57,19 +57,19 @@ |
|
|
|
</view> |
|
|
|
</view> |
|
|
|
<view class="content"> |
|
|
|
<view class="content"> |
|
|
|
<view class="filter-box"> |
|
|
|
<view class="filter-box"> |
|
|
|
<view v-for="(item, index) in filterList" :key="index" class="filter-item" :class="{ active: activeFilter === item}" @click="changeFilter(item)"> |
|
|
|
<view v-for="(item, index) in filterList" :key="index" class="filter-item" :class="{ active: activeFilter === item.value}" @click="changeFilter(item.value)"> |
|
|
|
{{ item }} |
|
|
|
{{ item.name }} |
|
|
|
<text v-if="item === '价格'" class="down" :class="{ on: activeFilter === '价格' && filterDirection === 'DESC'}" style="top: 22rpx;"></text> |
|
|
|
<text v-if="item.value === 'price'" class="down" :class="{ on: activeFilter === 'price' && filterDirection === 'DESC'}" style="top: 22rpx;"></text> |
|
|
|
<text v-if="item === '价格'" class="up" :class="{ on: activeFilter === '价格' && filterDirection === 'ASC'}"></text> |
|
|
|
<text v-if="item.value === 'price'" class="up" :class="{ on: activeFilter === 'price' && filterDirection === 'ASC'}"></text> |
|
|
|
</view> |
|
|
|
</view> |
|
|
|
</view> |
|
|
|
</view> |
|
|
|
<view class="goods-list"> |
|
|
|
<view class="goods-list"> |
|
|
|
<view v-for="(item, index) in goods" :key="index" class="good"> |
|
|
|
<view v-for="(item, index) in goods" :key="index" class="good" @click="onGoodDetail(item.goods_id)"> |
|
|
|
<image :src="item.pic" mode="aspectFill"></image> |
|
|
|
<image :src="item.goods_image" mode="aspectFill"></image> |
|
|
|
<view class="name">{{ item.name }}</view> |
|
|
|
<view class="name">{{ item.goods_name }}</view> |
|
|
|
<view class="price"> |
|
|
|
<view class="price"> |
|
|
|
<text class="now-price">¥{{ item.price }}</text> |
|
|
|
<text class="now-price">¥{{ item.goods_price_min>0?Number(item.goods_price_min):0.00 }}</text> |
|
|
|
<text class="origin-price">¥{{ item.originPrice }}</text> |
|
|
|
<text v-if="item.line_price_min > 0" class="origin-price">¥{{ item.line_price_min>0?Number(item.line_price_min):'' }}</text> |
|
|
|
</view> |
|
|
|
</view> |
|
|
|
</view> |
|
|
|
</view> |
|
|
|
</view> |
|
|
|
</view> |
|
|
@ -96,6 +96,7 @@ |
|
|
|
import * as Api from '@/api/shop/index'; |
|
|
|
import * as Api from '@/api/shop/index'; |
|
|
|
import * as cstegory from '@/api/category' |
|
|
|
import * as cstegory from '@/api/category' |
|
|
|
import * as GoodsApi from '@/api/goods' |
|
|
|
import * as GoodsApi from '@/api/goods' |
|
|
|
|
|
|
|
import { debounce } from 'lodash'; |
|
|
|
|
|
|
|
|
|
|
|
export default { |
|
|
|
export default { |
|
|
|
data() { |
|
|
|
data() { |
|
|
@ -106,91 +107,24 @@ |
|
|
|
}, |
|
|
|
}, |
|
|
|
id: '', |
|
|
|
id: '', |
|
|
|
scrollTop: 0, |
|
|
|
scrollTop: 0, |
|
|
|
shopDetail: { |
|
|
|
shopDetail: {}, |
|
|
|
logo: '', |
|
|
|
goodsCate: [], |
|
|
|
name: '小米旗舰店', |
|
|
|
|
|
|
|
label: '商家直营 正品保障' |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
goodsCate: [ |
|
|
|
|
|
|
|
{ id: 1, name: '热门分类', children: [{ id: 1, name: '二级分类1'}, { id: 1, name: '二级分类2'}, { id: 1, name: '二级分类3'}, { id: 1, name: '二级分类4'}, { id: 1, name: '二级分类5'}]}, |
|
|
|
|
|
|
|
{ id: 1, name: '手机', children: [{ id: 1, name: '二级分类1'}, { id: 1, name: '二级分类2'}, { id: 1, name: '二级分类3'}, { id: 1, name: '二级分类4'}, { id: 1, name: '二级分类5'}]}, |
|
|
|
|
|
|
|
{ id: 1, name: '平板', children: [{ id: 1, name: '二级分类1'}, { id: 1, name: '二级分类2'}, { id: 1, name: '二级分类3'}, { id: 1, name: '二级分类4'}, { id: 1, name: '二级分类5'}]}, |
|
|
|
|
|
|
|
{ id: 1, name: '电脑', children: [{ id: 1, name: '二级分类1'}, { id: 1, name: '二级分类2'}, { id: 1, name: '二级分类3'}, { id: 1, name: '二级分类4'}, { id: 1, name: '二级分类5'}]}, |
|
|
|
|
|
|
|
{ id: 1, name: '冰箱', children: [{ id: 1, name: '二级分类1'}, { id: 1, name: '二级分类2'}, { id: 1, name: '二级分类3'}, { id: 1, name: '二级分类4'}, { id: 1, name: '二级分类5'}]}, |
|
|
|
|
|
|
|
], |
|
|
|
|
|
|
|
firstCate: '', |
|
|
|
firstCate: '', |
|
|
|
secondCate: '', |
|
|
|
secondCate: '', |
|
|
|
activeFilter: '综合', |
|
|
|
activeFilter: 'all', |
|
|
|
filterDirection: 'ASC', |
|
|
|
filterDirection: 'ASC', |
|
|
|
filterList: ['综合', '价格', '折扣', '销量'], |
|
|
|
filterList: [ |
|
|
|
|
|
|
|
{ name: '综合', value: 'all' }, |
|
|
|
|
|
|
|
{ name: '价格', value: 'price' }, |
|
|
|
|
|
|
|
{ name: '折扣', value: 'discount' }, |
|
|
|
|
|
|
|
{ name: '销量', value: 'sales' }], |
|
|
|
isTop: false, |
|
|
|
isTop: false, |
|
|
|
page: 1, |
|
|
|
page: 1, |
|
|
|
limit: 10, |
|
|
|
limit: 10, |
|
|
|
loadTitle: '', |
|
|
|
loadTitle: '', |
|
|
|
loading: false, |
|
|
|
loading: false, |
|
|
|
finished: true, |
|
|
|
finished: true, |
|
|
|
goods: [ |
|
|
|
goods: [] |
|
|
|
// { |
|
|
|
|
|
|
|
// pic: '', |
|
|
|
|
|
|
|
// name: '小米耳机最新版小米耳机最新版', |
|
|
|
|
|
|
|
// price: 208.00, |
|
|
|
|
|
|
|
// originPrice: 809, |
|
|
|
|
|
|
|
// }, |
|
|
|
|
|
|
|
// { |
|
|
|
|
|
|
|
// pic: '', |
|
|
|
|
|
|
|
// name: '小米耳机最新版小米耳机最新版', |
|
|
|
|
|
|
|
// price: 208.00, |
|
|
|
|
|
|
|
// originPrice: 809, |
|
|
|
|
|
|
|
// }, |
|
|
|
|
|
|
|
// { |
|
|
|
|
|
|
|
// pic: '', |
|
|
|
|
|
|
|
// name: '小米耳机最新版小米耳机最新版', |
|
|
|
|
|
|
|
// price: 208.00, |
|
|
|
|
|
|
|
// originPrice: 809, |
|
|
|
|
|
|
|
// }, |
|
|
|
|
|
|
|
// { |
|
|
|
|
|
|
|
// pic: '', |
|
|
|
|
|
|
|
// name: '小米耳机最新版小米耳机最新版', |
|
|
|
|
|
|
|
// price: 208.00, |
|
|
|
|
|
|
|
// originPrice: 809 |
|
|
|
|
|
|
|
// }, |
|
|
|
|
|
|
|
// { |
|
|
|
|
|
|
|
// pic: '', |
|
|
|
|
|
|
|
// name: '小米耳机最新版小米耳机最新版', |
|
|
|
|
|
|
|
// price: 208.00, |
|
|
|
|
|
|
|
// originPrice: 809, |
|
|
|
|
|
|
|
// }, |
|
|
|
|
|
|
|
// { |
|
|
|
|
|
|
|
// pic: '', |
|
|
|
|
|
|
|
// name: '小米耳机最新版小米耳机最新版', |
|
|
|
|
|
|
|
// price: 208.00, |
|
|
|
|
|
|
|
// originPrice: 809, |
|
|
|
|
|
|
|
// }, |
|
|
|
|
|
|
|
// { |
|
|
|
|
|
|
|
// pic: '', |
|
|
|
|
|
|
|
// name: '小米耳机最新版小米耳机最新版', |
|
|
|
|
|
|
|
// price: 208.00, |
|
|
|
|
|
|
|
// originPrice: 809, |
|
|
|
|
|
|
|
// }, |
|
|
|
|
|
|
|
// { |
|
|
|
|
|
|
|
// pic: '', |
|
|
|
|
|
|
|
// name: '小米耳机最新版小米耳机最新版', |
|
|
|
|
|
|
|
// price: 208.00, |
|
|
|
|
|
|
|
// originPrice: 809, |
|
|
|
|
|
|
|
// }, |
|
|
|
|
|
|
|
// { |
|
|
|
|
|
|
|
// pic: '', |
|
|
|
|
|
|
|
// name: '小米耳机最新版小米耳机最新版', |
|
|
|
|
|
|
|
// price: 208.00, |
|
|
|
|
|
|
|
// originPrice: 809, |
|
|
|
|
|
|
|
// }, |
|
|
|
|
|
|
|
// { |
|
|
|
|
|
|
|
// pic: '', |
|
|
|
|
|
|
|
// name: '小米耳机最新版小米耳机最新版', |
|
|
|
|
|
|
|
// price: 208.00, |
|
|
|
|
|
|
|
// originPrice: 809, |
|
|
|
|
|
|
|
// }, |
|
|
|
|
|
|
|
] |
|
|
|
|
|
|
|
}; |
|
|
|
}; |
|
|
|
}, |
|
|
|
}, |
|
|
|
// computed: { |
|
|
|
// computed: { |
|
|
@ -203,8 +137,14 @@ |
|
|
|
// } |
|
|
|
// } |
|
|
|
// }, |
|
|
|
// }, |
|
|
|
watch: { |
|
|
|
watch: { |
|
|
|
|
|
|
|
firstCate() { |
|
|
|
|
|
|
|
this.goods = []; |
|
|
|
|
|
|
|
this.page = 1; |
|
|
|
|
|
|
|
this.loading = false; |
|
|
|
|
|
|
|
this.finished = false; |
|
|
|
|
|
|
|
this.getGoodsList(); |
|
|
|
|
|
|
|
}, |
|
|
|
secondCate() { |
|
|
|
secondCate() { |
|
|
|
console.log(this.secondCate); |
|
|
|
|
|
|
|
this.goods = []; |
|
|
|
this.goods = []; |
|
|
|
this.page = 1; |
|
|
|
this.page = 1; |
|
|
|
this.loading = false; |
|
|
|
this.loading = false; |
|
|
@ -234,16 +174,21 @@ |
|
|
|
search() { |
|
|
|
search() { |
|
|
|
// 跳转商品搜索 |
|
|
|
// 跳转商品搜索 |
|
|
|
uni.navigateTo({ |
|
|
|
uni.navigateTo({ |
|
|
|
url: '/pages/search/index' |
|
|
|
url: `/pages/search/index?merchantId=${this.id}` |
|
|
|
}) |
|
|
|
}) |
|
|
|
}, |
|
|
|
}, |
|
|
|
changeFilter(item) { |
|
|
|
changeFilter(item) { |
|
|
|
if (item !== this.activeFilter) { |
|
|
|
if (item !== this.activeFilter) { |
|
|
|
this.activeFilter = item; |
|
|
|
this.activeFilter = item; |
|
|
|
this.filterDirection = 'ASC'; |
|
|
|
this.filterDirection = 'ASC'; |
|
|
|
} else if (item === '价格') { |
|
|
|
} else if (item === 'price') { |
|
|
|
this.filterDirection = this.filterDirection === 'ASC' ? 'DESC' : 'ASC'; |
|
|
|
this.filterDirection = this.filterDirection === 'ASC' ? 'DESC' : 'ASC'; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
this.goods = []; |
|
|
|
|
|
|
|
this.page = 1; |
|
|
|
|
|
|
|
this.loading = false; |
|
|
|
|
|
|
|
this.finished = false; |
|
|
|
|
|
|
|
this.getGoodsList(); |
|
|
|
}, |
|
|
|
}, |
|
|
|
openScrollTo() { |
|
|
|
openScrollTo() { |
|
|
|
uni.pageScrollTo({ |
|
|
|
uni.pageScrollTo({ |
|
|
@ -284,18 +229,17 @@ |
|
|
|
* 获取商品列表 |
|
|
|
* 获取商品列表 |
|
|
|
* @param {number} pageNo 页码 |
|
|
|
* @param {number} pageNo 页码 |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
getGoodsList() { |
|
|
|
getGoodsList: debounce(function() { |
|
|
|
if (this.loading || this.finished) { |
|
|
|
if (this.loading || this.finished) { |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
this.loadTitle = ""; |
|
|
|
this.loadTitle = ""; |
|
|
|
const param = { |
|
|
|
const param = { |
|
|
|
sortType: this.activeFilter, |
|
|
|
sortType: this.activeFilter, |
|
|
|
sortPrice: this.filterDirection === 'ASC' ? 1 : 0, |
|
|
|
sortPrice: this.filterDirection === 'DESC' ? 1 : 0, |
|
|
|
categoryId: this.secondCate, |
|
|
|
categoryId: this.secondCate || this.firstCate, |
|
|
|
// goodsName: app.options.search || '', |
|
|
|
merchantId: this.id, |
|
|
|
page: this.page++, |
|
|
|
page: this.page++, |
|
|
|
pageSize: 10 |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
GoodsApi.list(param) |
|
|
|
GoodsApi.list(param) |
|
|
|
.then(result => { |
|
|
|
.then(result => { |
|
|
@ -306,12 +250,18 @@ |
|
|
|
this.finished = data.length < 10; |
|
|
|
this.finished = data.length < 10; |
|
|
|
this.loadTitle = this.finished ? "已全部加载完" : "上拉加载更多"; |
|
|
|
this.loadTitle = this.finished ? "已全部加载完" : "上拉加载更多"; |
|
|
|
}) |
|
|
|
}) |
|
|
|
}, |
|
|
|
}, 500), |
|
|
|
toCart() { |
|
|
|
toCart() { |
|
|
|
uni.switchTab({ |
|
|
|
uni.switchTab({ |
|
|
|
url: '/pages/cart/index' |
|
|
|
url: '/pages/cart/index' |
|
|
|
}) |
|
|
|
}) |
|
|
|
}, |
|
|
|
}, |
|
|
|
|
|
|
|
// 跳转商品详情页 |
|
|
|
|
|
|
|
onGoodDetail(goodsId) { |
|
|
|
|
|
|
|
this.$navTo('pages/goods/detail', { |
|
|
|
|
|
|
|
goodsId |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
}, |
|
|
|
} |
|
|
|
} |
|
|
|
}; |
|
|
|
}; |
|
|
|
</script> |
|
|
|
</script> |
|
|
|