From 05316275ee6f1623cc022a3cb4967a440c105a6b Mon Sep 17 00:00:00 2001
From: cloudroam <cloudroam>
Date: 星期二, 29 七月 2025 16:43:42 +0800
Subject: [PATCH] add:编辑资料

---
 components/share-popup.vue |   46 +++++++++++++++++++++++++++++++++++++++-------
 1 files changed, 39 insertions(+), 7 deletions(-)

diff --git a/components/share-popup.vue b/components/share-popup.vue
index 9cd2ef9..f316f4d 100644
--- a/components/share-popup.vue
+++ b/components/share-popup.vue
@@ -4,14 +4,16 @@
     <view class="share-content">
       <view class="share-title">分享到</view>
       <view class="share-options">
-        <button class="share-item" open-type="share" @click="handleShare('wechat')">
+        <!-- 分享给好友 -->
+        <button class="share-item" open-type="share">
           <image src="/static/common/wechat.png" class="share-icon" />
           <text>微信好友</text>
         </button>
-        <button class="share-item" open-type="share" @click="handleShare('moments')">
+        <!-- 分享到朋友圈 -->
+        <view class="share-item" @click="handleShareTimeline">
           <image src="/static/common/wechat-moments.png" class="share-icon" />
           <text>朋友圈</text>
-        </button>
+        </view>
         <view class="share-item" @click="handleCopyLink">
           <image src="/static/common/link.png" class="share-icon" />
           <text>复制链接</text>
@@ -48,10 +50,40 @@
   emit('update:show', false)
 }
 
-// 处理分享
-const handleShare = (type: 'wechat' | 'moments') => {
-  // 小程序分享通过页面配置和按钮的 open-type="share" 实现
-  // 分享内容在页面的 onShareAppMessage 中配置
+// 处理分享到朋友圈
+const handleShareTimeline = () => {
+  // #ifdef MP-WEIXIN
+  // 使用微信原生朋友圈分享
+  wx.openChannelsActivity({
+    finderUserName: '', // 视频号用户名,可选
+    success: (res) => {
+      console.log('打开朋友圈成功', res)
+      uni.showToast({
+        title: '已打开朋友圈',
+        icon: 'success'
+      })
+    },
+    fail: (err) => {
+      console.error('打开朋友圈失败', err)
+      // 如果打开失败,尝试使用小程序分享
+      uni.showModal({
+        title: '提示',
+        content: '无法直接打开朋友圈,请点击右上角分享到朋友圈',
+        showCancel: false
+      })
+    }
+  })
+  // #endif
+  
+  // #ifndef MP-WEIXIN
+  // 非微信小程序环境
+  uni.showToast({
+    title: '请点击右上角分享到朋友圈',
+    icon: 'none',
+    duration: 2000
+  })
+  // #endif
+  
   closePopup()
 }
 

--
Gitblit v1.9.3