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 @@ + + + + + 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 @@ + + + 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 @@ + + + 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 @@ 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 @@ + + + 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 @@ 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 @@