搜索完成 #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() { searchwordlist({type}) {
return vm.$u.post('ShopSearch/searchwordlist') return vm.$u.post('ShopSearch/searchWordList',{type})
}, },
// 提交试穿订单 // 提交试穿订单
saveGoodsTry({ member_name, member_mobile, area_info, address_detail, goods_id, num, store_id, appointment_time }) { 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, fav_id: fid,
type: type 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> <text>输入达人名称</text>
</view> </view>
<view class="list"> <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>
</view> </view>
</template> </template>

View File

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

View File

@ -1,59 +1,276 @@
<template> <template>
<view class="out"> <view class="classify-goods">
<u-tabs :list="list" :current="current" @change="tabsChange" active-color="#FF780F" :show-bar="false" height="88" font-size="32" inactive-color="#333333"></u-tabs> <view class="tab-container">
<swiper :current="swiperCurrent" @animationfinish="animationfinish"> <view class="salenum" :class="{ 'current' : current == 0 }" @click="switchCurrent(0)">店铺</view>
<!-- 店铺 --> <view class="price" :class="{ 'current' : current == 1 }" @click="switchCurrent(1)">
<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>
<view class="store"></view> <view class="evaluation" :class="{ 'current' : current == 2 }" @click="switchCurrent(2)">社区</view>
</scroll-view> </view>
</swiper-item> <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)">
<swiper-item class="swiper-item" v-for="(item, index) in dataList[current]" :key="index"> <image :src="goods.store_avatar"></image>
<scroll-view scroll-y style="height: 800rpx;width: 100%;" @scrolltolower="onreachBottom"> <view class="right">
<view class="anchor"></view> <view class="name u-line-1">{{ goods.store_name }}</view>
</scroll-view> <view class="briefing u-line-2">{{ goods.store_description }}</view>
</swiper-item> </view>
<!-- 社区 --> </view>
<swiper-item class="swiper-item" v-for="(item, index) in dataList[current]" :key="index"> <u-loadmore :status="loadStatus" bgColor="#FFFFFF" margin-top="20" margin-bottom="20" v-if="goodsList.length >= pageSize"></u-loadmore>
<scroll-view scroll-y style="height: 800rpx;width: 100%;" @scrolltolower="onreachBottom"> <u-empty mode="list" v-if="!goodsList.length"></u-empty>
<view class="community"></view> </scroll-view>
</scroll-view> <scroll-view style="width:100%;" :style="{ height: scrollHeight }" scroll-y="true" @scrolltolower="loadMore" v-if=" current == 2 ">
</swiper-item> <view class="box" style="padding: 0 30rpx;">
</swiper> <view style="display:flex">
</view> <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> </template>
<script> <script>
import videoItem from "@/components/index/video-item/index"
import darenItem from "@/components/index/daren-item/index"
export default { export default {
data() { data() {
return { return {
list: [{ pageSize: 12,
name: "店铺" cid: '',
}, { page: 1,
name: "达人"
}, {
name: "社区"
}],
current: 0, current: 0,
swiperCurrent: 0, priceOrderAsc: true, //
dataList: [[1],[2],[3]], 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) { onLoad(option) {
this.value = option.value
this.setViewHeight();
this.ShopSearch()
},
onNavigationBarSearchInputConfirmed(value) {
this.value = value.text
console.log(this.value)
this.ShopSearch()
}, },
methods: { methods: {
tabsChange(index) { changeType(member_id){
this.current = Number(index); console.log(member_id);
this.swiperCurrent = this.current; 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) { setOrderSort() {
const current = Number(e.detail.current); 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.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> </style>

View File

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

View File

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

View File

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