From a9dea3af14cf6a984b845e87fb30fe5f55edb34b Mon Sep 17 00:00:00 2001 From: callmeyan Date: Thu, 6 Apr 2023 16:55:46 +0800 Subject: [PATCH] update --- components/FoodsList/FoodsList.vue | 89 ++++++++++++++++++++++++++++++ pages.json | 20 ++++++- pages/index/detail.vue | 54 ++++++++++++++++++ pages/index/index.vue | 33 ++++++----- pages/index/search.vue | 19 +++++++ service/api.ts | 43 ++++++++++++++- service/models.ts | 32 +++++++++++ uni.scss | 4 ++ 8 files changed, 275 insertions(+), 19 deletions(-) create mode 100644 components/FoodsList/FoodsList.vue create mode 100644 pages/index/detail.vue create mode 100644 pages/index/search.vue create mode 100644 service/models.ts diff --git a/components/FoodsList/FoodsList.vue b/components/FoodsList/FoodsList.vue new file mode 100644 index 0000000..e764e2c --- /dev/null +++ b/components/FoodsList/FoodsList.vue @@ -0,0 +1,89 @@ + + + + + \ No newline at end of file diff --git a/pages.json b/pages.json index bd06457..70e68c7 100644 --- a/pages.json +++ b/pages.json @@ -17,7 +17,25 @@ } } - ], + ,{ + "path" : "pages/index/search", + "style" : + { + "navigationBarTitleText": "", + "enablePullDownRefresh": false + } + + } + ,{ + "path" : "pages/index/detail", + "style" : + { + "navigationBarTitleText": "", + "enablePullDownRefresh": false + } + + } + ], "globalStyle": { "navigationBarTextStyle": "white", "navigationBarTitleText": "我爱外卖", diff --git a/pages/index/detail.vue b/pages/index/detail.vue new file mode 100644 index 0000000..efb6892 --- /dev/null +++ b/pages/index/detail.vue @@ -0,0 +1,54 @@ + + + + + \ No newline at end of file diff --git a/pages/index/index.vue b/pages/index/index.vue index 9c50e5b..16d9937 100644 --- a/pages/index/index.vue +++ b/pages/index/index.vue @@ -1,14 +1,14 @@ @@ -65,6 +60,12 @@ }) } + + function showSearchPage(){ + uni.navigateTo({ + url:'/pages/index/search' + }) + } const foodsName = '鱼香肉丝,鱼香茄子,烂肉豇豆,麻婆豆腐'.split(','); @@ -87,27 +88,24 @@ \ No newline at end of file diff --git a/pages/index/search.vue b/pages/index/search.vue new file mode 100644 index 0000000..8c3b35f --- /dev/null +++ b/pages/index/search.vue @@ -0,0 +1,19 @@ + + + + + diff --git a/service/api.ts b/service/api.ts index 8d6eee2..bbb3c20 100644 --- a/service/api.ts +++ b/service/api.ts @@ -1 +1,42 @@ -export const API_URL = 'http://localhost:8080' \ No newline at end of file +import { FoodsModel, ResponseModel } from "./models" + +export const API_URL = 'http://localhost:8080' +function request(url : string, method : 'GET' | 'POST' = 'GET', data : any = null) { + return new Promise((resolve, reject) => { + uni.request({ + url: API_URL + url, + method, + data, + header: { + 'Content-Type': 'application/json' + }, + success(ret) { + if (ret.statusCode == 200) { + const data = ret.data as ResponseModel; + if (data.code != 200) { + reject(Error(data.msg)) + } else { + resolve(data.data) + } + } else { + reject(Error('服务器异常')) + } + }, + fail(e) { + console.log(e) + reject(Error(e.errMsg)) + } + }) + // task. + }) +} +export function foodsDetail(id : any) { + return request(`/api/food/${id}`) + // uni.request({ + // url: API_URL + '/api/food/recommend', + // success(ret) { + // foodsList.value = ret.data.data + // // console.log(ret.data.data) + // } + // }) +} \ No newline at end of file diff --git a/service/models.ts b/service/models.ts new file mode 100644 index 0000000..186b3f1 --- /dev/null +++ b/service/models.ts @@ -0,0 +1,32 @@ + +export type ResponseModel = { + code : number + data : T + msg : string +} + +export type FoodsModel = { + createBy ?: any; + createTime : string; + updateBy ?: any; + updateTime : string; + remark ?: any; + id : number; + cid : number; + title : string; + cover : string; + description : string; + content ?: any; + coupon : number; + couponDesc : string; + couponStartTime : string; + couponEndTime : string; + price : number; + sort : number; + area ?: any; + recommend : number; + recommendStartTime : string; + recommendEndTime ?: any; + saleCount : number; + state : number; +} \ No newline at end of file diff --git a/uni.scss b/uni.scss index e537d9d..671a5ae 100644 --- a/uni.scss +++ b/uni.scss @@ -74,3 +74,7 @@ $uni-color-subtitle: #555555; // 二级标题颜色 $uni-font-size-subtitle:26px; $uni-color-paragraph: #3F536E; // 文章段落颜色 $uni-font-size-paragraph:15px; + +img,image{ + max-width: 100%; +} \ No newline at end of file