index.vue 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  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.solutionDetail.content = unescapeHtml(this.solutionDetail.content);
  58. this.solutionDetail.date_time = timestampToTime(this.solutionDetail.date_time);
  59. this.timer = setTimeout(()=>{
  60. this.addRead();
  61. },1000*10)
  62. },
  63. mounted() {
  64. this.$root.$on('changeLang',this.switchLang)
  65. this.isPhone = isMediaView(0,1024);
  66. // console.log(this.isPhone);
  67. // console.log(`this.isPhone:${this.isPhone}`);
  68. },
  69. beforeDestroy() {
  70. if (this.timer){
  71. clearTimeout(this.timer);
  72. }
  73. },
  74. methods:{
  75. getLangText(str) {
  76. return langMap.getText(this.lang, str);
  77. },
  78. getAbbrText(str) {
  79. return langMap.getAbbrText(this.lang, str);
  80. },
  81. async addRead(){
  82. let err,res;
  83. let url = `/api/addNewsRead.php?id=${this.solutionId}`;
  84. [err,res] = await handle(this.$axios.$get(url));
  85. if(err) {
  86. console.log(err);
  87. return alert(err.message);
  88. }
  89. console.log(typeof res.code)
  90. if(res.code === 1){
  91. // this.solutionDetail.hits = res.data;
  92. console.log('page add hits ok')
  93. }else{
  94. console.log('not match result');
  95. console.log(res);
  96. }
  97. },
  98. }
  99. }
  100. </script>
  101. <style scoped>
  102. .big-title {
  103. margin: 5px auto;
  104. justify-content: left;
  105. }
  106. .solution-info{
  107. /* 两边布局*/
  108. display: flex;
  109. flex-direction: row;
  110. justify-content: space-between;
  111. align-items: flex-start;
  112. flex-wrap: wrap;
  113. font-size: 0.8rem;
  114. color: #999999;
  115. cursor: default;
  116. }
  117. </style>