fix 搜索search

develop
GJW200011 4 years ago
parent 8aff1d8fb6
commit 7b6459a082

@ -1,6 +1,6 @@
// pages/index/search/search.js
import {
httpUtil,http,
httpUtil, http,
location_city
} from "../../../utils/util"
Page({
@ -11,16 +11,16 @@ Page({
data: {},
search_(keyword, city_id) {
const search_his = wx.getStorageSync('search_his') || []
if ((keyword && "undefined" !== keyword)||this.data.placeholder) {
if (!keyword ){
keyword =this.data.placeholder
if ((keyword && "undefined" !== keyword) || this.data.placeholder) {
if (!keyword) {
keyword = this.data.placeholder
}
for(var i=0; i<search_his.length; i++) {
if(keyword == search_his[i]) { // 相同的全部删除
for (var i = 0; i < search_his.length; i++) {
if (keyword == search_his[i]) { // 相同的全部删除
search_his.splice(i, 1); // 删除该元素
i--;
i--;
}
}
}
search_his.unshift(keyword)
this.setData({
keyword,
@ -32,7 +32,7 @@ Page({
}).then(res => {
this.setData({
ip_info: res.ip_info,
cancel_noContWarn:true,
cancel_noContWarn: true,
search_list: res.search_list,
suggest_list: res.suggest_list
})
@ -101,10 +101,10 @@ Page({
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
// 获取search关键词
httpUtil("/api/v1/hot-search","get").then(res=>{
this.setData({placeholder:res.keyword})
})
// 获取search关键词
httpUtil("/api/v1/hot-search", "get").then(res => {
this.setData({ placeholder: res.keyword })
})
let city_id
if ('undefined' == options.city_id) {
location_city().then(res => {

Loading…
Cancel
Save