diff --git a/src/pages.json b/src/pages.json
index 19e9be6..309fe12 100644
--- a/src/pages.json
+++ b/src/pages.json
@@ -60,10 +60,6 @@
}
],
"subPackages": [
- {
- "root": "pages/order",
- "pages": []
- },
{
"root": "pages/shop",
"pages": [
diff --git a/src/pages/merchant/components/product-car.vue b/src/pages/merchant/components/product-car.vue
deleted file mode 100644
index d8e464e..0000000
--- a/src/pages/merchant/components/product-car.vue
+++ /dev/null
@@ -1,78 +0,0 @@
-
-
-
-
-
- emit('add', v)" @remove="emit('remove', v)" />
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/src/pages/merchant/components/product-cart.vue b/src/pages/merchant/components/product-cart.vue
new file mode 100644
index 0000000..65800db
--- /dev/null
+++ b/src/pages/merchant/components/product-cart.vue
@@ -0,0 +1,62 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/pages/merchant/components/product-row.vue b/src/pages/merchant/components/product-row.vue
index 625d967..7a7f1c5 100644
--- a/src/pages/merchant/components/product-row.vue
+++ b/src/pages/merchant/components/product-row.vue
@@ -1,28 +1,24 @@
-
+
{{ props.name }}
- ¥{{ hooks.useMoney(props.price) }}
-
- ¥{{ hooks.useMoney(props.marketPrice) }}
-
+ ¥{{ hooks.useMoney(props.price) }}
+ ¥{{ hooks.useMoney(props.marketPrice) }}
+ x{{ props.count }}
- x{{ props.count }}
{{ hooks.useFormatNum("库存", "", props.stock) }}
-
+
{{ hooks.useFormatNum("销量", "", props.salesCount) }}
-
+
{{ props.modelValue }}
@@ -92,9 +74,3 @@ const remove = () => {
-
-
diff --git a/src/pages/merchant/components/product-total.vue b/src/pages/merchant/components/product-total.vue
index 8a5aef4..e5c2cbb 100644
--- a/src/pages/merchant/components/product-total.vue
+++ b/src/pages/merchant/components/product-total.vue
@@ -1,59 +1,37 @@
-
-
-
-
-
-
-
- ¥ {{ hooks.useMoney(props.totPrice) }}
- 共{{ props.totCount }}件
-
-
-
- 购买
-
-
+
+
+
+
+
+
+ ¥ {{ hooks.useMoney(props.totPrice) }}
+ 共{{ props.totCount }}件
+
+
+ 购买
+
-
-
\ No newline at end of file
diff --git a/src/pages/merchant/detail.vue b/src/pages/merchant/detail.vue
index f51ca1b..b1f6500 100644
--- a/src/pages/merchant/detail.vue
+++ b/src/pages/merchant/detail.vue
@@ -7,21 +7,23 @@ import { merchantApi, foodApi, payApi } from "@@/api"
import { filePath } from "@@/utils/file"
import ProductRow from "./components/product-row.vue"
-import ProductCar from "./components/product-car.vue"
+import ProductCart from "./components/product-cart.vue"
import ProductTotal from "./components/product-total.vue"
const state = reactive({
detailId: null,
canteenDetail: {},
+ foodList: [],
+
+ cartList: [],
totPrice: 0,
totCount: 0,
- currentClassifyIndex: 0,
- showCarDialog: false,
- carList: [],
classifyList: [],
- shopList: [],
+ currentClassifyIndex: 0,
+
+ showCartDialog: false,
})
onLoad((options: any) => {
@@ -31,10 +33,15 @@ onLoad((options: any) => {
})
onShow(() => {
getDetail()
- getShopCar()
+ getFoodCart()
getClassify()
})
+const getHeight = () => {
+ const rpx = 480
+ return `calc(100vh - ${uni.upx2px(rpx)}px)`
+}
+
// 获取食堂详情信息
const getDetail = async () => {
uni.showLoading({ title: "加载中...", mask: true })
@@ -43,46 +50,46 @@ const getDetail = async () => {
uni.hideLoading()
}
-const getShopCar = async () => {
+// 获取购物车信息
+const getFoodCart = async () => {
const { data } = await foodApi.getShopCar({ merchantId: state.detailId, hardType: "CANTEEN" })
- state.carList = data ?? []
- if (isEmpty(state.carList)) {
- state.shopList.forEach((v: any) => {
+ state.cartList = data ?? []
+ if (isEmpty(state.cartList)) {
+ state.foodList.forEach((v: any) => {
v.productCount = 0
})
} else {
- asyncCarCount(state.shopList)
+ syncCartCount(state.foodList)
}
- state.totPrice = state.carList.map((v) => Number(v.totalPrice)).reduce((pre, next) => pre + next, 0)
- state.totCount = state.carList.map((v) => v.productCount).reduce((pre, next) => pre + next, 0)
+ state.totPrice = state.cartList.map((v) => Number(v.totalPrice)).reduce((pre, next) => pre + next, 0)
+ state.totCount = state.cartList.map((v) => v.productCount).reduce((pre, next) => pre + next, 0)
}
-const getClassify = async () => {
- const _pa = { merchantId: state.detailId }
- const { data } = await foodApi.classify(_pa)
- state.classifyList = data
- if (!isEmpty(state.classifyList)) {
- getPorduct()
- }
-}
-
-const updateShopCar = async () => {
- if (isEmpty(state.carList)) return
- const list = state.carList
- .filter((v) => v.productCount !== undefined && v.productCount >= 0)
- .map((v) => {
- return {
- productCount: v.productCount,
- productId: v.productId,
+// 同步购物车购买数量
+const syncCartCount = (foodList: any) => {
+ if (state.cartList && state.cartList.length) {
+ for (const i of foodList) {
+ for (const v of state.cartList) {
+ if (i.id == v.productId) {
+ i.productCount = v.productCount
+ }
}
- })
- if (isEmpty(list)) return
- const _pa = { merchantId: state.detailId, list: list, hardType: "CANTEEN" }
- const { data, code }: any = await foodApi.updateShopCar(_pa)
- if (code == 0) await getShopCar()
+ }
+ }
+ state.foodList = foodList
}
-const getPorduct = async () => {
+// 获取菜品分类
+const getClassify = async () => {
+ const { data } = await foodApi.classify({ merchantId: state.detailId })
+ state.classifyList = data ?? []
+ if (!isEmpty(state.classifyList)) {
+ getFoodList()
+ }
+}
+
+// 获取食物列表
+const getFoodList = async () => {
const target = state.classifyList[state.currentClassifyIndex]
if (isEmpty(target)) return
const _pa = {
@@ -94,51 +101,31 @@ const getPorduct = async () => {
i.productCount = 0
i.productId = i.id
})
- asyncCarCount(data)
+ syncCartCount(data)
}
-// 同步购买数量
-const asyncCarCount = (shopList) => {
- if (state.carList && state.carList.length) {
- for (const i of shopList) {
- for (const v of state.carList) {
- if (i.id == v.productId) {
- i.productCount = v.productCount
- }
- }
- }
- }
- state.shopList = shopList
+// 切换选中的分类
+const doClassify = (i: any) => {
+ state.currentClassifyIndex = i
+ getClassify()
}
-const doAdd = async (item: any) => {
- chentProductCount(item, "add")
-}
-
-const remove = async (item: any) => {
- chentProductCount(item, "remove")
-}
-
-const chentProductCount = async (item: any, type: "add" | "remove") => {
+// 设置购物车商品的数量
+const chentProductCartCount = async (item: any) => {
try {
uni.showLoading({ title: "加载中", mask: true })
- let count = item.productCount
- if (type === "add") {
- count += 1
- const { code }: any = await foodApi.checkSpuStock({ spuId: item.productId, incrCount: count })
- if (code != 0) throw new Error()
- } else if (type === "remove") {
- count -= 1
- }
- const target = state.carList.find((v) => v.productId == item.productId)
- const targetIndex = state.carList.findIndex((v) => v.productId == item.productId)
- if (target) {
- state.carList[targetIndex].productCount = count
+ // 检查商品库存
+ const { code }: any = await foodApi.checkSpuStock({ spuId: item.productId, incrCount: item.productCount })
+ if (code != 0) throw new Error()
+
+ const targetIndex = state.cartList.findIndex((v) => v.productId == item.productId)
+ if (targetIndex !== -1) {
+ state.cartList[targetIndex].productCount = item.productCount
} else {
- state.carList.push({ ...item, productId: item.id, productCount: count })
+ state.cartList.push({ ...item, productId: item.id, productCount: item.productCount })
}
nextTick(async () => {
- await updateShopCar()
+ await updateFoodCart()
})
} catch (e) {
console.error(e)
@@ -147,52 +134,57 @@ const chentProductCount = async (item: any, type: "add" | "remove") => {
}
}
-const doClassify = (i: any) => {
- state.currentClassifyIndex = i
- getClassify()
+// 保存购物车商品
+const updateFoodCart = async () => {
+ if (isEmpty(state.cartList)) return
+ const list = state.cartList
+ .filter((v) => v.productCount !== undefined && v.productCount >= 0)
+ .map((v) => {
+ return {
+ productCount: v.productCount,
+ productId: v.productId,
+ }
+ })
+ if (isEmpty(list)) return
+ const _pa = { merchantId: state.detailId, list: list, hardType: "CANTEEN" }
+ const { data, code }: any = await foodApi.updateShopCar(_pa)
+ if (code == 0) await getFoodCart()
}
-const doVisibleCar = async () => {
- state.showCarDialog = true
-}
+// 打开购物车
+const doVisibleCart = async () => (state.showCartDialog = true)
-const submitPay = async () => {
- try {
- if (isEmpty(state.carList)) {
- uni.showToast({ title: "请至少购买一件商品", icon: "none" })
- return
- }
- uni.showLoading({ title: "支付中...", mask: false })
- const _createtPa = {
- carParentId: state.carList[0].parentCarId,
- hardType: "CANTEEN",
- }
- const { data: createData, code: createCode }: any = await payApi.createHardwareOrder(_createtPa)
- if (createCode != 0) throw new Error()
- uni.hideLoading()
- uni.showToast({ title: "支付成功", icon: "none" })
- router.jump("/pages/tabbar/order")
- } catch (error) {
- console.error(error)
- uni.hideLoading()
- }
-}
-
-const doPay = async () => {
+// 购买
+const doBuy = async () => {
uni.showModal({
title: "提示",
content: "是否确定购买",
confirmColor: "#0094ff",
success: async (res) => {
if (!res.confirm) return
- submitPay()
+ submitBuy()
},
})
}
-const getHeight = () => {
- const rpx = 480
- return `calc(100vh - ${uni.upx2px(rpx)}px)`
+// 确认购买
+const submitBuy = async () => {
+ try {
+ if (isEmpty(state.cartList)) return uni.showToast({ title: "请至少购买一件商品", icon: "none" })
+ uni.showLoading({ title: "支付中...", mask: true })
+ const _createtPa = {
+ carParentId: state.cartList[0].parentCarId,
+ hardType: "CANTEEN",
+ }
+ const { data: createData, code: createCode }: any = await payApi.createHardwareOrder(_createtPa)
+ if (createCode != 0) throw new Error()
+ uni.showToast({ title: "支付成功", icon: "none" })
+ router.jump("/pages/tabbar/order")
+ } catch (error) {
+ console.error(error)
+ } finally {
+ uni.hideLoading()
+ }
}
const doPhone = () => {
@@ -202,6 +194,7 @@ const doPhone = () => {
}
hooks.useMakePhoneCall(state.canteenDetail.phone)
}
+
const doFood = () => {
router.jump("/pages/merchant/food", { merchantId: state.detailId })
}
@@ -307,11 +300,10 @@ const doFood = () => {
-
-
+
+
{
:marketPrice="pV.marketPrice"
:salesCount="pV.salesCount"
:stock="pV.stock"
- @add="doAdd(pV)"
- @remove="remove(pV)"
+ @add="chentProductCartCount(pV)"
+ @remove="chentProductCartCount(pV)"
/>
@@ -332,18 +324,19 @@ const doFood = () => {
-
+
- chentProductCartCount(v)"
+ @remove="(v) => chentProductCartCount(v)"
+ @submit="doBuy"
/>
diff --git a/src/pages/order/detail.vue b/src/pages/order/detail.vue
index fbf3350..4aa47ac 100644
--- a/src/pages/order/detail.vue
+++ b/src/pages/order/detail.vue
@@ -61,7 +61,7 @@ const doCancelRefund = async () => {
const data = refundApi.cancel(_pa)
uni.hideLoading()
uni.showToast({ title: "取消成功", icon: "none" })
- router.jump("/pages/tabbar/order", {}, 2)
+ router.jump("/pages/tabbar/individualOrder", {}, 2)
},
})
}
@@ -198,14 +198,14 @@ const doCancelRefund = async () => {
取消申请
diff --git a/src/pages/refund/apply.vue b/src/pages/refund/apply.vue
index 848c33e..d1447f9 100644
--- a/src/pages/refund/apply.vue
+++ b/src/pages/refund/apply.vue
@@ -20,6 +20,7 @@ const state = reactive({
shopCarList: [],
setting: {},
selectList: [],
+ header: "",
})
const uploadApplyPicUrls = ref | string>>([]) // 补充凭证图片
const applyPicUrls = computed(() => uploadApplyPicUrls.value.map((item: any) => JSON.parse(item.response).data.url).join(","))
@@ -35,12 +36,12 @@ onLoad((options: any) => {
if (!isEmpty(options.id)) {
state.detailId = options.id
}
- state.header = hooks.useDefaultHeader()
})
onShow(() => {
getDetail()
getSetting()
getShopCarList()
+ state.header = hooks.useDefaultHeader()
})
const getSetting = async () => {
diff --git a/src/pages/tabbar/flowStatistics.vue b/src/pages/tabbar/flowStatistics.vue
index d622e2d..a398ffb 100644
--- a/src/pages/tabbar/flowStatistics.vue
+++ b/src/pages/tabbar/flowStatistics.vue
@@ -26,22 +26,10 @@
v-model:model-str="state.formatVal"
@confirm="datePickerConfirm"
format="YYYY-MM-DD"
+ :quickDate="[]"
+ :drawerSize="900"
>
-
+
筛选
@@ -66,7 +54,7 @@
流水次数
- {{ v.totalPayCount }}
+ {{ v.totalPayCount || 0 }}
@@ -76,7 +64,7 @@
盈利次数
- {{ v.totalProfitCount }}
+ {{ v.totalProfitCount || 0 }}
diff --git a/src/pages/tabbar/individualOrder.vue b/src/pages/tabbar/individualOrder.vue
index fd6e0b2..6c5251a 100644
--- a/src/pages/tabbar/individualOrder.vue
+++ b/src/pages/tabbar/individualOrder.vue
@@ -15,8 +15,20 @@
>
-
+
+
+ 筛选
+
@@ -59,9 +71,12 @@
-
- 申请退款
-
+
+ 售后详情
+
+ 申请退款
+
+
@@ -218,7 +233,7 @@
-
-
-
-
-
-
-
+
+
+
+
+
+
+ 取消
+
+ 确定
+
+
+
-
\ No newline at end of file