diff --git a/App.vue b/App.vue
index e48dc02..429439a 100644
--- a/App.vue
+++ b/App.vue
@@ -26,4 +26,8 @@
.justify-between{
justify-content: space-between;
}
+
+ img,image{
+ max-width: 100%;
+ }
diff --git a/components/AddToCart.vue b/components/AddToCart.vue
new file mode 100644
index 0000000..4b023b5
--- /dev/null
+++ b/components/AddToCart.vue
@@ -0,0 +1,100 @@
+
+
+
+
+ {{(carts.price/100).toFixed(2)}}元
+
+
+ 加入购物车
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/components/CustNavBar/CustNavBar.vue b/components/CustNavBar/CustNavBar.vue
new file mode 100644
index 0000000..a5ffb0b
--- /dev/null
+++ b/components/CustNavBar/CustNavBar.vue
@@ -0,0 +1,52 @@
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/components/index.ts b/components/index.ts
new file mode 100644
index 0000000..8e9bc25
--- /dev/null
+++ b/components/index.ts
@@ -0,0 +1,5 @@
+import AddToCart from './AddToCart.vue';
+
+export {
+ AddToCart
+}
\ No newline at end of file
diff --git a/pages.json b/pages.json
index 70e68c7..08b5721 100644
--- a/pages.json
+++ b/pages.json
@@ -3,6 +3,9 @@
{
"path": "pages/index/index",
"style": {
+ "app-plus": {
+ "titleNView": false
+ }
}
}, {
"path": "pages/order/index",
@@ -16,26 +19,32 @@
"enablePullDownRefresh": false
}
+ }, {
+ "path": "pages/index/search",
+ "style": {
+ "navigationBarTitleText": "",
+ "enablePullDownRefresh": false
+ }
+
+ }, {
+ "path": "pages/index/detail",
+ "style": {
+ "enablePullDownRefresh": false,
+ "app-plus": {
+ "titleNView": false
+ }
+ }
+
+ }, {
+ "path": "pages/index/category",
+ "style": {
+ "app-plus": {
+ "titleNView": false
+ }
+ }
+
}
- ,{
- "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/category.vue b/pages/index/category.vue
new file mode 100644
index 0000000..e7f4b57
--- /dev/null
+++ b/pages/index/category.vue
@@ -0,0 +1,94 @@
+
+
+
+
+
+ 搜索 鱼香肉丝 试试
+
+
+
+
+
+
+ {{c.title}}
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/pages/index/detail.vue b/pages/index/detail.vue
index efb6892..a85d7f6 100644
--- a/pages/index/detail.vue
+++ b/pages/index/detail.vue
@@ -1,27 +1,32 @@
-
-
-
-
- {{f.title}}
-
-
- {{f.saleCount}}
-
-
-
- {{f.price}}
- {{f.coupon}}
+
+
+
+
-
-
- 加入购物车
+
+
+ {{f.title}}
+
+
+
+ 销量{{f.saleCount}}
+
+
+ ¥
+ {{f.coupon ? (((f.price+f.coupon)/100).toFixed(2)) : (f.price/100).toFixed(2)}}
+ {{(f.price/100).toFixed(2)}}
+
+
+
+ {{f.couponDesc}}
+
-
-
-
+
+
@@ -29,26 +34,97 @@
import { foodsDetail } from '../../service/api';
import { ref } from "vue";
import { FoodsModel } from '../../service/models';
+ import { AddToCart } from '../../components'
const props = defineProps<{
- id : any
+ id ?: any
}>();
const f = ref()
- foodsDetail(props.id).then((foods) => {
+ foodsDetail(Number(props.id || 1)).then((foods) => {
+ uni.setNavigationBarTitle({
+ title: foods.title
+ })
f.value = foods
})
\ No newline at end of file
diff --git a/pages/index/index.vue b/pages/index/index.vue
index 16d9937..c6413f6 100644
--- a/pages/index/index.vue
+++ b/pages/index/index.vue
@@ -20,7 +20,7 @@
{{c.id}}{{c.title}}
-
+
@@ -50,20 +50,16 @@
}
})
- function loadFoodByCid(cid) {
- uni.request({
- url: API_URL + '/api/food/category/' + cid,
- success(ret) {
- foodsList.value = ret.data.data
- // console.log(ret.data.data)
- }
+ function loadFoodByCid(cid : any) {
+ uni.navigateTo({
+ url: `/pages/index/category?cid=${cid}`
})
}
-
- function showSearchPage(){
+
+ function showSearchPage() {
uni.navigateTo({
- url:'/pages/index/search'
+ url: '/pages/index/search'
})
}
@@ -148,9 +144,8 @@
box-sizing: border-box;
image {
- width: 40px;
- height: 40px;
+ width: 32px;
+ height: 32px;
}
}
-
\ No newline at end of file
diff --git a/service/api.ts b/service/api.ts
index bbb3c20..c5d90fe 100644
--- a/service/api.ts
+++ b/service/api.ts
@@ -1,4 +1,4 @@
-import { FoodsModel, ResponseModel } from "./models"
+import { CartModel, CategoryModel, FoodsModel, ResponseModel } from "./models"
export const API_URL = 'http://localhost:8080'
function request(url : string, method : 'GET' | 'POST' = 'GET', data : any = null) {
@@ -32,11 +32,19 @@ function request(url : string, method : 'GET' | 'POST' = 'GET', data : any =
}
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)
- // }
- // })
+}
+export function addToCart(fid : any, count = 1) {
+ return request(`/api/carts`, 'POST', {
+ fid, count
+ })
+}
+export function cartList() {
+ return request(`/api/carts/list`)
+}
+
+export function allCategories() {
+ return request(`/api/category`);
+}
+export function loadCategoryGoods(cid : any) {
+ return request(`/api/food/category/${cid}`);
}
\ No newline at end of file
diff --git a/service/models.ts b/service/models.ts
index 186b3f1..078549e 100644
--- a/service/models.ts
+++ b/service/models.ts
@@ -29,4 +29,31 @@ export type FoodsModel = {
recommendEndTime ?: any;
saleCount : number;
state : number;
+}
+export interface CartModel {
+ createBy?: any;
+ createTime: string;
+ updateBy?: any;
+ updateTime?: any;
+ remark?: any;
+ fid: number;
+ uid: number;
+ foodsCover: string;
+ foodsTitle: string;
+ foodPrice: number;
+ count: number;
+ state: number;
+}
+
+export interface CategoryModel {
+ createBy?: any;
+ createTime: string;
+ updateBy?: any;
+ updateTime: string;
+ remark?: any;
+ id: number;
+ title: string;
+ sort: number;
+ cover: string;
+ state: number;
}
\ No newline at end of file
diff --git a/uni.scss b/uni.scss
index 671a5ae..8871650 100644
--- a/uni.scss
+++ b/uni.scss
@@ -16,6 +16,7 @@
/* 行为相关颜色 */
$uni-color-primary: #ff5801;
+$uni-color-primary-1: #ff4203;
$uni-color-success: #4cd964;
$uni-color-warning: #f0ad4e;
$uni-color-error: #dd524d;
@@ -74,7 +75,3 @@ $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