You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.
< template >
<!-- 20221118 -- >
< view class = "mall-search-page" >
<!-- 页面内容 -- >
< view class = "page-content" >
<!-- 搜索页 -- >
< ty -layer -search :hot-list ="searchHotList" :history-list.sync ="searchHistoryList" @search ="search"
@remove ="remove" :placeholder ="'请输入您想咨询专家的专业方向、建筑类型'" >
<!-- 当页没有标题 。 APP页面传入导航条以兼容样式 -- >
<!-- # ifdef APP - PLUS -- >
<!-- 占位 view , 避免页面内容出现在状态栏 -- >
< view class = "height-status-bar" > < / view >
<!-- # endif -- >
< / t y - l a y e r - s e a r c h >
< / view >
<!-- 页面浮层 -- >
< view class = "page-layer" >
< / view >
< / view >
< / template >
< script >
import mall from "./api/mall.js"
export default {
data ( ) {
return {
// 热门搜索
searchHotList : [ ] ,
// 历史搜索
searchHistoryList : [ ] ,
}
} ,
onShow ( ) {
// 获取历史搜索
if ( this . cn . isLogin ( ) ) {
this . listHistorySearch ( )
}
} ,
onReady ( ) {
// 获取热门搜索
this . listHotSearch ( )
} ,
methods : {
/**
* 获取热门搜索
* @date 2022-11-18
*/
listHotSearch ( ) {
mall . listHotSearch ( ) . then ( res => {
if ( res . code == 0 ) {
this . searchHotList = res . data . search _hot _list
}
} )
} ,
/**
* 获取历史搜索
* @date 2022-11-18
*/
listHistorySearch ( ) {
mall . listHistorySearch ( ) . then ( res => {
if ( res . code == 0 ) {
this . searchHistoryList = res . data . search _history _list
}
} )
} ,
/**
* 清空历史搜索
* @date 2022-11-18
*/
remove ( ) {
if ( ! this . searchHistoryList . length ) {
this . cn . toast ( '暂无历史搜索记录' )
return false
}
this . cn . confirm ( '是否确定清空历史搜索' ) . then ( res => {
if ( res . confirm ) {
mall . deleteAllHistorySearch ( ) . then ( res => {
if ( res . code == 0 ) {
this . cn . toast ( '清空成功' )
// 清空历史搜索
this . searchHistoryList = [ ]
}
} )
}
} )
} ,
/**
* 搜索
* @date 2022-11-18
*/
search ( e ) {
if ( this . cn . isLogin ( ) ) {
mall . insertHistorySearch ( e . keyword ) . then ( res => {
// uni.navigateTo({
// url: '/pages/mall/list?keyword=' + e.keyword
// })
uni . setStorageSync ( 'expertKeyword' , e . keyword )
uni . switchTab ( {
url : '/pages/expert/index'
} )
} )
} else {
uni . setStorageSync ( 'expertKeyword' , e . keyword )
uni . switchTab ( {
url : '/pages/expert/index'
} )
}
}
}
}
< / script >
< style scoped >
< / style >