Browse Source

地图 目的地搜索

master
石可 4 years ago
parent
commit
b4ec6d4773
  1. 2
      common/api.js
  2. 18
      common/styles/iconfont.css
  3. 35
      components/lf-nav/lf-nav.vue
  4. 6
      pages.json
  5. 2
      pages/goodsDetail/index.vue
  6. 2
      pages/index/index.vue
  7. 12
      pages/recommList/index.vue
  8. 123
      pages/search/search.vue
  9. 77
      pages/search/searchList.vue
  10. 294
      pages/shopmap/index.vue

2
common/api.js

@ -12,6 +12,8 @@ export const API_WXLOGIN = '/api/login'; //登录
export const API_INDEX = '/api/index'; //首页
export const API_FAVOURITE = '/api/agent_product/guess'; //猜你喜欢
export const API_SEARCHTARGET = '/api/agent_product/travel_search'; //猜你喜欢
export const API_CHANNEL = '/api/channel/list'; //全部频道列表
export const API_MYCHANNEL = '/api/user_channel/list'; //我的频道列表
export const API_EDITCHANNEL = '/api/user_channel/update'; //编辑频道

18
common/styles/iconfont.css

@ -1,8 +1,8 @@
@font-face {
font-family: "lf-iconfont"; /* Project id 2651793 */
src: url('//at.alicdn.com/t/font_2651793_2rvexfo9ayn.woff2?t=1631096351657') format('woff2'),
url('//at.alicdn.com/t/font_2651793_2rvexfo9ayn.woff?t=1631096351657') format('woff'),
url('//at.alicdn.com/t/font_2651793_2rvexfo9ayn.ttf?t=1631096351657') format('truetype');
src: url('//at.alicdn.com/t/font_2651793_o7fen3k0lq.woff2?t=1634315157253') format('woff2'),
url('//at.alicdn.com/t/font_2651793_o7fen3k0lq.woff?t=1634315157253') format('woff'),
url('//at.alicdn.com/t/font_2651793_o7fen3k0lq.ttf?t=1634315157253') format('truetype');
}
.lf-iconfont {
@ -13,6 +13,18 @@
-moz-osx-font-smoothing: grayscale;
}
.lf-icon-dingwei:before {
content: "\ec32";
}
.lf-icon-dianhuaben:before {
content: "\e62a";
}
.lf-icon-cuo1:before {
content: "\e60b";
}
.lf-icon-dizhi:before {
content: "\e814";
}

35
components/lf-nav/lf-nav.vue

