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 @@