Kaynağa Gözat

Merge branch 'ch/ht_3.1' of eta_mini/eta_mini_h5 into master_ht

leichen 2 ay önce
ebeveyn
işleme
a4bea4df2a

+ 1 - 1
src/api/modules/chart.js

@@ -3,7 +3,7 @@ import {get,post} from '@/api/index'
 export default{
   // 获取图表详情
   getChartDetail:params=>{
-    return get('/mychart/detail',params)
+    return get('v1/chart/detail',params)
   },
   // 收藏图表
   chartCollect:params=>{

+ 2 - 2
src/api/modules/common.js

@@ -2,8 +2,8 @@ import {get,post} from '@/api/index'
 
 export default{
   // 系统配置
-  systemConfig:()=>{
-    return get('/system/config',{})
+  systemConfig:params=>{
+    return get('/system/config',params)
   }
   
 }

+ 12 - 1
src/api/modules/report.js

@@ -8,7 +8,14 @@ export default{
   getReportDisclaimer:params=>{
     return get('/auth/disclaimer',params)
   },
-
+  // 收藏报告
+  reportCollect:params=>{
+    return post('/user/bookMark',params)
+  },
+  // 取消收藏报告
+  reportCollectCancel:params=>{
+    return post('/user/unBookMark',params)
+  },
   // 获取PDF报告详情
   getPdfReportDetail:params=>{
     return get('/report/pdf/detail',params)
@@ -21,4 +28,8 @@ export default{
   pdfReportCollectCancel:params=>{
     return post('/myreport/pdf/collectCancel',params)
   },
+  // 获取收藏进入图表上一张下一张信息
+  myChartLocate:params=>{
+    return get('/user/bookmark/chartList',params)
+  }
 }

+ 10 - 0
src/router/modules/chart.js

@@ -0,0 +1,10 @@
+export default[
+  {
+    path:'/chart/detail',
+    component:()=>import('@/views/chart/Detail.vue'),
+    name:'ChartDetail',
+    meta:{
+      title:'图表详情'
+    },
+  }
+]

+ 217 - 0
src/views/chart/Detail.vue

@@ -0,0 +1,217 @@
+<script setup>
+import { useRoute } from 'vue-router'
+import apiReport from '@/api/modules/report'
+import apiCommon from '@/api/modules/common'
+import { Message } from 'tdesign-mobile-vue';
+
+const route = useRoute()
+let chartId=route.query.chartId
+
+
+// 获取配置
+const chartBaseUrl = ref('')
+function getSystemConfig() {
+  apiCommon.systemConfig({config:'ChartLibUrlPrefix'}).then(res => {
+    if (res.Ret === 200) {
+      const ConfVal = res.data.Value || ''
+      chartBaseUrl.value = ConfVal
+    }
+  })
+}
+getSystemConfig()
+
+const chartInfo = ref({
+  UniqueCode: route.query.UniqueCode,
+  ChartName: route.query.ChartName,
+  IsCollect: true,
+  chartId: route.query.chartId
+})
+
+function getChartDetail(obj) {
+  const {chartInfoId, chartName, uniqueCode} = obj
+  chartInfo.value = {
+    chartId: chartInfoId,
+    ChartName: chartName,
+    UniqueCode: uniqueCode,
+    IsCollect: true
+  }
+
+}
+
+async function handleCollect() {
+  const data = {
+    sourceType: 'chart',
+    sourceId: Number(chartInfo.value.chartId)
+  }
+  const res = chartInfo.value.IsCollect ? await apiReport.reportCollectCancel(data) : await apiReport.reportCollect(data)
+  if(res.Ret===200){
+    Message.success(chartInfo.value.IsCollect?'取消收藏成功':'收藏成功')
+    chartInfo.value.IsCollect=!chartInfo.value.IsCollect
+    // 通知更新收藏列表
+    wx.miniProgram.postMessage({
+      data: 'refreshCollectList'
+    });
+  }
+}
+
+const chartRenderUrl = computed(() => {
+  return `${chartBaseUrl.value}/chart/previewHT?code=${chartInfo.value.UniqueCode}&token=${route.query.token}`
+})
+
+
+// 获取图列表切换用
+let changeChartList=ref([])
+async function getChangeChartList(){
+  // if(route.query.fromPage!=='myCollect') return
+  let res=await apiReport.myChartLocate({
+    key: route.query.searchKey,
+  })
+  if(res.Ret===200){
+    changeChartList.value=res.data||[]
+  }
+}
+getChangeChartList()
+
+// 切换上一张下一张
+function handleChangeChart(type){
+  const index=changeChartList.value.findIndex(e=>e.chartInfoId==chartInfo.value.chartId)
+  if(type==='pre'){
+    if(index<1) return Message.warning('当前已是第一张')
+    const obj=changeChartList.value[index-1]
+    getChartDetail(obj)
+  }else{
+    if(index===changeChartList.value.length-1) return Message.warning('当前已是最后一张')
+    const obj=changeChartList.value[index+1]
+    getChartDetail(obj)
+  }
+}
+
+
+const isShowMZSM = ref(false)
+
+
+</script>
+<template>
+  <div class="chart-detail-page" v-if="chartInfo">
+    <div class="chart-title">{{chartInfo.ChartName}}</div> 
+    <div class="collect-icon" @click="handleCollect" >{{chartInfo.IsCollect?'取消收藏':'收藏'}}</div>
+    <!-- <div class="mz-tips" @click="isShowMZSM = true">免责声明</div> -->
+    <!-- 图表渲染盒子 -->
+    <div class="chart-render-wrap">
+      <iframe :src="chartRenderUrl"></iframe>
+    </div>
+    <div v-if="chartInfo.SourcesFrom&&JSON.parse(chartInfo.SourcesFrom).text"><span>来源:{{chartInfo.SourcesFrom?JSON.parse(chartInfo.SourcesFrom).text:''}}</span></div>
+
+    <div class="change-btns-box" v-if="changeChartList.length>1">
+      <div class="btn bottom" @click="handleChangeChart('pre')">
+        <div class="triangle-left"></div>
+        <div>上一张</div>
+      </div>
+      <div class="btn" @click="handleChangeChart('next')">
+        <div class="triangle-right"></div>
+        <div>下一张</div>
+      </div>
+    </div>
+    <!-- 收藏 -->
+    <!-- <svg-icon @click="handleCollect" class="collect-icon" :name="chartInfo.IsCollect?'collected':'collect'" /> -->
+  </div>
+  <!-- 免责声明 -->
+  <disclaimers-wrap v-model:show="isShowMZSM" />
+</template>
+
+<style lang="scss" scoped>
+.chart-detail-page {
+  background-color: #fff;
+  padding: var(--page-padding);
+  min-height: 100vh;
+  .chart-title {
+    font-size: 36px;
+    line-height: 44px;
+    margin-bottom: 20px;
+  }
+  .mz-tips {
+    text-align: right;
+    color: var(--primary-color);
+    font-size: var(--font-size-small);
+  }
+  .chart-render-wrap {
+    margin-top: 50px;
+    height: 850px;
+    margin-bottom: 40px;
+    iframe {
+      width: 100%;
+      height: 100%;
+      border: none;
+    }
+  }
+  .change-btns-box {
+    position: fixed;
+    z-index: 99;
+    right: 34px;
+    bottom: 150px;
+    .btn {
+      width: 100%;
+      height: 120px;
+      background-color: #f3f5f9;
+      display: flex;
+      flex-direction: column; /* 垂直方向排列子元素 */
+      justify-content: center; /* 水平居中(对于列布局,这将使整列居中) */
+      .triangle-left {
+        margin: 0 auto;
+        width: 0;
+        height: 0;
+        border-top: 20px solid transparent;
+        border-right: 40px solid #fff;
+        border-bottom: 20px solid transparent;
+        border-left: none;
+        margin-bottom: 10px;
+      }
+      .triangle-right {
+        margin: 0 auto;
+        width: 0;
+        height: 0;
+        border-top: 20px solid transparent;
+        border-left: 40px solid #fff;
+        border-bottom: 20px solid transparent;
+        border-right: none;
+        margin-bottom: 10px;
+      }
+    }
+    .bottom {
+      border-bottom: #666666 1px solid;
+    }
+  }
+}
+.collect-icon {
+  color: #666666;
+}
+
+@media (min-width: 600px) {
+  .chart-detail-page {
+    min-height: 100vh;
+    .chart-title {
+      font-size: 18px;
+      line-height: 22px;
+      margin-bottom: 10px;
+    }
+    .chart-render-wrap {
+      margin-top: 25px;
+      height: 400px;
+    }
+    .change-btns-box{
+      bottom: 35px;
+      justify-content: center;
+      gap: 0 10px;
+      .btn{
+        max-width: 200px;
+        height: 34px;
+        border-radius: 34px;
+        line-height: 34px;
+      }
+    }
+  }
+  .collect-icon{
+    color: #666666;
+  }
+}
+</style>

+ 36 - 1
src/views/report/Detail.vue

@@ -29,6 +29,7 @@ const productId = route.query.productId
 const isSubscribe=ref(true)
 const isFree=ref(true)
 const priceNum=ref('')
+const reportCollected = ref(false)
 const riskLevelInfo=ref('')
 const visible = ref(false);
 const subscribeStatus = ref('')//expired --过期 unSubscribe--未订阅 subscribed--订阅中
@@ -69,6 +70,7 @@ async function getReportInfo() {
     reportInfo.value = detail
     riskLevelInfo.value = riskLevel
     isLogin.value=res.data.login
+    reportCollected.value = res.data.isCollected || false
     riskLevelStatus.value=res.data.riskLevelStatus
     headImgStyle.value = reportInfo.value.headResource.style ? JSON.parse(reportInfo.value.headResource.style) : []
     endImgStyle.value = reportInfo.value.endResource.style ? JSON.parse(reportInfo.value.endResource.style) : []
@@ -92,11 +94,17 @@ async function getReportInfo() {
       }
     });
 
-    reportContent.value = reportInfo.value.content
+    reportContent.value = formatIframeData(reportInfo.value.content)
     splitReportContent(reportContent.value)
   }
 }
 getReportInfo()
+
+// 给报告详情中图表加参数
+function formatIframeData(str) {
+  return str.replace(/\/chartshow\?code=/g, `/chartshow?source=ht_chart&token=${localStorage.getItem('token')}&reportId=${reportId}&code=`)
+}
+
 function getAuthorFollowState() {
   apiUser.getFollowState({
     names: reportInfo.value.author
@@ -154,6 +162,22 @@ function changeFollowStateList(item) {
     })
 }
 
+// 点击收藏
+async function handleCollect() {
+  const data = {
+    sourceType: 'report',
+    sourceId: Number(reportId)
+  }
+  const res = reportCollected.value ? await apiReport.reportCollectCancel(data) : await apiReport.reportCollect(data)
+  if (res.Ret === 200) {
+    Message.success(reportCollected.value ? '取消收藏成功' : '收藏成功')
+    reportCollected.value = !reportCollected.value
+    // 通知更新收藏列表
+    wx.miniProgram.postMessage({
+      data: 'refreshCollectList'
+    });
+  }
+}
 
 // 显示免责声明
 const isShowMZSM = ref(false)
@@ -384,6 +408,12 @@ function goDetails(item){
     </div>
     <!-- 右侧悬浮操作栏 -->
     <div class="right-fix-box">
+      <!-- 收藏 -->
+      <svg-icon
+        @click="handleCollect"
+        class="item collect-icon"
+        :name="reportCollected ? 'collected' : 'collect'"
+      />
       <!-- 返回顶部 -->
       <div class="item back-top-img">
         <svg-icon
@@ -642,6 +672,11 @@ function goDetails(item){
     .item {
       margin-top: 10px;
     }
+    .collect-icon {
+      width: 100px;
+      height: 100px;
+      display: block;
+    }
     .back-top-img {
       width: 100px;
       height: 100px;

+ 25 - 0
src/views/report/PDF.vue

@@ -28,6 +28,7 @@ const productId = route.query.productId
 const isSubscribe=ref(true)
 const isFree=ref(true)
 const pdfUrl = ref('')
+const reportCollected = ref(false)
 const authorInfoList=ref([])
 const visible = ref(false);
 const subscribeStatus = ref('')//expired --过期 unSubscribe--未订阅 subscribed--订阅中
@@ -42,6 +43,7 @@ async function getReportInfo() {
   if (res.Ret === 200 && res.ErrCode === 0) {
     reportInfo.value = res.data
     isLogin.value=res.data.login
+    reportCollected.value = res.data.isCollected || false
     riskLevelStatus.value=res.data.riskLevelStatus
     isSubscribe.value=res.data.isSubscribe
     isFree.value=res.data.isFree
@@ -116,6 +118,23 @@ function changeFollowStateList(item) {
     })
 }
 
+// 点击收藏
+async function handleCollect() {
+  const data = {
+    sourceType: 'report',
+    sourceId: Number(reportId)
+  }
+  const res = reportCollected.value ? await apiReport.reportCollectCancel(data) : await apiReport.reportCollect(data)
+  if (res.Ret === 200) {
+    Message.success(reportCollected.value ? '取消收藏成功' : '收藏成功')
+    reportCollected.value = !reportCollected.value
+    // 通知更新收藏列表
+    wx.miniProgram.postMessage({
+      data: 'refreshCollectList'
+    });
+  }
+}
+
 // 显示免责声明
 const isShowMZSM = ref(false)
 // 显示返回顶部
@@ -218,6 +237,12 @@ function goDetails(item){
     </div>
     <!-- 右侧悬浮操作栏 -->
     <div class="right-fix-box">
+      <!-- 收藏 -->
+      <svg-icon
+        @click="handleCollect"
+        class="item collect-icon"
+        :name="reportCollected ? 'collected' : 'collect'"
+      />
       <!-- 返回顶部 -->
       <div class="item back-top-img">
         <svg-icon