first commit

This commit is contained in:
编码猿
2024-09-27 02:06:13 +08:00
commit 852d94fbb9
36760 changed files with 3274413 additions and 0 deletions

View File

@@ -0,0 +1,84 @@
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}`
})
}
});

View File

@@ -0,0 +1,10 @@
{
"navigationBarTitleText": "搜索",
"navigationStyle": "custom",
"usingComponents": {
"van-tag": "@vant/weapp/tag/index",
"van-row": "@vant/weapp/row/index",
"van-col": "@vant/weapp/col/index"
}
}

View File

@@ -0,0 +1,30 @@
<view class="search">
<view class="search_head" style="margin-top: {{height}}px;">
搜索
</view>
<view class="search_top">
<input placeholder="请输入搜索内容" class="button" value="{{SearchKeyword}}" bindtap="onChangeShowState" bindinput="getitems"/>
<view bindtap="cliekss" class="sum"><text>搜索</text></view>
</view>
<view class="content">
<view class="{{showView?'popular':'list'}}" bindtap="onChangeShowState">
<view class="title">热门搜索</view>
<van-tag round wx:for="{{tagList}}" data-hi="{{item.text}}" wx:key="index" type="warning" size="large" bindtap="getitem">{{item.text}}</van-tag>
</view>
<view class="{{showView?'list':'popular'}}">
<van-row type="flex">
<van-col class="shop_item"
wx:for="{{searchList}}"
span="12"
data-list="{{item}}"
bindtap="enterInfo"
wx:key="index">
<image src="{{item.wares_masterimg}}"></image>
<text class="title">{{item.wares_title}}</text>
<text class="info">{{ item.wares_info}}...</text>
<text class="price">¥{{item.wares_nowprice}}</text>
</van-col>
</van-row>
</view>
</view>
</view>

View File

@@ -0,0 +1,84 @@
.search{
width: 100%
}
.search_head{
text-align: center;
width: 100%;
position: fixed;
background: #fff
}
.search_top {
margin-top: 75px;
height: 32px;
width: 100%;
position: fixed;
display: flex;
justify-content : space-between;
align-items: center
}
.button{
margin: auto;
width: 70%;
height: 30px;
font-size: 15px;
border-radius: 47px;
padding-left: 15px;
background: #f8f8f8;
border: #000 1px;
opacity:0.8
}
.sum{
font-size: 14px;
color: #000;
padding-right: 30px
}
.content{
padding-top: 120px;
}
.popular {
padding: 1px;
display: block;
}
.title{
text-align: center;
font-size: 18px;
}
.van-tag {
margin-left: 15px;
margin-top: 10px
}
.list{
margin-top: 10px;
display: none;
}
.van-col--12 {
text-align: center
}
.shop_item {
margin-bottom: 10px;
}
.shop_item image{
width: 160px;
height: 145px;
}
.shop_item text {
display: block
}
.shop_item .title{
font-size: 14px;
color: rgba(0,0,0,.87);
}
.shop_item .info{
font-size: 12px;
color: rgba(0,0,0,.54);
margin-top: 4px;
}
.shop_item .price{
font-size: 14px;
color: #ea625b;
margin-top: 4px;
line-height: 21px;
}