index.vue 20 KB

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