diff --git a/.hbuilderx/launch.json b/.hbuilderx/launch.json
deleted file mode 100644
index 81f13f4..0000000
--- a/.hbuilderx/launch.json
+++ /dev/null
@@ -1,16 +0,0 @@
-{ // launch.json 配置了启动调试时相关设置,configurations下节点名称可为 app-plus/h5/mp-weixin/mp-baidu/mp-alipay/mp-qq/mp-toutiao/mp-360/
- // launchtype项可配置值为local或remote, local代表前端连本地云函数,remote代表前端连云端云函数
- "version": "0.0",
- "configurations": [{
- "default" :
- {
- "launchtype" : "local"
- },
- "mp-weixin" :
- {
- "launchtype" : "local"
- },
- "type" : "uniCloud"
- }
- ]
-}
diff --git a/src/App.vue b/src/App.vue
index 73eca76..f314ac1 100644
--- a/src/App.vue
+++ b/src/App.vue
@@ -2,11 +2,6 @@
import { isDevEnv, getLaunchParam } from "@/sheep/utils/app"
import { getAppInfo } from "@@/utils/app"
-// import { onLaunch, onShow, onHide } from "@dcloudio/uni-app"
-// onLaunch(() => {})
-// onShow(() => {})
-// onHide(() => {})
-
interface TabbarItem {
pagePath: string
text: string
@@ -33,6 +28,14 @@ const tabbar: TabbarItem[] = [
launchParam: ["selfMerchant"],
auth: ["user"],
},
+ {
+ pagePath: "pages/tabbar/onlineShop",
+ text: "在线商城",
+ iconPath: "/static/tabbar/online-shop.png",
+ selectedIconPath: "/static/tabbar/online-shop-select.png",
+ launchParam: ["onlineShop"],
+ auth: ["user"],
+ },
{
pagePath: "pages/tabbar/coopMerchant",
text: "合作商家",
@@ -54,7 +57,7 @@ const tabbar: TabbarItem[] = [
text: "订单",
iconPath: "/static/tabbar/order.png",
selectedIconPath: "/static/tabbar/order-select.png",
- launchParam: ["canteen", "selfMerchant", "coopMerchant"],
+ launchParam: ["canteen", "selfMerchant", "onlineShop", "coopMerchant"],
auth: ["user"],
},
{
@@ -94,7 +97,7 @@ const tabbar: TabbarItem[] = [
text: "我的",
iconPath: "/static/tabbar/my.png",
selectedIconPath: "/static/tabbar/my-select.png",
- launchParam: ["canteen", "selfMerchant", "coopMerchant"],
+ launchParam: ["canteen", "selfMerchant", "onlineShop", "coopMerchant"],
auth: ["user", "merchant", "doorAdmin"],
},
]
@@ -149,6 +152,9 @@ export default {
case "selfMerchant":
uni.switchTab({ url: "/pages/tabbar/selfMerchant" })
break
+ case "onlineShop":
+ uni.switchTab({ url: "/pages/tabbar/onlineShop" })
+ break
case "coopMerchant":
uni.switchTab({ url: "/pages/tabbar/coopMerchant" })
break
@@ -160,7 +166,7 @@ export default {
const userRole = uni.getStorageSync("userRole")
const launchParam = getLaunchParam()
if (launchParam == "thirdApp") {
- uni.navigateTo({ url: "/pages/thirdApp/thirdAppList" })
+ uni.reLaunch({ url: "/pages/thirdApp/thirdAppList" })
return
}
if (launchParam) {
@@ -169,6 +175,7 @@ export default {
return uni.switchTab({ url: "/pages/tabbar/individualOrder" })
case "user":
if (launchParam === "selfMerchant") return uni.switchTab({ url: "/pages/tabbar/selfMerchant" })
+ if (launchParam === "onlineShop") return uni.reLaunch({ url: "/pages/tabbar/onlineShop" })
if (launchParam === "coopMerchant") return uni.reLaunch({ url: "/pages/tabbar/coopMerchant" })
return
case "doorAdmin":
@@ -179,8 +186,6 @@ export default {
}
}
},
- onShow() {},
- onHide() {},
methods: {
async _initTabbar() {
diff --git a/src/pages.json b/src/pages.json
index af29477..eff3e15 100644
--- a/src/pages.json
+++ b/src/pages.json
@@ -23,6 +23,13 @@
"disableScroll": true
}
},
+ {
+ "path": "pages/tabbar/onlineShop",
+ "style": {
+ "navigationBarTitleText": "在线商城",
+ "disableScroll": true
+ }
+ },
{
"path": "pages/tabbar/coopMerchant",
"style": {
@@ -483,6 +490,12 @@
"iconPath": "",
"selectedIconPath": ""
},
+ {
+ "pagePath": "pages/tabbar/onlineShop",
+ "text": "",
+ "iconPath": "",
+ "selectedIconPath": ""
+ },
{
"pagePath": "pages/tabbar/coopMerchant",
"text": "",
@@ -521,7 +534,7 @@
},
{
"pagePath": "pages/tabbar/message",
- "text": "通知公告",
+ "text": "",
"iconPath": "",
"selectedIconPath": ""
},
diff --git a/src/pages/cabinet/buy.vue b/src/pages/cabinet/buy.vue
index c335748..08eaf96 100644
--- a/src/pages/cabinet/buy.vue
+++ b/src/pages/cabinet/buy.vue
@@ -1,29 +1,31 @@
-
-
+
+
+
- {{ item.spuDetail.name }}
+ {{ item.spuDetail.name }}
¥{{ displayPrice(item.spuDetail.price) }}
+
-
-
-
+
+
+
-
+
开 门
@@ -95,7 +97,6 @@ const goOpenDoor = () => {
.open-door-btn-wrapper {
.open-door-btn {
position: relative;
- z-index: 2;
transition: transform 0.2s;
&:active {
@@ -107,7 +108,6 @@ const goOpenDoor = () => {
position: absolute;
width: 200rpx;
height: 200rpx;
- z-index: 1;
}
.ripple {
@@ -115,8 +115,8 @@ const goOpenDoor = () => {
width: 200rpx;
height: 200rpx;
border-radius: 50%;
- border: 2px solid rgba(7, 121, 253);
- animation: ripple 1s linear infinite;
+ border: 8px solid rgba(7, 121, 253);
+ animation: ripple 2s linear infinite;
opacity: 0;
&:nth-child(2) {
diff --git a/src/pages/canteen/detail.vue b/src/pages/canteen/detail.vue
index 01b2f3f..496d130 100644
--- a/src/pages/canteen/detail.vue
+++ b/src/pages/canteen/detail.vue
@@ -156,7 +156,7 @@ const updateFoodCart = async () => {
}
// 打开购物车
-const doVisibleCart = async () => (state.showCartDialog = true)
+const doVisibleCart = () => (state.showCartDialog = true)
// 购买 打开预订时间段选择对话框
const doBuy = async () => {
diff --git a/src/pages/shop/components/product-car.vue b/src/pages/shop/components/product-cart.vue
similarity index 63%
rename from src/pages/shop/components/product-car.vue
rename to src/pages/shop/components/product-cart.vue
index d75f2fb..998380c 100644
--- a/src/pages/shop/components/product-car.vue
+++ b/src/pages/shop/components/product-cart.vue
@@ -6,27 +6,28 @@
title="购物车"
position="bottom"
size="60%"
+ bgColor="#ECF4F9"
@close="doClose"
>
emit('add', v)"
@remove="(v) => emit('remove', v)"
/>
-
+
@@ -38,28 +39,26 @@ import { filePath } from "@/sheep/utils/file"
import ProductRow from "./product-row.vue"
import ProductTotal from "./product-total.vue"
-const emit = defineEmits(["update:modelValue", "doPay", "add", "remove"])
+const emit = defineEmits(["update:modelValue", "add", "remove", "submit"])
-export type Props = {
- modelValue: any
- carList: any
- totPrice: number
- totCount: number
-}
-const props = withDefaults(defineProps(), {
- modelValue: false,
- carList: [],
- totPrice: 0,
- totCount: 0,
-})
+const props = withDefaults(
+ defineProps<{
+ modelValue: any
+ cartList: any
+ totPrice: number
+ totCount: number
+ }>(),
+ {
+ modelValue: false,
+ cartList: [],
+ totPrice: 0,
+ totCount: 0,
+ },
+)
-const doClose = () => {
- emit("update:modelValue", false)
-}
+const doClose = () => emit("update:modelValue", false)
-const doPay = () => {
- emit("doPay")
-}
+const doPay = () => emit("submit")
const getHeight = () => {
const { bottom } = uni.getSystemInfoSync().safeAreaInsets!
diff --git a/src/pages/shop/components/product-row.vue b/src/pages/shop/components/product-row.vue
index 17866d2..4b0b92f 100644
--- a/src/pages/shop/components/product-row.vue
+++ b/src/pages/shop/components/product-row.vue
@@ -1,46 +1,45 @@
-
+
{{ props.productName }}
- 规格:{{ "" + props.spec + props.unit }}
-
-
-
-
-
- ¥{{ (Number(productPrice) / 100).toFixed(2) }}
- x{{ productCount }}
+
+ ¥{{ hooks.useMoney(props.promotionPrice) }}
+ ¥{{ hooks.useMoney(props.retailPrice) }}
+ 单位:{{ props.unit }}
{{ hooks.useFormatNum("库存", "", props.stock) }}
-
+
{{ hooks.useFormatNum("销量", "", props.salesCount) }}
+
+
+ ¥{{ hooks.useMoney(productPrice) }}
+ x {{ productCount }}
+
+
加入购物车
-
-
-
-
- {{ productCount }}
-
-
+
+ ¥{{ hooks.useMoney(totalPrice) }}
+
+
+
+
+ {{ productCount }}
+
+
+
@@ -50,49 +49,53 @@
-
-
diff --git a/src/pages/shop/components/product-sku.vue b/src/pages/shop/components/product-sku.vue
index 2b88015..d2daab7 100644
--- a/src/pages/shop/components/product-sku.vue
+++ b/src/pages/shop/components/product-sku.vue
@@ -5,70 +5,61 @@
showFooter
title="加入购物车"
position="bottom"
- size="60%"
+ size="70%"
+ bgColor="#ECF4F9"
+ :duration="100"
@close="doClose"
>
-
-
-
-
-
-
-
- {{ state.goodsDetail.productName }}
-
-
-
- 售价¥{{ retailPrice }}
- 促销价¥{{ promotionPrice }}
-
-
- 库存{{ state.goodsDetail.stock }}
- 已售{{ state.goodsDetail.salesCount }}
-
+
+
+
+ 商品信息
+
+
+
+ {{ state.goodsDetail.productName }}
+
+ 促销 ¥{{ state.selectedSku.promotionPrice }}
+ 原价 ¥{{ state.selectedSku.retailPrice }}
+ 内装数量:{{ state.selectedSku.packageNum }}
+
-
-
- 规格
+
+
+ 包装单位
-
-
-
-
-
- 购买数量
-
-
-
-
-
- {{ String(state.goodsCount).padStart(2, "0") }}
-
-
-
+ {{ v.spec + " " + v.unit }}
-
-
+
+
+
+
+ 购买数量
+
+
+
+
+ {{ String(state.goodsCount).padStart(2, "0") }}
+
+
+
+
+
+
-
+
@@ -77,38 +68,37 @@
import { shopApi } from "@/sheep/api"
import { filePath } from "@/sheep/utils/file"
import { computed, reactive, watch } from "vue"
+import { hooks } from "@@/index"
-const emit = defineEmits(["update:modelValue", "onAddToCar"])
+const emit = defineEmits(["update:modelValue", "onSkuAddToCart"])
+
+const props = withDefaults(
+ defineProps<{
+ modelValue: boolean
+ productData: any
+ }>(),
+ {
+ modelValue: false,
+ productData: {},
+ },
+)
-export type Props = {
- modelValue: boolean
- productData: any
- onAddToCar?: () => void
-}
-const props = withDefaults(defineProps(), {
- modelValue: false,
- productData: {},
-})
const state = reactive({
goodsCount: 1,
- selectedSku: {},
+ selectedSku: {
+ retailPrice: 0,
+ promotionPrice: 0,
+ packageNum: 0,
+ },
goodsDetail: {},
})
-// 售价
-const retailPrice = computed(() =>
- state.selectedSku.retailPrice ? Number(state.selectedSku.retailPrice) * Number(state.goodsCount) : 0,
-)
-// 优惠价
-const promotionPrice = computed(() =>
- state.selectedSku.promotionPrice ? Number(state.selectedSku.promotionPrice) * Number(state.goodsCount) : 0,
-)
watch(
() => props.modelValue,
async (newValue) => {
if (newValue) {
// 获取商品详情
- const { data } = await shopApi.getSupermarketSpuDetail({ id: props.productData.productId })
+ const { data } = await shopApi.getSupermarketSpuDetail({ id: props.productData.id })
state.goodsDetail = data
if (data.skuList.length > 0) {
state.selectedSku = state.goodsDetail.skuList[0]
@@ -117,122 +107,37 @@ watch(
},
)
-// SKU 列表
-// const skuList = computed(() => {
-// let skuPrices = props.goodsInfo.skus;
-// for (let price of skuPrices) {
-// price.value_id_array = price.properties.map((item) => item.valueId);
-// }
-// return skuPrices;
-// });
-
-// 当前所选属性下,获取所有有库存的 SKU 们
-// function getCanUseSkuList() {
-// let newSkus = [];
-// for (let sku of skuList.value) {
-// if (sku.stock <= 0) {
-// continue;
-// }
-// let isOk = true;
-// state.currentPropertyArray.forEach((propertyId) => {
-// // propertyId 不为空,并且,这个 条 sku 没有被选中,则排除
-// if (propertyId.toString() !== "" && sku.value_id_array.indexOf(propertyId) < 0) {
-// isOk = false;
-// }
-// });
-// if (isOk) {
-// newSkus.push(sku);
-// }
-// }
-// return newSkus;
-// }
-
-// 选择规格
-function onSelectSku(skuItem: any) {
- // const index = state.currentPropertyArray.findIndex((item: any) => item.id === skuItem.id);
- // if (index === -1) {
+// 选择规格/取消选择规格
+const onSelectSku = (skuItem: any) => {
if (state.selectedSku.id === skuItem.id) {
state.selectedSku = {}
- } else {
- state.selectedSku = skuItem
+ return
}
- // } else {
- // state.currentPropertyArray.splice(index, 1);
- // }
-
- // 清空已选择
- // let isChecked = true; // 选中 or 取消选中
- // if (state.currentPropertyArray[propertyId] !== undefined && state.currentPropertyArray[propertyId] === valueId) {
- // 点击已被选中的,删除并填充 ''
- // isChecked = false;
- // state.currentPropertyArray.splice(propertyId, 1, "");
- // } else {
- // 选中
- // state.currentPropertyArray[propertyId] = valueId;
- // }
- // 选中的 property 大类
- // let choosePropertyId: any = [];
- // state.currentPropertyArray.forEach((currentPropertyId: string) => {
- // if (currentPropertyId !== "") {
- // // currentPropertyId 为空是反选 填充的
- // choosePropertyId.push(currentPropertyId);
- // }
- // });
- // 当前所选 property 下,所有可以选择的 SKU 们
- // let newSkuList = getCanUseSkuList();
- // 判断所有 property 大类是否选择完成
- // if (choosePropertyId.length === skuData.length && newSkuList.length) {
- // newSkuList[0].name = state.selectedSku.goods_num || 1;
- // state.selectedSku = newSkuList[0];
- // } else {
- // state.selectedSku = {};
- // }
- // if (choosePropertyId.length === skuData.value.length) {
- // state.selectedSku = state.currentPropertyArray;
- // }
- // 改变 property 禁用状态
- // changeDisabled(isChecked, propertyId, valueId);
+ state.selectedSku = skuItem
}
// 加数量
const handleNumAdd = () => {
- if (state.goodsCount >= state.goodsDetail.stock) {
- return
- }
+ if (state.goodsCount >= state.goodsDetail.stock) return uni.showToast({ title: "库存不足", icon: "none" })
state.goodsCount += 1
}
// 减数量
const handleNumRemove = () => {
- if (state.goodsCount <= 1) {
- return
- }
+ if (state.goodsCount <= 1) return
state.goodsCount -= 1
}
-// 点击加入购物车
-const handleClickAddToCar = async () => {
- // 检查规格选择
- if (!state.selectedSku.id) {
- uni.showToast({
- title: "请选择规格",
- icon: "none",
- duration: 1000,
- })
- return
- }
+// 点击sku加入到购物车
+const handleSkuAddToCar = async () => {
+ // 检查包装单位选择
+ if (!state.selectedSku.id) return uni.showToast({ title: "请选择包装单位", icon: "none" })
+
// 检查库存
try {
uni.showLoading({ title: "加载中", mask: true })
- const { code }: any = await shopApi.checkSpuStock({
- spuId: state.goodsDetail.id,
- incrCount: state.goodsCount,
- })
+ const { code }: any = await shopApi.checkSpuStock({ spuId: state.goodsDetail.id, incrCount: state.goodsCount })
if (code != 0) {
- return uni.showToast({
- title: "库存不足",
- icon: "none",
- duration: 1000,
- })
+ return uni.showToast({ title: "库存不足", icon: "none" })
}
} catch (e) {
console.error(e)
@@ -240,22 +145,20 @@ const handleClickAddToCar = async () => {
uni.hideLoading()
}
// 检查库存
- if (state.goodsDetail.stock === 0) {
- uni.showToast({
- title: "库存不足",
- icon: "none",
- duration: 1000,
- })
- return
- }
- emit("onAddToCar", { ...state.goodsDetail, productCount: state.goodsCount, productId: state.selectedSku.id })
+ if (state.goodsDetail.stock === 0) return uni.showToast({ title: "库存不足", icon: "none" })
+
+ emit("onSkuAddToCart", { ...state.goodsDetail, productCount: state.goodsCount, productId: state.selectedSku.id })
}
const doClose = () => {
emit("update:modelValue", false)
state.goodsCount = 1
- state.selectedSku = {}
+ state.selectedSku = {
+ retailPrice: 0,
+ promotionPrice: 0,
+ packageNum: 0,
+ }
state.goodsDetail = {}
}
diff --git a/src/pages/shop/components/product-total.vue b/src/pages/shop/components/product-total.vue
index 76e4e26..41b66f2 100644
--- a/src/pages/shop/components/product-total.vue
+++ b/src/pages/shop/components/product-total.vue
@@ -1,37 +1,37 @@
-
-
-
-
-
-
- ¥ {{ hooks.useMoney(props.totPrice) }}
- 共{{ props.totCount }}件
-
-
- 提交订单
-
+
+
+
+
+
+
+ ¥ {{ hooks.useMoney(props.totPrice) }}
+ 共{{ props.totCount }}件
+
+
+ 提交订单
+
diff --git a/src/pages/shop/components/select-sku.vue b/src/pages/shop/components/select-sku.vue
deleted file mode 100644
index 3eeb8c3..0000000
--- a/src/pages/shop/components/select-sku.vue
+++ /dev/null
@@ -1,447 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
- {{ property.name }}
-
-
-
-
-
- 购买数量
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/src/pages/shop/detail.vue b/src/pages/shop/detail.vue
index f9909e4..eaae7fb 100644
--- a/src/pages/shop/detail.vue
+++ b/src/pages/shop/detail.vue
@@ -66,15 +66,12 @@
:borderColor="['#89c0ff']"
>
-
-
-
-
-
+
+
-
-
+
+
-
-
+