|
@@ -15,25 +15,25 @@
|
|
<view class='bnt flex-center' @tap='searchBut'>搜索</view>
|
|
<view class='bnt flex-center' @tap='searchBut'>搜索</view>
|
|
</view>
|
|
</view>
|
|
</view>
|
|
</view>
|
|
- <!-- #ifdef MP -->
|
|
|
|
- <view class='title'>热门搜索</view>
|
|
|
|
- <!-- #endif -->
|
|
|
|
- <!-- #ifndef MP -->
|
|
|
|
- <view class='title'>热门搜索</view>
|
|
|
|
- <!-- #endif -->
|
|
|
|
- <view class='list acea-row'>
|
|
|
|
- <block v-for="(item,index) in hotSearchList" :key="index">
|
|
|
|
- <view class='item' @tap='setHotSearchValue(item.title)'>{{item.title}}</view>
|
|
|
|
- </block>
|
|
|
|
- </view>
|
|
|
|
- <view class='line'></view>
|
|
|
|
|
|
+ <scroll-view :scroll-x="true" scroll-with-animation style="white-space: nowrap;margin: 20rpx 0rpx;padding: 0 20rpx;">
|
|
|
|
+ <view :class="optionIndex == item.id ? 'active-option' : ''" style="color: #141414;display: inline-block;margin-right: 30rpx;width: 96rpx;"
|
|
|
|
+ v-for="(item, index) in optionData" :key="index" @tap="onOptionClick(item)">
|
|
|
|
+ <view class="flex-col flex-center">
|
|
|
|
+ <image style="width: 100%;height: 96rpx;" :src="item.icon"></image>
|
|
|
|
+ <view style="font-size: 21rpx;margin-top: 10rpx;">{{item.name}}</view>
|
|
|
|
+ </view>
|
|
|
|
+ </view>
|
|
|
|
+ </scroll-view>
|
|
</view>
|
|
</view>
|
|
<view style="padding: 0 20rpx;flex: 1;overflow: hidden;" class="flex-col">
|
|
<view style="padding: 0 20rpx;flex: 1;overflow: hidden;" class="flex-col">
|
|
<!-- 销量排行 -->
|
|
<!-- 销量排行 -->
|
|
<view class="tab-list" style="margin-top: 10rpx;">
|
|
<view class="tab-list" style="margin-top: 10rpx;">
|
|
<view :class=" item.checked ? 'tab-item2' : 'tab-item2-false' " v-for="item in labelList" :key="item.id" @click="item2Click(item)">{{item.label}}</view>
|
|
<view :class=" item.checked ? 'tab-item2' : 'tab-item2-false' " v-for="item in labelList" :key="item.id" @click="item2Click(item)">{{item.label}}</view>
|
|
</view>
|
|
</view>
|
|
-
|
|
|
|
|
|
+ <view class="flex-center flex-col" v-if="noDataTip">
|
|
|
|
+ <image :src="urlDomain+'crmebimage/presets/noSearch.png'"></image>
|
|
|
|
+ <text class="no-data-tip">{{noDataTip}}</text>
|
|
|
|
+ </view>
|
|
<scroll-view scroll-y scroll-with-animation style="flex: 1;overflow: hidden;">
|
|
<scroll-view scroll-y scroll-with-animation style="flex: 1;overflow: hidden;">
|
|
<view class="content-goods2" v-for="item in merchantList" :key="item.id" @click="merchantTab(item)">
|
|
<view class="content-goods2" v-for="item in merchantList" :key="item.id" @click="merchantTab(item)">
|
|
<view>
|
|
<view>
|
|
@@ -70,6 +70,7 @@
|
|
|
|
|
|
</view>
|
|
</view>
|
|
</view>
|
|
</view>
|
|
|
|
+ <view class="flex-center no-data-tip" v-if="loadTitle">{{loadTitle}}</view>
|
|
</scroll-view>
|
|
</scroll-view>
|
|
</view>
|
|
</view>
|
|
</view>
|
|
</view>
|
|
@@ -92,9 +93,12 @@
|
|
import navBar from '@/components/navBar';
|
|
import navBar from '@/components/navBar';
|
|
// #endif
|
|
// #endif
|
|
import {
|
|
import {
|
|
- getMerchantList,
|
|
|
|
|
|
+ getMerchantSearchList,
|
|
getHomeInfo
|
|
getHomeInfo
|
|
} from '@/api/home.js';
|
|
} from '@/api/home.js';
|
|
|
|
+ import {
|
|
|
|
+ getProduct
|
|
|
|
+ } from '@/api/takeout.js';
|
|
let app = getApp();
|
|
let app = getApp();
|
|
export default {
|
|
export default {
|
|
components: {
|
|
components: {
|
|
@@ -104,6 +108,8 @@
|
|
},
|
|
},
|
|
data() {
|
|
data() {
|
|
return {
|
|
return {
|
|
|
|
+ optionData: [],
|
|
|
|
+ optionIndex: 0,
|
|
winHeight: 0,
|
|
winHeight: 0,
|
|
navTitle: '搜索外卖商家',
|
|
navTitle: '搜索外卖商家',
|
|
hostProduct: [],
|
|
hostProduct: [],
|
|
@@ -112,6 +118,7 @@
|
|
bastList: [],
|
|
bastList: [],
|
|
hotSearchList: [],
|
|
hotSearchList: [],
|
|
theme: app.globalData.theme,
|
|
theme: app.globalData.theme,
|
|
|
|
+ page: 1,
|
|
labelList: [{
|
|
labelList: [{
|
|
id: 1,
|
|
id: 1,
|
|
label: "销量排行",
|
|
label: "销量排行",
|
|
@@ -129,7 +136,10 @@
|
|
label: "减配送费",
|
|
label: "减配送费",
|
|
checked: false
|
|
checked: false
|
|
}],
|
|
}],
|
|
|
|
+ urlDomain: this.$Cache.get("imgHost"),
|
|
merchantList: [],
|
|
merchantList: [],
|
|
|
|
+ noDataTip: '',
|
|
|
|
+ loadTitle: '',
|
|
cateId: 0
|
|
cateId: 0
|
|
};
|
|
};
|
|
},
|
|
},
|
|
@@ -151,19 +161,43 @@
|
|
if (e.searchVal) that.searchValue = e.searchVal;
|
|
if (e.searchVal) that.searchValue = e.searchVal;
|
|
e.navTitle ? that.navTitle = e.navTitle : ''
|
|
e.navTitle ? that.navTitle = e.navTitle : ''
|
|
e.id ? that.cateId = e.id : ''
|
|
e.id ? that.cateId = e.id : ''
|
|
- that.getMatchedData()
|
|
|
|
|
|
+ getProduct(that.cateId).then(res => {
|
|
|
|
+ const data = res.data;
|
|
|
|
+ // data[0].id = 0;
|
|
|
|
+ if (data.length !== 0) {
|
|
|
|
+ that.optionIndex = data[0].id;
|
|
|
|
+ data[0].name = '全部';
|
|
|
|
+ data[0].icon = '/static/img/quanbu.png';
|
|
|
|
+ that.optionData = data
|
|
|
|
+ }
|
|
|
|
+ that.getMatchedData()
|
|
|
|
+ })
|
|
},
|
|
},
|
|
methods: {
|
|
methods: {
|
|
getMatchedData() {
|
|
getMatchedData() {
|
|
- getMerchantList({
|
|
|
|
|
|
+ getMerchantSearchList({
|
|
latitude: uni.getStorageSync('user_latitude'),
|
|
latitude: uni.getStorageSync('user_latitude'),
|
|
longitude: uni.getStorageSync('user_longitude'),
|
|
longitude: uni.getStorageSync('user_longitude'),
|
|
- cateId: this.cateId
|
|
|
|
|
|
+ categoryIds: this.optionIndex || this.cateId,
|
|
|
|
+ keywords: this.searchValue,
|
|
|
|
+ page: this.page,
|
|
|
|
+ limit: 10
|
|
}).then(res => {
|
|
}).then(res => {
|
|
- this.merchantList = res.data.list;
|
|
|
|
|
|
+ let list = res.data.list || [];
|
|
|
|
+ this.loadTitle = list.length !== 0 && list.length < 10 ? "我也是有底线的~" : '';
|
|
|
|
+ this.merchantList = this.$util.SplitArray(list, this.merchantList);
|
|
|
|
+ this.noDataTip = this.merchantList.length ? '' : ' 暂无外卖商家 ';
|
|
console.log('商品信息:', this.merchantList);
|
|
console.log('商品信息:', this.merchantList);
|
|
|
|
+ this.page += 1;
|
|
});
|
|
});
|
|
},
|
|
},
|
|
|
|
+ onOptionClick(item) {
|
|
|
|
+ if (this.optionIndex === item.id) return
|
|
|
|
+ this.page = 1;
|
|
|
|
+ this.merchantList = [];
|
|
|
|
+ this.optionIndex = item.id;
|
|
|
|
+ this.getMatchedData()
|
|
|
|
+ },
|
|
getRoutineHotSearch: function() {
|
|
getRoutineHotSearch: function() {
|
|
let that = this;
|
|
let that = this;
|
|
getSearchKeyword().then(res => {
|
|
getSearchKeyword().then(res => {
|
|
@@ -173,6 +207,7 @@
|
|
setHotSearchValue: function(event) {
|
|
setHotSearchValue: function(event) {
|
|
this.$set(this, 'searchValue', event);
|
|
this.$set(this, 'searchValue', event);
|
|
this.page = 1;
|
|
this.page = 1;
|
|
|
|
+ this.merchantList = [];
|
|
this.$set(this, 'bastList', []);
|
|
this.$set(this, 'bastList', []);
|
|
this.getMatchedData()
|
|
this.getMatchedData()
|
|
// uni.navigateTo({
|
|
// uni.navigateTo({
|
|
@@ -190,13 +225,12 @@
|
|
val = e.detail.value
|
|
val = e.detail.value
|
|
}
|
|
}
|
|
if (that.searchValue.length > 0 || val) {
|
|
if (that.searchValue.length > 0 || val) {
|
|
|
|
+ this.page = 1;
|
|
|
|
+ this.merchantList = [];
|
|
this.getMatchedData()
|
|
this.getMatchedData()
|
|
- // uni.navigateTo({
|
|
|
|
- // url: `/pages/goods/goods_list/index?searchValue=${val?val:that.searchValue}`
|
|
|
|
- // })
|
|
|
|
} else {
|
|
} else {
|
|
return this.$util.Tips({
|
|
return this.$util.Tips({
|
|
- title: '请输入要搜索的商品',
|
|
|
|
|
|
+ title: '请输入要搜索的外卖商家',
|
|
icon: 'none',
|
|
icon: 'none',
|
|
duration: 1000,
|
|
duration: 1000,
|
|
mask: true,
|
|
mask: true,
|
|
@@ -223,6 +257,10 @@
|
|
position: relative;
|
|
position: relative;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ .no-data-tip {
|
|
|
|
+ color: #CCC;
|
|
|
|
+ }
|
|
|
|
+
|
|
page {
|
|
page {
|
|
background-color: #f5f5f5 !important;
|
|
background-color: #f5f5f5 !important;
|
|
}
|
|
}
|
|
@@ -445,4 +483,8 @@
|
|
padding: 4rpx 16rpx;
|
|
padding: 4rpx 16rpx;
|
|
margin-right: 20rpx;
|
|
margin-right: 20rpx;
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ .active-option {
|
|
|
|
+ color: $bg-color-primary !important;
|
|
|
|
+ }
|
|
</style>
|
|
</style>
|