From 20e58e01c2756e897cb8b17ca554134c2cd53420 Mon Sep 17 00:00:00 2001 From: H1d3rOne Date: Tue, 10 Mar 2026 23:04:54 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=AE=8C=E5=96=84=E5=88=86=E4=BA=AB?= =?UTF-8?q?=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 使用button open-type=share配合onShareAppMessage - 页面加载时自动创建分享链接 - 点击分享按钮直接打开微信转发 - 已修改八字和紫微结果页 --- xuan-deduct-uniapp/src/pages/bazi/result.vue | 30 ++----- xuan-deduct-uniapp/src/pages/taluo/result.vue | 82 +++++++++---------- xuan-deduct-uniapp/src/pages/ziwei/result.vue | 56 ++++--------- 3 files changed, 64 insertions(+), 104 deletions(-) diff --git a/xuan-deduct-uniapp/src/pages/bazi/result.vue b/xuan-deduct-uniapp/src/pages/bazi/result.vue index e9ccf1b..0e96779 100644 --- a/xuan-deduct-uniapp/src/pages/bazi/result.vue +++ b/xuan-deduct-uniapp/src/pages/bazi/result.vue @@ -162,7 +162,7 @@ - @@ -240,6 +240,8 @@ export default { console.log('this.result.baZi:', this.result.baZi) console.log('this.result.lunar:', this.result.lunar) console.log('this.result.shengXiao:', this.result.shengXiao) + + this.createShareLink() } else { console.log('app.globalData.baziResult 是 undefined 或 null') uni.showToast({ @@ -280,10 +282,8 @@ export default { } return '-' }, - async shareResult() { + async createShareLink() { try { - uni.showLoading({ title: '创建分享链接...' }) - const shareData = { type: 'bazi', resultData: JSON.stringify(this.result), @@ -292,30 +292,12 @@ export default { const res = await api.shareApi.create(shareData) - uni.hideLoading() - if (res.success) { this.shareId = res.shareId - - // 使用微信小程序的分享功能 - // 用户点击右上角分享按钮时会自动调用 onShareAppMessage - uni.showModal({ - title: '分享提示', - content: '请点击右上角"..."按钮,选择"转发"分享给好友', - showCancel: false - }) - } else { - uni.showToast({ - title: res.error || '创建分享失败', - icon: 'none' - }) + console.log('分享链接创建成功:', this.shareId) } } catch (e) { - uni.hideLoading() - uni.showToast({ - title: '分享失败:' + (e.message || '未知错误'), - icon: 'none' - }) + console.error('创建分享链接失败:', e) } } } diff --git a/xuan-deduct-uniapp/src/pages/taluo/result.vue b/xuan-deduct-uniapp/src/pages/taluo/result.vue index e441918..4a10ae4 100644 --- a/xuan-deduct-uniapp/src/pages/taluo/result.vue +++ b/xuan-deduct-uniapp/src/pages/taluo/result.vue @@ -116,20 +116,11 @@