diff --git a/package.json b/package.json
index d41bb0c..1d34db9 100644
--- a/package.json
+++ b/package.json
@@ -87,4 +87,4 @@
"vite": "5.2.8",
"vue-tsc": "^1.0.24"
}
-}
+}
\ No newline at end of file
diff --git a/src/pages/merchant/components/product-row.vue b/src/pages/merchant/components/product-row.vue
index dafd6ed..625d967 100644
--- a/src/pages/merchant/components/product-row.vue
+++ b/src/pages/merchant/components/product-row.vue
@@ -1,6 +1,6 @@
-
-
-
-
-
- {{ props.name }}
-
-
- ¥{{ hooks.useMoney(props.price) }}
-
-
- ¥{{ hooks.useMoney(props.marketPrice) }}
-
-
-
- x{{ props.count }}
-
-
- {{ hooks.useFormatNum("库存", "", props.stock) }}
-
- {{ hooks.useFormatNum("销量", "", props.salesCount) }}
-
-
-
-
-
- {{ props.modelValue }}
-
-
-
-
-
-
+
+
+
+
+ {{ props.name }}
+
+ ¥{{ hooks.useMoney(props.price) }}
+
+ ¥{{ hooks.useMoney(props.marketPrice) }}
+
+
+ x{{ props.count }}
+
+ {{ hooks.useFormatNum("库存", "", props.stock) }}
+
+ {{ hooks.useFormatNum("销量", "", props.salesCount) }}
+
+
+
+
+
+ {{ props.modelValue }}
+
+
+
+
+
+
\ No newline at end of file
+
diff --git a/src/pages/merchant/detail.vue b/src/pages/merchant/detail.vue
index 683cc88..906b282 100644
--- a/src/pages/merchant/detail.vue
+++ b/src/pages/merchant/detail.vue
@@ -50,7 +50,13 @@ const getShopCar = async () => {
const _pa = { merchantId: state.detailId, hardType: "CANTEEN" }
const { data } = await foodApi.getShopCar(_pa)
state.carList = data ?? []
- asyncCarCount(state.shopList)
+ if (isEmpty(state.carList)) {
+ state.shopList.forEach((v: any) => {
+ v.productCount = 0
+ })
+ } else {
+ asyncCarCount(state.shopList)
+ }
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)
}
@@ -110,22 +116,39 @@ const asyncCarCount = (shopList) => {
}
const doAdd = async (item: any) => {
- chentProductCount(item)
+ chentProductCount(item, "add")
}
const remove = async (item: any) => {
- chentProductCount(item)
+ chentProductCount(item, "remove")
}
-const chentProductCount = async (item: any) => {
- 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 = item.productCount
- } else {
- state.carList.push({ ...item, productId: item.id })
+const chentProductCount = async (item: any, type: "add" | "remove") => {
+ 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
+ } else {
+ state.carList.push({ ...item, productId: item.id, productCount: count })
+ }
+ nextTick(async () => {
+ await updateShopCar()
+ })
+ } catch (e) {
+ console.error(e)
+ } finally {
+ uni.hideLoading()
}
- nextTick(() => updateShopCar())
}
const doClassify = (i: any) => {
diff --git a/src/pages/merchant/index.vue b/src/pages/merchant/index.vue
index 1f8b76e..57a4924 100644
--- a/src/pages/merchant/index.vue
+++ b/src/pages/merchant/index.vue
@@ -1,33 +1,23 @@
-
-
-
-
+
-
\ No newline at end of file
+
diff --git a/src/pages/shop/components/product-car.vue b/src/pages/shop/components/product-car.vue
index 46dd417..d75f2fb 100644
--- a/src/pages/shop/components/product-car.vue
+++ b/src/pages/shop/components/product-car.vue
@@ -13,11 +13,14 @@
v-for="v in carList"
:key="v.id"
:productId="v.productId"
+ :spuId="v.spuId"
:merchantId="v.merchantId"
- :picUrl="v.productPic"
+ :picUrl="filePath(v.productPic)"
:productName="v.productName"
:productCount="v.productCount"
:productPrice="v.productPrice"
+ :spec="v.spec"
+ :unit="v.unit"
@add="(v) => emit('add', v)"
@remove="(v) => emit('remove', v)"
/>
@@ -31,6 +34,7 @@
diff --git a/src/pages/shop/components/product-sku.vue b/src/pages/shop/components/product-sku.vue
index db6885d..2b88015 100644
--- a/src/pages/shop/components/product-sku.vue
+++ b/src/pages/shop/components/product-sku.vue
@@ -110,6 +110,9 @@ watch(
// 获取商品详情
const { data } = await shopApi.getSupermarketSpuDetail({ id: props.productData.productId })
state.goodsDetail = data
+ if (data.skuList.length > 0) {
+ state.selectedSku = state.goodsDetail.skuList[0]
+ }
}
},
)
@@ -191,12 +194,14 @@ function onSelectSku(skuItem: any) {
// changeDisabled(isChecked, propertyId, valueId);
}
+// 加数量
const handleNumAdd = () => {
if (state.goodsCount >= state.goodsDetail.stock) {
return
}
state.goodsCount += 1
}
+// 减数量
const handleNumRemove = () => {
if (state.goodsCount <= 1) {
return
@@ -205,18 +210,39 @@ const handleNumRemove = () => {
}
// 点击加入购物车
-const handleClickAddToCar = () => {
- if (state.goodsDetail.stock === 0) {
+const handleClickAddToCar = async () => {
+ // 检查规格选择
+ if (!state.selectedSku.id) {
uni.showToast({
- title: "库存不足",
+ title: "请选择规格",
icon: "none",
duration: 1000,
})
return
}
- if (!state.selectedSku.id) {
+ // 检查库存
+ try {
+ uni.showLoading({ title: "加载中", mask: true })
+ const { code }: any = await shopApi.checkSpuStock({
+ spuId: state.goodsDetail.id,
+ incrCount: state.goodsCount,
+ })
+ if (code != 0) {
+ return uni.showToast({
+ title: "库存不足",
+ icon: "none",
+ duration: 1000,
+ })
+ }
+ } catch (e) {
+ console.error(e)
+ } finally {
+ uni.hideLoading()
+ }
+ // 检查库存
+ if (state.goodsDetail.stock === 0) {
uni.showToast({
- title: "请选择规格",
+ title: "库存不足",
icon: "none",
duration: 1000,
})
diff --git a/src/pages/shop/detail.vue b/src/pages/shop/detail.vue
index 38025ff..7979162 100644
--- a/src/pages/shop/detail.vue
+++ b/src/pages/shop/detail.vue
@@ -3,8 +3,8 @@
-
-
+
+
@@ -14,7 +14,7 @@
-
+
@@ -24,6 +24,7 @@
{{ state.detail.deptName }}
+ {{ state.detail.phone }}
营业时间
@@ -32,18 +33,17 @@
{{ state.detail.jobEndTime }}
-
- 超市地址
+
+ 地址
{{ state.detail.addressDes }}
-
-
+
@@ -185,6 +185,8 @@ const getPorduct = async () => {
// productName: target.name,
merchantId: state.merchantId,
categoryId: target.id,
+ current: 1,
+ size: 9999,
})
state.goodsList = data.records
// state.goodsList.forEach((i) => {
@@ -235,19 +237,38 @@ const onAddToCar = (cartGoodsInfo: any) => {
showSkuDialog.value = false
}
// 同步购物车中的数据
-const chentProductCount = async (item: any) => {
- 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 = item.productCount
- state.carList[targetIndex].productId = item.productId
- console.log("1", state.carList[targetIndex])
- } else {
- state.carList.push(item)
- console.log("2", item)
- }
+const chentProductCount = async (item: any, type?: "add" | "remove") => {
+ try {
+ console.log("ccccccc", item)
- nextTick(() => updateShopCar()) // 保存购物车数据
+ uni.showLoading({ title: "加载中", mask: true })
+ let count = item.productCount
+ if (type === "add") {
+ count += 1
+ const { code }: any = await shopApi.checkSpuStock({ spuId: item.spuId, 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
+ state.carList[targetIndex].productId = item.productId
+ state.carList[targetIndex].spuId = item.spuId
+ console.log("1", state.carList[targetIndex])
+ } else {
+ state.carList.push(item)
+ console.log("2", item)
+ }
+
+ nextTick(async () => await updateShopCar()) // 保存购物车数据
+ } catch (e) {
+ console.error(e)
+ } finally {
+ uni.hideLoading()
+ }
}
// 保存购物车数据
const updateShopCar = async () => {
@@ -277,10 +298,10 @@ const doVisibleCar = async () => {
}
const doAdd = async (item: any) => {
- chentProductCount(item)
+ chentProductCount(item, "add")
}
const doRemove = async (item: any) => {
- chentProductCount(item)
+ chentProductCount(item, "remove")
}
// 点击提交订单
diff --git a/src/pages/tabbar/my.vue b/src/pages/tabbar/my.vue
index 5f8f6b3..86c1b1d 100644
--- a/src/pages/tabbar/my.vue
+++ b/src/pages/tabbar/my.vue
@@ -1,171 +1,184 @@
-
-
-
-
-
-
- {{ state.userInfo?.sysUser?.name }}
-
-
- ID {{ state.userInfo?.sysUser?.userId }}
-
-
- 请先登录
-
-
-
+
+
+
+
+
+
+ {{ state.userInfo?.sysUser?.name }}
+
+
+ ID {{ state.userInfo?.sysUser?.userId }}
+
+
+ 请先登录
+
+
+
-
-
-
-
- {{ v.text }}
-
-
-
-
+
+
+
+
+ {{ v.text }}
+
+
+
+
-
-
- 退出登录
-
-
-
+
+
+ 退出登录
+
+
+
diff --git a/src/pages/tabbar/order.vue b/src/pages/tabbar/order.vue
index 314d4e4..a687daf 100644
--- a/src/pages/tabbar/order.vue
+++ b/src/pages/tabbar/order.vue
@@ -15,7 +15,7 @@ const data = {
{ id: 1, name: "未支付", disabled: false },
{ id: 5, name: "待核销", disabled: false },
{ id: 10, name: "售后", disabled: false },
- { id: 15, name: "已核销", disabled: false },
+ { id: 20, name: "已核销", disabled: false },
],
}
const state = reactive({
@@ -98,8 +98,8 @@ const doRefund = (v: any) => {
未支付
待核销
- 售后中
- 已核销
+ 售后
+ 已核销
diff --git a/src/pages/tabbar/shop.vue b/src/pages/tabbar/shop.vue
index 7d06868..ff1aebd 100644
--- a/src/pages/tabbar/shop.vue
+++ b/src/pages/tabbar/shop.vue
@@ -1,94 +1,83 @@
-
-
-
-
-
-
-
-
- {{ v.name }}
-
-
- {{ v.deptName }}
-
-
-
-
- 2.5
-
-
- 营业时间
-
- {{ v.jobStartTime }}
- ~
- {{ v.jobEndTime }}
-
- 22km
-
-
- 地址
- {{ v.addressDes }}
-
-
-
-
-
- 推荐理由:
-
- 实力评分,资历好,规模大。实力评分,资历好,规模大。实力评分,资历好,规模大。
-
-
-
-
-
+
+
+
+
+
+
+
+
+ {{ v.name }}
+
+
+ {{ v.deptName }}
+
+
+ {{ v.phone }}
+
+ 营业时间
+
+ {{ v.jobStartTime }}
+ ~
+ {{ v.jobEndTime }}
+
+
+
+ 地址
+ {{ v.addressDes }}
+
+
+
+
+
+
diff --git a/src/pages/wallet/apply-detail.vue b/src/pages/wallet/apply-detail.vue
index 1f8b76e..57a4924 100644
--- a/src/pages/wallet/apply-detail.vue
+++ b/src/pages/wallet/apply-detail.vue
@@ -1,33 +1,23 @@
-
-
-
-
+
-
\ No newline at end of file
+
diff --git a/src/pages/wallet/detail.vue b/src/pages/wallet/detail.vue
index 4cdcbe0..5033e4e 100644
--- a/src/pages/wallet/detail.vue
+++ b/src/pages/wallet/detail.vue
@@ -1,6 +1,6 @@
-
-
-
-
-
-
-
-
-
-
-
- {{ v.title }}
- 支付交易
- {{ v.title }}
-
-
- {{ hooks.useMoney(v.price) }}元
-
-
-
- {{ hooks.useTime(v.createTime, "") }}
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+ {{ v.title }}
+ {{ v.title }}
+ {{ v.title }}
+ {{ v.title }}
+ {{ v.title }}
+
+
+ {{ hooks.useMoney(v.price) }}元
+
+
+
+ {{ hooks.useTime(v.createTime, "") }}
+
+
+
+
-
\ No newline at end of file
+
diff --git a/src/pages/wallet/list.vue b/src/pages/wallet/list.vue
index 5ae9644..76ce397 100644
--- a/src/pages/wallet/list.vue
+++ b/src/pages/wallet/list.vue
@@ -158,28 +158,25 @@ const doFreeze = async () => {
-
+
{{ v.walletTypeName }}
- 冻结审核中
-
- 正常
- 已冻结
-
+ 正常
+ 已冻结
¥{{ hooks.useMoney(v.balance) }}
-
+
绑定
diff --git a/src/pages/wallet/recharge.vue b/src/pages/wallet/recharge.vue
index 562ffa1..1b26eda 100644
--- a/src/pages/wallet/recharge.vue
+++ b/src/pages/wallet/recharge.vue
@@ -1,156 +1,158 @@
-
-
-
-
-
-
-
-
-
-
- {{ state.detail.walletTypeName }}
-
-
-
-
- ¥{{ hooks.useMoney(state.detail.balance) }}
-
-
+
+
+
+
+
+
+
+
+
+ {{ state.detail.walletTypeName }}
+
+
+
+ ¥{{ hooks.useMoney(state.detail.balance) }}
+
- 充值
-
-
- ¥{{ hooks.useMoney(v.payPrice) }}
-
-
- 支付
-
-
-
-
-
-
- 确认充值
-
-
+ 充值
+
+
+ ¥{{ hooks.useMoney(v.payPrice) }}
+
+
+ 支付
+
+
+
+
+
+
+ 确认充值
+
+
\ No newline at end of file
+
diff --git a/src/sheep/api/food.ts b/src/sheep/api/food.ts
index 7c5ba07..e29256f 100644
--- a/src/sheep/api/food.ts
+++ b/src/sheep/api/food.ts
@@ -1,53 +1,63 @@
-import request from "@/sheep/utils/request";
+import request from "@/sheep/utils/request"
export default {
- page: (data: any) =>
- request({
- url: `/canteen/canteenDailyMenu/app/page`,
- method: "POST",
- data,
- params:{
- pageNo: data.pageNo,
- pagesize: data.pagesize
- },
- custom: {
- showLoading: false,
- },
- }),
- classify: (params: any) =>
- request({
- url: `/canteen/canteenOnlineCategory/app/getAllSimple`,
- method: "GET",
- params,
- custom: {
- showLoading: false,
- },
- }),
- product: (params: any) =>
- request({
- url: `/canteen/canteenOnlineSpu/app/getCanteenSpuList`,
- method: "GET",
- params,
- custom: {
- showLoading: false,
- },
- }),
- getShopCar: (params: any) =>
- request({
- url: `/hard/hard-car/app/mch-detail`,
- method: "GET",
- params,
- custom: {
- showLoading: false,
- },
- }),
- updateShopCar: (data: any) =>
- request({
- url: `/hard/hard-car/app/save-or-upload`,
- method: "POST",
- data,
- custom: {
- showLoading: false,
- },
- }),
-};
+ page: (data: any) =>
+ request({
+ url: `/canteen/canteenDailyMenu/app/page`,
+ method: "POST",
+ data,
+ params: {
+ pageNo: data.pageNo,
+ pagesize: data.pagesize,
+ },
+ custom: {
+ showLoading: false,
+ },
+ }),
+ classify: (params: any) =>
+ request({
+ url: `/canteen/canteenOnlineCategory/app/getAllSimple`,
+ method: "GET",
+ params,
+ custom: {
+ showLoading: false,
+ },
+ }),
+ product: (params: any) =>
+ request({
+ url: `/canteen/canteenOnlineSpu/app/getCanteenSpuList`,
+ method: "GET",
+ params,
+ custom: {
+ showLoading: false,
+ },
+ }),
+ getShopCar: (params: any) =>
+ request({
+ url: `/hard/hard-car/app/mch-detail`,
+ method: "GET",
+ params,
+ custom: {
+ showLoading: false,
+ },
+ }),
+ updateShopCar: (data: any) =>
+ request({
+ url: `/hard/hard-car/app/save-or-upload`,
+ method: "POST",
+ data,
+ custom: {
+ showLoading: false,
+ },
+ }),
+ checkSpuStock: (params) => {
+ return request({
+ url: "/canteen/canteenOnlineSpu/app/checkSpuStock",
+ method: "GET",
+ params,
+ custom: {
+ showLoading: false,
+ },
+ })
+ },
+}
diff --git a/src/sheep/api/product.ts b/src/sheep/api/product.ts
index 0e17b45..e653608 100644
--- a/src/sheep/api/product.ts
+++ b/src/sheep/api/product.ts
@@ -1,11 +1,11 @@
-import request from "@/sheep/utils/request";
+import request from "@/sheep/utils/request"
export default {
- get: (params) => {
- return request({
- url: "/canteen/canteenOnlineSpu/app/getCanteenSpuDetails",
- method: "GET",
- params,
- });
- },
-};
+ get: (params) => {
+ return request({
+ url: "/canteen/canteenOnlineSpu/app/getCanteenSpuDetails",
+ method: "GET",
+ params,
+ })
+ },
+}
diff --git a/src/sheep/api/shop.ts b/src/sheep/api/shop.ts
index ce8be34..20f6be5 100644
--- a/src/sheep/api/shop.ts
+++ b/src/sheep/api/shop.ts
@@ -1,68 +1,41 @@
-import request from "@/sheep/utils/request";
+import request from "@/sheep/utils/request"
export default {
- getSupermarketSpuCategory: (params: any) =>
- request({
- url: `/supermarket/supermarketCategory/app/simpleAll`,
- method: "GET",
- params,
- custom: {
- showLoading: false,
- },
- }),
- getSupermarketSpuList: (data: any) =>
- request({
- url: `/supermarket/supermarketSpu/app/selectListAll`,
- method: "POST",
- data,
- custom: {
- showLoading: false,
- },
- }),
- getSupermarketSpuDetail: (params: any) =>
- request({
- url: `/supermarket/supermarketSpu/app/SpuDetails`,
- method: "GET",
- params,
- custom: {
- showLoading: false,
- },
- }),
-
- // del: (params: any) =>
- // request({
- // url: `/sys/user/face-delete`,
- // method: "DELETE",
- // params,
- // custom: {
- // showLoading: false,
- // },
- // }),
- // create: (data: any) =>
- // request({
- // url: `/sys/user/face-create`,
- // method: "POST",
- // data,
- // custom: {
- // showLoading: false,
- // },
- // }),
- // get: (params: any) =>
- // request({
- // url: `/sys/user/face-get`,
- // method: "GET",
- // params,
- // custom: {
- // showLoading: false,
- // },
- // }),
- // put: (data: any) =>
- // request({
- // url: `/sys/user/face-update`,
- // method: "PUT",
- // data,
- // custom: {
- // showLoading: false,
- // },
- // }),
-};
+ getSupermarketSpuCategory: (params: any) =>
+ request({
+ url: `/supermarket/supermarketCategory/app/simpleAll`,
+ method: "GET",
+ params,
+ custom: {
+ showLoading: false,
+ },
+ }),
+ getSupermarketSpuList: (data: any) =>
+ request({
+ url: `/supermarket/supermarketSpu/app/selectListAll`,
+ method: "POST",
+ data,
+ custom: {
+ showLoading: false,
+ },
+ }),
+ getSupermarketSpuDetail: (params: any) =>
+ request({
+ url: `/supermarket/supermarketSpu/app/SpuDetails`,
+ method: "GET",
+ params,
+ custom: {
+ showLoading: false,
+ },
+ }),
+ checkSpuStock: (params) => {
+ return request({
+ url: "/supermarket/supermarketSpu/app/checkSpuStock",
+ method: "GET",
+ params,
+ custom: {
+ showLoading: false,
+ },
+ })
+ },
+}
diff --git a/src/sheep/api/wallet.ts b/src/sheep/api/wallet.ts
index 0754360..d1c6340 100644
--- a/src/sheep/api/wallet.ts
+++ b/src/sheep/api/wallet.ts
@@ -29,7 +29,7 @@ export default {
}),
bind: (data: any) =>
request({
- url: "pay/wallet/bind-card",
+ url: "wallet/wallet-active/app/bind-card",
method: "POST",
data,
custom: {
@@ -38,7 +38,7 @@ export default {
}),
freeze: (data: any) =>
request({
- url: "pay/wallet/apply-freeze",
+ url: "wallet/wallet-freeze/app/apply-freeze",
method: "POST",
data,
custom: {
diff --git a/src/sheep/utils/request.ts b/src/sheep/utils/request.ts
index ee1aafe..3486139 100644
--- a/src/sheep/utils/request.ts
+++ b/src/sheep/utils/request.ts
@@ -120,6 +120,12 @@ http.interceptors.response.use(
icon: "none",
})
}
+ if (response.data.code === 1) {
+ const tokenKey = constant.storageConstant.TOKEN
+ uni.removeStorageSync(tokenKey)
+ uni.showToast({ title: "登录已过期,请重新登录", icon: "none" })
+ router.jump("/pages/test/login")
+ }
const tokenKey = constant.storageConstant.TOKEN
const tokenStorage = uni.getStorageSync(tokenKey)
if (!isEmpty(tokenStorage) && response.config.url != "/sys/auth/refresh-token") {