|
|
|
@ -2,7 +2,7 @@ const { getHotSearch,getSearch } = require("../../api/index.js")
|
|
|
|
|
|
|
|
|
|
Page({
|
|
|
|
|
/**
|
|
|
|
|
* 页面的初始数据1
|
|
|
|
|
* 页面的初始数据
|
|
|
|
|
*/
|
|
|
|
|
data: {
|
|
|
|
|
search:"",
|
|
|
|
@ -11,19 +11,19 @@ Page({
|
|
|
|
|
goodsData:[]
|
|
|
|
|
},
|
|
|
|
|
/**
|
|
|
|
|
* 生命周期函数--监听页面加载2
|
|
|
|
|
* 生命周期函数--监听页面加载
|
|
|
|
|
*.list-keywords {
|
|
|
|
|
*margin: 10px;1
|
|
|
|
|
*padding: 10px;1
|
|
|
|
|
*background: #fff;1
|
|
|
|
|
*margin: 10px;
|
|
|
|
|
*padding: 10px;
|
|
|
|
|
*background: #fff;
|
|
|
|
|
*}1
|
|
|
|
|
*.list-keywords .item{
|
|
|
|
|
*display: inline-block;1
|
|
|
|
|
*display: inline-block;
|
|
|
|
|
*padding: 5px 10px;
|
|
|
|
|
*background: #f1f1f1;1
|
|
|
|
|
*background: #f1f1f1;
|
|
|
|
|
*margin: 5px;
|
|
|
|
|
*font-size: 12px;1
|
|
|
|
|
*color: #666;1
|
|
|
|
|
*font-size: 12px;
|
|
|
|
|
*color: #666;
|
|
|
|
|
*}
|
|
|
|
|
*/
|
|
|
|
|
onLoad(options) {
|
|
|
|
@ -33,7 +33,7 @@ Page({
|
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
// 内容改变3
|
|
|
|
|
// 内容改变
|
|
|
|
|
onChange(e){//内容展示函数
|
|
|
|
|
this.setData({
|
|
|
|
|
value:e.detail//获取值
|
|
|
|
@ -41,20 +41,20 @@ Page({
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 展示搜索数据,在goods页面展示4
|
|
|
|
|
* 1. 在搜索页面通过网络请求获取数据,传递到goods页面显示5
|
|
|
|
|
* 2. 在搜索页面将搜索的关键字传递到goods页面,在goods页面做网络请求6
|
|
|
|
|
* 展示搜索数据,在goods页面展示
|
|
|
|
|
* 1. 在搜索页面通过网络请求获取数据,传递到goods页面显示
|
|
|
|
|
* 2. 在搜索页面将搜索的关键字传递到goods页面,在goods页面做网络请求
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
// 实现搜索7
|
|
|
|
|
// 实现搜索
|
|
|
|
|
onSearch(){//搜索函数
|
|
|
|
|
this.http(this.data.value)//10
|
|
|
|
|
this.http(this.data.value)//1
|
|
|
|
|
},
|
|
|
|
|
onSearchCliclk(){//搜索点击函数
|
|
|
|
|
this.http(this.data.value)//11
|
|
|
|
|
this.http(this.data.value)//1
|
|
|
|
|
},
|
|
|
|
|
/**
|
|
|
|
|
* 获取热门关键字8
|
|
|
|
|
* 获取热门关键字
|
|
|
|
|
*/
|
|
|
|
|
clickGetKeyWords(e){
|
|
|
|
|
this.http(e.currentTarget.dataset.hotkey)//使用this
|
|
|
|
@ -62,22 +62,22 @@ Page({
|
|
|
|
|
http(search){
|
|
|
|
|
getSearch({search}).then(res =>{
|
|
|
|
|
if(!res.data.msg){
|
|
|
|
|
// 序列化9
|
|
|
|
|
// 序列化
|
|
|
|
|
let goods = JSON.stringify(res.data.data)
|
|
|
|
|
wx.navigateTo({
|
|
|
|
|
url: '/pages/goods/goods?goodsData=' + goods,//给出跳转网址
|
|
|
|
|
url: '/pages/goods/goods?goodsData=' + goods,//给出跳转网址0
|
|
|
|
|
})
|
|
|
|
|
}else{
|
|
|
|
|
wx.showToast({
|
|
|
|
|
title: res.data.msg,//获取记录搜索结果总数
|
|
|
|
|
title: res.data.msg,//获取记录搜索结果总数0
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
}) /**
|
|
|
|
|
* 展示搜索数据,在goods页面展示4
|
|
|
|
|
* 1. 在搜索页面通过网络请求获取数据,传递到goods页面显示5
|
|
|
|
|
* 2. 在搜索页面将搜索的关键字传递到goods页面,在goods页面做网络请求6
|
|
|
|
|
* 展示搜索数据,在goods页面展示
|
|
|
|
|
* 1. 在搜索页面通过网络请求获取数据,传递到goods页面显示
|
|
|
|
|
* 2. 在搜索页面将搜索的关键字传递到goods页面,在goods页面做网络请求
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
// 实现搜索7
|