From a8f9fa152ae7371dc232dbf9270bea728c67765e Mon Sep 17 00:00:00 2001 From: owen Date: Fri, 1 Dec 2023 00:39:10 +0800 Subject: [PATCH] =?UTF-8?q?=E8=90=A5=E9=94=80=EF=BC=9A=E5=95=86=E5=9F=8E?= =?UTF-8?q?=E8=A3=85=E4=BF=AE=E5=A2=9E=E5=8A=A0=E6=8E=A7=E4=BB=B6=E3=80=90?= =?UTF-8?q?APP=20=E9=93=BE=E6=8E=A5=E9=80=89=E6=8B=A9=E3=80=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit (cherry picked from commit 23a6bf5ef5aaca20bc83cfe12313f3adb0a46c3b) --- .../AppLinkInput/AppLinkSelectDialog.vue | 198 ++++++++++++++ src/components/AppLinkInput/data.ts | 246 ++++++++++++++++++ src/components/AppLinkInput/index.vue | 43 +++ .../components/mobile/Carousel/property.vue | 2 +- .../components/mobile/ImageBar/property.vue | 2 +- .../components/mobile/MagicCube/property.vue | 2 +- .../components/mobile/MenuGrid/property.vue | 2 +- .../components/mobile/MenuList/property.vue | 2 +- .../components/mobile/MenuSwiper/property.vue | 2 +- .../components/mobile/NoticeBar/property.vue | 2 +- .../components/mobile/TabBar/property.vue | 2 +- .../components/mobile/TitleBar/property.vue | 2 +- src/utils/index.ts | 22 ++ .../components/ProductCategorySelect.vue | 12 +- 14 files changed, 526 insertions(+), 13 deletions(-) create mode 100644 src/components/AppLinkInput/AppLinkSelectDialog.vue create mode 100644 src/components/AppLinkInput/data.ts create mode 100644 src/components/AppLinkInput/index.vue diff --git a/src/components/AppLinkInput/AppLinkSelectDialog.vue b/src/components/AppLinkInput/AppLinkSelectDialog.vue new file mode 100644 index 00000000..a536ac13 --- /dev/null +++ b/src/components/AppLinkInput/AppLinkSelectDialog.vue @@ -0,0 +1,198 @@ + + + diff --git a/src/components/AppLinkInput/data.ts b/src/components/AppLinkInput/data.ts new file mode 100644 index 00000000..fd7780f1 --- /dev/null +++ b/src/components/AppLinkInput/data.ts @@ -0,0 +1,246 @@ +// APP 链接类型(需要特殊处理,例如商品详情) +export const enum APP_LINK_TYPE_ENUM { + // 拼团活动 + ACTIVITY_COMBINATION, + // 秒杀活动 + ACTIVITY_SECKILL, + // 文章详情 + ARTICLE_DETAIL, + // 优惠券详情 + COUPON_DETAIL, + // 自定义页面详情 + DIY_PAGE_DETAIL, + // 品类列表 + PRODUCT_CATEGORY_LIST, + // 商品列表 + PRODUCT_LIST, + // 商品详情 + PRODUCT_DETAIL_NORMAL, + // 拼团商品详情 + PRODUCT_DETAIL_COMBINATION, + // 积分商品详情 + PRODUCT_DETAIL_POINT, + // 秒杀商品详情 + PRODUCT_DETAIL_SECKILL +} + +// APP 链接列表(做一下持久化?) +export const APP_LINK_GROUP_LIST = [ + { + name: '商城', + links: [ + { + name: '首页', + path: '/pages/index/index' + }, + { + name: '商品分类', + path: '/pages/index/category', + type: APP_LINK_TYPE_ENUM.PRODUCT_CATEGORY_LIST + }, + { + name: '购物车', + path: '/pages/index/cart' + }, + { + name: '个人中心', + path: '/pages/index/user' + }, + { + name: '商品搜索', + path: '/pages/index/search' + }, + { + name: '自定义页面', + path: '/pages/index/page', + type: APP_LINK_TYPE_ENUM.DIY_PAGE_DETAIL + }, + { + name: '客服', + path: '/pages/chat/index' + }, + { + name: '系统设置', + path: '/pages/public/setting' + }, + { + name: '问题反馈', + path: '/pages/public/feedback' + }, + { + name: '常见问题', + path: '/pages/public/faq' + } + ] + }, + { + name: '商品', + links: [ + { + name: '商品列表', + path: '/pages/goods/list', + type: APP_LINK_TYPE_ENUM.PRODUCT_LIST + }, + { + name: '商品详情', + path: '/pages/goods/index', + type: APP_LINK_TYPE_ENUM.PRODUCT_DETAIL_NORMAL + }, + { + name: '拼团商品详情', + path: '/pages/goods/groupon', + type: APP_LINK_TYPE_ENUM.PRODUCT_DETAIL_COMBINATION + }, + { + name: '秒杀商品详情', + path: '/pages/goods/seckill', + type: APP_LINK_TYPE_ENUM.PRODUCT_DETAIL_SECKILL + }, + { + name: '积分商品详情', + path: '/pages/goods/score', + type: APP_LINK_TYPE_ENUM.PRODUCT_DETAIL_POINT + } + ] + }, + { + name: '营销活动', + links: [ + { + name: '拼团订单', + path: '/pages/activity/groupon/order' + }, + { + name: '营销商品', + path: '/pages/activity/index' + }, + { + name: '拼团活动', + path: '/pages/activity/groupon/list', + type: APP_LINK_TYPE_ENUM.ACTIVITY_COMBINATION + }, + { + name: '秒杀活动', + path: '/pages/activity/seckill/list', + type: APP_LINK_TYPE_ENUM.ACTIVITY_SECKILL + }, + { + name: '签到中心', + path: '/pages/app/sign' + }, + { + name: '积分商城', + path: '/pages/app/score-shop' + }, + { + name: '优惠券中心', + path: '/pages/coupon/list' + }, + { + name: '优惠券详情', + path: '/pages/coupon/detail', + type: APP_LINK_TYPE_ENUM.COUPON_DETAIL + }, + { + name: '文章详情', + path: '/pages/public/richtext', + type: APP_LINK_TYPE_ENUM.ARTICLE_DETAIL + } + ] + }, + { + name: '分销商城', + links: [ + { + name: '分销中心', + path: '/pages/commission/index' + }, + { + name: '申请分销商', + path: '/pages/commission/apply' + }, + { + name: '推广商品', + path: '/pages/commission/goods' + }, + { + name: '分销订单', + path: '/pages/commission/order' + }, + { + name: '分享记录', + path: '/pages/commission/share-log' + }, + { + name: '我的团队', + path: '/pages/commission/team' + } + ] + }, + { + name: '支付', + links: [ + { + name: '充值余额', + path: '/pages/pay/recharge' + }, + { + name: '充值记录', + path: '/pages/pay/recharge-log' + }, + { + name: '申请提现', + path: '/pages/pay/withdraw' + }, + { + name: '提现记录', + path: '/pages/pay/withdraw-log' + } + ] + }, + { + name: '用户中心', + links: [ + { + name: '用户信息', + path: '/pages/user/info' + }, + { + name: '用户订单', + path: '/pages/order/list' + }, + { + name: '售后订单', + path: '/pages/order/aftersale/list' + }, + { + name: '商品收藏', + path: '/pages/user/goods-collect' + }, + { + name: '浏览记录', + path: '/pages/user/goods-log' + }, + { + name: '地址管理', + path: '/pages/user/address/list' + }, + { + name: '发票管理', + path: '/pages/user/invoice/list' + }, + { + name: '用户佣金', + path: '/pages/user/wallet/commission' + }, + { + name: '用户余额', + path: '/pages/user/wallet/money' + }, + { + name: '用户积分', + path: '/pages/user/wallet/score' + } + ] + } +] diff --git a/src/components/AppLinkInput/index.vue b/src/components/AppLinkInput/index.vue new file mode 100644 index 00000000..a01386b9 --- /dev/null +++ b/src/components/AppLinkInput/index.vue @@ -0,0 +1,43 @@ + + diff --git a/src/components/DiyEditor/components/mobile/Carousel/property.vue b/src/components/DiyEditor/components/mobile/Carousel/property.vue index 700e0005..972ba507 100644 --- a/src/components/DiyEditor/components/mobile/Carousel/property.vue +++ b/src/components/DiyEditor/components/mobile/Carousel/property.vue @@ -103,7 +103,7 @@ - + diff --git a/src/components/DiyEditor/components/mobile/ImageBar/property.vue b/src/components/DiyEditor/components/mobile/ImageBar/property.vue index 58af1bc8..d8163615 100644 --- a/src/components/DiyEditor/components/mobile/ImageBar/property.vue +++ b/src/components/DiyEditor/components/mobile/ImageBar/property.vue @@ -13,7 +13,7 @@ - + diff --git a/src/components/DiyEditor/components/mobile/MagicCube/property.vue b/src/components/DiyEditor/components/mobile/MagicCube/property.vue index 57c0af79..fe938e5b 100644 --- a/src/components/DiyEditor/components/mobile/MagicCube/property.vue +++ b/src/components/DiyEditor/components/mobile/MagicCube/property.vue @@ -17,7 +17,7 @@ - + diff --git a/src/components/DiyEditor/components/mobile/MenuGrid/property.vue b/src/components/DiyEditor/components/mobile/MenuGrid/property.vue index e09dd318..b92e2099 100644 --- a/src/components/DiyEditor/components/mobile/MenuGrid/property.vue +++ b/src/components/DiyEditor/components/mobile/MenuGrid/property.vue @@ -38,7 +38,7 @@ - + diff --git a/src/components/DiyEditor/components/mobile/MenuList/property.vue b/src/components/DiyEditor/components/mobile/MenuList/property.vue index 270ca261..0ed6035c 100644 --- a/src/components/DiyEditor/components/mobile/MenuList/property.vue +++ b/src/components/DiyEditor/components/mobile/MenuList/property.vue @@ -31,7 +31,7 @@ - + diff --git a/src/components/DiyEditor/components/mobile/MenuSwiper/property.vue b/src/components/DiyEditor/components/mobile/MenuSwiper/property.vue index 2175d57e..31e158ce 100644 --- a/src/components/DiyEditor/components/mobile/MenuSwiper/property.vue +++ b/src/components/DiyEditor/components/mobile/MenuSwiper/property.vue @@ -48,7 +48,7 @@ - + diff --git a/src/components/DiyEditor/components/mobile/NoticeBar/property.vue b/src/components/DiyEditor/components/mobile/NoticeBar/property.vue index 11e7f4b7..a3eefebe 100644 --- a/src/components/DiyEditor/components/mobile/NoticeBar/property.vue +++ b/src/components/DiyEditor/components/mobile/NoticeBar/property.vue @@ -35,7 +35,7 @@
- +
diff --git a/src/components/DiyEditor/components/mobile/TabBar/property.vue b/src/components/DiyEditor/components/mobile/TabBar/property.vue index eefdf54a..a7634a5b 100644 --- a/src/components/DiyEditor/components/mobile/TabBar/property.vue +++ b/src/components/DiyEditor/components/mobile/TabBar/property.vue @@ -88,7 +88,7 @@
- + diff --git a/src/components/DiyEditor/components/mobile/TitleBar/property.vue b/src/components/DiyEditor/components/mobile/TitleBar/property.vue index 3e4dac2d..941e6d92 100644 --- a/src/components/DiyEditor/components/mobile/TitleBar/property.vue +++ b/src/components/DiyEditor/components/mobile/TitleBar/property.vue @@ -92,7 +92,7 @@ - + diff --git a/src/utils/index.ts b/src/utils/index.ts index 2eacb7e8..99f47697 100644 --- a/src/utils/index.ts +++ b/src/utils/index.ts @@ -1,3 +1,5 @@ +import { toNumber } from 'lodash-es' + /** * * @param component 需要注册的组件 @@ -264,6 +266,26 @@ export const calculateRelativeRate = (value?: number, reference?: number) => { return ((100 * ((value || 0) - reference)) / reference).toFixed(0) } +/** + * 获取链接的参数值 + * @param key 参数键名 + * @param urlStr 链接地址,默认为当前浏览器的地址 + */ +export const getUrlValue = (key: string, urlStr: string = location.href): string => { + if (!urlStr || !key) return '' + const url = new URL(decodeURIComponent(urlStr)) + return url.searchParams.get(key) ?? '' +} + +/** + * 获取链接的参数值(值类型) + * @param key 参数键名 + * @param urlStr 链接地址,默认为当前浏览器的地址 + */ +export const getUrlNumberValue = (key: string, urlStr: string = location.href): number => { + return toNumber(getUrlValue(key, urlStr)) +} + export const treeFormatter = (ary: any, val: string, valueField = 'value', nameField = 'label') => { let o = '' if (ary != null) { diff --git a/src/views/mall/product/category/components/ProductCategorySelect.vue b/src/views/mall/product/category/components/ProductCategorySelect.vue index 179a6a3b..c1810f5d 100644 --- a/src/views/mall/product/category/components/ProductCategorySelect.vue +++ b/src/views/mall/product/category/components/ProductCategorySelect.vue @@ -20,8 +20,12 @@ import { propTypes } from '@/utils/propTypes' defineOptions({ name: 'ProductCategorySelect' }) const props = defineProps({ - modelValue: oneOfType([propTypes.number.def(undefined), propTypes.array.def([])]).def(undefined), // 选中的ID - multiple: propTypes.bool.def(false) // 是否多选 + // 选中的ID + modelValue: oneOfType([Number, Array]), + // 是否多选 + multiple: propTypes.bool.def(false), + // 上级品类的编号 + parentId: propTypes.number.def(undefined) }) /** 选中的分类 ID */ @@ -38,10 +42,10 @@ const selectCategoryId = computed({ const emit = defineEmits(['update:modelValue']) /** 初始化 **/ -const categoryList = ref([]) // 分类树 +const categoryList = ref([]) // 分类树 onMounted(async () => { // 获得分类树 - const data = await ProductCategoryApi.getCategoryList({}) + const data = await ProductCategoryApi.getCategoryList({ parentId: props.parentId }) categoryList.value = handleTree(data, 'id', 'parentId') })