搜索完成 #139

Merged
theluyuan merged 1 commits from xbx into master 2020-08-09 10:37:03 +00:00
7 changed files with 304 additions and 75 deletions

View File

@ -294,8 +294,8 @@ export default {
})
},
// 搜索发现列表
searchwordlist() {
return vm.$u.post('ShopSearch/searchwordlist')
searchwordlist({type}) {
return vm.$u.post('ShopSearch/searchWordList',{type})
},
// 提交试穿订单
saveGoodsTry({ member_name, member_mobile, area_info, address_detail, goods_id, num, store_id, appointment_time }) {
@ -332,6 +332,13 @@ export default {
fav_id: fid,
type: type
})
},
//店铺列表
storeList({ page, name_search }) {
return vm.$u.post('shop/storeList',{
page,
name_search: name_search
})
}
}
}

View File

@ -5,7 +5,7 @@
<text>输入达人名称</text>
</view>
<view class="list">
<darenItem style="margin-top:20rpx;margin-right:23rpx" v-for="item in recommendList" :key="item.id" :info="item" v-on:pChangeType="changeType"></darenItem>
<darenItem style="margin-top:20rpx;" v-for="item in recommendList" :key="item.id" :info="item" v-on:pChangeType="changeType"></darenItem>
</view>
</view>
</template>

View File

