Browse Source
feat(菜品详情): 添加菜品详情页面和路由配置
feat(菜品详情): 添加菜品详情页面和路由配置
- 创建新的菜品详情页面组件 dishDetail.vue - 在 pages.json 中添加菜品详情页路由配置 - 将原分类页面改为全部菜品页面并更新底部导航栏文本 - 删除无用的测试文件 test.jsmaster
3 changed files with 30 additions and 197 deletions
-
10pages.json
-
23pages/allDish/dishDetail.vue
-
194test.js
@ -0,0 +1,23 @@ |
|||
<script setup> |
|||
import navv from "@/components/nav/nav.vue"; |
|||
import topTitle from "@/components/topTitle/topTitle.vue"; |
|||
</script> |
|||
|
|||
<template> |
|||
<navv> |
|||
<template #default="{ fixStyle, padStyle }"> |
|||
<topTitle title="菜品详情" :style="fixStyle" /> |
|||
<view :style="padStyle"> |
|||
<view |
|||
v-for="(item, index) in 1000" :key="index" |
|||
> |
|||
{{ item }} |
|||
</view> |
|||
</view> |
|||
</template> |
|||
</navv> |
|||
</template> |
|||
|
|||
<style scoped lang="scss"> |
|||
|
|||
</style> |
|||
@ -1,194 +0,0 @@ |
|||
// const clickItem = {
|
|||
// id: "c64a7f8fad6840298d37bcae9d04fb0b",
|
|||
// name: "土豆",
|
|||
// imageUrl: "http://cdn.boofoo.top/product/53e9a8b6-f9bf-41c4-b7e5-fce85655c05f_small",
|
|||
// type: "a22663477eb54bf2b2f895b631aae577",
|
|||
// oneTypeId: "decd4ccd5e334809977a2375f1717962",
|
|||
// minPrice: 1.28,
|
|||
// maxPrice: 1.28,
|
|||
// minMeasurePrice: null,
|
|||
// maxMeasurePrice: null,
|
|||
// unit: "普/斤",
|
|||
// stock: -1,
|
|||
// measureUnit: "斤",
|
|||
// specialOrder: 4,
|
|||
// oldPrice: null,
|
|||
// foodName: null,
|
|||
// mealTime: null,
|
|||
// specs: [
|
|||
// {
|
|||
// id: "d764e74bc24f483ba3c5fe76a4d63018",
|
|||
// unit: "普/斤",
|
|||
// stock: -1,
|
|||
// price: 1.28,
|
|||
// measureUnit: "斤",
|
|||
// measurePrice: 1.5,
|
|||
// oldPrice: null,
|
|||
// promotePrice: 0.98,
|
|||
// virtualStock: true,
|
|||
// minNum: 1,
|
|||
// chuxiao: false,
|
|||
// sum: 0,
|
|||
// },
|
|||
// ],
|
|||
// chuxiao: false,
|
|||
// showChoose: 0,
|
|||
// };
|
|||
|
|||
// // console.log(inputValue)
|
|||
// // console.log(inputValue)
|
|||
// const item = clickItem.item;
|
|||
// const exa = clickItem.exa;
|
|||
// if ((inputValue !== "" && clickItem.quantity == -1) || clickItem.quantity != -1) {
|
|||
// if (exa == "sum") {
|
|||
// products.value.forEach((each) => {
|
|||
// each.specs.forEach((child) => {
|
|||
// if (child.id == clickItem.id) {
|
|||
// if (child.sum === "") {
|
|||
// child.sum = inputValue.value;
|
|||
// }
|
|||
// if (child.stock == child.sum) {
|
|||
// uni.showToast({
|
|||
// title: "采购数量不能大于库存数量",
|
|||
// });
|
|||
// return;
|
|||
// };
|
|||
// if (child.stock == 0) {
|
|||
// uni.showToast({
|
|||
// title: "库存数量为0无法添加",
|
|||
// });
|
|||
// return;
|
|||
// };
|
|||
// if (clickItem.quantity == 1) {
|
|||
// // 核心逻辑:判断首次添加还是后续添加
|
|||
// let addQuantity = 1; // 默认每次加1
|
|||
// let newNum;
|
|||
// // 首次添加(当前数量为0)
|
|||
// if (item.sum === 0) {
|
|||
// // 使用minNum作为首次添加数量,确保至少添加1个
|
|||
// addQuantity = item.minNum > 0 ? item.minNum : 1;
|
|||
// newNum = addQuantity;
|
|||
// }
|
|||
// else {
|
|||
// // 后续添加,每次加1
|
|||
// newNum = Number(item.sum) + 1;
|
|||
// // 后续添加时,实际增加的数量就是1
|
|||
// addQuantity = 1;
|
|||
// }
|
|||
// console.log("当前数量:", newNum, "本次添加:", addQuantity);
|
|||
// // 更新商品数量
|
|||
// child.sum = newNum;
|
|||
// addNum = addQuantity;
|
|||
|
|||
// // child.sum++;
|
|||
// }
|
|||
// else if (clickItem.quantity == -1) {
|
|||
// let reduceQuantity = -1; // 默认每次减1
|
|||
// // 确保minNum有合理的值,默认为1
|
|||
// const minNum = item.minNum > 0 ? item.minNum : 1;
|
|||
// // 核心逻辑:判断是否需要按起订量减少
|
|||
// if (item.sum > minNum) {
|
|||
// // 数量大于起订量,正常减1
|
|||
// item.sum = Number(item.sum) + reduceQuantity;
|
|||
// }
|
|||
// else if (item.sum === minNum) {
|
|||
// // 数量等于起订量,直接减少起订量
|
|||
// reduceQuantity = -minNum;
|
|||
// item.sum = Number(item.sum) + reduceQuantity;
|
|||
// }
|
|||
// else {
|
|||
// // 数量小于起订量,正常减1(但不小于0)
|
|||
// item.sum = Math.max(0, Number(item.num) + reduceQuantity);
|
|||
// }
|
|||
|
|||
// addNum = reduceQuantity;
|
|||
// child.sum = item.sum;
|
|||
// // child.sum--;
|
|||
// console.log(child.sum);
|
|||
// if (child.sum <= 0) {
|
|||
// that.clearOneCart(clickItem.id);
|
|||
// }
|
|||
// };
|
|||
// _this.setData({
|
|||
// products: products.value,
|
|||
// inputValue: child.sum,
|
|||
// });
|
|||
// }
|
|||
// });
|
|||
// });
|
|||
// }
|
|||
// else if (exa == "quantity") {
|
|||
// cartList.value.forEach((child) => {
|
|||
// if (child.productId == clickItem.id) {
|
|||
// if (child.quantity === "") {
|
|||
// child.quantity = inputValue.value;
|
|||
// }
|
|||
// if (clickItem.quantity == 1) {
|
|||
// child.quantity++;
|
|||
// }
|
|||
// else if (clickItem.quantity == -1) {
|
|||
// child.quantity--;
|
|||
// };
|
|||
// _this.setData({
|
|||
// cartList: cartList.value,
|
|||
// inputValue: child.quantity,
|
|||
// });
|
|||
// }
|
|||
// });
|
|||
// if (clickItem.quantity == -1) {
|
|||
// if (clickItem.num - 1 <= 0) {
|
|||
// that.clearOneCart(clickItem.id);
|
|||
// }
|
|||
// }
|
|||
// }
|
|||
// console.log(item);
|
|||
// let data = {
|
|||
// // quantity: clickItem.quantity,
|
|||
// quantity: addNum,
|
|||
// specId: clickItem.id,
|
|||
// Chuxiao: clickItem.chuxiao,
|
|||
// warehouseId: uni.getStorageSync("warehousId"),
|
|||
// addrId: uni.getStorageSync("addressId"),
|
|||
// };
|
|||
// if (!data.specId) {
|
|||
// uni.showModal({
|
|||
// title: "提示",
|
|||
// content: "当前商品规格错误,请稍候再试",
|
|||
// showCancel: false,
|
|||
// confirmText: "确定",
|
|||
// success: (res) => {
|
|||
|
|||
// },
|
|||
// });
|
|||
// }
|
|||
// if (data.isChuxiao === "" || data.isChuxiao === undefined) {
|
|||
// data.isChuxiao = false;
|
|||
// }
|
|||
// if (!data.warehouseId || !data.addrId) {
|
|||
// uni.showModal({
|
|||
// title: "提示",
|
|||
// content: "请先选择收货地址,再添加商品",
|
|||
// showCancel: false,
|
|||
// confirmText: "确定",
|
|||
// success: (res) => {
|
|||
|
|||
// },
|
|||
// });
|
|||
// }
|
|||
// keys.push(clickItem.id);
|
|||
// serve.addCart(data, (res) => {
|
|||
// // console.log(res)
|
|||
// // console.log(keys);
|
|||
// keys.splice(clickItem.id, 1);
|
|||
// // console.log(keys);
|
|||
// if (res.data.code == 0) {
|
|||
// _this.initCartInfo();
|
|||
// }
|
|||
// else {
|
|||
// uni.showToast({
|
|||
// title: res.data.message,
|
|||
// icon: "none",
|
|||
// });
|
|||
// }
|
|||
// });
|
|||
// }
|
|||
Write
Preview
Loading…
Cancel
Save
Reference in new issue