2025.4.28

This commit is contained in:
fanshuai 2025-04-28 17:55:43 +08:00
parent 498064df29
commit c62aa6280a
12 changed files with 134 additions and 19 deletions

5
app/api/base.js Normal file
View 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
View File

@ -0,0 +1,7 @@
const {require} = require("../utils/request")
const { goods} = require("./base")
function getGoods(data){
return request()
}

View File

@ -7,13 +7,14 @@
"pages/index/index", "pages/index/index",
"pages/shopping/shopping", "pages/shopping/shopping",
"pages/mine/mine", "pages/mine/mine",
"pages/logs/logs" "pages/logs/logs",
"pages/search/search"
], ],
"window": { "window": {
"navigationBarTextStyle": "black", "navigationBarTextStyle": "black",
"navigationBarTitleText": "嗨果嗨鲜", "navigationBarTitleText": "嗨果嗨鲜",
"navigationBarBackgroundColor": "#ffffff", "navigationBarBackgroundColor": "#ffffff"
"navigationStyle": "custom"
}, },
"componentFramework": "glass-easel", "componentFramework": "glass-easel",

View File

@ -21,9 +21,12 @@ Page({
} }
] ]
}, },
onSearch(e) { /*
console.log('搜索内容:', e.detail); 点击搜索框获取焦点
// 处理搜索逻辑 */
}, clickSearch(){
wx.navigateTo({
url: '/pages/search/search',
})
}
}) })

View File

@ -7,6 +7,4 @@
"goods-list":"/components/goods-list/goods-list" "goods-list":"/components/goods-list/goods-list"
} }
} }

View File

@ -1,19 +1,19 @@
<view class="head"> <view class="head">
<view class="head_a"> <view class="head_a">
<view class="head_b"> <view class="head_b">
<view class="head_c"> <!-- <view class="head_c">
<view class="head_text">嗨果嗨鲜</view> <view class="head_text">嗨果嗨鲜</view>
<view class="head_shouhuo"> <view class="head_shouhuo">
<van-icon name="location-o" />默认收货地址 <van-icon name="location-o" />默认收货地址
</view> </view>
</view> </view> -->
<view class="head_d"> <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>
</view> </view>
<view class="head_box" > <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-item wx:for="{{navData}}" wx:key="id" icon="{{item.icon}}" text="{{item.text}}" icon-color="{{item.color}}" />
</van-grid> </van-grid>
<goods-list></goods-list> <goods-list></goods-list>

View File

@ -5,10 +5,10 @@
} }
.head_a{ .head_a{
position: fixed; position: fixed;
top: 50px; top: 0px;
left: 0; left: 0;
right: 0; right: 0;
height:100px; height:44px;
background-color: #fff; background-color: #fff;
display: flex; display: flex;
align-items: center; align-items: center;
@ -19,13 +19,13 @@
display: flex; display: flex;
flex-direction: column; flex-direction: column;
} }
.head_c{ /* .head_c{
position: relative; position: relative;
bottom: 10px; bottom: 10px;
display: flex; display: flex;
align-items:center; align-items:center;
justify-content:space-between; justify-content:space-between;
} } */
.van-search{ .van-search{
width: 360px; width: 360px;
} }
@ -43,7 +43,7 @@ right: 85px;
} }
.head_box{ .head_box{
margin-top: 160px; margin-top: 60px;
padding: 10px; padding: 10px;
overflow-y: auto; overflow-y: auto;
} }

View 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:""
})
}
})

View File

@ -0,0 +1,6 @@
{
"usingComponents": {
"van-search": "@vant/weapp/search/index",
"van-button": "@vant/weapp/button/index"
}
}

View 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>

View 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
View 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
};