85 lines
1.8 KiB
JavaScript
85 lines
1.8 KiB
JavaScript
const app = getApp()
|
|
Page({
|
|
data: {
|
|
height: 0,
|
|
SearchKeyword: "",
|
|
showView: true,
|
|
searchList: [],
|
|
inputValue: '',
|
|
tagList: [
|
|
{ text: "小米" },
|
|
{ text: "华为" },
|
|
{ text: "16t" },
|
|
{ text: "11Pro" },
|
|
{ text: "锤子" },
|
|
{ text: "三星" }
|
|
]
|
|
},
|
|
|
|
onLoad: function () {
|
|
this.getSearch();
|
|
this.setData({
|
|
height: app.globalData.statusBarHeight
|
|
})
|
|
},
|
|
//显示,隐藏
|
|
onChangeShowState: function () {
|
|
this.setData({
|
|
showView: (!this.data.showView)
|
|
})
|
|
},
|
|
//获取input里的值
|
|
getitems: function (e) {
|
|
this.setData({
|
|
inputValue: e.detail.value
|
|
})
|
|
// this.getSearch(this.data.inputValue);
|
|
console.log(e.detail.value)
|
|
},
|
|
// getSear: function (data) {
|
|
// this.getitems()
|
|
// },
|
|
//上下联动
|
|
getitem: function(data) {
|
|
// var a = data.currentTarget.dataset.hi
|
|
// console.log(a)
|
|
this.setData({
|
|
SearchKeyword: "",
|
|
SearchKeyword: data.currentTarget.dataset.hi
|
|
})
|
|
this.getSearch(this.data.SearchKeyword);
|
|
console.log(this.data.SearchKeyword)
|
|
|
|
},
|
|
|
|
async getSearch(datas) {
|
|
console.log(datas)
|
|
var data = await global.$api.post({
|
|
url: "/home/search",
|
|
data: {
|
|
keyword: datas
|
|
}
|
|
});
|
|
console.log(data)
|
|
this.searchList = data;
|
|
data.result.forEach((val) => {
|
|
val.wares_info = val.wares_info.substring(0, 10) + '..';
|
|
val.wares_masterimg = JSON.parse(val.wares_masterimg)[0]
|
|
})
|
|
this.setData({
|
|
searchList: data.result
|
|
})
|
|
},
|
|
cliekss(){
|
|
this.getSearch(this.data.inputValue)
|
|
},
|
|
|
|
enterInfo(item) {
|
|
console.log("item: ", item.currentTarget.dataset.list.wares_id)
|
|
wx.navigateTo({
|
|
url: `/pages/info/info?id=${item.currentTarget.dataset.list.wares_id}`
|
|
})
|
|
}
|
|
});
|
|
|