Browse Source

增加分享

HW 3 years ago
parent
commit
8f5ae4d72c
2 changed files with 15 additions and 9 deletions
  1. 2 2
      src/pages/details/index.jsx
  2. 13 7
      src/pages/index/index.jsx

+ 2 - 2
src/pages/details/index.jsx

@@ -63,8 +63,8 @@ class Details extends Component {
   //朋友圈分享
   onShareTimeline(){
     return {
-      title: this.state.weChatShareDetails.title,
-      query: 'id=6',
+      title: this.state.weChatShareDetails.title || this.state.projectInfor.name,
+      query: 'id='+this.inst.router.params.id,
       imageUrl: this.state.weChatShareDetails.momentsUrl ? (resourceAddress + this.state.weChatShareDetails.momentsUrl) : (resourceAddress + this.state.projectInfor.thumbnailUrl)
     }
   }

+ 13 - 7
src/pages/index/index.jsx

@@ -97,7 +97,7 @@ class Index extends Component {
     getWeChatShareDetails({type:1}).then(v=>{
       if(v.error.length === 0){
         this.setState({
-          weChatShareDetails:v.data
+          weChatShareDetails:v.data || {}
         })
       }else{
         Taro.showToast({title:v.error[0].message,icon:'none'})
@@ -106,18 +106,24 @@ class Index extends Component {
   }
 
   onShareAppMessage(){
-    return {
-      title: this.state.weChatShareDetails.title,
-      imageUrl: resourceAddress + this.state.weChatShareDetails.shareUrl
+    let data = {
+      title: this.state.weChatShareDetails.title || '科德高企培育',
     }
+    if(this.state.weChatShareDetails.shareUrl){
+      data.imageUrl = resourceAddress + this.state.weChatShareDetails.shareUrl
+    }
+    return data
   }
 
   //朋友圈分享
   onShareTimeline(){
-    return {
-      title: this.state.weChatShareDetails.title,
-      imageUrl: resourceAddress + this.state.weChatShareDetails.momentsUrl
+    let data = {
+      title: this.state.weChatShareDetails.title || '科德高企培育',
+    }
+    if(this.state.weChatShareDetails.momentsUrl){
+      data.imageUrl = resourceAddress + this.state.weChatShareDetails.momentsUrl
     }
+    return data
   }
 
   render () {