Index.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563
  1. <script setup>
  2. import {
  3. apiReportIndexPageAuthList,
  4. apiReportIndexPageList,
  5. apiReportIndexNewbanner,
  6. apiLatestNews
  7. } from '@/api/report'
  8. import { onActivated, onMounted, reactive, ref } from "vue"
  9. import Search from "@/components/Search.vue"
  10. import SelfList from '@/components/SelfList.vue'
  11. import { useRouter } from "vue-router"
  12. import { ElMessageBox } from 'element-plus'
  13. import moment from 'moment'
  14. import 'moment/dist/locale/zh-cn'
  15. moment.locale('zh-cn')
  16. const router = useRouter()
  17. // 向小程序发送数据
  18. const handleDataToXcx=()=>{
  19. const postData={
  20. path:'/pages/report/report',
  21. params:{},
  22. title:'FICC研报',
  23. shareImg:''
  24. }
  25. wx.miniProgram.postMessage({ data: postData })
  26. }
  27. // 获取最新资讯
  28. let latestNewsList=ref([])
  29. const getLatestNews=async ()=>{
  30. const res=await apiLatestNews({chart_permission_id:Number(selectSubType.value)})
  31. if(res.code===200){
  32. latestNewsList.value=res.data||[]
  33. }
  34. }
  35. // 获取顶部权限分类数据
  36. let authData=reactive({
  37. isBuy:false,
  38. contactInfo:null
  39. })
  40. let firstTypeList = ref([])//一级分类数据
  41. let subTypeList = ref([])//二级分类数据
  42. let selectFirstType = ref('')//选择的一级分类
  43. let selectSubType = ref('')//选择的二级分类ID
  44. const getTopPermissionList = async () => {
  45. const res = await apiReportIndexPageAuthList()
  46. if (res.code === 200) {
  47. firstTypeList.value = res.data.permission_list.filter(item => item.sort != 100000)
  48. clickFirstType(firstTypeList.value[0])
  49. authData.isBuy=res.data.check_flag
  50. authData.contactInfo=res.data.contact_info
  51. }
  52. }
  53. getTopPermissionList()
  54. // 获取报告列表数据
  55. let reportState = reactive({
  56. list: [],
  57. page: 1,
  58. pageSize: 20,
  59. finished: false,
  60. loading: false,
  61. dateArr: [],//日期数据
  62. })
  63. const getReportList = async () => {
  64. reportState.loading = true
  65. const res = await apiReportIndexPageList({
  66. chart_permission_id: Number(selectSubType.value),
  67. current_index: reportState.page,
  68. page_size: reportState.pageSize
  69. })
  70. reportState.loading = false
  71. if (res.code === 200) {
  72. if (res.data.paging.is_end) {
  73. reportState.finished = true
  74. }
  75. //处理数据
  76. if (res.data.list) {
  77. if(reportState.list.length==0){
  78. // 第一页数据
  79. reportState.list = res.data.list
  80. res.data.list.forEach(item => {
  81. reportState.dateArr.push(item.date)
  82. })
  83. }else {
  84. //判断是否前面已经有相同日期数据 有的话添加合并
  85. let arr = []
  86. let temTimearr = []
  87. res.data.list.forEach(item => {
  88. if (reportState.dateArr.includes(item.date)) {
  89. reportState.list.forEach(_item => {
  90. if (item.date === _item.date) {
  91. _item.sub_list = [..._item.sub_list, ...item.sub_list]
  92. }
  93. })
  94. } else {
  95. arr.push(item)
  96. temTimearr.push(item.date)
  97. }
  98. });
  99. reportState.list = [...reportState.list, ...arr]
  100. reportState.dateArr = [...reportState.dateArr, ...temTimearr]
  101. }
  102. }
  103. }
  104. }
  105. //点击顶部一级分类
  106. const clickFirstType = (item) => {
  107. selectFirstType.value = item.classify_name
  108. subTypeList.value = item.list
  109. clickSubType(item.list[0])
  110. }
  111. //点击二级分类
  112. const clickSubType = (item) => {
  113. selectSubType.value = item.chart_permission_id
  114. reportState.list = []
  115. reportState.page = 1
  116. reportState.finished = false
  117. getReportList()
  118. handleShowAuthData(item)
  119. getLatestNews()
  120. }
  121. // 判断是否要为已购用户且点击的品种没有权限
  122. const handleShowAuthData=(e)=>{
  123. if(authData.isBuy){
  124. if(!e.auth_ok){
  125. const htmlStr=`您暂无该品种权限,若想查看请联系对口销售--${authData.contactInfo.name}:${authData.contactInfo.mobile}`
  126. ElMessageBox({
  127. title:'温馨提醒',
  128. message:htmlStr,
  129. center: true,
  130. dangerouslyUseHTMLString: true,
  131. confirmButtonText:'知道了',
  132. confirmButtonClass:'self-elmessage-confirm-btn'
  133. })
  134. }
  135. }
  136. }
  137. // 列表加载更多
  138. const onLoad=()=>{
  139. reportState.page++
  140. getReportList()
  141. }
  142. // 获取上新公告
  143. let newAnnounce=ref(null)
  144. const getNewAnnounce=async ()=>{
  145. const res=await apiReportIndexNewbanner()
  146. if(res.code===200){
  147. newAnnounce.value=res.data
  148. }
  149. }
  150. getNewAnnounce()
  151. //跳转至研报分类页
  152. const handleGoMoreClassify = () => {
  153. router.push({ path:'/report/classify' });
  154. };
  155. //点击上新公告
  156. const handleClickAnnounce=(data)=>{
  157. //redirect_type 0活动 1专栏
  158. if(data.redirect_type==0){
  159. router.push({
  160. path:'/activity/detail',
  161. query:{
  162. id:data.Activity.activityID
  163. }
  164. })
  165. }else{
  166. router.push({
  167. path:'/report/specialcolumndetail',
  168. query:{
  169. columnId:data.ReportId
  170. }
  171. })
  172. }
  173. }
  174. //格式化上新公告中的活动时间
  175. const formatAnnounceActivityTime=(start,end)=>{
  176. const day = moment(start).format('YYYY-MM-DD');
  177. const startTime = moment(start).format('HH:mm');
  178. const endTime = moment(end).format('HH:mm');
  179. return `${day} ${startTime}-${endTime}`
  180. }
  181. //跳转报告详情
  182. const handleGoReportDetail=(item)=>{
  183. if(['晨报','周报'].includes(item.classify_name_first)){
  184. router.push({
  185. path:'/report/chapterdetail',
  186. query:{
  187. chapterId:item.report_chapter_id
  188. }
  189. })
  190. }else{
  191. router.push({
  192. path:'/report/detail',
  193. query:{
  194. reportId:item.report_id
  195. }
  196. })
  197. }
  198. }
  199. let isMounted = ref(false);
  200. onMounted(() => {
  201. isMounted.value = true;
  202. handleDataToXcx()
  203. });
  204. // 格式化列表日期
  205. const formatDate=(e)=>{
  206. const isSameYear=moment(e).isSame(new Date(), 'year');
  207. if(isSameYear){//今年
  208. return moment(e).format('MM.DD')+' '+ moment(e).format('ddd')
  209. }else{
  210. return moment(e).format('YY.MM.DD')+' '+moment(e).format('ddd')
  211. }
  212. }
  213. //组件激活时
  214. onActivated(()=>{
  215. handleDataToXcx()
  216. })
  217. </script>
  218. <template>
  219. <!-- 搜索 -->
  220. <template v-if="isMounted&&$route.path=='/report/index'">
  221. <teleport to="#reportIndex-in-head">
  222. <Search
  223. style="margin-top: 10px;"
  224. placeholder="请输入标题/关键词"
  225. :disabled="true"
  226. @click="$router.push('/report/search')"
  227. ></Search>
  228. </teleport>
  229. </template>
  230. <div class="hasrightaside-box report-index-page">
  231. <div class="content-box report-main">
  232. <div class="top-nav-wrap">
  233. <div class="flex first-nav">
  234. <div
  235. :class="['item', item.classify_name == selectFirstType && 'item-active']"
  236. v-for="item in firstTypeList"
  237. :key="item.classify_name"
  238. @click="clickFirstType(item)"
  239. >{{ item.classify_name }}</div>
  240. <!-- 查看更多 -->
  241. <div class="see-more" @click="handleGoMoreClassify">查看更多</div>
  242. </div>
  243. <div class="flex sub-nav">
  244. <span
  245. :class="['sub-item', item.chart_permission_id == selectSubType && 'sub-active']"
  246. v-for="item in subTypeList"
  247. :key="item.chart_permission_id"
  248. @click="clickSubType(item)"
  249. >{{ item.chart_permission_name }}</span>
  250. </div>
  251. </div>
  252. <!-- 报告列表 -->
  253. <SelfList
  254. :finished="reportState.finished"
  255. :isEmpty="reportState.list.length === 0 && reportState.finished"
  256. :loading="reportState.loading"
  257. @listOnload="onLoad"
  258. >
  259. <div class="report-list-wrap">
  260. <div class="item" v-for="item in reportState.list" :key="item.date">
  261. <div class="item-time">{{ formatDate(item.date) }}</div>
  262. <div class="content-list">
  263. <div class="content-item" v-for="citem in item.sub_list" :key="citem.report_id">
  264. <div class="content-box">
  265. <div class="all-btn" @click="handleGoReportDetail(citem)">查看全部</div>
  266. <div class="c-time">{{ moment(citem.publish_time).format('HH:mm:ss') }}</div>
  267. <div class="c-title">{{ citem.title }}</div>
  268. <div class="desc" v-html="citem.content_sub"></div>
  269. <div class="tags">
  270. <span style="margin-right:30px" v-if="citem.classify_name_first">#{{ citem.classify_name_first }}</span>
  271. <span v-if="citem.classify_name_second">#{{ citem.classify_name_second }}</span>
  272. </div>
  273. </div>
  274. </div>
  275. </div>
  276. </div>
  277. </div>
  278. </SelfList>
  279. </div>
  280. <div class="right-aside-box" style="position: relative;z-index: 100;">
  281. <div class="fix-top" style="z-index: 100;">
  282. <div class="recmd-box">
  283. <div class="label">最新资讯</div>
  284. <div
  285. class="recmd-item"
  286. v-for="item in latestNewsList"
  287. :key="item.report_id"
  288. @click="handleGoReportDetail(item)"
  289. >
  290. <div class="title">{{item.classify_name_second}}</div>
  291. <div>{{item.stage}} | {{item.title}}</div>
  292. </div>
  293. </div>
  294. <div class="hot-box" style="margin-top: 60px;">
  295. <div class="label">上新公告</div>
  296. <div class="img-con" :style="'background-image:url('+newAnnounce.ImgUrl+')'" v-if="newAnnounce">
  297. <!-- 活动的话要手搓文字上去 -->
  298. <div class="activity-con" v-if="newAnnounce.redirect_type==0" @click="handleClickAnnounce(newAnnounce)">
  299. <div class="multi-ellipsis title">{{newAnnounce.Activity.activityTypeName}}</div>
  300. <div class="user-name">主讲人: {{newAnnounce.Activity.speaker}}</div>
  301. <div class="time">{{formatAnnounceActivityTime(newAnnounce.Activity.startTime,newAnnounce.Activity.endTime)}}</div>
  302. </div>
  303. </div>
  304. </div>
  305. </div>
  306. </div>
  307. </div>
  308. <!-- 回到顶部 -->
  309. <el-backtop :bottom="100" visibility-height="500">
  310. <img src="@/assets/icon-back-top.png" alt="" style="width: 60px;">
  311. </el-backtop>
  312. </template>
  313. <style lang="scss" scoped>
  314. .el-backtop{
  315. z-index: 1000;
  316. }
  317. .report-index-page {
  318. position: relative;
  319. .report-main {
  320. .top-nav-wrap {
  321. position: fixed;
  322. top: 60px;
  323. z-index: 99;
  324. background-color: #fff;
  325. padding-top: 30px;
  326. padding-bottom: 12px;
  327. width: 100%;
  328. .first-nav {
  329. width: calc(100vw - 500px);
  330. overflow-x: auto;
  331. overflow-y: hidden;
  332. &::-webkit-scrollbar{
  333. height: 5px;
  334. }
  335. .item {
  336. width: 140px;
  337. height: 40px;
  338. flex-shrink: 0;
  339. background: #F6F6F6;
  340. border-radius: 20px;
  341. text-align: center;
  342. line-height: 40px;
  343. font-size: 16px;
  344. margin-right: 30px;
  345. cursor: pointer;
  346. &:hover {
  347. background: #FFFBF5;
  348. color: #F3A52F;
  349. border: 1px solid #F3A52F;
  350. box-shadow: 0px 6px 7px 1px #FFF7EB;
  351. }
  352. }
  353. .item-active {
  354. background: #FFFBF5;
  355. color: #F3A52F;
  356. border: 1px solid #F3A52F;
  357. box-shadow: 0px 6px 7px 1px #FFF7EB;
  358. }
  359. .see-more{
  360. height: 20px;
  361. flex-shrink: 0;
  362. color: #f3a52f;
  363. font-size: 16px;
  364. position: relative;
  365. top: 10px;
  366. margin-left: 30px;
  367. cursor: pointer;
  368. @media (max-width:1200px){
  369. font-size: 14px;
  370. margin-left: 10px;
  371. font-size: 14px;
  372. top: 4px;
  373. }
  374. &::after{
  375. content: '';
  376. display: inline-block;
  377. width: 16px;
  378. height: 16px;
  379. background-image: url('../../assets/icon-more.png');
  380. background-size: cover;
  381. position: relative;
  382. top: 2px;
  383. left: 5px;
  384. @media (max-width:1200px){
  385. width: 12px;
  386. height: 12px;
  387. top: 0;
  388. }
  389. }
  390. }
  391. }
  392. .sub-nav {
  393. margin-top: 30px;
  394. overflow-x: auto;
  395. overflow-y: hidden;
  396. &::-webkit-scrollbar {
  397. height: 5px;
  398. }
  399. width: calc(100vw - 500px);
  400. .sub-item {
  401. flex-shrink: 0;
  402. margin-right: 30px;
  403. font-size: 16px;
  404. color: #666666;
  405. cursor: pointer;
  406. }
  407. .sub-active {
  408. color: #F3A52F;
  409. }
  410. }
  411. }
  412. .report-list-wrap {
  413. margin-top: 120px;
  414. .item{
  415. margin-bottom: 30px;
  416. }
  417. .item-time {
  418. font-size: 16px;
  419. margin-bottom: 20px;
  420. }
  421. .content-list {
  422. padding-left: 20px;
  423. .content-box {
  424. padding: 0 0px 10px 14px;
  425. position: relative;
  426. .all-btn {
  427. position: absolute;
  428. right: 20px;
  429. bottom: 10px;
  430. width: 88px;
  431. height: 30px;
  432. line-height: 30px;
  433. background: #FFFBF5;
  434. border-radius: 15px;
  435. border: 1px solid #F3A52F;
  436. color: #F3A52F;
  437. font-size: 14px;
  438. text-align: center;
  439. cursor: pointer;
  440. }
  441. }
  442. .content-item {
  443. padding: 0 0 30px 20px;
  444. border-left: 1px solid #F3A52F;
  445. position: relative;
  446. &:last-child {
  447. border-bottom: none;
  448. padding-bottom: 0px;
  449. }
  450. &::before {
  451. content: '';
  452. display: block;
  453. box-sizing: border-box;
  454. width: 14px;
  455. height: 14px;
  456. border-radius: 50%;
  457. border: 3px solid #FADBAC;
  458. position: absolute;
  459. left: 0;
  460. top: 0;
  461. background: #F3A52F;
  462. transform: translate(-50%, -50%);
  463. z-index: 2;
  464. }
  465. &::after {
  466. content: '';
  467. display: block;
  468. width: 20px;
  469. height: 1px;
  470. background-color: #F3A52F;
  471. position: absolute;
  472. top: 0;
  473. left: 0;
  474. z-index: 1;
  475. }
  476. .c-time {
  477. position: relative;
  478. top: -8px;
  479. font-size: 14px;
  480. color: #666;
  481. }
  482. .c-title {
  483. font-size: 16px;
  484. font-weight: bold;
  485. word-wrap: break-word;
  486. white-space: normal;
  487. word-break: break-all;
  488. margin-top: 5px;
  489. }
  490. .desc {
  491. line-height: 1.5;
  492. margin-top: 10px;
  493. color: #666666;
  494. font-size: 14px;
  495. :deep(div){
  496. word-wrap: break-word;
  497. }
  498. word-wrap: break-word;
  499. }
  500. .tags {
  501. margin-top: 14px;
  502. color: #F3A52F;
  503. min-height: 30px;
  504. }
  505. }
  506. }
  507. }
  508. }
  509. .right-aside-box{
  510. .activity-con{
  511. padding: 17px 10px;
  512. .title{
  513. color: #fff;
  514. font-size: 16px;
  515. font-weight: bold;
  516. }
  517. .user-name{
  518. margin: 5px 0;
  519. font-size: 14px;
  520. color: #fff;
  521. }
  522. .time{
  523. font-size: 12px;
  524. color: #F3A52F;
  525. }
  526. }
  527. }
  528. }
  529. </style>