This commit is contained in:
pplokijuhyg 2019-12-24 21:54:49 +08:00
parent ef6a5868f1
commit 01d1215d5d
5 changed files with 31 additions and 5 deletions

View File

@ -4,5 +4,11 @@ Component({
data: { data: {
}, },
methods: { methods: {
search(a){
console.log(a)
wx.navigateTo({
url:"/pages/search/search?key=" + a.detail.value
})
}
} }
}) })

View File

@ -1,4 +1,4 @@
<view class="search"> <view class="search">
<image></image> <image></image>
<input type="text" placeholder="输入您要搜索的产品" /> <input type="text" confirm-type="search " bindconfirm="search" placeholder="输入您要搜索的产品" />
</view> </view>

View File

@ -1,18 +1,34 @@
// pages/search/search.js // pages/search/search.js
import bin from "../../utils/bin"
Page({ Page({
/** /**
* 页面的初始数据 * 页面的初始数据
*/ */
data: { data: {
list:[]
}, },
/** /**
* 生命周期函数--监听页面加载 * 生命周期函数--监听页面加载
*/ */
onLoad: function (options) { onLoad: function (options) {
bin.request({
url:"Goods/search",
urldata:{
keywords:options.key,
p:0,
sort:"",
shop_price:"",
sort_asc:"",
desc:""
}
}).then((res)=>{
console.log(res)
this.setData({
list:res.data.result.goods_list
})
})
}, },
/** /**

View File

@ -1,6 +1,9 @@
{ {
"navigationBarTitleText": "搜索",
"usingComponents": { "usingComponents": {
"search":"../components/index/search/index", "search":"../components/index/search/index",
"hot":"../components/search/hot/index" "hot":"../components/search/hot/index",
"commodity":"../components/index/list/commodity/index"
} }
} }

View File

@ -1,4 +1,5 @@
<view class="box"> <view class="box">
<search></search> <search></search>
<hot></hot> <!-- <hot></hot> -->
<commodity wx:for="{{list}}" title="{{item.goods_name}}" price="{{item.shop_price}}" img="{{item.image}}" shopid="{{item.goods_id}}"></commodity>
</view> </view>