diff --git a/src/pages/prosperity-shop/categary-manage.vue b/src/pages/prosperity-shop/categary-manage.vue new file mode 100644 index 0000000..d8e56e0 --- /dev/null +++ b/src/pages/prosperity-shop/categary-manage.vue @@ -0,0 +1,135 @@ + + + diff --git a/src/pages/prosperity-shop/components/product-cart.vue b/src/pages/prosperity-shop/components/product-cart.vue new file mode 100644 index 0000000..7f6fe8d --- /dev/null +++ b/src/pages/prosperity-shop/components/product-cart.vue @@ -0,0 +1,57 @@ + + + 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..0bd6273 --- /dev/null +++ b/src/pages/prosperity-shop/components/product-sku.vue @@ -0,0 +1,148 @@ + + + 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..b97b7f6 --- /dev/null +++ b/src/pages/prosperity-shop/components/product-total.vue @@ -0,0 +1,39 @@ + + + diff --git a/src/pages/prosperity-shop/goods-detail.vue b/src/pages/prosperity-shop/goods-detail.vue new file mode 100644 index 0000000..296314e --- /dev/null +++ b/src/pages/prosperity-shop/goods-detail.vue @@ -0,0 +1,158 @@ + + + + + diff --git a/src/pages/prosperity-shop/goods-form.vue b/src/pages/prosperity-shop/goods-form.vue new file mode 100644 index 0000000..92e7734 --- /dev/null +++ b/src/pages/prosperity-shop/goods-form.vue @@ -0,0 +1,340 @@ + + + diff --git a/src/pages/prosperity-shop/goods-manage.vue b/src/pages/prosperity-shop/goods-manage.vue new file mode 100644 index 0000000..afc8ad7 --- /dev/null +++ b/src/pages/prosperity-shop/goods-manage.vue @@ -0,0 +1,172 @@ + + + + + diff --git a/src/pages/prosperity-shop/goods-search.vue b/src/pages/prosperity-shop/goods-search.vue new file mode 100644 index 0000000..5c6aa9c --- /dev/null +++ b/src/pages/prosperity-shop/goods-search.vue @@ -0,0 +1,121 @@ + + + + + diff --git a/src/pages/prosperity-shop/settlement.vue b/src/pages/prosperity-shop/settlement.vue new file mode 100644 index 0000000..bcb5fa0 --- /dev/null +++ b/src/pages/prosperity-shop/settlement.vue @@ -0,0 +1,151 @@ + + + diff --git a/src/pages/prosperity-shop/shop-detail.vue b/src/pages/prosperity-shop/shop-detail.vue new file mode 100644 index 0000000..77917ec --- /dev/null +++ b/src/pages/prosperity-shop/shop-detail.vue @@ -0,0 +1,299 @@ + + + + + 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..3196e13 --- /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 = (mchId: string) => { + uni.navigateTo({ url: `/pages/prosperity-shop/settlement?mchId=${mchId}` }) + } + + // 点击提交订单 + const doBuy = async (pickUpId: string) => { + if (isEmpty(cartList.value)) return uni.showToast({ title: "请至少购买一件商品", icon: "none" }) + uni.showModal({ + title: "提示", + content: "是否确定购买", + confirmColor: "#0094ff", + success: async (res) => { + if (!res.confirm) return + submitPay(pickUpId) + }, + }) + } + + // 确认提交订单 + const submitPay = async (pickUpId: string) => { + try { + uni.showLoading({ title: "支付中...", mask: false }) + const { code, msg }: any = await orderApi.appCreateFarmerReserveOrder({ + carParentId: cartList.value[0].parentCarId, + pickUpId, + }) + 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-categary-manage.ts b/src/pages/prosperity-shop/use-categary-manage.ts new file mode 100644 index 0000000..470902b --- /dev/null +++ b/src/pages/prosperity-shop/use-categary-manage.ts @@ -0,0 +1,33 @@ +import { prosperityShopApi } from "@/sheep/api" +import { ref } from "vue" + +export function useCategaryManage() { + const categoryList = ref([]) + + // 获取商品分类 + const getGoodsCategory = async () => { + const { code, data, msg } = await prosperityShopApi.getGoodsCategory() + if (code != 0) return uni.showToast({ title: msg || "商品分类获取失败", icon: "none" }) + categoryList.value = data + } + // 删除分类 + const delCategary = async (id: string) => { + if (!id) return uni.showToast({ title: "分类id不存在", icon: "none" }) + uni.showModal({ + title: "确定删除分类吗?", + content: "", + success: async (res) => { + if (res.confirm) { + uni.showLoading({ title: "正在删除" }) + const { code, msg } = await prosperityShopApi.delCategary(id) + if (code != 0) return uni.showToast({ title: msg || "删除失败", icon: "none" }) + uni.showToast({ title: "删除成功", icon: "none" }) + getGoodsCategory() + uni.hideLoading() + } + }, + }) + } + + return { categoryList, getGoodsCategory, delCategary } +} diff --git a/src/pages/prosperity-shop/use-goods-manage.ts b/src/pages/prosperity-shop/use-goods-manage.ts new file mode 100644 index 0000000..107c4a3 --- /dev/null +++ b/src/pages/prosperity-shop/use-goods-manage.ts @@ -0,0 +1,42 @@ +import { prosperityShopApi } from "@/sheep/api" + +export function useGoodsManage(pageRef) { + // 新增商品 + const addGoods = () => { + uni.navigateTo({ url: `/pages/prosperity-shop/goods-form` }) + } + // 编辑商品 + const editGoods = (id: string) => { + if (!id) return uni.showToast({ title: "商品id不存在", icon: "none" }) + uni.navigateTo({ url: `/pages/prosperity-shop/goods-form?id=${id}` }) + } + // 删除商品 + const deleteGoods = (id: string) => { + if (!id) return uni.showToast({ title: "商品id不存在", icon: "none" }) + uni.showModal({ + title: "确定删除商品吗?", + content: "", + success: async (res) => { + if (res.confirm) { + const { code } = await prosperityShopApi.deleteGoods(id) + if (code != 0) return uni.showToast({ title: "删除失败", icon: "error" }) + uni.showToast({ title: "删除成功", icon: "none" }) + pageRef.value && pageRef.value.reload(false) + } + }, + }) + } + // 查看详情 + const doGoodsDetail = (id: string, merchantId: string) => { + if (!id) return uni.showToast({ title: "商品id不存在", icon: "none" }) + uni.navigateTo({ + url: `/pages/prosperity-shop/goods-detail?id=${id}&mchId=${merchantId}`, + }) + } + // 分类管理 + const categaryManage = () => { + uni.navigateTo({ url: "/pages/prosperity-shop/categary-manage" }) + } + + return { addGoods, editGoods, deleteGoods, doGoodsDetail, categaryManage } +} diff --git a/src/pages/prosperity-shop/use-shop-detail-scroll.ts b/src/pages/prosperity-shop/use-shop-detail-scroll.ts new file mode 100644 index 0000000..da4a1aa --- /dev/null +++ b/src/pages/prosperity-shop/use-shop-detail-scroll.ts @@ -0,0 +1,45 @@ +import { computed, ref } from "vue" + +interface scrollDetail { + deltaX: number + deltaY: number + scrollHeight: number + scrollLeft: number + scrollTop: number + scrollWidth: number +} + +export default function useShopDetailScroll() { + const scrollDetail = ref({} as scrollDetail) + + const onScroll = (e: any) => { + scrollDetail.value = e.detail + } + + const filterStyle = computed(() => { + if (!scrollDetail.value.scrollTop) return {} + const scrollY = scrollDetail.value.scrollTop + const blur = Math.min(1, scrollY / 400) * 10 + return { + backdropFilter: `blur(${blur}rpx)`, + } + }) + + const searchStyle = computed(() => { + if (!scrollDetail.value.scrollTop) return {} + const minWidth = 10 + const scrollY = scrollDetail.value.scrollTop + const scrollHeight = scrollDetail.value.scrollHeight + const scrollWidth = scrollDetail.value.scrollWidth + const calcWidth = Math.min(((scrollY / scrollHeight) * scrollWidth) / 2, scrollWidth) + if (isNaN(calcWidth)) return { width: `${minWidth}%` } + if (calcWidth < 2) return { width: `${calcWidth + minWidth}%` } + return { + width: `${calcWidth + minWidth}%`, + border: `2rpx solid #1879ff`, + opacity: (calcWidth / 100) * 6, + } + }) + + return { scrollDetail, onScroll, filterStyle, searchStyle } +} diff --git a/src/pages/tabbar/prosperityShop.vue b/src/pages/tabbar/prosperityShop.vue new file mode 100644 index 0000000..b2aa3c0 --- /dev/null +++ b/src/pages/tabbar/prosperityShop.vue @@ -0,0 +1,121 @@ + + + diff --git a/src/pages/tabbar/prosperityShopMchList.vue b/src/pages/tabbar/prosperityShopMchList.vue new file mode 100644 index 0000000..5d60c97 --- /dev/null +++ b/src/pages/tabbar/prosperityShopMchList.vue @@ -0,0 +1,129 @@ + + + diff --git a/src/sheep/api/prosperity-shop.ts b/src/sheep/api/prosperity-shop.ts new file mode 100644 index 0000000..3b3bc10 --- /dev/null +++ b/src/sheep/api/prosperity-shop.ts @@ -0,0 +1,104 @@ +import request from "@/sheep/utils/request" + +export default { + // 获取超市列表 + getShopList: (params: { productLimit: number }): Promise => { + return request({ + url: "/supermarket/app/mall/merchant/list", + method: "GET", + params: { productLimit: 5 }, + }) + }, + // 获取商品分类列表 + getGoodsCategory: (params?: any): Promise => { + return request({ + url: "/supermarket/app/mall/merchant/category/list", + method: "GET", + params, + }) + }, + // 获取超市详情 + getShopDetail: (id: string): Promise => { + return request({ + url: `/supermarket/app/mall/merchant/${id}`, + method: "GET", + }) + }, + // 获取超市商品分类列表树 + getGoodsCategoryTree: (params?: { merchantId: string }): Promise => { + return request({ + url: `/supermarket/app/mall/category/tree`, + method: "GET", + params, + }) + }, + // 获取商品列表 + getGoodsList: (params: any): Promise => { + return request({ + url: `/supermarket/app/mall/product/page`, + method: "GET", + params, + }) + }, + // 获取商品详情 + getGoodsDetail: (id: string): Promise => { + return request({ + url: `/supermarket/app/mall/product/${id}`, + method: "GET", + }) + }, + // 共富商城商品管理获取自己商户的商品列表 + getManageGoodsList: (params: any): Promise => { + return request({ + url: `/supermarket/app/mall/merchant/product/list`, + method: "GET", + params, + }) + }, + // 删除商品 + deleteGoods: (id: string): Promise => { + return request({ + url: `/supermarket/app/mall/merchant/product/${id}`, + method: "DELETE", + }) + }, + // 新增商品 + addGoods: (data: any): Promise => { + return request({ + url: `/supermarket/app/mall/merchant/product/create`, + method: "POST", + data, + }) + }, + // 修改商品 + editGoods: (data: any): Promise => { + return request({ + url: `/supermarket/app/mall/merchant/product/update`, + method: "PUT", + data, + }) + }, + // 删除商品分类 + delCategary: (id: any): Promise => { + return request({ + url: `/supermarket/app/mall/merchant/category/${id}`, + method: "DELETE", + }) + }, + // 新增商品分类 + addCategary: (data: any): Promise => { + return request({ + url: `/supermarket/app/mall/merchant/category/create`, + method: "POST", + data, + }) + }, + // 编辑商品分类 + editCategary: (data: any): Promise => { + return request({ + url: `/supermarket/app/mall/merchant/category/update`, + method: "PUT", + data, + }) + }, +} diff --git a/src/sheep/components/node-tree.vue b/src/sheep/components/node-tree.vue new file mode 100644 index 0000000..5733c3a --- /dev/null +++ b/src/sheep/components/node-tree.vue @@ -0,0 +1,63 @@ + + + + + diff --git a/src/sheep/components/shop-categary-picker.vue b/src/sheep/components/shop-categary-picker.vue new file mode 100644 index 0000000..db8272e --- /dev/null +++ b/src/sheep/components/shop-categary-picker.vue @@ -0,0 +1,38 @@ + + + diff --git a/src/sheep/utils/tree-to-list.ts b/src/sheep/utils/tree-to-list.ts new file mode 100644 index 0000000..ba991d7 --- /dev/null +++ b/src/sheep/utils/tree-to-list.ts @@ -0,0 +1,11 @@ +const treeToList = (tree: T[], result: T[] = []): T[] => { + for (const node of tree) { + result.push(node) + if (node?.children?.length) { + treeToList(node.children, result) + } + } + return result +} + +export default treeToList 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 diff --git a/src/static/icon/clear-storage copy.png b/src/static/icon/clear-storage copy.png new file mode 100644 index 0000000..5d7d35e Binary files /dev/null and b/src/static/icon/clear-storage copy.png differ diff --git a/src/static/icon/empty-todo.png b/src/static/icon/empty-todo.png new file mode 100644 index 0000000..65138c1 Binary files /dev/null and b/src/static/icon/empty-todo.png differ diff --git a/src/static/icon/feedback.png b/src/static/icon/feedback.png new file mode 100644 index 0000000..153cfb2 Binary files /dev/null and b/src/static/icon/feedback.png differ diff --git a/src/static/icon/guarantee.png b/src/static/icon/guarantee.png new file mode 100644 index 0000000..6e16542 Binary files /dev/null and b/src/static/icon/guarantee.png differ diff --git a/src/static/icon/login.png b/src/static/icon/login.png new file mode 100644 index 0000000..2265310 Binary files /dev/null and b/src/static/icon/login.png differ diff --git a/src/static/icon/lost-and-found.png b/src/static/icon/lost-and-found.png new file mode 100644 index 0000000..88c3414 Binary files /dev/null and b/src/static/icon/lost-and-found.png differ diff --git a/src/static/icon/meeting-booking.png b/src/static/icon/meeting-booking.png new file mode 100644 index 0000000..8827528 Binary files /dev/null and b/src/static/icon/meeting-booking.png differ diff --git a/src/static/icon/notice.png b/src/static/icon/notice.png new file mode 100644 index 0000000..7beed03 Binary files /dev/null and b/src/static/icon/notice.png differ diff --git a/src/static/icon/repair-report.png b/src/static/icon/repair-report.png new file mode 100644 index 0000000..6b8d629 Binary files /dev/null and b/src/static/icon/repair-report.png differ diff --git a/src/static/icon/todo.png b/src/static/icon/todo.png new file mode 100644 index 0000000..f2d2377 Binary files /dev/null and b/src/static/icon/todo.png differ diff --git a/src/static/icon/vip.png b/src/static/icon/vip.png new file mode 100644 index 0000000..36302bb Binary files /dev/null and b/src/static/icon/vip.png differ diff --git a/src/static/icon/visitor.png b/src/static/icon/visitor.png new file mode 100644 index 0000000..9ba7a3f Binary files /dev/null and b/src/static/icon/visitor.png differ diff --git a/src/static/page/cart_empty.png b/src/static/page/cart_empty.png new file mode 100644 index 0000000..4b24439 Binary files /dev/null and b/src/static/page/cart_empty.png differ diff --git a/src/static/page/shop-goods-search.png b/src/static/page/shop-goods-search.png new file mode 100644 index 0000000..900b785 Binary files /dev/null and b/src/static/page/shop-goods-search.png differ