@ -9,8 +9,10 @@
</block>
<block v-else>
<view class="head-nav" :style="{'top': headHeight - 40 + 'px'}" v-if="showIcon">
<text class="lf-iconfont icon-daifukuan font-40size" @click="clickDropOut"></text>
<text class="lf-iconfont icon-sousuo font-40size" @click="clickHome"></text>
<view class="lf-row-between" @click="goMap()">
<text class="lf-iconfont lf-icon-dizhi font-40size lf-color-white lf-m-r-10"></text>
<view class="lf-font-28 lf-color-white">地图</view>
</view>
</view>
<view class="title-box" :style="{'margin': headHeight - 36 + 'px auto 0'}" @click="goSearch()">
<view v-if="search" class="search-father">
@ -89,6 +91,11 @@
url: '/pages/search/search'
})
},
goMap() {
uni.navigateTo({
url: '/pages/shopmap/index'
})
},
//
getSystemInfo(){
let result = uni.getSystemInfoSync();
@ -161,27 +168,27 @@
}
.head .head-nav{
position: absolute;
left: 2vw;
left: 3vw;
cursor: pointer;
width: 130rpx;
background-color: #FFFFFF;
border: 1rpx solid #dcd3d5;
width: 156rpx;
background-color: #1998FE;
// border: 1rpx solid #dcd3d5;
border-radius: 30rpx;
height: 60rpx;
box-sizing: border-box;
display: flex;
justify-content: space-between;
justify-content: center;
align-items: center;
padding: 0 12rpx;
}
.head .head-nav::after{
position: absolute;
content: '';
width: 2rpx;
height: 40rpx;
background-color: #f7f7f7;
left: 50%;
top: calc(50% - 20rpx);
// position: absolute;
// content: '';
// width: 2rpx;
// height: 40rpx;
// background-color: #f7f7f7;
// left: 50%;
// top: calc(50% - 20rpx);
}
.title-box{
max-width: 49%;

6
pages.json

@ -26,6 +26,12 @@
"navigationBarTitleText": "搜索"
}
},
{
"path": "pages/shopmap/index",
"style": {
"navigationBarTitleText": "多门店"
}
},
{
"path": "pages/search/searchList",
"style": {

2
pages/goodsDetail/index.vue

@ -40,7 +40,7 @@
<text class="lf-iconfont lf-icon-xiangyou lf-text-vertical"></text>
</view>
</view>
<view v-if="goods_detail.product.type == 0">
<view v-if="goods_detail.product.type == 0 && goods_detail.product.extends.field_0_departure_place && goods_detail.product.extends.field_0_destination">
<view class="lf-row-between list-item lf-m-t-20">
<view class="lf-row-center">
<text class="lf-font-28 lf-color-gray">出发地</text>

2
pages/index/index.vue

@ -1,6 +1,6 @@
<template>
<view>
<lf-nav :search="true" :bgColor="nav_bg_color" :inputColor="nav_input_color" :textColor="nav_text_color" :spreadOut="false"></lf-nav>
<lf-nav :showIcon="true" :search="true" :bgColor="nav_bg_color" :inputColor="nav_input_color" :textColor="nav_text_color" :spreadOut="false"></lf-nav>
<swiper class="head" :current="banner_current" autoplay interval="3000">
<swiper-item @click="clickBanner(item.type,item.url)" v-for="(item,index) of banner" :key="index">
<image :src="item.picture" class="swipe-img" mode="aspectFill"></image>

12
pages/recommList/index.vue

@ -59,10 +59,18 @@
loadingClass: true,
loadingText: '正在加载中',
page: 1,
isPage: true
isPage: true,
pid: item.pid
}
});
this.tab_list = tab_list;
let list = []
tab_list.forEach((item,index) => {
if(item.pid == 0) {
list.push(item)
}
})
this.tab_list = list;
console.log(this.tab_list)
this.getData()
}).catch(err => {

123
pages/search/search.vue

@ -1,23 +1,47 @@
<template>
<view>
<view class="lf-p-t-30 lf-p-r-30 lf-flex lf-w-100 lf-bg-white">
<u-icon name="search" class="search-icon"></u-icon>
<input class="rom-search" type="text" v-model="searchContent" @confirm="setSearch()" placeholder="请输入商品名称"/>
<view class="head" v-if="tab_list.length">
<u-tabs :list="tab_list" :is-scroll="false" :current="current" @change="tabChange"></u-tabs>
</view>
<view class="history-card" v-if="historySearch != ''">
<view class="lf-font-28 lf-color-gray lf-p-b-30 lf-p-l-30">
历史搜索
<view v-if="current != 2">
<view class="lf-row-between lf-bg-white" style="align-items: center;">
<view class="lf-p-t-30 lf-p-r-30 lf-flex lf-bg-white">
<u-icon name="search" class="search-icon"></u-icon>
<input class="rom-search" type="text" v-model="searchContent" @confirm="setSearch()" placeholder="请输入商品名称"/>
</view>
<view class="lf-bg-white lf-font-28 lf-color-222 lf-p-t-30 lf-p-r-30">取消</view>
</view>
<view class="lf-flex lf-flex-wrap lf-p-l-20 lf-p-r-20">
<view class="search-tag" v-for="(i,index) of historySearch" :key="index" @click="gosearch(i)">{{i}}</view>
<view class="history-card" v-if="historySearch != ''">
<view class="lf-font-28 lf-color-gray lf-p-b-30 lf-p-l-30">
历史搜索
</view>
<view class="lf-flex lf-flex-wrap lf-p-l-20 lf-p-r-20">
<view class="search-tag" v-for="(i,index) of historySearch" :key="index" @click="gosearch(i)">{{i}}</view>
</view>
</view>
</view>
<view class="history-card" v-else>
<view class="lf-font-28 lf-color-gray lf-p-b-30 lf-p-l-30">
历史搜索
<view class="history-card" v-else>
<view class="lf-font-28 lf-color-gray lf-p-b-30 lf-p-l-30">
历史搜索
</view>
<view class="lf-flex lf-flex-wrap lf-p-l-30 lf-p-r-20">
暂无历史搜索记录
</view>
</view>
<view class="lf-flex lf-flex-wrap lf-p-l-30 lf-p-r-20">
暂无历史搜索记录
</view>
<view class="lf-row-center" v-if="current == 2" >
<view class="taget-form lf-m-t-40 lf-p-30">
<view class="lf-flex-column">
<view class="lf-color-gray lf-font-28 lf-m-b-34">出发地和目的地</view>
<view class="lf-flex lf-m-b-40">
<text style="color: #1998FE;" class="lf-font-22 lf-m-r-32"></text>
<input v-model="start_place" type="text" class="lf-font-28 lf-color-222" placeholder="请输入出发地" />
</view>
<view class="lf-flex lf-m-b-40">
<text style="color: #1998FE;" class="lf-font-22 lf-m-r-32"></text>
<input v-model="target_place" type="text" class="lf-font-28 lf-color-222" placeholder="请输入目的地" />
</view>
<button class="choose_btn" @click="searchTarget()">立即购买</button>
</view>
</view>
</view>
</view>
@ -29,10 +53,60 @@
data() {
return {
historySearch: [],
searchContent: ''
searchContent: '',
value1: 1,
options1: [{
label: '商品',
value: 1,
},
{
label: '地图',
value: 2,
},
{
label: '出发地和目的地',
value: 3,
}
],
tab_list: [
{id: 1,name: '商品'},
{id: 2,name: '地图'},
{id: 3,name: '地址'}
],
current: 0,
windowHeight: 0,
start_place: '',
target_place: ''
}
},
onLoad() {
this.windowHeight = getApp().globalData.windowHeight;
},
methods: {
searchTarget() {
if(!this.start_place) {
this.$msg('请输入出发地!')
return
}
if(!this.target_place) {
this.$msg('请输入目的地!')
return
}
uni.navigateTo({
url: '/pages/search/searchList?start_place=' + this.start_place+'&target_place='+this.target_place
})
},
tabChange(index){
this.current = index;
if(this.current == 1) {
uni.navigateTo({
url: '/pages/shopmap/index'
})
}
},
getCategory(e) {
console.log(e)
},
gosearch(i) {
uni.navigateTo({
url: '/pages/search/searchList?serach_content=' + i
@ -64,6 +138,23 @@
</style>
<style lang="scss" scoped>
.choose_btn {
width: 626rpx;
height: 82rpx;
background: #1998FE;
border-radius: 10rpx;
font-size: 32rpx;
color: white;
display: flex;
justify-content: center;
align-items: center;
}
.taget-form {
width: 686rpx;
height: 410rpx;
border-radius: 10rpx;
border: 1rpx solid #D9D9D9;
}
.history-card {
background-color: white;
width: 100%;
@ -99,7 +190,7 @@
font-size: 28rpx;
}
.rom-search {
width: 686rpx;
width: 605rpx;
height: 60rpx;
background: #f5f5f5;
border-radius: 30rpx;

77
pages/search/searchList.vue

@ -1,13 +1,13 @@
<template>
<view>
<view class="lf-p-t-30 lf-p-b-30">
<view class="lf-m-b-30 lf-flex lf-w-100">
<view class="lf-m-b-30 lf-flex lf-w-100" v-if="!start_place && !target_place">
<u-icon name="search" class="search-icon"></u-icon>
<input class="rom-search" type="text" placeholder="请输入商品名称" @confirm="startSearch()" v-model="search_content" />
</view>
<view class="special_tab">
<u-tabs :list="tab_list" active-color="#1998FE" inactive-color='#777777' :is-scroll="true" @click="clicksort" :current="current" @change="tabChange"></u-tabs>
<view style="position: absolute;right: 30rpx;top: 140rpx;display: flex;flex-direction: column;">
<view :class="!start_place?'shop_search':'target_search'">
<u-icon name="arrow-up" style="font-size: 20rpx;" :class="sort==0?'':'lf-color-blue'"></u-icon>
<u-icon name="arrow-down" style="font-size: 20rpx;" :class="sort==0?'lf-color-blue':''"></u-icon>
</view>
@ -105,19 +105,55 @@
pageSize: 20,
isRefresher: false,
sort: 0,
start_place: '',
target_place: ''
}
},
methods: {
searchTarget() {
let tab_item = this.tab_list[this.current];
this.$http(this.API.API_SEARCHTARGET,{
departure_place: this.start_place,
destination: this.target_place,
type:this.current,
by: this.sort
}).then(res => {
console.log('==========',res.data.data)
let isPage = res.data.prev_page_url == null?false:true;
tab_item.isPage = isPage;
if(!isPage){
tab_item.loadingClass = false;
tab_item.loadingText = '没有更多数据啦~';
}
tab_item.isRefresher = false;
if(tab_item.page == 1){
tab_item.list = res.data.data;
}else{
tab_item.list.push(...res.data.data);
}
console.log('==========',tab_item.list)
}).catch(err => {
})
},
changeSort(sort) {
console.log('排序')
this.sort != this.sort
this.getActivityList()
if(this.start_place && this.target_place) {
this.searchTarget();
}else {
this.getActivityList()
}
},
// scroll-view
onRefresherrefresh(){
this.tab_list[this.current].isRefresher = true;
this.$u.throttle(() => {
this.getActivityList();
if(this.start_place && this.target_place) {
this.searchTarget();
}else {
this.getActivityList()
}
}, 200);
},
//
@ -125,7 +161,11 @@
let tab_item = this.tab_list[this.current];
if(tab_item.isPage){
tab_item.page = tab_item.page + 1;
this.getActivityList();
if(this.start_place && this.target_place) {
this.searchTarget();
}else {
this.getActivityList()
}
}
},
getActivityList(){
@ -152,7 +192,11 @@
}else {
this.sort = 0
}
this.getActivityList()
if(this.start_place && this.target_place) {
this.searchTarget();
}else {
this.getActivityList()
}
}else {
return
}
@ -160,7 +204,11 @@
tabChange(index){
this.current = index;
console.log('重复只想')
this.getActivityList()
if(this.start_place && this.target_place) {
this.searchTarget();
}else {
this.getActivityList()
}
},
//
swiperChange(event){
@ -177,9 +225,14 @@
this.windowHeight = getApp().globalData.windowHeight;
},
onLoad(e) {
this.search_content = e.serach_content
this.search_content = e.serach_content;
this.start_place = e.start_place;
this.target_place = e.target_place;
if(this.search_content) {
this.getActivityList()
this.getActivityList();
}
if(this.start_place && this.target_place) {
this.searchTarget();
}
console.log('传来的搜索',e)
}
@ -187,6 +240,12 @@
</script>
<style lang="scss" scoped>
.shop_search {
position: absolute;right: 30rpx;top: 140rpx;display: flex;flex-direction: column;
}
.target_search {
position: absolute;right: 30rpx;top: 50rpx;display: flex;flex-direction: column;
}
.content{
padding: 0;
box-sizing: border-box;

294
pages/shopmap/index.vue

@ -0,0 +1,294 @@
<template>
<view>
<view class="lf-p-t-20 head" v-if="tab_list_father.length">
<u-tabs :list="tab_list_father" :is-scroll="true" :current="current_father" @change="tabChangeFather()"></u-tabs>
</view>
<view>
<map class="lf-map-height" :longitude="self_longitude" :latitude="self_latitude" :markers="markers_list">
</map>
</view>
<view class="lf-m-t-40 lf-p-l-32 lf-p-r-32">
<view class="lf-row-between lf-m-b-40">
<view class="lf-font-32 lf-color-222">地图上的门店</view>
<view class="lf-font-24 lf-color-blue lf-row-center">
<text class="lf-iconfont lf-icon-dingwei lf-m-r-10 lf-font-22"></text>
我的位置
</view>
</view>
<view class="special_tab" style="position: relative;">
<u-tabs :list="tab_list" active-color="#1998FE" inactive-color='#777777' :is-scroll="true" @click="clicksort" :current="current" @change="tabChange"></u-tabs>
<view style="position: absolute;right: 44rpx;top: 20rpx;display: flex;flex-direction: column;">
<u-icon name="arrow-up" style="font-size: 20rpx;" :class="sort==0?'':'lf-color-blue'"></u-icon>
<u-icon name="arrow-down" style="font-size: 20rpx;" :class="sort==0?'lf-color-blue':''"></u-icon>
</view>
</view>
<swiper :style="{height: '600rpx', width: '750rpx'}" :current="current" @change="swiperChange">
<swiper-item v-for="(tabItem, tabIndex) in tab_list" :key="tabIndex">
<scroll-view class="com" :scroll-y="true" :refresher-enabled="true" :refresher-triggered="tabItem.isRefresher" @scrolltolower="onScrolltolower" @refresherrefresh="onRefresherrefresh">
<view class="lf-m-t-20"></view>
<view>
<!-- 活动列表 -->
<view class="content">
<view class="item" v-for="(item,index) of tabItem.list" :key="index" @click="$url('/pages/goodsDetail/index?goods_id='+item.id)">
<view class="cover">
<image :src="item.picture" class="lf-w-100 lf-h-100" mode="aspectFill"></image>
</view>
<view style="width: 420rpx;">
<view class="lf-font-28 lf-color-333 lf-line-2">{{item.title}}</view>
<view class="lf-font-24 lf-color-gray lf-line-2 lf-m-t-10" style="min-height: 64rpx;">本套票只包含两个成人不可带小孩本套票只包含两个成人不可带小孩本套票只包含两个成人不可带小孩</view>
<view class="lf-flex lf-m-t-25">
<lf-price :price="item.price"></lf-price>
<text class="lf-font-24 lf-color-gray lf-line-through lf-m-l-15">¥{{item.original_price}}</text>
</view>
</view>
</view>
</view>
<!-- 加载 -->
<view class="loading-more">
<text v-if="tabItem.list.length" :class="{'loading-more-text': loadingClass}">{{ loadingText }}</text>
<lf-nocontent v-else></lf-nocontent>
</view>
<!-- 回到顶部 -->
<u-back-top :scroll-top="pageScrollTop" :custom-style="{background: 'rgba(51, 51 51, 0.3)'}"></u-back-top>
</view>
</scroll-view>
</swiper-item>
</swiper>
</view>
</view>
</template>ß
<script>
export default {
data() {
return {
tab_list_father: [],
current_father: 0,
windowHeight: 0,
markers_list: [
{
id: 0,
name: '时尚',
address: '杭州市',
latitude: 30.353351,
longitude: 120.231010,
width: 50,
height: 50
}
],
self_latitude: '',
self_longitude: '',
//
tab_list: [
{
id: 1,
name: '销量',
list: [],
isRefresher: false,
loadingClass: true,
loadingText: '正在加载中',
page: 1,
isPage: true
},
{
id: 2,
name: '距离',
list: [],
isRefresher: false,
loadingClass: true,
loadingText: '正在加载中',
page: 1,
isPage: true
},
{
id: 4,
name: '价格',
list: [],
isRefresher: false,
loadingClass: true,
loadingText: '正在加载中',
page: 1,
isPage: true
},
],
current: 0,
loadingClass: false,
loadingText: '已加载全部数据~',
page: 1,
isPage: true,
pageSize: 20,
isRefresher: false,
sort: 0,
}
},
onLoad() {
this.getCategory();
this.windowHeight = getApp().globalData.windowHeight;
this.getShopDistance();
},
methods: {
//
getShopDistance() {
let that = this;
wx.getLocation({
type: 'wgs84',
isHighAccuracy: true,
success (res) {
that.self_latitude = res.latitude
that.self_longitude = res.longitude
console.log(that.self_longitude)
console.log(that.self_latitude)
console.log(res)
},
fail(err) {
console.log(err)
}
})
},
tabChangeFather(index){
this.current_father = index;
this.clearTabItem()
if(this.tab_list_father[index].list.length <= 0){
this.getActivityList(); // tab
}
},
clearTabItem(){
let tab_item = this.tab_list_father[this.current];
tab_item.page = 1;
tab_item.isPage = true;
tab_item.isRefresher = true;
tab_item.loadingClass = true;
tab_item.loadingText = '正在加载中';
tab_item.list = [];
},
getCategory(options = {}) {
this.$http(this.API.API_CATEGORYLIST).then(res => {
let res_list = res.data || [];
let tab_list_father = res_list.map(item => {
return {
id: item.id,
name: item.name,
list: [],
isRefresher: false,
loadingClass: true,
loadingText: '正在加载中',
page: 1,
isPage: true,
pid: item.pid
}
});
let list = []
tab_list_father.forEach((item,index) => {
if(item.pid == 0) {
list.push(item)
}
})
console.log(list)
this.tab_list_father = list;
console.log(this.tab_list_father)
this.getActivityList()
}).catch(err => {
})
},
clicksort(index) {
if(index == 3) {
if(this.sort == 0) {
this.sort = 1
}else {
this.sort = 0
}
this.getActivityList()
}else {
return
}
},
tabChange(index){
this.current = index;
console.log('重复只想')
this.getActivityList()
},
//
swiperChange(event){
this.current = event.detail.current;
if(event.detail.source == '') return; //
},
changeSort(sort) {
console.log('排序')
this.sort != this.sort
this.getActivityList()
},
// scroll-view
onRefresherrefresh(){
this.tab_list_father[this.current].isRefresher = true;
this.$u.throttle(() => {
this.clearTabItem();
this.getActivityList();
}, 200);
},
//
onScrolltolower(){
let tab_item = this.tab_list_father[this.current];
if(tab_item.isPage){
tab_item.page = tab_item.page + 1;
this.getActivityList();
}
},
getActivityList(){
let tab_item = this.tab_list_father[this.current_father];
console.log('页数',tab_item.id)
if(this.$shared.isValueType(tab_item) == 'undefined') return;
this.$http(this.API.API_ADVICELIST,{page: tab_item.page,category_id: tab_item.id}).then(res => {
let isPage = res.data.next_page_url == null?false:true;
tab_item.isPage = isPage;
if(!isPage){
tab_item.loadingClass = false;
tab_item.loadingText = '没有更多数据啦~';
}
tab_item.isRefresher = false;
if(tab_item.page == 1){
tab_item.list = res.data.data;
}else{
tab_item.list.push(...res.data.data);
}
}).catch(err => {
})
},
}
}
</script>
<style lang="scss" scoped>
.lf-map-height {
width: 100%;
height: 500rpx;
}
/deep/.special_tab .u-scroll-box {
display: flex;
justify-content: center;
align-items: center;
border-bottom: 1rpx solid rgba(0, 0, 0, 0.1);
}
/deep/.special_tab .u-scroll-box .u-tab-bar {
background-color: #1998FE!important;
width: 80rpx!important;
position: absolute;
left: 0;
bottom: -12rpx;
}
/deep/.special_tab .u-tabs .u-scroll-box .u-tab-bar {
background-color: #1998FE!important;
width: 56rpx!important;
position: absolute;
height: 5rpx!important;
left: 8rpx;
bottom: -4rpx;
}
/deep/.special_tab .u-tab-item {
font-size: 28rpx!important;
}
</style>
Loading…
Cancel
Save