From 199e9f7b8aea46b63ebc5c7f9d7dc06e7ba4565d Mon Sep 17 00:00:00 2001 From: H1d3rOne Date: Tue, 10 Mar 2026 23:23:10 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=AE=8C=E5=96=84=E6=89=80=E6=9C=89?= =?UTF-8?q?=E6=B5=8B=E7=AE=97=E7=BB=93=E6=9E=9C=E9=A1=B5=E7=9A=84=E5=88=86?= =?UTF-8?q?=E4=BA=AB=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 - 页面加载时自动创建分享链接 - 点击分享按钮直接打开微信转发 - 已修改八字、紫微、塔罗、占星、奇门、六爻、梅花、大六壬结果页 - 删除旧的shareResult方法 --- .../src/pages/daliuren/result.vue | 48 ++++---------- .../src/pages/liuyao/result.vue | 36 +++++++++- .../src/pages/meihua/result.vue | 56 +++++++--------- xuan-deduct-uniapp/src/pages/qimen/result.vue | 54 +++++---------- xuan-deduct-uniapp/src/pages/taluo/result.vue | 29 ++++++++- .../src/pages/zhanxing/result.vue | 65 ++++++++----------- 6 files changed, 144 insertions(+), 144 deletions(-) diff --git a/xuan-deduct-uniapp/src/pages/daliuren/result.vue b/xuan-deduct-uniapp/src/pages/daliuren/result.vue index fc39f47..f07dc4e 100644 --- a/xuan-deduct-uniapp/src/pages/daliuren/result.vue +++ b/xuan-deduct-uniapp/src/pages/daliuren/result.vue @@ -215,7 +215,7 @@ - @@ -229,7 +229,15 @@ import api from '@/utils/api.js' export default { data() { return { - result: {} + result: {}, + shareId: '' + } + }, + onShareAppMessage() { + return { + title: `${this.result.name || '大六壬'}的测算结果`, + path: `/pages/share/view?shareId=${this.shareId}`, + imageUrl: '/static/share.png' } }, computed: { @@ -262,50 +270,22 @@ export default { onLoad() { this.result = getApp().globalData.daliurenResult || {} console.log('大六壬结果:', this.result) + this.createShareLink() }, methods: { - async shareResult() { + async createShareLink() { try { - uni.showLoading({ title: '创建分享链接...' }) - const shareData = { type: 'daliuren', resultData: JSON.stringify(this.result), name: this.result.name || '大六壬' } - const res = await api.shareApi.create(shareData) - - uni.hideLoading() - if (res.success) { - const shareUrl = `/pages/share/view?shareId=${res.shareId}` - - uni.showModal({ - title: '分享成功', - content: '点击确定转发给微信好友', - success: (modalRes) => { - if (modalRes.confirm) { - uni.shareAppMessage({ - title: `${this.result.name || '大六壬'}的测算结果`, - path: shareUrl, - imageUrl: '/static/share.png' - }) - } - } - }) - } else { - uni.showToast({ - title: res.error || '创建分享失败', - icon: 'none' - }) + this.shareId = res.shareId } } catch (e) { - uni.hideLoading() - uni.showToast({ - title: '分享失败:' + (e.message || '未知错误'), - icon: 'none' - }) + console.error('创建分享链接失败:', e) } } } diff --git a/xuan-deduct-uniapp/src/pages/liuyao/result.vue b/xuan-deduct-uniapp/src/pages/liuyao/result.vue index 702497e..4137071 100644 --- a/xuan-deduct-uniapp/src/pages/liuyao/result.vue +++ b/xuan-deduct-uniapp/src/pages/liuyao/result.vue @@ -173,16 +173,31 @@ + + + + diff --git a/xuan-deduct-uniapp/src/pages/meihua/result.vue b/xuan-deduct-uniapp/src/pages/meihua/result.vue index 9da034a..63627c6 100644 --- a/xuan-deduct-uniapp/src/pages/meihua/result.vue +++ b/xuan-deduct-uniapp/src/pages/meihua/result.vue @@ -149,7 +149,7 @@ - @@ -158,11 +158,20 @@