浏览代码

Merge branch 'fix_share' into debug

Karsa 10 月之前
父节点
当前提交
4146f37277
共有 5 个文件被更改,包括 146 次插入63 次删除
  1. 5 0
      src/api/api.js
  2. 36 16
      src/views/report/reportDetail.vue
  3. 7 5
      src/views/reportEn/detail.vue
  4. 33 14
      src/views/smartReport/detail.vue
  5. 65 28
      src/views/utils/wxShare.js

+ 5 - 0
src/api/api.js

@@ -25,4 +25,9 @@ export const getWxSign = params=>{
 // 智能研报详情
 // 智能研报详情
 export const smartReportDetail=params=>{
 export const smartReportDetail=params=>{
   return get('/smart_report/share/detail',params)
   return get('/smart_report/share/detail',params)
+}
+
+//获取分享信息
+export const getShareInfo=params=>{
+  return get('/smart_report/wechat_share/detail',params)
 }
 }

+ 36 - 16
src/views/report/reportDetail.vue

@@ -81,7 +81,7 @@
       <div style="padding: 0.6rem; box-sizing: border-box; overflow: hidden">
       <div style="padding: 0.6rem; box-sizing: border-box; overflow: hidden">
 
 
         <!-- 章节报告 -->
         <!-- 章节报告 -->
-        <div class="chapter-wrap" v-if="reportInfo.HasChapter===1">
+        <!-- <div class="chapter-wrap" v-if="reportInfo.HasChapter===1">
           <div class="chapter-item" v-for="item in reportInfo.ChapterList" :key="item.ReportChapterId">
           <div class="chapter-item" v-for="item in reportInfo.ChapterList" :key="item.ReportChapterId">
             <div style="margin-bottom:10px">
             <div style="margin-bottom:10px">
               <span class="type" v-if="item.TypeName">{{item.TypeName}}</span>
               <span class="type" v-if="item.TypeName">{{item.TypeName}}</span>
@@ -89,9 +89,9 @@
             </div>
             </div>
             <div id="resetcss" style="overflow:hidden;" v-html="item.Content"></div>
             <div id="resetcss" style="overflow:hidden;" v-html="item.Content"></div>
           </div>
           </div>
-        </div>
+        </div> -->
 
 
-        <div id="resetcss" style="overflow:hidden;" v-else>
+        <div id="resetcss" style="overflow:hidden;">
           <ul>
           <ul>
             <li v-for="(html,index) in realContent" :key="index" v-html="html"></li>
             <li v-for="(html,index) in realContent" :key="index" v-html="html"></li>
           </ul>
           </ul>
@@ -165,9 +165,10 @@
 <script>
 <script>
 import {
 import {
   reportDetail,
   reportDetail,
+  getShareInfo
 } from "@/api/api.js";
 } from "@/api/api.js";
 import _ from 'lodash';
 import _ from 'lodash';
-import wxShare from '../utils/wxShare.js';
+import {wxShare,injectSdk} from '../utils/wxShare.js';
 
 
 import AudioPlay from './audioPlay.vue';
 import AudioPlay from './audioPlay.vue';
 import { Watermark,BlindWatermark } from 'watermark-js-plus'
 import { Watermark,BlindWatermark } from 'watermark-js-plus'
@@ -189,11 +190,13 @@ export default {
       Disclaimer:''
       Disclaimer:''
     };
     };
   },
   },
+  created() {
+    wx.hideAllNonBaseMenuItem();
+  },
   mounted() {
   mounted() {
-    wx.ready(function(){
-        wx.hideOptionMenu();
-    });
-    this.getreportdetail();
+    injectSdk().then(res => {
+      this.getShareData()
+    })
     window.addEventListener('scroll', this.loadMoreHandle);
     window.addEventListener('scroll', this.loadMoreHandle);
   },
   },
 
 
