From 69f6439d06a7c9c964328f59ec1e48d5863c1bab Mon Sep 17 00:00:00 2001 From: 15093570141 <141405260+17521612761@users.noreply.github.com> Date: Wed, 23 Oct 2024 00:04:50 +0800 Subject: [PATCH] =?UTF-8?q?uniapp=E3=80=90=E4=BC=98=E5=8C=96=E3=80=91?= =?UTF-8?q?=EF=BC=88=E5=88=86=E4=BA=AB=E6=A8=A1=E5=9D=97=EF=BC=89=EF=BC=9A?= =?UTF-8?q?=E5=B0=81=E8=A3=85=E5=88=86=E4=BA=AB=E8=AF=B7=E6=B1=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../CoreShop/core/hooks/index.ts | 1 - .../CoreShop/core/hooks/use-share.ts | 61 ----------- .../CoreShop/core/utils/handle-share.ts | 41 +++++++ .../CoreShop/core/utils/index.ts | 6 +- .../CoreShop/pages/goods/detail.vue | 102 +++++------------- .../CoreShop/pages/home/home.vue | 36 ++++++- .../CoreShop/pages/member/member.vue | 23 +++- .../CoreShop/pages/share/jump/jump.vue | 28 ++--- .../activity/groupBuying/detail/detail.vue | 37 +++---- .../activity/pinTuan/detail/detail.vue | 39 ++++++- .../activity/seckill/detail/detail.vue | 37 +++---- .../activity/solitaire/detail/detail.vue | 35 ++---- .../pages/subpackage/agency/index/index.vue | 35 ++---- .../pages/subpackage/agency/store/index.vue | 45 +++----- .../subpackage/article/detail/detail.vue | 51 ++++----- .../pages/subpackage/custom/custom.vue | 36 ++++++- .../subpackage/distribution/index/index.vue | 43 +++----- .../subpackage/distribution/store/index.vue | 43 +++----- .../pages/subpackage/form/detail/detail.vue | 36 ++----- .../pages/subpackage/notice/detail/detail.vue | 46 +++----- .../subpackage/serviceGoods/detail/detail.vue | 39 ++++++- 21 files changed, 377 insertions(+), 443 deletions(-) delete mode 100644 CoreCms.Net.Uni-App/CoreShop/core/hooks/use-share.ts create mode 100644 CoreCms.Net.Uni-App/CoreShop/core/utils/handle-share.ts diff --git a/CoreCms.Net.Uni-App/CoreShop/core/hooks/index.ts b/CoreCms.Net.Uni-App/CoreShop/core/hooks/index.ts index 932f35ab..015a01b7 100644 --- a/CoreCms.Net.Uni-App/CoreShop/core/hooks/index.ts +++ b/CoreCms.Net.Uni-App/CoreShop/core/hooks/index.ts @@ -1,4 +1,3 @@ /** 系统配置 */ export * from './systemInfo'; export * from './use-loading'; -export * from './use-share'; diff --git a/CoreCms.Net.Uni-App/CoreShop/core/hooks/use-share.ts b/CoreCms.Net.Uni-App/CoreShop/core/hooks/use-share.ts deleted file mode 100644 index b3945b4a..00000000 --- a/CoreCms.Net.Uni-App/CoreShop/core/hooks/use-share.ts +++ /dev/null @@ -1,61 +0,0 @@ -import { onShareAppMessage, onShareTimeline } from '@dcloudio/uni-app'; -import { queryShare } from '@/core/api'; -import { ShareClientEnum, ShareModelEnum, ShareEnum } from '@/core/enum'; -import { handleShowToast } from '@/core/utils'; -import { UserToken } from '@/core/consts'; - -interface RequestParam { - client ?: ShareClientEnum; - url ?: string; - type ?: ShareModelEnum; - page ?: ShareEnum; - params ?: any; - token ?: string; -} - -export const useShareHook = () => { - - /** 获取分享url */ - const getShareUrl = (requestParam : RequestParam) => { - return new Promise(async (resolve) => { - let data = requestParam; - if (uni.getStorageSync(UserToken)) { - data['token'] = uni.getStorageSync(UserToken) - } - const share = await queryShare(data); - if (share.status) { - resolve(share.data); - } else { - handleShowToast(share.msg); - } - }) - } - - const shareAppMessage = (options : Page.CustomShareContent) => { - onShareAppMessage(() => { - console.log('onShareAppMessage'); - return { - ...options - }; - }); - return { onShareAppMessage }; - }; - - const shareTimeline = (options : Page.CustomShareContent) => { - onShareTimeline(() => { - console.log('shareTimeline'); - return { - ...options - }; - }); - return { onShareTimeline }; - }; - - const share = (customShareContent : Page.CustomShareContent, shareTimelineContent ?: Page.CustomShareContent) => { - const { onShareAppMessage } = shareAppMessage(customShareContent); - const { onShareTimeline } = shareTimeline(shareTimelineContent ? shareTimelineContent : customShareContent); - return { onShareAppMessage, onShareTimeline }; - }; - - return { share, getShareUrl, shareAppMessage, shareTimeline }; -}; \ No newline at end of file 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 70cdc3de..9c866f75 100644 --- a/CoreCms.Net.Uni-App/CoreShop/pages/goods/detail.vue +++ b/CoreCms.Net.Uni-App/CoreShop/pages/goods/detail.vue @@ -26,19 +26,18 @@