index.vue 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. <template>
  2. <div class="content">
  3. <lucency-header :lang="lang" page-key="news" :is-phone="isPhone" />
  4. <item-banner :title="'合方圆'" :sub-title="solutionDetail.title"></item-banner>
  5. <big-title>
  6. {{solutionDetail.title}}
  7. <span class="author">
  8. {{solutionDetail.author}}
  9. </span>
  10. </big-title>
  11. <div class="conBox solution-view" v-html="solutionDetail.content">
  12. </div>
  13. <div class="conBox solution-info">
  14. <span class="viewer">
  15. {{solutionDetail.hits}}人浏览
  16. </span>
  17. <span class="time">
  18. 发布日期: {{solutionDetail.date_time}}
  19. </span>
  20. </div>
  21. <default-footer :lang="lang"/>
  22. <site-bar wechat-src="/image/wechat.jpg"></site-bar>
  23. </div>
  24. </template>
  25. <script>
  26. import axios from "axios";
  27. import langMap from "~/map/langMap";
  28. import defaultFooter from "~/components/footer/defaultFooter";
  29. import {getTypeSubText, getTypeText} from "~/map/newMap";
  30. import handle from "~/until/handle";
  31. import {timestampToTime} from "~/until/time";
  32. import {unescapeHtml} from "~/until/unescapeHtml";
  33. import {isMediaView} from "@/until/mediaView";
  34. import BigTitle from "~/components/public/bigTitle.vue";
  35. import LucencyHeader from "~/components/header/lucencyHeader.vue";
  36. import ItemBanner from "~/components/banner/itemBanner.vue";
  37. import {apiMap, baseUrl} from "~/map/apiMap";
  38. export default {
  39. name: "newsItemIndex",
  40. props:['uLang','pType', 'pInfo', "pId"],
  41. components:{ItemBanner, LucencyHeader, BigTitle, defaultFooter},
  42. data(){
  43. return {
  44. langType: langMap.lang,
  45. lang: this.uLang?this.uLang:langMap.lang.cn,
  46. solutionId: null,
  47. solutionDetail: {},
  48. productTypeText: getTypeText(this.pType),
  49. productTypeSubText: getTypeSubText(this.pType),
  50. timer: null,
  51. isPhone: false,
  52. }
  53. },
  54. beforeMount() {
  55. console.log(this.pInfo);
  56. this.solutionDetail = this.pInfo;
  57. this.solutionId = this.pId;
  58. this.solutionDetail.content = unescapeHtml(this.solutionDetail.content);
  59. this.solutionDetail.date_time = timestampToTime(this.solutionDetail.date_time);
  60. this.timer = setTimeout(()=>{
  61. this.addRead();
  62. },1000*10)
  63. },
  64. mounted() {
  65. this.$root.$on('changeLang',this.switchLang)
  66. this.isPhone = isMediaView(0,1024);
  67. // console.log(this.isPhone);
  68. // console.log(`this.isPhone:${this.isPhone}`);
  69. },
  70. beforeDestroy() {
  71. if (this.timer){
  72. clearTimeout(this.timer);
  73. }
  74. },
  75. methods:{
  76. getLangText(str) {
  77. return langMap.getText(this.lang, str);
  78. },
  79. getAbbrText(str) {
  80. return langMap.getAbbrText(this.lang, str);
  81. },
  82. async addRead(){
  83. let err,res;
  84. let url = apiMap.addPageRead.path;
  85. url += `?id=${this.solutionId}`;
  86. [err,res] = await handle(this.$axios.$get(url));
  87. if(err) {
  88. console.log(err);
  89. return alert(err.message);
  90. }
  91. console.log(typeof res.code)
  92. if(res.code === 1){
  93. // this.solutionDetail.hits = res.data;
  94. console.log('page add hits ok')
  95. }else{
  96. console.log('not match result');
  97. console.log(res);
  98. }
  99. },
  100. }
  101. }
  102. </script>
  103. <style scoped>
  104. .big-title {
  105. margin: 5px auto;
  106. justify-content: left;
  107. }
  108. .solution-info{
  109. /* 两边布局*/
  110. display: flex;
  111. flex-direction: row;
  112. justify-content: space-between;
  113. align-items: flex-start;
  114. flex-wrap: wrap;
  115. font-size: 0.8rem;
  116. color: #999999;
  117. cursor: default;
  118. }
  119. </style>