Преглед на файлове

【功能完善】小程序支持转发到朋友圈

puhui999 преди 8 месеца
родител
ревизия
4c4134389e
променени са 1 файла, в които са добавени 15 реда и са изтрити 4 реда
  1. 15 4
      sheep/components/s-layout/s-layout.vue

+ 15 - 4
sheep/components/s-layout/s-layout.vue

@@ -60,12 +60,11 @@
   /**
    * 模板组件 - 提供页面公共组件,属性,方法
    */
-  import { computed, reactive, ref } from 'vue';
+  import { computed } from 'vue';
   import sheep from '@/sheep';
   import { isEmpty } from 'lodash-es';
-  import { onShow } from '@dcloudio/uni-app';
   // #ifdef MP-WEIXIN
-  import { onShareAppMessage } from '@dcloudio/uni-app';
+  import { onShareAppMessage, onShareTimeline, onShow } from '@dcloudio/uni-app';
   // #endif
 
   const props = defineProps({
@@ -191,7 +190,11 @@
   });
 
   // #ifdef MP-WEIXIN
-  // 微信小程序分享
+  uni.showShareMenu({
+    withShareTicket: true,
+    menus: ['shareAppMessage', 'shareTimeline'],
+  });
+  // 微信小程序分享好友
   onShareAppMessage(() => {
     return {
       title: shareInfo.value.title,
@@ -199,6 +202,14 @@
       imageUrl: shareInfo.value.image,
     };
   });
+  // 微信小程序分享朋友圈
+  onShareTimeline(() => {
+    return {
+      title: shareInfo.value.title,
+      query: shareInfo.value.path,
+      imageUrl: shareInfo.value.image,
+    };
+  });
   // #endif
 
   onShow(() => {