Browse Source

修改返回

wangxy 18 hours ago
parent
commit
6c74de0eb3
1 changed files with 42 additions and 31 deletions
  1. 42 31
      components/sharePopUp/index.vue

+ 42 - 31
components/sharePopUp/index.vue

@@ -94,38 +94,49 @@
 
 	// 分享到微信
 	const shareToWeChat = (scene) => {
-		// 获取分享类型,确保是数字类型
-		const shareType = Number(props.type)
-
-		// 构建基础分享配置
-		const shareConfig = {
-			provider: 'weixin',
-			scene: scene === 'timeline' ? 'WXSceneTimeline' : 'WXSceneSession',
-			type: shareType,
-			success: function(res) {
-				emit('success', {
-					scene
-				})
-			},
-			fail: function(err) {
-				emit('error', err)
-				handleShareError(err)
-			}
-		}
-		// 根据类型添加不同的参数
-		if (shareType == 2) {
-			// 纯图片分享
-			shareConfig.imageUrl = props.image
-		} else {
-			// 图文或链接分享(兼容原有逻辑)
-			shareConfig.title = props.title
-			shareConfig.summary = props.desc
-			shareConfig.imageUrl = props.image
-			shareConfig.href = props.link
-		}
 
-		console.log('分享配置:', shareConfig)
-		uni.share(shareConfig)
+    uni.downloadFile({
+      url: props.image, // 你的网络图片地址
+      success: (downloadRes) =>{
+        // 获取分享类型,确保是数字类型
+        const shareType = Number(props.type)
+        // 构建基础分享配置
+        const shareConfig = {
+          provider: 'weixin',
+          scene: scene === 'timeline' ? 'WXSceneTimeline' : 'WXSceneSession',
+          type: shareType,
+          success: function(res) {
+            emit('success', {
+              scene
+            })
+          },
+          fail: function(err) {
+            emit('error', err)
+            handleShareError(err)
+          }
+        }
+        // 根据类型添加不同的参数
+        if (shareType == 2) {
+          // 纯图片分享
+          // shareConfig.imageUrl = props.image
+          shareConfig.imageUrl =  downloadRes.tempFilePath
+        } else {
+          // 图文或链接分享(兼容原有逻辑)
+          shareConfig.title = props.title
+          shareConfig.summary = props.desc
+          shareConfig.imageUrl = props.image
+          shareConfig.href = props.link
+        }
+        console.log('分享配置:', shareConfig)
+        uni.share(shareConfig)
+      }}).fail(() => {
+      // 其他错误
+      uni.showToast({
+        title: '海报分享失败,请检测网络状态',
+        icon: 'none',
+        duration: 3000
+      })
+    })
 	}