@ -21,7 +21,7 @@ export default {
// type: 2 1:
onLoad(option) {
this.type = option.type;
if(option.type == 2) this.getWordList();
this.getWordList();
},
//
onNavigationBarButtonTap(e) {
@ -37,8 +37,10 @@ export default {
},
methods:{
getWordList() {
this.$u.api.searchwordlist().then(res => {
this.searchwordlist = res.data;
this.$u.api.searchwordlist({type:this.type}).then(res => {
console.log(res)
this.searchwordlist = res.data;
})
},
search(value){
@ -52,14 +54,17 @@ export default {
type: this.type,
}
if(this.type == 2) {
Object.assign(params, {
order: 'goods_salenum'
})
}
this.$u.route({
url: "/pageB/search/out",
params: params,
})
this.$u.route({
url: "/pageB/search/out",
params: params,
})
}else{
this.$u.route({
url: "/pageB/search/searchGoods",
params: params,
})
}
}
}
}

View File

@ -1,59 +1,276 @@
<template>
<view class="out">
<u-tabs :list="list" :current="current" @change="tabsChange" active-color="#FF780F" :show-bar="false" height="88" font-size="32" inactive-color="#333333"></u-tabs>
<swiper :current="swiperCurrent" @animationfinish="animationfinish">
<!-- 店铺 -->
<swiper-item class="swiper-item" v-for="(item, index) in dataList[current]" :key="index">
<scroll-view scroll-y style="height: 800rpx;width: 100%;" @scrolltolower="onreachBottom">
<view class="store"></view>
</scroll-view>
</swiper-item>
<!-- 达人 -->
<swiper-item class="swiper-item" v-for="(item, index) in dataList[current]" :key="index">
<scroll-view scroll-y style="height: 800rpx;width: 100%;" @scrolltolower="onreachBottom">
<view class="anchor"></view>
</scroll-view>
</swiper-item>
<!-- 社区 -->
<swiper-item class="swiper-item" v-for="(item, index) in dataList[current]" :key="index">
<scroll-view scroll-y style="height: 800rpx;width: 100%;" @scrolltolower="onreachBottom">
<view class="community"></view>
</scroll-view>
</swiper-item>
</swiper>
</view>
<view class="classify-goods">
<view class="tab-container">
<view class="salenum" :class="{ 'current' : current == 0 }" @click="switchCurrent(0)">店铺</view>
<view class="price" :class="{ 'current' : current == 1 }" @click="switchCurrent(1)">
达人
</view>
<view class="evaluation" :class="{ 'current' : current == 2 }" @click="switchCurrent(2)">社区</view>
</view>
<scroll-view scroll-y class="goods-container" :style="{ height: scrollHeight }" @scrolltolower="loadMore" v-show="current == 0">
<view v-for="goods in goodsList" :key="goods.store_id" class="goods-item" @click="toDetailsPage(goods.store_id)">
<image :src="goods.store_avatar"></image>
<view class="right">
<view class="name u-line-1">{{ goods.store_name }}</view>
<view class="briefing u-line-2">{{ goods.store_description }}</view>
</view>
</view>
<u-loadmore :status="loadStatus" bgColor="#FFFFFF" margin-top="20" margin-bottom="20" v-if="goodsList.length >= pageSize"></u-loadmore>
<u-empty mode="list" v-if="!goodsList.length"></u-empty>
</scroll-view>
<scroll-view style="width:100%;" :style="{ height: scrollHeight }" scroll-y="true" @scrolltolower="loadMore" v-if=" current == 2 ">
<view class="box" style="padding: 0 30rpx;">
<view style="display:flex">
<view>
<videoItem v-for="(item,id) in goodsList.filter((_, index) => !(index&1))" :key="id" :item="item"
@getArticlelist="getArticlelist"></videoItem>
</view>
<view style="margin-left:20rpx">
<videoItem v-for="(item,id) in goodsList.filter((_, index) => index&1)" :key="id" :item="item"
@getArticlelist="getArticlelist"></videoItem>
</view>
</view>
</view>
<u-loadmore :status="loadStatus" bgColor="#FFFFFF" margin-top="20" margin-bottom="20" v-if="goodsList.length >= pageSize"></u-loadmore>
<u-empty mode="list" v-if="!goodsList.length"></u-empty>
</scroll-view>
<scroll-view style="width:100%;padding: 20rpx 30rpx;margin-right:23rpx;" :style="{ height: scrollHeight }" scroll-y="true" @scrolltolower="loadMore" v-if=" current == 1 ">
<view class="list" >
<darenItem style="margin-top:20rpx;margin-right:23rpx;box-shadow:0px 3rpx 7rpx 0px rgba(153, 153, 153, 0.35);" v-for="item in goodsList" :key="item.id" :info="item" v-on:pChangeType="changeType"></darenItem>
</view>
<u-loadmore :status="loadStatus" bgColor="#FFFFFF" margin-top="20" margin-bottom="20" v-if="goodsList.length >= pageSize"></u-loadmore>
<u-empty mode="list" v-if="!goodsList.length"></u-empty>
</scroll-view>
</view>
</template>
<script>
import videoItem from "@/components/index/video-item/index"
import darenItem from "@/components/index/daren-item/index"
export default {
data() {
return {
list: [{
name: "店铺"
}, {
name: "达人"
}, {
name: "社区"
}],
pageSize: 12,
cid: '',
page: 1,
current: 0,
swiperCurrent: 0,
dataList: [[1],[2],[3]],
priceOrderAsc: true, //
goodsList: [],
scrollHeight: '',
loadStatus: 'loadmore',
timer: true, // ,
value:""
}
},
components:{
videoItem,
darenItem
},
watch: {
current(value) {
this.page = 1;
this.ShopSearch({ laod: 'reload' });
},
priceOrderAsc(value) {
this.page = 1;
this.ShopSearch({ laod: 'reload' });
}
},
onLoad(option) {
this.value = option.value
this.setViewHeight();
this.ShopSearch()
},
onNavigationBarSearchInputConfirmed(value) {
this.value = value.text
console.log(this.value)
this.ShopSearch()
},
methods: {
tabsChange(index) {
this.current = Number(index);
this.swiperCurrent = this.current;
changeType(member_id){
console.log(member_id);
this.$emit("pChangeType")
this.$u.api.attentionMember({
member_id: member_id
}).then((res)=>{
console.log(res)
for(let i in this.goodsList){
if(this.goodsList[i].member_id == member_id){
this.goodsList[i].is_attention = res.message == "已取消关注!" ? 0 : 1
}
}
})
},
animationfinish(e) {
const current = Number(e.detail.current);
setOrderSort() {
let sort = '';
if(this.current == 0) {
sort = 'goods_salenum';
} else if (this.current == 1) {
if(this.priceOrderAsc) sort = 'goods_price_asc';
else sort = 'goods_price_desc';
} else if (this.current == 2) {
sort = 'evaluation_count';
}
return sort;
},
// goods_salenum evaluation_count goods_price_asc goods_price_desc
async ShopSearch({ load = 'reload' } = {}) {
// const res = await this.$u.api.ShopSearch({
// keyword: this.value,
// page: this.page,
// order: sort,
// })
console.log(this.value)
let res = {}
if(this.current == 0) {
res = await this.$u.api.storeList({
name_search: this.value,
page: this.page
})
this.timer = true;
if(res.errCode == 0) {
if(load == 'reload') this.goodsList = res.data.list.data;
else if(load == 'loadmore') this.goodsList.push(...res.data.list.data);
}
console.log(this.goodsList)
return res.data.list.data.length;
} else if (this.current == 1) {
res = await this.$u.api.getExpertList({
like_nickname: this.value,
page: this.page
})
this.timer = true;
if(res.errCode == 0) {
if(load == 'reload') this.goodsList = res.data.list;
else if(load == 'loadmore') this.goodsList.push(...res.data.list);
}
console.log(this.goodsList)
return res.data.list.length;
} else if (this.current == 2) {
res = await this.$u.api.getArticlelist({
value: this.value,
page: this.page
})
this.timer = true;
if(res.errCode == 0) {
if(load == 'reload') this.goodsList = res.data.list;
else if(load == 'loadmore') this.goodsList.push(...res.data.list);
}
console.log(this.goodsList)
return res.data.list.length;
}
},
loadMore() {
if(this.goodsList.length < this.pageSize) return false;
if(!this.timer) return false;
this.loadStatus = "loading";
this.page++;
this.ShopSearch({ load: 'loadmore' }).then(length => {
if(length == 0) {
this.page--;
this.loadStatus = 'nomore';
} else {
this.loadStatus = 'loading';
}
}).catch(() => {
this.loadStatus = "nomore";
this.page--;
})
},
switchCurrent(current) {
// if(current == 1 && this.current == 1) this.priceOrderAsc = !this.priceOrderAsc;
this.current = current;
this.swiperCurrent = current;
this.goodsList = []
this.ShopSearch()
},
setViewHeight() {
const res = uni.getSystemInfoSync();
this.scrollHeight = res.windowHeight - res.windowWidth / 750 * 90 + 'px';
},
toDetailsPage(id) {
this.$u.route('/pageC/merchant/index', {
id: id
});
}
}
};
</script>
<style lang="scss" scoped>
.list{
display: flex;
flex-wrap: wrap;
width: calc(100% + 23rpx);
margin-right: -23rpx;
}
.classify-goods {
.tab-container {
box-sizing: border-box;
padding: 30rpx 40rpx;
display: flex;
margin-bottom: 30rpx;
> view {
height: 30rpx;
line-height: 30rpx;
flex: 1;
font-size: 32rpx;
color: rgba(51,51,51,1);
}
.salenum {
text-align: left;
}
.price {
display: flex;
align-items: center;
justify-content: center;
.text {
margin-right: 5rpx;
}
.icon {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
}
}
.evaluation {
text-align: right;
}
.current {
color: rgba(255,120,15,1);
}
}
.goods-container {
.goods-item {
margin: 0 auto;
width: 690rpx;
display: flex;
background-color: #F5F5F5;
margin-bottom: 30rpx;
align-items: center;
> image {
width: 220rpx;
height: 200rpx;
flex-shrink: 0;
margin-right: 30rpx;
}
.right {
width: 418rpx;
.name {
font-size: 30rpx;
color: rgba(51,51,51,1);
margin-bottom: 20rpx;
}
.briefing {
font-size: 28rpx;
color: rgba(102,102,102,1);
line-height: 42rpx;
}
}
}
}
}
</script>
<style lang="scss" scoped>
</style>

View File

@ -36,24 +36,29 @@ export default {
goodsList: [],
scrollHeight: '',
loadStatus: 'loadmore',
timer: true, //
timer: true, // ,
value:""
}
},
watch: {
current(value) {
this.page = 1;
this.goodsListByClassId({ laod: 'reload' });
this.ShopSearch({ laod: 'reload' });
},
priceOrderAsc(value) {
this.page = 1;
this.goodsListByClassId({ laod: 'reload' });
this.ShopSearch({ laod: 'reload' });
}
},
onLoad(option) {
this.cid = option.cid;
this.goodsListByClassId({ load: 'reload' });
this.value = option.value
this.setViewHeight();
this.setTitle(option.cname);
this.ShopSearch()
},
onNavigationBarSearchInputConfirmed(value) {
this.value = value.text
this.ShopSearch()
},
methods: {
setOrderSort() {
@ -69,10 +74,10 @@ export default {
return sort;
},
// goods_salenum evaluation_count goods_price_asc goods_price_desc
async goodsListByClassId({ load = 'reload' } = {}) {
async ShopSearch({ load = 'reload' } = {}) {
const sort = this.setOrderSort();
const res = await this.$u.api.goodsListByClassId({
gc_id: this.cid,
const res = await this.$u.api.ShopSearch({
keyword: this.value,
page: this.page,
order: sort,
})
@ -88,7 +93,7 @@ export default {
if(!this.timer) return false;
this.loadStatus = "loading";
this.page++;
this.goodsListByClassId({ load: 'loadmore' }).then(length => {
this.ShopSearch({ load: 'loadmore' }).then(length => {
if(length == 0) {
this.page--;
this.loadStatus = 'nomore';
@ -101,22 +106,17 @@ export default {
})
},
switchCurrent(current) {
this.ShopSearch()
if(current == 1 && this.current == 1) this.priceOrderAsc = !this.priceOrderAsc;
this.current = current;
},
setViewHeight() {
const res = uni.getSystemInfoSync();
this.scrollHeight = res.windowHeight - (90 / 2) + 'px';
},
setTitle(title) {
uni.setNavigationBarTitle({
title: title
});
this.scrollHeight = res.windowHeight - res.windowWidth / 750 * 90 + 'px';
},
toDetailsPage(id) {
this.$u.route('/pageB/sdetails/index', {
id: id,
type: 1 // 1 2 3 4
id: id
});
}
}

View File

@ -442,7 +442,7 @@
},
goSearch() {
this.$u.route("/pageB/search/index", {
type: 1,
type: 2,
});
}
},

View File

@ -114,7 +114,7 @@
this.$u.route({
url: "pageB/search/index",
params: {
type: 2,
type: 1,
}
})
},