Sfoglia il codice sorgente

feat:首页分享好友,朋友圈

zhanghui 2 anni fa
parent
commit
822d03f05f
1 ha cambiato i file con 50 aggiunte e 4 eliminazioni
  1. 50 4
      pages/index/index.vue

+ 50 - 4
pages/index/index.vue

@@ -276,7 +276,18 @@ export default {
     }
   },
   onLoad(e) {
+
+    if (e.shareUserId){
+      //用户点击分享到好友或者朋友圈传递过来的参数
+      console.log('shareUserId===============>',e.shareUserId)
+      // setTimeout(()=>{
+      //   this.userInfo = uni.getStorageSync('userInfo');
+      //   this.scanCode(this.userInfo.otherId,e.shareUserId);
+      // },5000)
+    }
+
     if(e.q){
+      //用户扫技师端二维码传递过来的参数
       const q = decodeURIComponent(e.q)
       let a = q.split('?')
       let b=a[1].split('&')
@@ -325,12 +336,47 @@ export default {
     },2000)
 
   },
-  // 分享到朋友圈
-  onShareTimeline() {
+  //分享到朋友圈
+  onShareTimeline(option) {
+    return {
+      title: '娇骄儿造型',
+      imageUrl:'/static/logo.png',
+      query: `shareUserId='${this.userInfo.id}`,
+      success(res) {
+        uni.showToast({
+          title: '分享成功'
+        })
+      },
+      fail(res) {
+        uni.showToast({
+          title: '分享失败',
+          icon: 'none'
+        })
+      }
+    };
   },
-  // 分享到用户
-  onShareAppMessage(OBJECT) {
+
+  //分享到好友
+  onShareAppMessage: function (res) {
+    return {
+      title: '娇骄儿造型',
+      imageUrl:'/static/logo.png',
+      path: `/pages/index/index?shareUserId=${this.userInfo.id}`,
+      success(res){
+        uni.showToast({
+          title:'分享成功'
+        })
+      },
+      fail(res){
+        uni.showToast({
+          title:'分享失败',
+          icon:'none'
+        })
+      }
+    };
   },
+
+
   methods: {
 
     scanCode(otherId,memberId){