diff --git a/.env b/.env
index f789095..7fbf7e7 100644
--- a/.env
+++ b/.env
@@ -20,15 +20,15 @@ VITE_OAUTH2_APP_CLIENT='mini:mini'
# VITE_APP_DEV_SERVICE = https://stgl.pj.gov.cn/api # 域名线上
#VITE_APP_DEV_SERVICE = http://59.202.170.152:81/api # 信创线上
# VITE_APP_DEV_SERVICE = http://192.168.101.174:9999 # 邓-本地
-VITE_APP_DEV_SERVICE = http://127.0.0.1:9999 # 邓-本地
-; VITE_APP_DEV_SERVICE = http://123.157.250.162:8089/api # 测试线上
+# VITE_APP_DEV_SERVICE = http://127.0.0.1:9999 # 邓-本地
+VITE_APP_DEV_SERVICE = http://123.157.250.162:8089/api # 测试线上
# --------------------------- 开发环境 图片访问基础地址 ---------------------------
# VITE_IMAGE_DEV_PATH = https://stgl.pj.gov.cn/api # 域名线上
#VITE_IMAGE_DEV_PATH = http://59.202.170.152:81/api # 信创线上
# VITE_IMAGE_DEV_PATH = http://192.168.101.174:9999 # 邓-本地
-VITE_IMAGE_DEV_PATH = http://127.0.0.1:9999
-; VITE_IMAGE_DEV_PATH = http://123.157.250.162:8089/api # 测试线上
+# VITE_IMAGE_DEV_PATH = http://127.0.0.1:9999
+VITE_IMAGE_DEV_PATH = http://123.157.250.162:8089/api # 测试线上
# --------------------------- 生产环境 api地址 ----------------------------------
VITE_APP_PROD_SERVICE = https://stgl.pj.gov.cn/api # 域名线上
diff --git a/src/components/tongtong-plate/plate-keyboard.vue b/src/components/tongtong-plate/plate-keyboard.vue
new file mode 100644
index 0000000..e0c4ebb
--- /dev/null
+++ b/src/components/tongtong-plate/plate-keyboard.vue
@@ -0,0 +1,277 @@
+
+
+
+
+ 请点击选择车牌号
+
+
+
+
+
+
+
+ ABC
+
+ {{ it }}
+
+
+
+
+
+
+
+
+ 省
+ 字
+ {{ it }}
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/components/tongtong-plate/plate-number.vue b/src/components/tongtong-plate/plate-number.vue
new file mode 100644
index 0000000..d9891f2
--- /dev/null
+++ b/src/components/tongtong-plate/plate-number.vue
@@ -0,0 +1,312 @@
+
+
+
+
+ ·
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/pages.json b/src/pages.json
index 8b4094a..23db7a2 100644
--- a/src/pages.json
+++ b/src/pages.json
@@ -198,6 +198,13 @@
"navigationBarTitleText": "商品分类管理",
"disableScroll": true
}
+ },
+ {
+ "path": "settlement",
+ "style": {
+ "navigationBarTitleText": "结算",
+ "disableScroll": true
+ }
}
]
},
diff --git a/src/pages/canteen/detail.vue b/src/pages/canteen/detail.vue
index d9d3bab..406dcdd 100644
--- a/src/pages/canteen/detail.vue
+++ b/src/pages/canteen/detail.vue
@@ -55,7 +55,7 @@ const getDetail = async () => {
// 获取购物车信息
const getFoodCart = async () => {
- const { data } = await foodApi.getShopCar({ merchantId: state.detailId, hardType: "CANTEEN" })
+ const { data } = await orderApi.getShopCar({ merchantId: state.detailId, hardType: "CANTEEN" })
state.cartList = data ?? []
if (isEmpty(state.cartList)) {
state.foodList.forEach((v: any) => {
@@ -154,7 +154,7 @@ const updateFoodCart = async () => {
})
if (isEmpty(list)) return
const _pa = { merchantId: state.detailId, list: list, hardType: "CANTEEN" }
- const { data, code }: any = await foodApi.updateShopCar(_pa)
+ const { data, code }: any = await orderApi.updateShopCar(_pa)
if (code == 0) await getFoodCart()
}
diff --git a/src/pages/car/userCar/apply.vue b/src/pages/car/userCar/apply.vue
index a89aff6..41aba78 100644
--- a/src/pages/car/userCar/apply.vue
+++ b/src/pages/car/userCar/apply.vue
@@ -1,6 +1,7 @@
diff --git a/src/pages/prosperity-shop/components/product-sku.vue b/src/pages/prosperity-shop/components/product-sku.vue
new file mode 100644
index 0000000..bf8bc89
--- /dev/null
+++ b/src/pages/prosperity-shop/components/product-sku.vue
@@ -0,0 +1,157 @@
+
+
+
+ 商品信息
+
+
+
+ {{ goodsInfo.title }}
+
+ ¥{{ displayPrice(state.selectedSku.price, "") || 0 }}
+
+
+ 库存 {{ state.selectedSku.stock || 0 }}
+
+ 已选择
+ {{
+ `${state.selectedSku.skuName || "未选择"} / ${
+ state.selectedSku.weightG ? state.selectedSku.weightG + "克" : "未选择"
+ },数量 ${state.goodsCount}`
+ }}
+
+
+
+
+
+
+
+ 规格
+
+
+ {{ (v.skuName || "") + " / " + (v.skuWeight || "") + "克" }}
+
+
+
+
+
+
+ 购买数量
+
+ 库存 {{ state.selectedSku.stock }}
+
+
+
+
+ {{ String(state.goodsCount).padStart(2, "0") }}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/pages/prosperity-shop/components/product-total.vue b/src/pages/prosperity-shop/components/product-total.vue
new file mode 100644
index 0000000..f2114b6
--- /dev/null
+++ b/src/pages/prosperity-shop/components/product-total.vue
@@ -0,0 +1,38 @@
+
+
+
+
+
+
+
+ ¥ {{ hooks.useMoney(props.totPrice) }}
+ 共{{ props.totCount }}件
+
+
+ 去结算
+
+
+
+
diff --git a/src/pages/prosperity-shop/goods-detail.vue b/src/pages/prosperity-shop/goods-detail.vue
index bd32bfc..3212ce2 100644
--- a/src/pages/prosperity-shop/goods-detail.vue
+++ b/src/pages/prosperity-shop/goods-detail.vue
@@ -1,41 +1,45 @@
-
-
-
+
+
+
¥
- {{ displayPrice(state.detail.originalPrice, "") }}
+ {{ displayPrice(goodsDetail.originalPrice, "") }}
¥
- {{ displayPrice(state.detail.spuPrice, "") }}
+ {{ displayPrice(goodsDetail.spuPrice, "") }}
到手价
约省
- {{ displayPrice(Number(state.detail.originalPrice) - Number(state.detail.spuPrice), "") }}
+ {{ displayPrice(Number(goodsDetail.originalPrice) - Number(goodsDetail.spuPrice), "") }}
元
¥
- {{ displayPrice(state.detail.skuList[0].price, "") }}
+ {{ displayPrice(goodsDetail.skuList[0].price, "") }}
到手价
- {{ state.detail.status == "0" ? "在售" : "未售" }}
+ {{ goodsDetail.status == "0" ? "在售" : "未售" }}
- {{ state.detail.title }}
+ {{ goodsDetail.title }}
- 售卖时间 {{ state.detail.saleStartTime }} ~ {{ state.detail.saleEndTime }}
-
- 售卖单位 {{ state.detail.unit }}
- 剩余库存 {{ state.detail.totalStock }}
+ 售卖时间 {{ goodsDetail.saleStartTime }} ~ {{ goodsDetail.saleEndTime }}
+
+
+ 售卖单位 {{ goodsDetail.unit }}
+ 剩余库存 {{ goodsDetail.totalStock }}
+
+ 加入购物车
-
- 包装单位
-
+
+
+ 规格
+
{{ item.skuName }}
售价 {{ displayPrice(item.price) }}
@@ -44,37 +48,72 @@
+
商品描述
-
+
+
+
+
+
+
+
+
+
diff --git a/src/pages/prosperity-shop/goods-search.vue b/src/pages/prosperity-shop/goods-search.vue
index c7d4e75..c06a40e 100644
--- a/src/pages/prosperity-shop/goods-search.vue
+++ b/src/pages/prosperity-shop/goods-search.vue
@@ -110,7 +110,7 @@ const search = () => {
const doGoodsDetail = (id: string) => {
if (!id) return uni.showToast({ title: "商品id不存在", icon: "none" })
uni.navigateTo({
- url: `/pages/prosperity-shop/goods-detail?id=${id}`,
+ url: `/pages/prosperity-shop/goods-detail?id=${id}&merchantId=${state.params.merchantId}`,
})
}
diff --git a/src/pages/prosperity-shop/settlement.vue b/src/pages/prosperity-shop/settlement.vue
new file mode 100644
index 0000000..37a1cf3
--- /dev/null
+++ b/src/pages/prosperity-shop/settlement.vue
@@ -0,0 +1,66 @@
+
+
+
+ 温馨提示:当天的订单预计明天开始配送
+
+
+
+
+ 请选择自提点
+
+
+ 请选择自提点
+
+ {{ 0 || "请选择自提点" }}
+
+
+
+
+ 配送订单较多时,配送时间可能波动
+
+
+
+
+
+
+
+
+ {{ v.productName }}
+
+
+ ¥{{ hooks.useMoney(v.productPrice) }}
+ x {{ v.productCount }}
+
+ ¥{{ hooks.useMoney(v.totalPrice) }}
+
+
+
+ 你尚未选择任何商品
+
+
+
+
+
+
+ ¥ {{ hooks.useMoney(totPrice) }}
+ 共{{ totalCount }}件
+
+ 提交订单
+
+
+
+
+
+
diff --git a/src/pages/prosperity-shop/shop-detail.vue b/src/pages/prosperity-shop/shop-detail.vue
index c45f81b..eb7c978 100644
--- a/src/pages/prosperity-shop/shop-detail.vue
+++ b/src/pages/prosperity-shop/shop-detail.vue
@@ -1,7 +1,7 @@
-
+
搜索商品
-
- {{ state.detail.name }}
-
- {{ state.detail.status == "0" ? "开业中" : "未开业" }}
- {{ state.detail.businessHours }}
-
-
- 营业人 {{ state.detail.contactName }}·{{ state.detail.contactPhone }}
- 许可 {{ state.detail.licenseNo }}
-
+
+
+ {{ mchDetail.name }}
+ 营业
+ 营业人 {{ mchDetail.contactName }}·{{ mchDetail.contactPhone }}
- {{ state.detail.address }}
+ {{ mchDetail.address }}
-
+
-
+
+
+
+
+
+
+
+
diff --git a/src/pages/prosperity-shop/use-cart-buy.ts b/src/pages/prosperity-shop/use-cart-buy.ts
new file mode 100644
index 0000000..795388d
--- /dev/null
+++ b/src/pages/prosperity-shop/use-cart-buy.ts
@@ -0,0 +1,95 @@
+import { router } from "@/sheep"
+import { orderApi } from "@/sheep/api"
+import { useProsperityCartStore } from "@/sheep/stores/prosperity-cart"
+import { isEmpty } from "radash"
+import { computed } from "vue"
+
+export default function useCartBuy() {
+ const cartStore = useProsperityCartStore()
+
+ // 购物车商品总金额
+ const totPrice = computed(() => {
+ return cartStore.totPrice
+ })
+
+ // 购物车商品总数量
+ const totalCount = computed(() => {
+ return cartStore.totalCount
+ })
+
+ // 购物车商品列表
+ const cartList = computed(() => {
+ return cartStore.cartList
+ })
+
+ // 选择sku确认加入到购物车
+ const skuAddToCart = (sku: any, merchantId: string) => {
+ cartStore.addGoodsItemToCart(sku)
+ cartStore.updateShopCart(merchantId)
+ }
+
+ // 获取购物车列表
+ const getShopCart = async (merchantId: string) => {
+ await cartStore.getShopCart(merchantId)
+ }
+
+ // 添加一个商品数量
+ const addProductCount = async (productId: string, merchantId: string) => {
+ if (!merchantId) return
+ await cartStore.addProductCount(productId, merchantId)
+ }
+
+ // 减少一个商品数量
+ const removeProductCount = async (productId: string, merchantId: string) => {
+ if (!merchantId) return
+ await cartStore.removeProductCount(productId, merchantId)
+ }
+
+ const goSettlement = () => {
+ uni.navigateTo({ url: "/pages/prosperity-shop/settlement" })
+ }
+
+ // 点击提交订单
+ const doBuy = async () => {
+ if (isEmpty(cartList.value)) return uni.showToast({ title: "请至少购买一件商品", icon: "none" })
+ uni.showModal({
+ title: "提示",
+ content: "是否确定购买",
+ confirmColor: "#0094ff",
+ success: async (res) => {
+ if (!res.confirm) return
+ submitPay()
+ },
+ })
+ }
+
+ // 确认提交订单
+ const submitPay = async () => {
+ try {
+ uni.showLoading({ title: "支付中...", mask: false })
+ const { code, msg }: any = await orderApi.appCreateFarmerReserveOrder({
+ carParentId: cartStore.cartList[0].parentCarId,
+ hardType: "FARMER",
+ })
+ if (code != 0) throw new Error(msg)
+ uni.showToast({ title: "支付成功", icon: "none" })
+ router.jump("/pages/tabbar/order")
+ } catch (error: any) {
+ uni.showToast({ title: error.message, icon: "none" })
+ } finally {
+ uni.hideLoading()
+ }
+ }
+
+ return {
+ totPrice,
+ totalCount,
+ cartList,
+ getShopCart,
+ skuAddToCart,
+ addProductCount,
+ removeProductCount,
+ goSettlement,
+ doBuy,
+ }
+}
diff --git a/src/pages/prosperity-shop/use-shop-detail-scroll.ts b/src/pages/prosperity-shop/use-shop-detail-scroll.ts
index 63a908f..da4a1aa 100644
--- a/src/pages/prosperity-shop/use-shop-detail-scroll.ts
+++ b/src/pages/prosperity-shop/use-shop-detail-scroll.ts
@@ -9,7 +9,7 @@ interface scrollDetail {
scrollWidth: number
}
-export function useShopDetailScroll() {
+export default function useShopDetailScroll() {
const scrollDetail = ref({} as scrollDetail)
const onScroll = (e: any) => {
@@ -31,7 +31,7 @@ export function useShopDetailScroll() {
const scrollY = scrollDetail.value.scrollTop
const scrollHeight = scrollDetail.value.scrollHeight
const scrollWidth = scrollDetail.value.scrollWidth
- const calcWidth = Math.min((scrollY / scrollHeight) * scrollWidth, scrollWidth)
+ const calcWidth = Math.min(((scrollY / scrollHeight) * scrollWidth) / 2, scrollWidth)
if (isNaN(calcWidth)) return { width: `${minWidth}%` }
if (calcWidth < 2) return { width: `${calcWidth + minWidth}%` }
return {
diff --git a/src/pages/tabbar/canteenAnalyse.vue b/src/pages/tabbar/canteenAnalyse.vue
index d5e8dee..73d42e3 100644
--- a/src/pages/tabbar/canteenAnalyse.vue
+++ b/src/pages/tabbar/canteenAnalyse.vue
@@ -1,21 +1,13 @@
-
+
菜品分类购买数量占比图
-
+
@@ -30,40 +22,37 @@
个人菜品喜好排行
-
+
排名
菜品名称
分类
购买数量
-
+ }">
-
+ }">
{{ index + 1 }}
{{ index + 1 }}
- {{ item.productName || "未知菜品" }}
+ {{ item.productName || "未知菜品" }}
+
@@ -71,7 +60,9 @@
- {{ item.payCount }}次
+
+ {{ item.payCount }}次
diff --git a/src/pages/tabbar/flowStatistics.vue b/src/pages/tabbar/flowStatistics.vue
index 1eb7139..58e926e 100644
--- a/src/pages/tabbar/flowStatistics.vue
+++ b/src/pages/tabbar/flowStatistics.vue
@@ -1,35 +1,17 @@
-
+
流水统计
{{ formatVal }}
-
+
筛选
@@ -50,7 +32,8 @@
流水金额
- ¥ {{ hooks.useMoney(v.totalPayPrice) }}
+ ¥ {{ hooks.useMoney(v.totalPayPrice)
+ }}
流水次数
@@ -60,7 +43,9 @@
盈利金额
- ¥ {{ hooks.useMoney(v.totalProfitPrice) }}
+ ¥ {{
+ hooks.useMoney(v.totalProfitPrice)
+ }}
盈利次数
@@ -70,7 +55,8 @@
退款金额
- ¥ {{ hooks.useMoney(v.totalRefundPrice) }}
+ ¥ {{
+ hooks.useMoney(v.totalRefundPrice) }}
退款次数
@@ -80,7 +66,7 @@
-
+
每月流水合计
@@ -126,7 +112,9 @@ const query = (page: number, pagesize: number) => {
// 时间范围选择器确认
const datePickerConfirm = (date: any) => {
const list = formatVal.value.split("~")
- state.pa.createTimeList = [list[0] + " 00:00:00", list[1] + " 23:59:59"]
+ if (list && list.length == 2) {
+ state.pa.createTimeList = [list[0] + " 00:00:00", list[1] + " 23:59:59"]
+ }
pageRef.value.reload(false)
}
diff --git a/src/pages/tabbar/my.vue b/src/pages/tabbar/my.vue
index 9a82b73..3d6bcc4 100644
--- a/src/pages/tabbar/my.vue
+++ b/src/pages/tabbar/my.vue
@@ -2,13 +2,10 @@
-
-
+
+
{{ state.userInfo?.sysUser?.name }}
ID {{ state.userInfo?.sysUser?.userId }}
@@ -21,7 +18,8 @@
-
+
{{ v.text }}
@@ -31,13 +29,15 @@
-
+
退出登录
-
+
切换角色
@@ -50,7 +50,8 @@
-
+
是否核销该活动兑换券?
确认核销将会对用户的 消费钱包 扣除 1元 钱
@@ -80,7 +81,7 @@ const state = reactive({
{ text: "扫一扫", icon: "/static/icon/scan.png", path: "" },
{ text: "我的钱包", icon: "/static/icon/service_3.png", path: "/pages/wallet/list" },
{ text: "我的人脸", icon: "/static/icon/service_5.png", path: "/pages/human-face/list" },
- // { text: "车辆管理", icon: "/static/icon/service_6.png", path: "/pages/car/userCar/list" },
+ { text: "车辆管理", icon: "/static/icon/service_6.png", path: "/pages/car/userCar/list" },
{ text: "清除缓存", icon: "/static/icon/clear-storage.png", path: "" },
],
appInfo: "",
diff --git a/src/pages/tabbar/onlineShop.vue b/src/pages/tabbar/onlineShop.vue
index eafbbf9..ad60bd1 100644
--- a/src/pages/tabbar/onlineShop.vue
+++ b/src/pages/tabbar/onlineShop.vue
@@ -143,10 +143,10 @@ import { isEmpty } from "radash"
import { filePath } from "@@/utils/file"
import { merchantApi, onlineShopApi } from "@@/api"
import { hooks, router } from "@@/index"
-import { useCartStore } from "@/sheep/stores/cart"
+import { useOnlineCartStore } from "@/sheep/stores/online-cart"
import treeToList from "@/sheep/utils/tree-to-list"
-const cartStore = useCartStore()
+const cartStore = useOnlineCartStore()
const state = reactive({
params: {
diff --git a/src/pages/tabbar/prosperityShop.vue b/src/pages/tabbar/prosperityShop.vue
index 0ed586c..da6b446 100644
--- a/src/pages/tabbar/prosperityShop.vue
+++ b/src/pages/tabbar/prosperityShop.vue
@@ -57,20 +57,15 @@
-
+
- {{ v.name }}
-
- {{ v.contactName }}
-
+ {{ v.name }}222222222222222222222222
+
+
{{ v.contactPhone }}
-
- {{ v.email }}
-
-
- 营业
- {{ v.businessHours }}
+
+ 营业
@@ -83,21 +78,21 @@
{{ pV.title }}
-
+
¥
{{ pV.priceType == "1" ? displayPrice(pV.minPrice, "") : displayPrice(pV.spuPrice, "") }}
- {{ pV.unit || "" }}
-
-
¥
{{ displayPrice(pV.originalPrice, "") }}
- 库存{{ pV.totalStock }}
+
+
+ {{ pV.unit || "" }}
+ 库存{{ pV.totalStock }}
diff --git a/src/sheep/api/food.ts b/src/sheep/api/food.ts
index 9ac3f8d..82e71b4 100644
--- a/src/sheep/api/food.ts
+++ b/src/sheep/api/food.ts
@@ -23,18 +23,6 @@ export default {
method: "GET",
params,
}),
- getShopCar: (params: any) =>
- request({
- url: `/hard/hard-car/app/mch-detail`,
- method: "GET",
- params,
- }),
- updateShopCar: (data: any) =>
- request({
- url: `/hard/hard-car/app/save-or-upload`,
- method: "POST",
- data,
- }),
checkSpuStock: (params) => {
return request({
url: "/canteen/canteenOnlineSpu/app/checkSpuStock",
diff --git a/src/sheep/api/order.ts b/src/sheep/api/order.ts
index c210a9f..e251d50 100644
--- a/src/sheep/api/order.ts
+++ b/src/sheep/api/order.ts
@@ -25,6 +25,18 @@ export default {
method: "GET",
params,
}),
+ getShopCar: (params: any) =>
+ request({
+ url: `/hard/hard-car/app/mch-detail`,
+ method: "GET",
+ params,
+ }),
+ updateShopCar: (data: any) =>
+ request({
+ url: `/hard/hard-car/app/save-or-upload`,
+ method: "POST",
+ data,
+ }),
/**
* 预约时间列表
*/
@@ -44,4 +56,16 @@ export default {
method: "POST",
data,
}),
+ /**
+ * 创建共富商城预约订单
+ * @body body.carParentId 购物车id
+ * @body body.walletTypeId 钱包类型id
+ * @body body.pickUpId 自提点id
+ */
+ appCreateFarmerReserveOrder: (data: any) =>
+ request({
+ url: "/hard/hard-order/app/create-farmer-order",
+ method: "POST",
+ data,
+ }),
}
diff --git a/src/sheep/api/total.ts b/src/sheep/api/total.ts
index 3ee388b..2d9b2d0 100644
--- a/src/sheep/api/total.ts
+++ b/src/sheep/api/total.ts
@@ -20,7 +20,7 @@ export default {
data,
}),
/**
- * 个人菜品喜好排行
+ *
*/
productLikeTop: (data: any): any =>
request({
diff --git a/src/sheep/api/wallet.ts b/src/sheep/api/wallet.ts
index a8be597..4d94246 100644
--- a/src/sheep/api/wallet.ts
+++ b/src/sheep/api/wallet.ts
@@ -69,4 +69,26 @@ export default {
method: "GET",
data: {},
}),
+ /**
+ * 自提点分页
+ * @param params.pageNum 页码
+ * @param params.pageSize 每页数量
+ * @param params.mchIds 商户ID列表
+ */
+ pickUpPage: (params: any): Promise =>
+ request({
+ url: "wallet/mch-pick-up/app/page",
+ method: "GET",
+ params: params,
+ }),
+ /**
+ * 自提点详情
+ * @param params.id 自提点id
+ */
+ pickUpDetail: (params: any): Promise =>
+ request({
+ url: "wallet/mch-pick-up/app/detail",
+ method: "GET",
+ params: params,
+ }),
}
diff --git a/src/sheep/stores/cart.ts b/src/sheep/stores/online-cart.ts
similarity index 82%
rename from src/sheep/stores/cart.ts
rename to src/sheep/stores/online-cart.ts
index e2c7ff7..1182e23 100644
--- a/src/sheep/stores/cart.ts
+++ b/src/sheep/stores/online-cart.ts
@@ -1,14 +1,14 @@
import { defineStore } from "pinia"
-import { foodApi } from "../api"
+import { orderApi } from "../api"
-export const useCartStore = defineStore("cartStore", {
+export const useOnlineCartStore = defineStore("onlineCartStore", {
state: () => ({
cart: JSON.parse(uni.getStorageSync("onlineShopCart") || "[]"),
shopMerchantId: uni.getStorageSync("onlineShopMerchantId") || "",
}),
getters: {
totalCount(state) {
- return state.cart.reduce((prev: string, cur: any) => {
+ return state.cart.reduce((prev: number, cur: { productCount: number }) => {
return prev + cur.productCount
}, 0)
},
@@ -58,7 +58,7 @@ export const useCartStore = defineStore("cartStore", {
await this.getShopCart()
},
async getShopCart() {
- const { data } = await foodApi.getShopCar({ merchantId: this.shopMerchantId, hardType: "SUPERMARKET" })
+ const { data } = await orderApi.getShopCar({ merchantId: this.shopMerchantId, hardType: "SUPERMARKET" })
this.saveShopCart(data ?? [])
},
async updateShopCart() {
@@ -70,7 +70,7 @@ export const useCartStore = defineStore("cartStore", {
productId: v.productId,
}
})
- const { code }: any = await foodApi.updateShopCar({ merchantId: this.shopMerchantId, list, hardType: "SUPERMARKET" })
+ const { code }: any = await orderApi.updateShopCar({ merchantId: this.shopMerchantId, list, hardType: "SUPERMARKET" })
if (code == 0) return await this.getShopCart()
uni.showToast({ title: "更新购物车失败", icon: "none" })
},
diff --git a/src/sheep/stores/prosperity-cart.ts b/src/sheep/stores/prosperity-cart.ts
new file mode 100644
index 0000000..160c256
--- /dev/null
+++ b/src/sheep/stores/prosperity-cart.ts
@@ -0,0 +1,74 @@
+import { defineStore } from "pinia"
+import { orderApi } from "../api"
+
+// 共富商城购物车
+export const useProsperityCartStore = defineStore("prosperityCartStore", {
+ state: (): any => ({
+ cartList: [],
+ }),
+ getters: {
+ totalCount(state) {
+ return state.cartList.reduce((prev: number, cur: { productCount: number }) => {
+ return prev + cur.productCount
+ }, 0)
+ },
+ totPrice(state) {
+ return state.cartList
+ .map((item: any) => Number(item.totalPrice))
+ .reduce((prev: number, cur: number) => prev + cur, 0)
+ .toFixed(2)
+ },
+ },
+ actions: {
+ // 购物车添加商品项
+ addGoodsItemToCart(goodsItem: any) {
+ const findResult = this.cartList.find((item: any) => {
+ return item.productId === goodsItem.productId
+ })
+ if (!findResult) {
+ this.cartList.unshift(goodsItem)
+ } else {
+ findResult.productCount++
+ }
+ },
+ // 购物车商品项数量减一
+ async removeProductCount(productId: string, merchantId: string) {
+ this.cartList.forEach((item: any) => {
+ if (item.productId === productId) {
+ item.productCount--
+ }
+ })
+ await this.updateShopCart(merchantId)
+ await this.getShopCart(merchantId)
+ },
+ // 购物车商品项数量加一
+ async addProductCount(productId: string, merchantId: string) {
+ this.cartList.forEach((item: any) => {
+ if (item.productId === productId) {
+ item.productCount++
+ }
+ })
+ await this.updateShopCart(merchantId)
+ await this.getShopCart(merchantId)
+ },
+ // 获取购物车商品列表
+ async getShopCart(merchantId: string) {
+ const { data } = await orderApi.getShopCar({ merchantId, hardType: "FARMER" })
+ this.cartList = data ?? []
+ },
+ // 更新购物车商品列表
+ async updateShopCart(merchantId: string) {
+ const list = this.cartList
+ .filter((v) => v.productCount && v.productCount > 0)
+ .map((v) => {
+ return {
+ productCount: v.productCount,
+ productId: v.productId,
+ }
+ })
+ const { code }: any = await orderApi.updateShopCar({ merchantId, list, hardType: "FARMER" })
+ if (code == 0) return await this.getShopCart(merchantId)
+ uni.showToast({ title: "更新购物车失败", icon: "none" })
+ },
+ },
+})
diff --git a/src/static/icon/cart.png b/src/static/icon/cart.png
new file mode 100644
index 0000000..36593ea
Binary files /dev/null and b/src/static/icon/cart.png differ