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.
147 lines
2.7 KiB
147 lines
2.7 KiB
// pages/search/search.js
|
|
var app = getApp();
|
|
var util = require('../../utils/util.js')
|
|
var WXAPI = require('../../utils/server.js');
|
|
Page({
|
|
|
|
/**
|
|
* 页面的初始数据
|
|
*/
|
|
data: {
|
|
keyword: '',
|
|
shopList: [],
|
|
},
|
|
searchInput: function(e) {
|
|
this.setData({
|
|
keyword: e.detail.value
|
|
})
|
|
},
|
|
cleardata() {
|
|
console.log('1111')
|
|
this.setData({
|
|
keyword: ''
|
|
})
|
|
},
|
|
search() {
|
|
var that = this;
|
|
WXAPI.searchList({
|
|
accessId: app.globalData.accessId,
|
|
storeId: 239,
|
|
storeType: 1,
|
|
keyword: that.data.keyword,
|
|
num: 1,
|
|
type: 0
|
|
}).then(res => {
|
|
if (res.code == 200) {
|
|
var data = res.data
|
|
var goods = data.list;
|
|
var type = data.type;
|
|
if (type == 0) {
|
|
that.data.objectId = res.data.cid;
|
|
var page = that.data.page;
|
|
var shoplist = [];
|
|
for (var i = 0; i <= page * 2 - 1; i++) {
|
|
if (i == goods.length) {
|
|
break;
|
|
}
|
|
shoplist[i] = goods[i];
|
|
}
|
|
if (types) {
|
|
that.setData({
|
|
type: type,
|
|
goodslist: goods,
|
|
shopList: that.data.shopList.concat(shoplist)
|
|
});
|
|
} else {
|
|
that.setData({
|
|
type: type,
|
|
shopList: goods
|
|
});
|
|
}
|
|
} else {
|
|
that.setData({
|
|
type: type,
|
|
shopList: goods
|
|
});
|
|
}
|
|
} else {
|
|
that.setData({
|
|
period: true
|
|
});
|
|
}
|
|
});
|
|
// var result_list = []
|
|
// var city_list = that.data.city_list
|
|
// for (var i = 0; i < city_list.length; i++) {
|
|
// city_list[i].filter(item=>{
|
|
// if(item.G_CName.includes(that.data.searchKey)) {
|
|
// result_list.push(item)
|
|
// }
|
|
// })
|
|
// }
|
|
// that.setData({
|
|
// filterKey: that.data.searchKey,
|
|
// city_list: result_list
|
|
// })
|
|
},
|
|
navToSearch() {
|
|
// wx.navigateTo({
|
|
// url: '/pages/search/search'
|
|
// })
|
|
},
|
|
/**
|
|
* 生命周期函数--监听页面加载
|
|
*/
|
|
onLoad(options) {
|
|
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面初次渲染完成
|
|
*/
|
|
onReady() {
|
|
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面显示
|
|
*/
|
|
onShow() {
|
|
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面隐藏
|
|
*/
|
|
onHide() {
|
|
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面卸载
|
|
*/
|
|
onUnload() {
|
|
|
|
},
|
|
|
|
/**
|
|
* 页面相关事件处理函数--监听用户下拉动作
|
|
*/
|
|
onPullDownRefresh() {
|
|
|
|
},
|
|
|
|
/**
|
|
* 页面上拉触底事件的处理函数
|
|
*/
|
|
onReachBottom() {
|
|
|
|
},
|
|
|
|
/**
|
|
* 用户点击右上角分享
|
|
*/
|
|
onShareAppMessage() {
|
|
|
|
}
|
|
})
|