index.vue 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609
  1. <template>
  2. <div>
  3. <div class="auto content">
  4. <Row>
  5. <Col :span="15">
  6. <div class="atc">
  7. <Breadcrumb v-if="(columnName instanceof Array)">
  8. <BreadcrumbItem to="/">首页</BreadcrumbItem>
  9. <BreadcrumbItem :to="{path: '/lists', query:{id:'88'}}">{{columnName[0]}}</BreadcrumbItem>
  10. <BreadcrumbItem :to="{path: '/lists', query:{id:columnId}}">{{columnName[1]}}</BreadcrumbItem>
  11. </Breadcrumb>
  12. <Breadcrumb v-else>
  13. <BreadcrumbItem to="/">首页</BreadcrumbItem>
  14. <BreadcrumbItem :to="{path: '/lists', query:{id:columnId}}">{{columnName}}</BreadcrumbItem>
  15. </Breadcrumb>
  16. <h2>{{title}}</h2>
  17. <div class="up-time">
  18. <Row>
  19. <Col :span="8">
  20. <span>{{upTime}}</span>
  21. </Col>
  22. <Col :span="8">
  23. <span v-if="srcname">来源:{{srcname}}</span>
  24. </Col>
  25. <Col :span="8">
  26. <div style="display:flex">
  27. <span>分享:</span>
  28. <div class="bdsharebuttonbox">
  29. <!-- <a href="#" class="bds_more" data-cmd="more"></a> -->
  30. <a class="bds_tsina" data-cmd="tsina" title="分享到新浪微博"></a>
  31. <a class="bds_weixin" @click="showVxCode" title="分享到微信">
  32. <Modal
  33. title="分享到微信朋友圈"
  34. v-model="vxCodeShow"
  35. :footer-hide="true"
  36. width="300px"
  37. >
  38. <!-- <div id="code"></div>
  39. <canvas id="canvas"></canvas> -->
  40. <!-- <vue-qr id="vx-qrcode" :text="'http://aseanweb.info666.com/content/'+id" :size="200" :data-bd-imgshare-binded="0"></vue-qr> -->
  41. <!-- <qrcode :value="'http://aseanweb.info666.com/content/'+id" :options="{ size: 170 }"></qrcode> -->
  42. <qriously style="text-align: center;" :value="'http://aseanweb.info666.com/content/?id='+id" :size="200"/>
  43. <p>打开微信,点击底部的“发现”,使用“扫一扫”即可将网页分享至朋友圈。</p>
  44. </Modal>
  45. </a>
  46. <a class="bds_sqq" data-cmd="sqq" title="分享到QQ好友"></a>
  47. <a class="bds_qzone" data-cmd="qzone" title="分享到QQ空间"></a>
  48. <a class="bds_twi" data-cmd="twi" title="分享到Twitter"></a>
  49. <a class="bds_fbook" data-cmd="fbook" title="分享到Facebook"></a>
  50. </div>
  51. </div>
  52. </Col>
  53. </Row>
  54. </div>
  55. <div v-if="type=='2'">
  56. <div class="con-img-box" v-html="content"></div>
  57. <div class="keyword" v-if="keywords">
  58. <span>关键字:</span>
  59. <span v-for="item in keywords.split(' ')">
  60. <a
  61. @click="keywordList(item)"
  62. class="line-one"
  63. style="-webkit-box-orient: vertical;margin: 0 5px"
  64. >{{item}}</a>
  65. </span>
  66. </div>
  67. <div class="author">
  68. <span>【编辑:{{author}}】</span>
  69. </div>
  70. </div>
  71. <div v-if="type=='1'">
  72. <video width="100%" min-height="420px" controls ref="videoPlayer">
  73. <!-- <source v-lazy="vurl" type="video/mp4"> -->
  74. <source :src="vurl" type="video/mp4">您的浏览器不支持 HTML5 video 标签。
  75. </video>
  76. </div>
  77. <div class="lists" v-show="swiperList.length">
  78. <div class="public-tit clearfix">
  79. <h4 class="fl wgw-color">相关阅读</h4>
  80. </div>
  81. <div>
  82. <swiper
  83. :options="swiperOptionTop"
  84. class="swiper-container gallery-top"
  85. ref="swiperTop"
  86. >
  87. <swiper-slide v-for="(arr,index) in swiperList" :key="index">
  88. <Row>
  89. <Col :span="7" v-for="(item,i) in arr" :key="i">
  90. <nuxt-link
  91. :to="{path: '/content', query:{id:item.infoId}}"
  92. tag="a"
  93. target="_blank"
  94. >
  95. <img :src="item.path" :alt="item.title">
  96. <p class="line-two">{{item.title}}</p>
  97. </nuxt-link>
  98. </Col>
  99. </Row>
  100. </swiper-slide>
  101. <div class="swiper-pagination" slot="pagination"></div>
  102. <!-- <div class="swiper-button-next swiper-button-white" slot="button-next"></div>
  103. <div class="swiper-button-prev swiper-button-white" slot="button-prev"></div>-->
  104. </swiper>
  105. </div>
  106. <!-- <div class="lists-item" v-for="item in listData">
  107. <img v-lazy="picPath+item.infoimg" alt="" :key="item.infoId">
  108. <div class="content-text">
  109. <nuxt-link :to="'/content/'+item.infoId">{{item.title}}</nuxt-link>
  110. <p style="-webkit-box-orient: vertical;">{{item.summary}}</p>
  111. <div class="source" v-if="item.columnname?item.columnname.includes('—'):false">
  112. <nuxt-link :to="'/lists/'+item.parentcolumnId" class="line-one" style="-webkit-box-orient: vertical;" tag="a" target="_blank">{{item.columnname.split('—')[0]}}</nuxt-link>
  113. <span>—</span>
  114. <nuxt-link :to="'/lists/'+item.columnId" class="line-one" style="-webkit-box-orient: vertical;" tag="a" target="_blank">{{item.columnname.split('—')[1]}}</nuxt-link>
  115. <span>/{{item.uptimeStr}}</span>
  116. </div>
  117. <div class="source" v-else>
  118. <nuxt-link v-if="item.columnname" :to="'/lists/'+item.columnId" class="line-one" style="-webkit-box-orient: vertical;" tag="a" target="_blank">{{item.columnname}}/</nuxt-link>
  119. <span>{{item.uptimeStr}}</span>
  120. </div>
  121. </div>
  122. </div>-->
  123. </div>
  124. </div>
  125. </Col>
  126. <Col :span="1" style="height:100px"></Col>
  127. <Col :span="8">
  128. <div>
  129. <div class="public-tit clearfix">
  130. <h4 class="fl wgw-color">推荐阅读</h4>
  131. </div>
  132. <ul class="text4adlist">
  133. <li v-for="item in list" class="line-one">
  134. <nuxt-link
  135. :to="{path: '/content', query:{id:item.infoId}}"
  136. tag="a"
  137. target="_blank"
  138. >{{item.title}}</nuxt-link>
  139. </li>
  140. </ul>
  141. </div>
  142. <!-- <div style="margin-top:30px">
  143. <a v-if="imgTo" :href="imgTo">
  144. <img style="width:333px" v-lazy="'http://pic-asean2.oss-cn-hongkong.aliyuncs.com/'+imgPath" alt="">
  145. </a>
  146. <img v-else style="width:333px" v-lazy="'http://pic-asean2.oss-cn-hongkong.aliyuncs.com/'+imgPath" alt="">
  147. </div>-->
  148. </Col>
  149. </Row>
  150. </div>
  151. </div>
  152. </template>
  153. <script>
  154. import { getInfoDetail } from '~/api/content'
  155. import { getColumnAd } from '~/api/lists'
  156. import { mapMutations, mapState, mapGetters, mapActions } from 'vuex'
  157. import Bus from '~/common/bus'
  158. import { formatTime } from '~/common/publicFun'
  159. export default {
  160. data() {
  161. return {
  162. vxCodeShow: false,
  163. picPath: 'http://pic-asean2.oss-cn-hongkong.aliyuncs.com/',
  164. suffix:
  165. '?x-oss-process=image/watermark,image_d2F0ZXJtYXJrL3dtMS5wbmc_eC1vc3MtcHJvY2Vzcz1pbWFnZS9yZXNpemUsUF8zMA==,g_se,x_10,y_10,t_70',
  166. type: '',
  167. list: [],
  168. title: '',
  169. upTime: '',
  170. content: '',
  171. imgPath: '',
  172. imgTo: '',
  173. vurl: '',
  174. columnId: '',
  175. columnName: '',
  176. author: '范编辑',
  177. keywords: '',
  178. listData: [], //下方相关阅读列表
  179. srcname: '',
  180. summary: '',
  181. id: '',
  182. swiperList: [],
  183. swiperOptionTop: {
  184. // spaceBetween: 10,
  185. notNextTick: true,
  186. observer: true, //修改swiper自己或子元素时,自动初始化swiper
  187. observeParents: true, //修改swiper的父元素时,自动初始化swiper
  188. loop: true,
  189. loopedSlides: 5, //looped slides should be the same
  190. pagination: {
  191. el: '.swiper-pagination',
  192. type: 'bullets',
  193. clickable: true
  194. },
  195. navigation: {
  196. nextEl: '.swiper-button-next',
  197. prevEl: '.swiper-button-prev'
  198. },
  199. codes: '',
  200. // autoplay: {
  201. // delay: 2500,
  202. // disableOnInteraction: false
  203. // },
  204. }
  205. }
  206. },
  207. async asyncData({ query }) {
  208. let arr = []
  209. let picPath = 'http://pic-asean2.oss-cn-hongkong.aliyuncs.com/'
  210. let swiperList = []
  211. let keywords = ''
  212. let columnName = ''
  213. let [conData, imgObj] = await Promise.all([
  214. getInfoDetail({ reqdata: { infoId: query.id } }),
  215. getColumnAd({ reqdata: { adPosition: 'column' } })
  216. ])
  217. conData.object.relateList.map((item, index) => {
  218. if (index < 12) {
  219. arr.push({
  220. path: picPath + item.infoimg,
  221. infoId: item.infoId,
  222. title: item.title
  223. })
  224. if ((index + 1) % 3 == 0) {
  225. swiperList.push(arr)
  226. arr = []
  227. }
  228. }
  229. })
  230. arr.length ? swiperList.push(arr) : null
  231. keywords = conData.object.keywords
  232. if (conData.object.columnName.includes('-')) {
  233. columnName = conData.object.columnName.split('-')
  234. } else {
  235. columnName = conData.object.columnName
  236. }
  237. return {
  238. type: conData.object.infoType,
  239. content: conData.object.articleContent,
  240. title: conData.object.title,
  241. summary: conData.object.summary,
  242. upTime: conData.object.uptimeStr,
  243. list: conData.list||[],
  244. vurl:
  245. 'http://video-asean2.oss-cn-hongkong.aliyuncs.com/' +
  246. conData.object.vurl,
  247. columnId: conData.object.columnId,
  248. srcname: conData.object.srcname,
  249. author: conData.object.managerName || '',
  250. listData: conData.object.relateList || [],
  251. swiperList,
  252. keywords,
  253. columnName,
  254. imgPath: imgObj.object ? imgObj.object.adimg : '',
  255. imgTo: imgObj.object ? imgObj.object.adurl : ''
  256. }
  257. },
  258. beforeCreate() {},
  259. updated() {},
  260. mounted() {
  261. this.id = parseInt(this.$route.query.id)
  262. Bus.$emit('columnId', this.columnId)
  263. window._bd_share_main = ''
  264. this.shareArt()
  265. // this.getData(this.id);
  266. },
  267. // computed: {
  268. // swiperTop () {
  269. // return this.$refs.swiperTop.swiper
  270. // }
  271. // },
  272. watch: {
  273. // $route() {
  274. // this.id = this.$route.params.id;
  275. // this.getData(this.id);
  276. // },
  277. //更改视频源 videoUrl从弹出框组件传值
  278. vurl: function(val) {
  279. if (val != '' && this.$refs.videoPlayer) {
  280. this.$nextTick(() => {
  281. this.$refs.videoPlayer.src = val
  282. })
  283. }
  284. }
  285. },
  286. head() {
  287. return {
  288. title: this.title,
  289. meta: [{
  290. hid: 'keywords',
  291. name: 'keywords',
  292. content: `东盟头条,aseantop,${this.keywords?this.keywords.replace(' ',','):''}`
  293. },{
  294. hid: 'description',
  295. name: 'description',
  296. content: this.summary
  297. }]
  298. }
  299. },
  300. methods: {
  301. // ...mapMutations(["setColumnId"]),
  302. getData(id) {
  303. let params = {
  304. reqdata: {
  305. infoId: id
  306. }
  307. }
  308. getInfoDetail(params).then(res => {
  309. let arr = []
  310. this.type = res.object.infoType
  311. this.content = res.object.articleContent
  312. // this.content = this.joinSuffixToContent(res.object.articleContent);
  313. this.title = res.object.title
  314. this.summary = res.object.summary
  315. this.upTime = res.object.uptimeStr
  316. this.list = res.list
  317. this.vurl =
  318. 'http://video-asean2.oss-cn-hongkong.aliyuncs.com/' + res.object.vurl
  319. this.columnId = res.object.columnId
  320. this.srcname = res.object.srcname
  321. this.author = res.object.managerName || this.author
  322. this.listData = res.object.relateList || []
  323. res.object.relateList.map((item, index) => {
  324. if (index < 12) {
  325. arr.push({
  326. path: this.picPath + item.infoimg,
  327. infoId: item.infoId,
  328. title: item.title
  329. })
  330. if ((index + 1) % 3 == 0) {
  331. this.swiperList.push(arr)
  332. arr = []
  333. }
  334. }
  335. })
  336. arr.length ? this.swiperList.push(arr) : null
  337. this.keywords = res.object.keywords
  338. if (res.object.columnName.includes('-')) {
  339. this.columnName = res.object.columnName.split('-')
  340. } else {
  341. this.columnName = res.object.columnName
  342. }
  343. this.shareArt()
  344. Bus.$emit('columnId', res.object.columnId)
  345. })
  346. this.getAd()
  347. },
  348. getAd() {
  349. getColumnAd({ reqdata: { adPosition: 'column' } }).then(res => {
  350. this.imgPath = res.object.adimg
  351. this.imgTo = res.object.adurl
  352. })
  353. },
  354. joinSuffixToContent(content) {
  355. let arr = content.split('http://')
  356. let arrTag = []
  357. arr.map(item => {
  358. if (item.includes('title')) {
  359. let i = item.indexOf('"')
  360. let nPath = 'http://' + item.slice(0, i) + this.suffix + item.slice(i)
  361. arrTag.push(nPath)
  362. } else {
  363. arrTag.push(item)
  364. }
  365. })
  366. return arrTag.join('')
  367. },
  368. keywordList(keyword) {
  369. // this.$store.dispatch('saveKeyword',keyword);
  370. // this.$router.push({ name:'lists'})
  371. let routeData = this.$router.resolve({
  372. path: '/lists',
  373. query: { id: keyword }
  374. })
  375. window.open(routeData.href, '_blank')
  376. },
  377. shareArt() {
  378. this.$nextTick(() => {
  379. window._bd_share_config = {
  380. common: {
  381. // onAfterClick:this.setShareConfig,
  382. // onBeforeClick:this.setAShareConfig,
  383. bdSnsKey: {},
  384. bdText: this.title,
  385. bdDesc: this.summary,
  386. bdMini: '2',
  387. bdMiniList: false,
  388. bdPic: '',
  389. bdUrl: 'http://aseanweb.info666.com/content/?id=' + this.id,
  390. bdStyle: '0',
  391. bdSize: '16'
  392. },
  393. share: {},
  394. image: {
  395. viewList: ['tsina', 'weixin', 'sqq', 'qzone', 'twi', 'fbook'],
  396. viewText: '分享到:',
  397. viewSize: '16'
  398. },
  399. selectShare: {
  400. bdContainerClass: null,
  401. bdSelectMiniList: [
  402. 'tsina',
  403. 'weixin',
  404. 'sqq',
  405. 'qzone',
  406. 'twi',
  407. 'fbook'
  408. ]
  409. }
  410. }
  411. const s = document.createElement('script')
  412. s.type = 'text/javascript'
  413. s.src =
  414. 'http://bdimg.share.baidu.com/static/api/js/share.js?v=89860593.js?cdnversion=' +
  415. ~(-new Date() / 36e5)
  416. document.body.appendChild(s)
  417. })
  418. },
  419. // setShareConfig (cmd) {
  420. // console.log(this.$el.getElementsByTagName('iframe')[1])
  421. // // if (cmd === 'weixin') {
  422. // // var t = setTimeout(function () {
  423. // // if (document.getElementById('bdshare_weixin_qrcode_dialog_bg').length > 0) {
  424. // // clearTimeout(t);
  425. // // document.getElementsByClassName('bdshare_weixin_qrcode_dialog_qr').html(document.getElementById('vx-qrcode'));
  426. // // document.getElementById('bdshare_weixin_qrcode_dialog_bg').css('height','auto');
  427. // // var cssText = document.getElementById('bdshare_weixin_qrcode_dialog_bg').attr('style') + ';display:block !important;';
  428. // // document.getElementById('bdshare_weixin_qrcode_dialog_bg').css('cssText', cssText);
  429. // // }
  430. // // },500);
  431. // // }
  432. // },
  433. showVxCode() {
  434. this.vxCodeShow = !this.vxCodeShow
  435. }
  436. }
  437. }
  438. </script>
  439. <style lang="scss" scoped>
  440. .content {
  441. padding-top: 15px;
  442. margin-bottom: 123px;
  443. .atc {
  444. h2 {
  445. width: 100%;
  446. text-align: center;
  447. }
  448. .ivu-breadcrumb {
  449. margin: 0 0 10px 0;
  450. }
  451. .up-time {
  452. margin: 15px 0;
  453. border-bottom: 1px dashed #ddd;
  454. width: 100%;
  455. line-height: 29px;
  456. .ivu-col-span-8 {
  457. height: 29px;
  458. }
  459. }
  460. .con-img-box {
  461. font-size: 18px;
  462. }
  463. .keyword {
  464. margin: 30px 0 0 15px;
  465. span,
  466. a {
  467. font-size: 16px;
  468. font-weight: bold;
  469. }
  470. }
  471. .author {
  472. margin: 30px 30px 0 0;
  473. float: right;
  474. }
  475. .lists {
  476. padding-top: 90px;
  477. .lists-item {
  478. display: inline-flex;
  479. padding: 19px 0;
  480. border-bottom: 1px solid #ccc;
  481. width: 100%;
  482. img {
  483. width: 35%;
  484. height: 150px;
  485. border-radius: 10px;
  486. margin-right: 10px;
  487. }
  488. .content-text {
  489. position: relative;
  490. margin-left: 10px;
  491. width: 62%;
  492. a {
  493. font-size: 20px;
  494. float: left;
  495. width: 100%;
  496. margin-bottom: 4px;
  497. }
  498. p {
  499. font-size: 14px;
  500. margin: 0 0 10px 0;
  501. color: #aaaaaa;
  502. width: 100%;
  503. height: 85px;
  504. overflow: hidden;
  505. text-overflow: ellipsis;
  506. display: -webkit-box;
  507. -webkit-line-clamp: 4;
  508. }
  509. span {
  510. float: left;
  511. font-size: 12px;
  512. margin-top: 15px;
  513. }
  514. .source {
  515. position: absolute;
  516. bottom: 0px;
  517. left: 0px;
  518. width: 100%;
  519. a {
  520. font-size: 13px;
  521. width: auto;
  522. color: #515a6e;
  523. margin: auto;
  524. }
  525. span {
  526. float: left;
  527. font-size: 12px;
  528. margin: auto;
  529. }
  530. }
  531. }
  532. }
  533. .gallery-top {
  534. width: 100%;
  535. height: 220px;
  536. padding-bottom: 20px;
  537. .swiper-slide {
  538. display: inline-flex;
  539. .ivu-col {
  540. padding: 0 15px;
  541. img {
  542. // width: 90%;
  543. height: 150px;
  544. }
  545. p {
  546. margin-top: 15px;
  547. }
  548. }
  549. }
  550. }
  551. }
  552. }
  553. .public-tit {
  554. height: 42px;
  555. line-height: 42px;
  556. border-top: 1px solid #cecece;
  557. h4 {
  558. font-size: 16px;
  559. font-weight: normal !important;
  560. padding: 0 10px;
  561. border-top: 2px solid;
  562. margin-top: -1px;
  563. display: inline-block;
  564. }
  565. a {
  566. color: #999;
  567. font-size: 15px;
  568. }
  569. }
  570. .text4adlist {
  571. clear: both;
  572. li {
  573. height: 26px;
  574. padding-left: 10px;
  575. font-size: 14px;
  576. line-height: 26px;
  577. background: url(~/assets/img/blue_ico.jpg) no-repeat left center;
  578. overflow: hidden;
  579. a {
  580. line-height: 26px;
  581. font-size: 13px;
  582. color: #393939;
  583. }
  584. }
  585. }
  586. }
  587. .bd_weixin_popup {
  588. .bd_weixin_popup_main {
  589. display: none !important;
  590. table {
  591. }
  592. }
  593. }
  594. </style>