2025.4.28
This commit is contained in:
parent
498064df29
commit
c62aa6280a
5
app/api/base.js
Normal file
5
app/api/base.js
Normal file
@ -0,0 +1,5 @@
|
||||
module.exports = {
|
||||
bauseUrl:"http://192.168.2.123:8084",
|
||||
banner:"/api/banner",
|
||||
goods:/api/front/pageList/suggest
|
||||
}
|
||||
7
app/api/index.js
Normal file
7
app/api/index.js
Normal file
@ -0,0 +1,7 @@
|
||||
const {require} = require("../utils/request")
|
||||
const { goods} = require("./base")
|
||||
|
||||
|
||||
function getGoods(data){
|
||||
return request()
|
||||
}
|
||||
@ -7,13 +7,14 @@
|
||||
"pages/index/index",
|
||||
"pages/shopping/shopping",
|
||||
"pages/mine/mine",
|
||||
"pages/logs/logs"
|
||||
"pages/logs/logs",
|
||||
"pages/search/search"
|
||||
],
|
||||
"window": {
|
||||
"navigationBarTextStyle": "black",
|
||||
"navigationBarTitleText": "嗨果嗨鲜",
|
||||
"navigationBarBackgroundColor": "#ffffff",
|
||||
"navigationStyle": "custom"
|
||||
"navigationBarBackgroundColor": "#ffffff"
|
||||
|
||||
},
|
||||
|
||||
"componentFramework": "glass-easel",
|
||||
|
||||
@ -21,9 +21,12 @@ Page({
|
||||
}
|
||||
]
|
||||
},
|
||||
onSearch(e) {
|
||||
console.log('搜索内容:', e.detail);
|
||||
// 处理搜索逻辑
|
||||
},
|
||||
|
||||
/*
|
||||
点击搜索框获取焦点
|
||||
*/
|
||||
clickSearch(){
|
||||
wx.navigateTo({
|
||||
url: '/pages/search/search',
|
||||
})
|
||||
}
|
||||
})
|
||||
@ -7,6 +7,4 @@
|
||||
"goods-list":"/components/goods-list/goods-list"
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@ -1,19 +1,19 @@
|
||||
<view class="head">
|
||||
<view class="head_a">
|
||||
<view class="head_b">
|
||||
<view class="head_c">
|
||||
<!-- <view class="head_c">
|
||||
<view class="head_text">嗨果嗨鲜</view>
|
||||
<view class="head_shouhuo">
|
||||
<van-icon name="location-o" />默认收货地址
|
||||
</view>
|
||||
</view>
|
||||
</view> -->
|
||||
<view class="head_d">
|
||||
<van-search value="{{value}}" placeholder="请输入搜索关键词" bind:confirm="onSearch"/>
|
||||
<van-search bindtap="clickSearch" disabled bind:focus="clickSearch" value="{{value}}" placeholder="请输入搜索关键词" bind:confirm="onSearch"/>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="head_box" >
|
||||
<van-grid column-num="3" gutter="10">
|
||||
<van-grid column-num="3" gutter="10" border="{{false}}">
|
||||
<van-grid-item wx:for="{{navData}}" wx:key="id" icon="{{item.icon}}" text="{{item.text}}" icon-color="{{item.color}}" />
|
||||
</van-grid>
|
||||
<goods-list></goods-list>
|
||||
|
||||
@ -5,10 +5,10 @@
|
||||
}
|
||||
.head_a{
|
||||
position: fixed;
|
||||
top: 50px;
|
||||
top: 0px;
|
||||
left: 0;
|
||||
right: 0;
|
||||
height:100px;
|
||||
height:44px;
|
||||
background-color: #fff;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
@ -19,13 +19,13 @@
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
.head_c{
|
||||
/* .head_c{
|
||||
position: relative;
|
||||
bottom: 10px;
|
||||
display: flex;
|
||||
align-items:center;
|
||||
justify-content:space-between;
|
||||
}
|
||||
} */
|
||||
.van-search{
|
||||
width: 360px;
|
||||
}
|
||||
@ -43,7 +43,7 @@ right: 85px;
|
||||
|
||||
}
|
||||
.head_box{
|
||||
margin-top: 160px;
|
||||
margin-top: 60px;
|
||||
padding: 10px;
|
||||
overflow-y: auto;
|
||||
}
|
||||
37
app/pages/search/search.js
Normal file
37
app/pages/search/search.js
Normal file
@ -0,0 +1,37 @@
|
||||
Page({
|
||||
|
||||
/**
|
||||
* 页面的初始数据
|
||||
*/
|
||||
data: {
|
||||
searchText: ""
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面加载
|
||||
*/
|
||||
onLoad(options) {
|
||||
|
||||
},
|
||||
/*内容改变*/
|
||||
onChange(e) {
|
||||
// console.log(e.detail);
|
||||
this.setData({
|
||||
searchText:e.detail.value,
|
||||
})
|
||||
},
|
||||
// 实现搜索
|
||||
onSearch() {
|
||||
console.log("搜索");
|
||||
this.setData({
|
||||
searchText:""
|
||||
})
|
||||
},
|
||||
onSearchCliclk() {
|
||||
console.log("点击搜索");
|
||||
this.setData({
|
||||
searchText:""
|
||||
})
|
||||
}
|
||||
|
||||
})
|
||||
6
app/pages/search/search.json
Normal file
6
app/pages/search/search.json
Normal file
@ -0,0 +1,6 @@
|
||||
{
|
||||
"usingComponents": {
|
||||
"van-search": "@vant/weapp/search/index",
|
||||
"van-button": "@vant/weapp/button/index"
|
||||
}
|
||||
}
|
||||
12
app/pages/search/search.wxml
Normal file
12
app/pages/search/search.wxml
Normal file
@ -0,0 +1,12 @@
|
||||
<view class="search_head">
|
||||
<van-search
|
||||
value="{{ searchText }}"
|
||||
placeholder="请输入搜索关键词"
|
||||
use-action-slot
|
||||
bind:change="onChange"
|
||||
bind:search="onSearch"
|
||||
>
|
||||
|
||||
</van-search>
|
||||
<van-button style="margin-right: 10px;" type="primary" size="small" slot="action" bind:tap="onSearchCliclk">搜索</van-button>
|
||||
</view>
|
||||
9
app/pages/search/search.wxss
Normal file
9
app/pages/search/search.wxss
Normal file
@ -0,0 +1,9 @@
|
||||
.van-search{
|
||||
width: 310px;
|
||||
justify-content:space-between;
|
||||
}
|
||||
.search_head{
|
||||
display: flex;
|
||||
align-items:center;
|
||||
justify-content:space-between;
|
||||
}
|
||||
37
app/utils/request.js
Normal file
37
app/utils/request.js
Normal file
@ -0,0 +1,37 @@
|
||||
/**
|
||||
* @param {string} url 请求地址
|
||||
* @param {string} method 请求方法(GET/POST)
|
||||
* @param {string|object|arraybuffer} data 请求数据
|
||||
*/
|
||||
function request(url, method, data) {
|
||||
wx.showLoading({
|
||||
title: '加载数据...',
|
||||
mask: true
|
||||
});
|
||||
|
||||
const promise = new Promise((resolve, reject) => { // 修正:Pomise → Promise
|
||||
wx.request({
|
||||
url: url,
|
||||
method: method.toUpperCase(), // 确保 method 是大写(GET/POST)
|
||||
data: data,
|
||||
header: {
|
||||
'Content-Type': 'application/x-www-form-urlencoded' // 默认表单格式
|
||||
},
|
||||
success(res) {
|
||||
resolve(res);
|
||||
},
|
||||
fail(err) {
|
||||
reject(err);
|
||||
},
|
||||
complete() {
|
||||
wx.hideLoading();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
return promise;
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
request
|
||||
};
|
||||
Loading…
x
Reference in New Issue
Block a user