index.vue 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  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 langMap from "~/map/langMap";
  27. import defaultFooter from "~/components/footer/defaultFooter";
  28. import {getTypeSubText, getTypeText} from "~/map/newMap";
  29. import handle from "~/until/handle";
  30. import {timestampToTime} from "~/until/time";
  31. import {unescapeHtml} from "~/until/unescapeHtml";
  32. import {isMediaView} from "@/until/mediaView";
  33. import BigTitle from "~/components/public/bigTitle.vue";
  34. export default {
  35. name: "newsItemIndex",
  36. props:['uLang','pType'],
  37. components:{BigTitle, defaultFooter},
  38. data(){
  39. return {
  40. langType: langMap.lang,
  41. lang: this.uLang?this.uLang:langMap.lang.cn,
  42. solutionId: null,
  43. solutionDetail: {},
  44. productTypeText: getTypeText(this.pType),
  45. productTypeSubText: getTypeSubText(this.pType),
  46. timer: null,
  47. isPhone: false,
  48. }
  49. },
  50. beforeMount() {
  51. const queryString = window.location.search;
  52. const params = new URLSearchParams(queryString);
  53. if(params&&params.get('id')){
  54. this.solutionId = params.get('id');
  55. }else{
  56. window.location.href = '/news'
  57. }
  58. this.loadSolutionDetail();
  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 loadSolutionDetail(){
  82. let err,res;
  83. let url = `/api/getSolution.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 = res.data;
  92. // console.log(this.solutionDetail.detail)
  93. this.solutionDetail.content = unescapeHtml(this.solutionDetail.content);
  94. // console.log(this.solutionDetail.detail)
  95. this.solutionDetail.date_time = timestampToTime(this.solutionDetail.date_time);
  96. }else{
  97. console.log('not match result');
  98. console.log(res);
  99. return alert('加载解决方案失败!!!');
  100. }
  101. },
  102. async addRead(){
  103. let err,res;
  104. let url = `/api/addNewsRead.php?id=${this.solutionId}`;
  105. [err,res] = await handle(this.$axios.$get(url));
  106. if(err) {
  107. console.log(err);
  108. return alert(err.message);
  109. }
  110. console.log(typeof res.code)
  111. if(res.code === 1){
  112. // this.solutionDetail.hits = res.data;
  113. console.log('page add hits ok')
  114. }else{
  115. console.log('not match result');
  116. console.log(res);
  117. }
  118. },
  119. }
  120. }
  121. </script>
  122. <style scoped>
  123. .big-title {
  124. margin: 5px auto;
  125. justify-content: left;
  126. }
  127. .solution-info{
  128. /* 两边布局*/
  129. display: flex;
  130. flex-direction: row;
  131. justify-content: space-between;
  132. align-items: flex-start;
  133. flex-wrap: wrap;
  134. font-size: 0.8rem;
  135. color: #999999;
  136. cursor: default;
  137. }
  138. </style>