@@ -241,6 +244,13 @@ export default {
       .css({ display: "block", whiteSpace: "pre-wrap" });
       .css({ display: "block", whiteSpace: "pre-wrap" });
   },
   },
   methods: {
   methods: {
+    async getShareData() {
+      let res = await getShareInfo({ ReportCode: this.id })
+      if(res.Ret !== 200) return 
+      
+      wxShare(document.location.href,res.Data.H5ShareName||document.title,res.Data.H5ShareTitle,res.Data.H5ReportShareImg,0);
+      this.getreportdetail()
+    },
     showTips() {
     showTips() {
       //免责声明显示
       //免责声明显示
       $("#tipsAlert").animate({ top: 0 });
       $("#tipsAlert").animate({ top: 0 });
@@ -280,16 +290,16 @@ export default {
         document.title=(Data && Data.H5ShareName) || "研报"
         document.title=(Data && Data.H5ShareName) || "研报"
         if (Ret !== 200) return
         if (Ret !== 200) return
         // console.log('data',Data)
         // console.log('data',Data)
-        let H5ShareName = Data.H5ShareName
-        let H5ReportShareImg = Data.H5ReportShareImg
-        let wxShareTitle=!!Data.Hz?
-        '【第'+Data.Report.Stage+'期|FICC'+'】'+Data.Report.Title+'('+Data.Report.CreateTime.substring(5,7)+Data.Report.CreateTime.substring(8,10)+')':
-                          Data.Report.Title+'('+Data.Report.CreateTime.substring(5,7)+Data.Report.CreateTime.substring(8,10)+')'
+        // let H5ShareName = Data.H5ShareName
+        // let H5ReportShareImg = Data.H5ReportShareImg
+        // let wxShareTitle=!!Data.Hz?
+        // '【第'+Data.Report.Stage+'期|FICC'+'】'+Data.Report.Title+'('+Data.Report.CreateTime.substring(5,7)+Data.Report.CreateTime.substring(8,10)+')':
+        //                   Data.Report.Title+'('+Data.Report.CreateTime.substring(5,7)+Data.Report.CreateTime.substring(8,10)+')'
         this.reportInfo = Data.Report;
         this.reportInfo = Data.Report;
         this.Disclaimer = Data.Disclaimer||'';
         this.Disclaimer = Data.Disclaimer||'';
         this.isshow = true;
         this.isshow = true;
 
 
-        this.splitContentHandle(this.reportInfo.Content);
+        this.splitContentHandle();
 
 
         $(document).on("click", "#resetcss img", function (event) {
         $(document).on("click", "#resetcss img", function (event) {
           let imgArray = [];
           let imgArray = [];
@@ -303,7 +313,7 @@ export default {
             wx.previewImage({ current: curImageSrc, urls: imgArray });
             wx.previewImage({ current: curImageSrc, urls: imgArray });
           }
           }
         });
         });
-        wxShare(document.location.href,H5ShareName || document.title,wxShareTitle,H5ReportShareImg,0);
+
         //水印
         //水印
         localStorage.setItem('waterMarkStr',this.$route.query.flag||'')
         localStorage.setItem('waterMarkStr',this.$route.query.flag||'')
         const temwaterMarkStr=this.$route.query.flag||localStorage.getItem('waterMarkStr')
         const temwaterMarkStr=this.$route.query.flag||localStorage.getItem('waterMarkStr')
@@ -350,12 +360,22 @@ export default {
 
 
 
 
     /*内容分割*/
     /*内容分割*/
-    splitContentHandle(content) {
+    splitContentHandle() {
+      let content='';
+      if(this.reportInfo.HasChapter===1) {
+        this.reportInfo.ChapterList.forEach(item => {
+          content+=item.Content
+        })
+      }else {
+        content = this.reportInfo.Content;
+      }
+
       const arr = content.split("</p>");
       const arr = content.split("</p>");
       this.totalContent = arr.map((_) => _ + "</p>");
       this.totalContent = arr.map((_) => _ + "</p>");
       this.realContent = this.totalContent.slice(0, this.pageSize);
       this.realContent = this.totalContent.slice(0, this.pageSize);
       this.total_page = parseInt(this.totalContent.length / this.pageSize) + 1;
       this.total_page = parseInt(this.totalContent.length / this.pageSize) + 1;
       // console.log(this.realContent, this.totalContent);
       // console.log(this.realContent, this.totalContent);
+
     },
     },
 
 
     /* 加载下一页内容 */
     /* 加载下一页内容 */

+ 7 - 5
src/views/reportEn/detail.vue

@@ -115,7 +115,7 @@ import {
   reportEnDetail,
   reportEnDetail,
 } from "@/api/api.js";
 } from "@/api/api.js";
 import _ from 'lodash';
 import _ from 'lodash';
-import wxShare from '../utils/wxShare.js'
+import {wxShare,injectSdk} from '../utils/wxShare.js'
 import { Watermark,BlindWatermark } from 'watermark-js-plus'
 import { Watermark,BlindWatermark } from 'watermark-js-plus'
 import { Base64 } from 'js-base64';
 import { Base64 } from 'js-base64';
 export default {
 export default {
@@ -133,11 +133,13 @@ export default {
       total_page: 0,
       total_page: 0,
     };
     };
   },
   },
+  created() {
+    wx.hideAllNonBaseMenuItem();
+  },
   mounted() {
   mounted() {
-    wx.ready(function(){
-        wx.hideOptionMenu();
-    });
-    this.getreportdetail();
+    injectSdk().then(res => {
+      this.getreportdetail()
+    })
     window.addEventListener('scroll', this.loadMoreHandle);
     window.addEventListener('scroll', this.loadMoreHandle);
   },
   },
   destroyed() {
   destroyed() {

+ 33 - 14
src/views/smartReport/detail.vue

@@ -94,9 +94,9 @@
 </template>
 </template>
 
 
 <script>
 <script>
-import { smartReportDetail,reportDetail } from "@/api/api.js";
+import { getShareInfo,reportDetail } from "@/api/api.js";
 import _ from "lodash";
 import _ from "lodash";
-import wxShare from "../utils/wxShare.js";
+import {wxShare,injectSdk} from "../utils/wxShare.js";
 
 
 export default {
 export default {
   data() {
   data() {
@@ -124,11 +124,13 @@ export default {
       }
       }
     };
     };
   },
   },
+  created() {
+    wx.hideAllNonBaseMenuItem();
+  },
   mounted() {
   mounted() {
-    wx.ready(function(){
-        wx.hideOptionMenu();
-    });
-    this.getreportdetail();
+    injectSdk().then(res => {
+      this.getShareData()
+    })
     window.addEventListener("scroll", this.loadMoreHandle);
     window.addEventListener("scroll", this.loadMoreHandle);
     window.addEventListener('resize',this.pageResize)
     window.addEventListener('resize',this.pageResize)
   },
   },
@@ -139,6 +141,13 @@ export default {
   },
   },
 
 
   methods: {
   methods: {
+    async getShareData() {
+      let res = await getShareInfo({ ReportCode: this.id })
+      if(res.Ret !== 200) return 
+      
+      wxShare(document.location.href,res.Data.H5ShareName||document.title,res.Data.H5ShareTitle,res.Data.H5ReportShareImg,0);
+      this.getreportdetail()
+    },
     pageResize(){
     pageResize(){
       const el=document.getElementById('reportdtl')
       const el=document.getElementById('reportdtl')
       const windowWid=document.body.clientWidth
       const windowWid=document.body.clientWidth
@@ -165,11 +174,11 @@ export default {
       document.title = (Data && Data.H5ShareName) || "研报";
       document.title = (Data && Data.H5ShareName) || "研报";
       if (Ret !== 200) return;
       if (Ret !== 200) return;
       // console.log('data',Data)
       // console.log('data',Data)
-      let H5ShareName = Data.H5ShareName;
-      let H5ReportShareImg = Data.H5ReportShareImg;
-      let wxShareTitle = !!Data.Hz
-        ? "【第" + Data.Report.Stage + "期|FICC" + "】" + Data.Report.Title + "(" + Data.Report.CreateTime.substring(5, 7) + Data.Report.CreateTime.substring(8, 10) + ")"
-        : Data.Report.Title + "(" + Data.Report.CreateTime.substring(5, 7) + Data.Report.CreateTime.substring(8, 10) + ")";
+      // let H5ShareName = Data.H5ShareName;
+      // let H5ReportShareImg = Data.H5ReportShareImg;
+      // let wxShareTitle = !!Data.Hz
+      //   ? "【第" + Data.Report.Stage + "期|FICC" + "】" + Data.Report.Title + "(" + Data.Report.CreateTime.substring(5, 7) + Data.Report.CreateTime.substring(8, 10) + ")"
+      //   : Data.Report.Title + "(" + Data.Report.CreateTime.substring(5, 7) + Data.Report.CreateTime.substring(8, 10) + ")";
       this.reportInfo = Data.Report || {};
       this.reportInfo = Data.Report || {};
       this.headImgStyle=this.reportInfo.HeadStyle?JSON.parse(this.reportInfo.HeadStyle):[]
       this.headImgStyle=this.reportInfo.HeadStyle?JSON.parse(this.reportInfo.HeadStyle):[]
       this.endImgStyle=this.reportInfo.EndStyle?JSON.parse(this.reportInfo.EndStyle):[]
       this.endImgStyle=this.reportInfo.EndStyle?JSON.parse(this.reportInfo.EndStyle):[]
@@ -184,7 +193,9 @@ export default {
         this.pageResize()
         this.pageResize()
       })
       })
 
 
-      this.splitContentHandle(this.reportInfo.Content);
+      // wxShare(document.location.href, H5ShareName || document.title, wxShareTitle, H5ReportShareImg, 0);
+
+      // this.splitContentHandle();
 
 
       $(document).on("click", "#resetcss img", function (event) {
       $(document).on("click", "#resetcss img", function (event) {
         let imgArray = [];
         let imgArray = [];
@@ -198,11 +209,19 @@ export default {
           wx.previewImage({ current: curImageSrc, urls: imgArray });
           wx.previewImage({ current: curImageSrc, urls: imgArray });
         }
         }
       });
       });
-      wxShare(document.location.href, H5ShareName || document.title, wxShareTitle, H5ReportShareImg, 0);
     },
     },
 
 
     /*内容分割*/
     /*内容分割*/
-    splitContentHandle(content) {
+    splitContentHandle() {
+      let content='';
+      if(this.reportInfo.HasChapter===1) {
+        this.reportInfo.ChapterList.forEach(item => {
+          content+=item.Content
+        })
+      }else {
+        content = this.reportInfo.Content;
+      }
+
       const regex = new RegExp(`<div[^>]*class="?report-drag-item-wrap"?>`);
       const regex = new RegExp(`<div[^>]*class="?report-drag-item-wrap"?>`);
       const arr = content.split(regex);
       const arr = content.split(regex);
       this.totalContent = arr.map((_) => _ + "<div class='report-drag-item-wrap'>");
       this.totalContent = arr.map((_) => _ + "<div class='report-drag-item-wrap'>");

+ 65 - 28
src/views/utils/wxShare.js

@@ -1,33 +1,33 @@
 import {getWxSign} from '@/api/api';
 import {getWxSign} from '@/api/api';
 import { Toast } from 'vant';
 import { Toast } from 'vant';
 // import utils from '@/utils/utils';
 // import utils from '@/utils/utils';
-export default function wxShare(shareurl,title,desc,imgurl,hide){
-  getWxSign({
-    Url:window.location.href.split('#')[0]
-  }).then((res)=>{
-    if( res.Ret===200 ){
-      wx.config({
-        debug:false, // 开启调试模式,调用的所有api的返回值会在客户端alert出来,若要查看传入的参数,可以在pc端打开,参数信息会通过log打出,仅在pc端时才会打印。
-        appId:res.Data.AppId, // 必填,企业号的唯一标识,此处填写企业号corpid
-        timestamp:res.Data.Timestamp, // 必填,生成签名的时间戳
-        nonceStr:res.Data.NonceStr, // 必填,生成签名的随机串
-        signature:res.Data.Signature,// 必填,签名,见附录1
-        jsApiList:['updateTimelineShareData',//1.4.0的分享接口,注意:使用新版本的分享功能,一定要在该列表加上对应的老版本功能接口,否则新接口不起作用
-        'updateAppMessageShareData',//1.4.0的分享接口,注意:使用新版本的分享功能,一定要在该列表加上对应的老版本功能接口,否则新接口不起作用
-        'hideOptionMenu',
-        'showOptionMenu',
-        'hideMenuItems']
-        // 'onMenuShareAppMessage',//老版本分享接口。
-        // 'onMenuShareTimeline',
-      });
-    }else {
-      console.log(res)
-      if(res.Ret!==4003){
-        Toast('获取签名失败,请刷新重试!')
-      }
+export function wxShare(shareurl,title,desc,imgurl,hide){
+  // getWxSign({
+  //   Url:window.location.href.split('#')[0]
+  // }).then((res)=>{
+  //   if( res.Ret===200 ){
+  //     wx.config({
+  //       debug:false, // 开启调试模式,调用的所有api的返回值会在客户端alert出来,若要查看传入的参数,可以在pc端打开,参数信息会通过log打出,仅在pc端时才会打印。
+  //       appId:res.Data.AppId, // 必填,企业号的唯一标识,此处填写企业号corpid
+  //       timestamp:res.Data.Timestamp, // 必填,生成签名的时间戳
+  //       nonceStr:res.Data.NonceStr, // 必填,生成签名的随机串
+  //       signature:res.Data.Signature,// 必填,签名,见附录1
+  //       jsApiList:['updateTimelineShareData',//1.4.0的分享接口,注意:使用新版本的分享功能,一定要在该列表加上对应的老版本功能接口,否则新接口不起作用
+  //       'updateAppMessageShareData',//1.4.0的分享接口,注意:使用新版本的分享功能,一定要在该列表加上对应的老版本功能接口,否则新接口不起作用
+  //       'hideOptionMenu',
+  //       'showOptionMenu',
+  //       'hideMenuItems']
+  //       // 'onMenuShareAppMessage',//老版本分享接口。
+  //       // 'onMenuShareTimeline',
+  //     });
+  //   }else {
+  //     console.log(res)
+  //     if(res.Ret!==4003){
+  //       Toast('获取签名失败,请刷新重试!')
+  //     }
       
       
-      return 
-    }
+  //     return 
+  //   }
     if( hide==1 ){
     if( hide==1 ){
       wx.ready(function(){
       wx.ready(function(){
         wx.hideOptionMenu();
         wx.hideOptionMenu();
@@ -37,7 +37,7 @@ export default function wxShare(shareurl,title,desc,imgurl,hide){
       wx.ready(function(){
       wx.ready(function(){
         // config信息验证后会执行ready方法,所有接口调用都必须在config接口获得结果之后,config是一个客户端的异步操作,所以如果需要在页面加载时就调用相关接口,则须把相关接口放在ready函数中调用来确保正确执行。对于用户触发时才调用的接口,则可以直接调用,不需要放在ready函数中。
         // config信息验证后会执行ready方法,所有接口调用都必须在config接口获得结果之后,config是一个客户端的异步操作,所以如果需要在页面加载时就调用相关接口,则须把相关接口放在ready函数中调用来确保正确执行。对于用户触发时才调用的接口,则可以直接调用,不需要放在ready函数中。
         
         
-        wx.showOptionMenu();
+        // wx.showOptionMenu();
 
 
         let shareData = {
         let shareData = {
           title, // 分享标题
           title, // 分享标题
@@ -65,11 +65,48 @@ export default function wxShare(shareurl,title,desc,imgurl,hide){
         wx.hideMenuItems({
         wx.hideMenuItems({
           menuList: ['menuItem:share:qq','menuItem:share:weiboApp','menuItem:share:facebook','menuItem:share:QZone','menuItem:openWithSafari','menuItem:share:email'] // 要隐藏的菜单项,只能隐藏“传播类”和“保护类”按钮,所有menu项见附录3
           menuList: ['menuItem:share:qq','menuItem:share:weiboApp','menuItem:share:facebook','menuItem:share:QZone','menuItem:openWithSafari','menuItem:share:email'] // 要隐藏的菜单项,只能隐藏“传播类”和“保护类”按钮,所有menu项见附录3
         });
         });
+
+        wx.showAllNonBaseMenuItem();
       });
       });
       
       
       wx.error(function(res){
       wx.error(function(res){
         console.log(res);
         console.log(res);
       });
       });
     }
     }
-  });
+  // });
 }
 }
+
+
+export  function injectSdk() {
+  return new Promise((resove,reject) => {
+    getWxSign({
+      Url:window.location.href.split('#')[0]
+    }).then((res)=>{
+      if( res.Ret===200 ){
+        wx.config({
+          debug:false, // 开启调试模式,调用的所有api的返回值会在客户端alert出来,若要查看传入的参数,可以在pc端打开,参数信息会通过log打出,仅在pc端时才会打印。
+          appId:res.Data.AppId, // 必填,企业号的唯一标识,此处填写企业号corpid
+          timestamp:res.Data.Timestamp, // 必填,生成签名的时间戳
+          nonceStr:res.Data.NonceStr, // 必填,生成签名的随机串
+          signature:res.Data.Signature,// 必填,签名,见附录1
+          jsApiList:['updateTimelineShareData',//1.4.0的分享接口,注意:使用新版本的分享功能,一定要在该列表加上对应的老版本功能接口,否则新接口不起作用
+          'updateAppMessageShareData',//1.4.0的分享接口,注意:使用新版本的分享功能,一定要在该列表加上对应的老版本功能接口,否则新接口不起作用
+          'hideOptionMenu',
+          'showOptionMenu',
+          'hideMenuItems']
+          // 'onMenuShareAppMessage',//老版本分享接口。
+          // 'onMenuShareTimeline',
+        });
+
+        resove(res)
+      }else {
+        console.log(res)
+        if(res.Ret!==4003){
+          Toast('获取签名失败,请刷新重试!')
+        }
+        
+        reject(res) 
+      }
+    })
+  })
+}