diff --git a/CoreCms.Net.Uni-App/CoreShop/core/utils/handle-share.ts b/CoreCms.Net.Uni-App/CoreShop/core/utils/handle-share.ts new file mode 100644 index 00000000..736f27b9 --- /dev/null +++ b/CoreCms.Net.Uni-App/CoreShop/core/utils/handle-share.ts @@ -0,0 +1,41 @@ +import { ShareClientEnum, ShareModelEnum, ShareEnum } from '@/core/enum'; +import { UserToken } from '@/core/consts'; +import { queryShare } from '@/core/api'; +import { handleShowToast } from '@/core/utils'; +import { useShopConfigStore } from '@/core/store'; + +interface RequestParam { + client : ShareClientEnum, + url : string, + type : ShareModelEnum, + page : ShareEnum, + params ?: any, + token ?: string +} + +const getDefaultShareData = () => { + const shopConfigStore = useShopConfigStore(); + return { + title: shopConfigStore.config?.shopName, + imageUrl: shopConfigStore.config?.shopLogo, + path: "/pages/home/home" + } +} + +const getShareUrl = async (requestParam : RequestParam) => { + let data : RequestParam = requestParam; + if (uni.getStorageSync(UserToken)) { + data['token'] = uni.getStorageSync(UserToken) + } + const share = await queryShare(data); + if (share.status) { + return share.data; + } else { + handleShowToast(share.msg); + } +} + +export { + getShareUrl, + getDefaultShareData, +} \ No newline at end of file diff --git a/CoreCms.Net.Uni-App/CoreShop/core/utils/index.ts b/CoreCms.Net.Uni-App/CoreShop/core/utils/index.ts index 8eb5f04f..4d2aaa48 100644 --- a/CoreCms.Net.Uni-App/CoreShop/core/utils/index.ts +++ b/CoreCms.Net.Uni-App/CoreShop/core/utils/index.ts @@ -23,4 +23,8 @@ export * from './handle-toast'; export * from './handle-advertise-detail'; export * from './uni-promise'; -export * from './time-format'; \ No newline at end of file +export * from './time-format'; + + +/** 处理分享 */ +export * from './handle-share'; \ No newline at end of file diff --git a/CoreCms.Net.Uni-App/CoreShop/pages/goods/detail.vue b/CoreCms.Net.Uni-App/CoreShop/pages/goods/detail.vue index d14e26e2..9c866f75 100644 --- a/CoreCms.Net.Uni-App/CoreShop/pages/goods/detail.vue +++ b/CoreCms.Net.Uni-App/CoreShop/pages/goods/detail.vue @@ -27,12 +27,12 @@