chapterList.vue 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619
  1. <template>
  2. <view class="chapeter-list-page">
  3. <view class="chapter-list-wrap" v-if="info" @click.self="closeAttention">
  4. <view class="top-box" :style="'background-image:url(' + info.report_info.banner_url + ')'">
  5. <view class="title">{{info.report_info.classify_name_first}}</view>
  6. <view class="sub-title">{{info.report_info.title}}</view>
  7. <view class="flex top-bot">
  8. <view class="flex time-box">
  9. <view class="day">{{formatChapterTime(info.report_info.publish_time,'day')}}</view>
  10. <view>
  11. <view>{{formatChapterTime(info.report_info.publish_time,'week')}}</view>
  12. <view>{{formatChapterTime(info.report_info.publish_time,'year-month')}}</view>
  13. </view>
  14. </view>
  15. <template v-if="!info.report_info.video_url">
  16. <view class="flex audio-play-box" @click="handlePlayWeekAudio(null)" v-if="info.report_info.classify_name_first=='周报'&&info.auth_ok">
  17. <image class="icon" :src="curAudioReportId==reportId&&!curAudioPaused?'./static/audio-s.png':'./static/audio.png'" mode="aspectFill"/>
  18. <text>{{curAudioReportId==reportId&&!curAudioPaused?'暂停':'播放'}}</text>
  19. </view>
  20. </template>
  21. </view>
  22. <view :class="[info.report_info.classify_name_first=='晨报'?'stage-num-day':'stage-num-week']">第{{info.report_info.stage}}期</view>
  23. <template v-if="!info.report_info.video_url">
  24. <!-- 音频播放设置 -->
  25. <view class="audio-play-set-box" v-if="info.report_info.classify_name_first=='周报'&&info.auth_ok">
  26. <image class="btn" @click="handleGoSetAudioList" src="./static/set.png" mode="aspectFill"/>
  27. <view class="attention-box" v-if="showChapterListAttention">
  28. 点击<span style="color:#E3B377">设置</span>,打开<span style="color:#E3B377">播放列表</span>,进行<span style="color:#E3B377">关注品种配置</span>
  29. <image class="close-icon" src="./static/close2.png" @click.stop="closeAttention" />
  30. </view>
  31. </view>
  32. </template>
  33. </view>
  34. <view class="list-box">
  35. <view class="flex item" v-for="item in chapterList" :key="item.report_chapter_id" @click="goChapterDetail(item)">
  36. <view class="img-box">
  37. <image class="img" :src="item.report_chapter_type_thumb" mode="aspectFill" />
  38. </view>
  39. <view class="con">
  40. <view class="title">
  41. {{item.report_chapter_type_name}}
  42. <text class="tag" :style="{backgroundColor:getTagColor(tag)}" v-for="tag in item.trend.split(',')" :key="tag">{{tag}}</text>
  43. </view>
  44. <view class="van-multi-ellipsis--l2 sub-title">{{item.title}}</view>
  45. <view class="update-time">更新至:{{formatChapterTime(item.publish_time,'year-month-day')}}</view>
  46. <view
  47. class="audio-icon-box"
  48. v-if="!info.report_info.video_url&&info.report_info.classify_name_first=='周报'&&item.is_close==0"
  49. @click.stop="handlePlayWeekAudio(item)"
  50. >
  51. <image
  52. class="icon"
  53. :src="curAudioReportId==reportId&&!curAudioPaused&&curAudioUrl==item.video_url?'./static/a-play.png':'./static/a-pause.png'"
  54. mode="aspectFill"
  55. />
  56. </view>
  57. </view>
  58. </view>
  59. </view>
  60. <!-- 无权限 -->
  61. <view class="no-auth-box" v-if="!info.auth_ok">
  62. <image class="img" src="https://hzstatic.hzinsights.com/static/icon/hzyb/activity_no_auth.png" mode="widthFix" />
  63. <view class="apply-box" v-if="info.permission_check.type=='apply'">
  64. <view>您暂无权限查看报告,若想查看请申请开通</view>
  65. <view class="global-btn-yellow-change btn" @click="handleGoApply">立即申请</view>
  66. </view>
  67. <view class="apply-box" v-else>
  68. <view>您暂无权限查看报告 </view>
  69. <view>若想查看请联系对口销售:{{info.permission_check.name}}</view>
  70. <view class="global-btn-yellow-change btn" @click="handleCall">立即联系</view>
  71. </view>
  72. </view>
  73. </view>
  74. <!-- 申请提示弹窗 -->
  75. <van-popup :show="pupData.show" @close="pupData.show=false" :close-on-click-overlay="false">
  76. <view class="global-pup">
  77. <view class="content">
  78. <view v-html="pupData.content"></view>
  79. </view>
  80. <view class="flex bot">
  81. <view @click="pupData.show=false">知道了</view>
  82. </view>
  83. </view>
  84. </van-popup>
  85. <!-- 音频弹窗 -->
  86. <audioBox v-if="showAudioPop"></audioBox>
  87. </view>
  88. </template>
  89. <script>
  90. import {apiReportDetail,apiRddpShareImg} from '@/api/report'
  91. import {apiApplyPermission} from '@/api/user'
  92. import audioBox from './components/audioBox.vue'
  93. const dayjs=require('@/utils/dayjs.min')
  94. dayjs.locale('zh-cn')
  95. export default {
  96. computed:{
  97. showAudioPop(){//是否显示音频弹窗
  98. return this.$store.state.report.audioData.show
  99. },
  100. curAudioReportId(){//当前播放的音频所属报告
  101. return this.$store.state.report.audioData.reportId
  102. },
  103. curAudioPaused(){//当前音频是否暂停状态
  104. return this.$store.state.report.audioData.paused
  105. },
  106. curAudioUrl(){
  107. return this.$store.state.report.audioData.list[this.$store.state.report.audioData.index]?.video_url
  108. }
  109. },
  110. components: {
  111. audioBox
  112. },
  113. data() {
  114. return {
  115. reportId:0,
  116. chapterList:[],
  117. info:null,
  118. pupData:{
  119. show:false,
  120. content:'',//弹窗html字符串
  121. },
  122. shareData:null,
  123. showChapterListAttention:false,
  124. }
  125. },
  126. onLoad(opt){
  127. this.reportId=opt.reportId
  128. this.getDetail()
  129. },
  130. onShareAppMessage() {
  131. return {
  132. title:this.shareData.title,
  133. path:`/pages-report/chapterList?reportId=${this.reportId}`,
  134. imageUrl:this.shareData.shareImg||''
  135. }
  136. },
  137. onUnload(){
  138. uni.$off('chapterAudioSet')
  139. },
  140. methods: {
  141. handleCall(){
  142. uni.makePhoneCall({
  143. phoneNumber: this.info.permission_check.mobile,
  144. success: (result) => {},
  145. fail: (error) => {}
  146. })
  147. },
  148. // 关闭提示
  149. closeAttention(){
  150. if(this.info.report_info.classify_name_first=='晨报'||!this.info.auth_ok) return
  151. uni.setStorageSync('showChapterListAttention','true')
  152. this.showChapterListAttention=false
  153. },
  154. // 跳转设置播放清单
  155. handleGoSetAudioList(){
  156. this.addEventListenerAudioSet()
  157. uni.navigateTo({
  158. url:`/pages-report/audioPlayListSet?reportId=${this.reportId}`,
  159. })
  160. },
  161. // 监听播放清单的设置
  162. addEventListenerAudioSet(){
  163. uni.$on('chapterAudioSet',e=>{
  164. this.getDetail()
  165. })
  166. },
  167. // 点击播放音频
  168. handlePlayWeekAudio(e){
  169. const storeAudioData=this.$store.state.report.audioData
  170. // 如果点击的是总的播放按钮
  171. if(!e&&storeAudioData.reportId==this.reportId){
  172. if(this.globalBgMusic.paused){
  173. this.globalBgMusic.play()
  174. this.$store.commit('showPopAudio')
  175. }else{
  176. this.globalBgMusic.pause()
  177. }
  178. return
  179. }
  180. const arr=[]
  181. this.chapterList.forEach(item=>{
  182. if(item.is_close==0){
  183. arr.push({
  184. video_url:item.video_url,
  185. video_play_seconds:item.video_play_seconds,
  186. video_name:item.video_name,
  187. video_img:'https://hzstatic.hzinsights.com/static/yb_wx/report_list_zhou.png'
  188. })
  189. }
  190. })
  191. let index=0
  192. if(e){
  193. arr.forEach((_item,idx)=>{
  194. if(_item.video_url==e.video_url) index=idx
  195. })
  196. }
  197. if(storeAudioData.reportId==this.reportId&&storeAudioData.index==index){
  198. if(this.globalBgMusic.paused){
  199. this.globalBgMusic.play()
  200. this.$store.commit('showPopAudio')
  201. }else{
  202. this.globalBgMusic.pause()
  203. }
  204. }else{
  205. this.$store.commit('removeAudio')
  206. this.$nextTick(()=>{
  207. this.$store.commit('addAudio', {list:arr,reportId:this.reportId,index:index})
  208. })
  209. }
  210. },
  211. //获取报告详情
  212. async getDetail(){
  213. const res=await apiReportDetail({report_id:Number(this.reportId)})
  214. if(res.code===200){
  215. this.info=res.data
  216. this.chapterList=res.data.report_chapter_list
  217. uni.setNavigationBarTitle({
  218. title: res.data.report_info.classify_name_first,
  219. success: (result) => {},
  220. fail: () => {},
  221. complete: () => {}
  222. });
  223. if(!res.data.auth_ok){
  224. // 获取详情如果为联系销售根据判断条件是否主动申请一次
  225. if(this.info.permission_check.type=='contact'&&!this.info.permission_check.customer_info.has_apply){
  226. if(this.info.permission_check.customer_info.status=='冻结'||(this.info.permission_check.customer_info.status=='试用'&&this.info.permission_check.customer_info.is_suspend==1)){
  227. apiApplyPermission({
  228. company_name:this.info.permission_check.customer_info.company_name,
  229. real_name:this.info.permission_check.customer_info.name,
  230. source:4,
  231. from_page:'报告详情'
  232. }).then(res=>{
  233. if(res.code===200){
  234. console.log('主动申请成功');
  235. }
  236. })
  237. }
  238. }
  239. }
  240. this.getShareData()
  241. // 周报判断是否要显示提示
  242. if(res.data.report_info.classify_name_first=='周报'){
  243. const showAtt=uni.getStorageSync('showChapterListAttention')||""
  244. if(showAtt){
  245. this.showChapterListAttention=false
  246. }else{
  247. this.showChapterListAttention=true
  248. }
  249. }
  250. }
  251. },
  252. // 跳转章节详情
  253. goChapterDetail(item){
  254. uni.navigateTo({
  255. url:`/pages-report/chapterDetail?chapterId=${item.report_chapter_id}&fromPage=reportdetail`
  256. })
  257. },
  258. // 设置分享的数据
  259. async getShareData(){
  260. //处理分享标题
  261. let shareTitle=''
  262. let shareImg=''
  263. let imgText=''//分享图上需要显示的内容
  264. const shareTime=dayjs(this.info.report_info.publish_time).format('MMDD')
  265. if(this.info.report_info.abstract){
  266. shareTitle=this.info.report_info.abstract
  267. imgText=`<div style="font-size:78px">第${this.info.report_info.stage}期 | ${this.info.report_info.title}(${shareTime})</div>`
  268. }else{
  269. shareTitle=this.info.report_info.title
  270. imgText=`<div style="font-size:78px">${dayjs(this.info.report_info.publish_time).format('YYYY/MM/DD')}</div><div style="font-size:78px">第${this.info.report_info.stage}期 | ${this.info.report_info.classify_name_second}</div>`
  271. if(['晨报','周报'].includes(this.info.report_info.classify_name_first)){
  272. imgText=`<div style="font-size:78px">${dayjs(this.info.report_info.publish_time).format('YYYY/MM/DD')}</div><div style="font-size:78px">第${this.info.report_info.stage}期 | ${this.info.report_info.classify_name_first} </div>`
  273. }
  274. }
  275. const rddpImgRes=await apiRddpShareImg({
  276. pars:JSON.stringify({
  277. title:imgText,
  278. time_format:dayjs(this.info.report_info.publish_time).format('YYYY/MM/DD'),
  279. background_img:this.info.report_info.share_bg_img
  280. }),
  281. report_id:Number(this.reportId)
  282. })
  283. if(rddpImgRes.code===200){
  284. shareImg=rddpImgRes.data
  285. }
  286. this.shareData={
  287. title:shareTitle,
  288. reportId:this.reportId,
  289. shareImg:shareImg
  290. }
  291. },
  292. //点击申请
  293. async handleGoApply(){
  294. if(this.userInfo.is_bind===0){
  295. Dialog.confirm({
  296. title:'温馨提示',
  297. message:'为了优化您的用户体验,\n 请登录后查看更多信息!',
  298. confirmButtonText:'去登录',
  299. confirmButtonColor:'#E6B77D',
  300. cancelButtonColor:'#666'
  301. }).then(res=>{
  302. uni.reLaunch({url:'/pages/login'})
  303. })
  304. return
  305. }
  306. if(this.info.permission_check.type=='apply'){
  307. if(this.info.permission_check.customer_info.has_apply){// 已经申请过
  308. this.pupData.show=true
  309. this.pupData.content=`<p>您已提交过申请,请耐心等待</p>`
  310. }else{
  311. if(!this.info.permission_check.customer_info.status||this.info.permission_check.customer_info.status!='流失'||this.info.permission_check.customer_info.status!='关闭'){
  312. uni.redirectTo({
  313. url:"/pages-applyPermission/applyPermission?source=4&from_page=报告详情"
  314. })
  315. }else{//主动调一次申请权限接口
  316. const res=await apiApplyPermission({
  317. company_name:this.info.permission_check.customer_info.company_name,
  318. real_name:this.info.permission_check.customer_info.name,
  319. source:4,
  320. from_page:'报告详情'
  321. })
  322. if(res.code===200){
  323. this.pupData.show=true
  324. this.pupData.content=`<p>申请已提交</p><p>请等待销售人员与您联系</p>`
  325. this.getDetail()
  326. }
  327. }
  328. }
  329. }
  330. },
  331. // 格式化章节列表时间
  332. formatChapterTime(time,type){
  333. if(type==='day'){
  334. return dayjs(time).format('DD')
  335. }
  336. if(type==='week'){
  337. return dayjs(time).format('dddd')
  338. }
  339. if(type==='year-month'){
  340. return dayjs(time).format('YYYY-MM')
  341. }
  342. if(type==='year-month-day'){
  343. return dayjs(time).format('YYYY-MM-DD')
  344. }
  345. },
  346. // 设置tag颜色
  347. getTagColor(str){
  348. if( str.includes('多')||str.includes('强')||str.includes('反弹') ){
  349. return "#DF6051";
  350. }else if( str.includes('空')||str.includes('调整') ){
  351. return "#6FC5B4";
  352. }else{
  353. return "#009fe6";
  354. }
  355. },
  356. },
  357. }
  358. </script>
  359. <style lang="scss" scoped>
  360. .global-pup{
  361. background-color: #fff;
  362. width: 90vw;
  363. min-height: 200rpx;
  364. font-size: 32rpx;
  365. .content{
  366. padding: 34rpx;
  367. text-align: center;
  368. min-height: 250rpx;
  369. display: flex;
  370. align-items: center;
  371. text-align: center;
  372. line-height: 1.7;
  373. div{
  374. flex: 1;
  375. }
  376. }
  377. .bot{
  378. border-top: 1px solid #dedede;
  379. div{
  380. line-height: 96rpx;
  381. flex: 1;
  382. text-align: center;
  383. border-right: 1px solid #dedede;
  384. color:#E3B377;
  385. }
  386. div:last-child {
  387. border: none;
  388. }
  389. }
  390. }
  391. .chapter-list-wrap{
  392. .top-box{
  393. height: 418rpx;
  394. background-color: rgba($color: #000000, $alpha: 0.7);
  395. background-size: cover;
  396. color: #fff;
  397. position: relative;
  398. .title{
  399. text-align: center;
  400. font-size: 34rpx;
  401. font-weight: 600;
  402. padding-top: 78rpx;
  403. }
  404. .sub-title{
  405. font-size: 32rpx;
  406. text-align: center;
  407. width: 70%;
  408. margin-left: auto;
  409. margin-right: auto;
  410. }
  411. .top-bot{
  412. position: absolute;
  413. bottom: 70rpx;
  414. left: 34rpx;
  415. right: 34rpx;
  416. justify-content: space-between;
  417. align-items: center;
  418. .time-box{
  419. align-items: center;
  420. font-size: 24rpx;
  421. .day{
  422. font-size: 32rpx;
  423. border-right: 1px solid #fff;
  424. padding-right: 15rpx;
  425. margin-right: 15rpx;
  426. }
  427. }
  428. .audio-play-box{
  429. align-items: center;
  430. width: 180rpx;
  431. height: 52rpx;
  432. background-color: #E3B377;
  433. border-radius: 25rpx;
  434. justify-content: center;
  435. color: #fff;
  436. font-size: 24rpx;
  437. .icon{
  438. width: 34rpx;
  439. height: 34rpx;
  440. margin-right: 8rpx;
  441. }
  442. }
  443. }
  444. .stage-num-week{
  445. position: absolute;
  446. top: 40rpx;
  447. left: 34rpx;
  448. }
  449. .stage-num-day{
  450. position: absolute;
  451. right: 34rpx;
  452. bottom: 70rpx;
  453. }
  454. .audio-play-set-box{
  455. position: absolute;
  456. top: 20rpx;
  457. right: 34rpx;
  458. .btn{
  459. width: 91rpx;
  460. height: 52rpx;
  461. }
  462. .attention-box{
  463. position: absolute;
  464. width: 634rpx;
  465. right: 20rpx;
  466. top: 110%;
  467. background-color: #fff;
  468. color: #333;
  469. box-shadow: 0px 0px 10rpx 4rpx rgba(0, 0, 0, 0.16);
  470. padding: 20rpx 54rpx 20rpx 20rpx;
  471. border-radius: 8rpx;
  472. .close-icon{
  473. width: 24rpx;
  474. height: 24rpx;
  475. position: absolute;
  476. top: 50%;
  477. transform: translateY(-50%);
  478. right: 20rpx;
  479. }
  480. &::after{
  481. content: '';
  482. display:block;
  483. width: 0;
  484. height: 0;
  485. border: 10rpx solid transparent;
  486. border-bottom-color: #fff;
  487. position: absolute;
  488. top: -20rpx;
  489. right: 20rpx;
  490. }
  491. }
  492. }
  493. }
  494. .list-box{
  495. margin-top: -50rpx;
  496. border-top-left-radius: 40rpx;
  497. border-top-right-radius: 40rpx;
  498. min-height: 100rpx;
  499. background-color: #fff;
  500. position: relative;
  501. z-index: 2;
  502. .item{
  503. padding: 30rpx 34rpx;
  504. border-bottom: 1px solid #E5E5E5;
  505. .img-box{
  506. width: 104rpx;
  507. height: 104rpx;
  508. box-sizing: border-box;
  509. border-radius: 8rpx;
  510. border: solid 2.5rpx #E5E5E5;
  511. display: flex;
  512. align-items: center;
  513. justify-content: center;
  514. margin-right: 20rpx;
  515. .img{
  516. width: 60rpx;
  517. height: 60rpx;
  518. }
  519. }
  520. .con{
  521. flex: 1;
  522. position: relative;
  523. .title{
  524. font-size: 28rpx;
  525. color: #57768D;
  526. font-weight: bold;
  527. margin-bottom: 5rpx;
  528. .tag{
  529. font-size: 20rpx;
  530. color: #fff;
  531. font-weight: normal;
  532. display: inline-block;
  533. background-color: #1E88E5;
  534. line-height: 37rpx;
  535. padding: 0 6rpx;
  536. border-radius: 4rpx;
  537. margin-left: 10rpx;
  538. }
  539. }
  540. .sub-title{
  541. color: #999;
  542. }
  543. .update-time{
  544. color: #D4D4D4;
  545. font-size: 24rpx;
  546. margin-top: 5rpx;
  547. }
  548. .audio-icon-box{
  549. position: absolute;
  550. top: 50%;
  551. right: 0;
  552. width: 60rpx;
  553. height: 56rpx;
  554. transform: translateY(-50%);
  555. background: linear-gradient(180deg, #F3A52F 0%, #E3B377 100%);
  556. border-radius: 12rpx;
  557. display: flex;
  558. justify-content: center;
  559. align-items: center;
  560. .icon{
  561. width: 40rpx;
  562. height: 40rpx;
  563. }
  564. }
  565. }
  566. }
  567. }
  568. .no-auth-box{
  569. text-align: center;
  570. font-size: $global-font-size-lg;
  571. /* color: #E3B377; */
  572. img{
  573. width: 100%;
  574. margin-bottom: 50rpx;
  575. }
  576. .btn{
  577. /* width: 90%;
  578. margin-left: auto;
  579. margin-right: auto;
  580. line-height: 80rpx;
  581. background-color: #E6B77D;
  582. border-radius: 4rpx;
  583. color: #fff;
  584. margin-top: 100rpx;
  585. display: block; */
  586. width: 380rpx;
  587. line-height: 70rpx;
  588. margin-left: auto;
  589. margin-right: auto;
  590. margin-top: 40rpx;
  591. }
  592. }
  593. }
  594. </style>