diff --git a/app/api/base.js b/app/api/base.js new file mode 100644 index 0000000..ac9e069 --- /dev/null +++ b/app/api/base.js @@ -0,0 +1,5 @@ +module.exports = { + bauseUrl:"http://192.168.2.123:8084", + banner:"/api/banner", + goods:/api/front/pageList/suggest +} \ No newline at end of file diff --git a/app/api/index.js b/app/api/index.js new file mode 100644 index 0000000..1563d7a --- /dev/null +++ b/app/api/index.js @@ -0,0 +1,7 @@ +const {require} = require("../utils/request") +const { goods} = require("./base") + + +function getGoods(data){ + return request() +} \ No newline at end of file diff --git a/app/app.json b/app/app.json index 84a06c5..0a7e888 100644 --- a/app/app.json +++ b/app/app.json @@ -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", diff --git a/app/pages/index/index.js b/app/pages/index/index.js index 0e66446..242a0d8 100644 --- a/app/pages/index/index.js +++ b/app/pages/index/index.js @@ -21,9 +21,12 @@ Page({ } ] }, - onSearch(e) { - console.log('搜索内容:', e.detail); - // 处理搜索逻辑 - }, - + /* + 点击搜索框获取焦点 + */ + clickSearch(){ +wx.navigateTo({ + url: '/pages/search/search', +}) + } }) \ No newline at end of file diff --git a/app/pages/index/index.json b/app/pages/index/index.json index 9f8f689..fa29c04 100644 --- a/app/pages/index/index.json +++ b/app/pages/index/index.json @@ -7,6 +7,4 @@ "goods-list":"/components/goods-list/goods-list" } - - } \ No newline at end of file diff --git a/app/pages/index/index.wxml b/app/pages/index/index.wxml index 5932d32..bad0cfc 100644 --- a/app/pages/index/index.wxml +++ b/app/pages/index/index.wxml @@ -1,19 +1,19 @@ - + - + - + diff --git a/app/pages/index/index.wxss b/app/pages/index/index.wxss index 56fc16c..f485303 100644 --- a/app/pages/index/index.wxss +++ b/app/pages/index/index.wxss @@ -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; } \ No newline at end of file diff --git a/app/pages/search/search.js b/app/pages/search/search.js new file mode 100644 index 0000000..dfb045f --- /dev/null +++ b/app/pages/search/search.js @@ -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:"" + }) + } + +}) \ No newline at end of file diff --git a/app/pages/search/search.json b/app/pages/search/search.json new file mode 100644 index 0000000..b640ba8 --- /dev/null +++ b/app/pages/search/search.json @@ -0,0 +1,6 @@ +{ + "usingComponents": { + "van-search": "@vant/weapp/search/index", + "van-button": "@vant/weapp/button/index" + } +} \ No newline at end of file diff --git a/app/pages/search/search.wxml b/app/pages/search/search.wxml new file mode 100644 index 0000000..18b1d04 --- /dev/null +++ b/app/pages/search/search.wxml @@ -0,0 +1,12 @@ + + + + +搜索 + diff --git a/app/pages/search/search.wxss b/app/pages/search/search.wxss new file mode 100644 index 0000000..934be01 --- /dev/null +++ b/app/pages/search/search.wxss @@ -0,0 +1,9 @@ +.van-search{ + width: 310px; + justify-content:space-between; +} +.search_head{ + display: flex; + align-items:center; + justify-content:space-between; +} \ No newline at end of file diff --git a/app/utils/request.js b/app/utils/request.js new file mode 100644 index 0000000..dd34843 --- /dev/null +++ b/app/utils/request.js @@ -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 +}; \ No newline at end of file