Преглед изворни кода

Merge branch 'report_share'

jwyu пре 2 година
родитељ
комит
6b96768d3a
3 измењених фајлова са 71 додато и 28 уклоњено
  1. 4 3
      src/api/report.js
  2. 24 3
      src/views/report/ChapterDetail.vue
  3. 43 22
      src/views/report/Detail.vue

+ 4 - 3
src/api/report.js

@@ -207,9 +207,10 @@ export const apiDelMyComment=params=>{
 }
 
 /**
- * 日度点评分享图片
- * @param title
+ * 报告详情分享图片
+ * @param source (目前写死的)rddp_share_img
+ * @param pars json字符串类型参数{title:图片上的富文本,time_format:时间(没啥用),background_img:背景图}
  */
 export const apiRddpShareImg=params=>{
-    return post('/report/detail/rddp_share_img',params)
+    return post('/report/detail/rddp_share_img',{source:'rddp_share_img',...params})
 }

+ 24 - 3
src/views/report/ChapterDetail.vue

@@ -4,7 +4,8 @@ import {
     apiChapterDetail,
     apiChapterTickerValue,
     apiReportMoreRecmd,
-    apiReportDetailBanner
+    apiReportDetailBanner,
+    apiRddpShareImg
 } from '@/api/report'
 import {apiApplyPermission} from '@/api/user'
 import {apiGetWechatQRCode} from '@/api/common'
@@ -125,14 +126,34 @@ const getChapterReportDetail=async ()=>{
 
         //向小程序发送分享数据
         //处理分享标题
-        const shareTitle=`【${res.data.report_chapter_item.classify_name_first} | ${res.data.report_chapter_item.type_name}】${res.data.report_chapter_item.title}(${moment(res.data.report_chapter_item.publish_time).format('MMDD')})`
+        // const shareTitle=`【${res.data.report_chapter_item.classify_name_first} | ${res.data.report_chapter_item.type_name}】${res.data.report_chapter_item.title}(${moment(res.data.report_chapter_item.publish_time).format('MMDD')})`
+        let shareTitle='',shareImg='',imgText='';
+        const shareTime=moment(res.data.report_chapter_item.publish_time).format('MMDD')
+        if(res.data.report_chapter_item.abstract){
+          shareTitle=res.data.report_chapter_item.abstract
+          imgText=`<div style="font-size:68px">第${res.data.report_chapter_item.stage}期 | ${res.data.report_chapter_item.title}(${shareTime})</div>`
+        }else{
+          shareTitle=res.data.report_chapter_item.title
+          imgText=`<div style="font-size:68px">${moment(res.data.report_chapter_item.publish_time).format('YYYY/MM/DD')}</div><div style="font-size:68px">第${res.data.report_chapter_item.stage}期 | ${res.data.report_chapter_item.classify_name_first} | ${res.data.report_chapter_item.type_name} </div>`
+        }
+        const rddpImgRes=await apiRddpShareImg({
+            pars:JSON.stringify({
+                title:imgText,
+                time_format:moment(res.data.report_chapter_item.publish_time).format('YYYY/MM/DD'),
+                background_img:res.data.report_chapter_item.share_bg_img
+            })
+        })
+        if(rddpImgRes.code===200){
+            shareImg=rddpImgRes.data
+        }
+
         const postData={
             path:'/pages-report/chapterDetail',
             params:{
                 chapterId:chapterId.value
             },
             title:shareTitle,
-            shareImg:''
+            shareImg:shareImg
         }
         wx.miniProgram.postMessage({ data: postData })
 

+ 43 - 22
src/views/report/Detail.vue

@@ -66,34 +66,55 @@ const getReportDetail=async ()=>{
 
         //向小程序发送分享数据
         //处理分享标题
-        let shareTitle=''
-        let shareImg=''
+        let shareTitle='',shareImg='',imgText='';
         const shareTime=moment(res.data.report_info.publish_time).format('MMDD')
-        if(['晨报','周报'].includes(res.data.report_info.classify_name_first)){
-            shareTitle=`【${res.data.report_info.classify_name_first}】${res.data.report_info.title}(${shareTime})`
+        // if(['晨报','周报'].includes(res.data.report_info.classify_name_first)){
+        //     shareTitle=`【${res.data.report_info.classify_name_first}】${res.data.report_info.title}(${shareTime})`
+        // }else{
+        //     // 专栏类报告
+        //     if(res.data.report_show_type==2){
+        //         const abstract=res.data.report_info.abstract?`:${res.data.report_info.abstract}`:''
+        //         if(res.data.report_info.classify_name_second==res.data.report_info.title){
+        //             shareTitle=`${res.data.report_info.title}(${shareTime})${abstract}`
+        //         }else{
+        //             shareTitle=`【${res.data.report_info.classify_name_second}】${res.data.report_info.title}(${shareTime})`
+        //         }
+        //     }else{
+        //         shareTitle=`【${res.data.report_info.classify_name_second}】${res.data.report_info.title}(${shareTime})`
+        //     }
+        // }
+        // // 日度点评
+        // if(res.data.report_info.classify_name_first==='日度点评'){
+        //     shareTitle=res.data.report_info.abstract||'FICC日度点评'
+        //     const rddpImgRes=await apiRddpShareImg({
+        //         title:`【第${res.data.report_info.stage}期】${res.data.report_info.title}(${shareTime})`
+        //     })
+        //     if(rddpImgRes.code===200){
+        //         shareImg=rddpImgRes.data
+        //     }
+        // }
+
+        if(res.data.report_info.abstract){
+            shareTitle=res.data.report_info.abstract
+            imgText=`<div style="font-size:68px">第${res.data.report_info.stage}期 | ${res.data.report_info.title}(${shareTime})</div>`
         }else{
-            // 专栏类报告
-            if(res.data.report_show_type==2){
-                const abstract=res.data.report_info.abstract?`:${res.data.report_info.abstract}`:''
-                if(res.data.report_info.classify_name_second==res.data.report_info.title){
-                    shareTitle=`${res.data.report_info.title}(${shareTime})${abstract}`
-                }else{
-                    shareTitle=`【${res.data.report_info.classify_name_second}】${res.data.report_info.title}(${shareTime})`
-                }
-            }else{
-                shareTitle=`【${res.data.report_info.classify_name_second}】${res.data.report_info.title}(${shareTime})`
+            shareTitle=res.data.report_info.title
+            imgText=`<div style="font-size:68px">${moment(res.data.report_info.publish_time).format('YYYY/MM/DD')}</div><div style="font-size:68px">第${res.data.report_info.stage}期 | ${res.data.report_info.classify_name_second}</div>`
+            if(['晨报','周报'].includes(res.data.report_info.classify_name_first)){
+                imgText=`<div style="font-size:68px">${moment(res.data.report_info.publish_time).format('YYYY/MM/DD')}</div><div style="font-size:68px">第${res.data.report_info.stage}期 | ${res.data.report_info.classify_name_first} </div>`
             }
         }
-        // 日度点评
-        if(res.data.report_info.classify_name_first==='日度点评'){
-            shareTitle=res.data.report_info.abstract||'FICC日度点评'
-            const rddpImgRes=await apiRddpShareImg({
-                title:`【第${res.data.report_info.stage}期】${res.data.report_info.title}(${shareTime})`
+        const rddpImgRes=await apiRddpShareImg({
+            pars:JSON.stringify({
+                title:imgText,
+                time_format:moment(res.data.report_info.publish_time).format('YYYY/MM/DD'),
+                background_img:res.data.report_info.share_bg_img
             })
-            if(rddpImgRes.code===200){
-                shareImg=rddpImgRes.data
-            }
+        })
+        if(rddpImgRes.code===200){
+            shareImg=rddpImgRes.data
         }
+
         const postData={
             path:'/pages-report/reportDetail',
             params:{