index.vue 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. <template>
  2. <div class="content">
  3. <lucency-header :lang="lang" page-key="solution" />
  4. <item-banner :title="productTypeText" :sub-title="productTypeSubText"></item-banner>
  5. <div class="conBox big-title">
  6. <span >
  7. {{solutionDetail.title}}
  8. </span>
  9. <div class="hr"></div>
  10. <span class="author">
  11. {{solutionDetail.author}}
  12. </span>
  13. </div>
  14. <div class="conBox solution-view" v-html="solutionDetail.content">
  15. </div>
  16. <div class="conBox solution-info">
  17. <span class="viewer">
  18. {{solutionDetail.hits}}人浏览
  19. </span>
  20. <span class="time">
  21. 发布日期: {{solutionDetail.date_time}}
  22. </span>
  23. </div>
  24. <default-footer :lang="lang"/>
  25. <site-bar wechat-src="/image/wechat.jpg"></site-bar>
  26. </div>
  27. </template>
  28. <script>
  29. import langMap from "~/map/langMap";
  30. import defaultFooter from "~/components/footer/defaultFooter";
  31. import {getTypeSubText, getTypeText} from "~/map/solutionMap";
  32. import handle from "~/until/handle";
  33. import {timestampToTime} from "~/until/time";
  34. import {unescapeHtml} from "~/until/unescapeHtml";
  35. export default {
  36. name: "solutionItemIndex",
  37. props:['uLang','pType'],
  38. components:{defaultFooter},
  39. data(){
  40. return {
  41. langType: langMap.lang,
  42. lang: this.uLang?this.uLang:langMap.lang.cn,
  43. solutionId: null,
  44. solutionDetail: {},
  45. productTypeText: getTypeText(this.pType),
  46. productTypeSubText: getTypeSubText(this.pType),
  47. timer: null,
  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 = '/solution'
  57. }
  58. this.loadSolutionDetail();
  59. this.timer = setTimeout(()=>{
  60. this.addRead();
  61. },1000*10)
  62. },
  63. beforeDestroy() {
  64. if (this.timer){
  65. clearTimeout(this.timer);
  66. }
  67. },
  68. methods:{
  69. getLangText(str) {
  70. return langMap.getText(this.lang, str);
  71. },
  72. getAbbrText(str) {
  73. return langMap.getAbbrText(this.lang, str);
  74. },
  75. async loadSolutionDetail(){
  76. let err,res;
  77. let url = `/api/getSolution.php?id=${this.solutionId}`;
  78. [err,res] = await handle(this.$axios.$get(url));
  79. if(err) {
  80. console.log(err);
  81. return alert(err.message);
  82. }
  83. console.log(typeof res.rcode)
  84. if(res.rcode === 1){
  85. this.solutionDetail = res.data;
  86. // console.log(this.solutionDetail.detail)
  87. this.solutionDetail.content = unescapeHtml(this.solutionDetail.content);
  88. // console.log(this.solutionDetail.detail)
  89. this.solutionDetail.date_time = timestampToTime(this.solutionDetail.date_time);
  90. }else{
  91. console.log('not match result');
  92. console.log(res);
  93. return alert('加载解决方案失败!!!');
  94. }
  95. },
  96. async addRead(){
  97. let err,res;
  98. let url = `/api/addNewsRead.php?id=${this.solutionId}`;
  99. [err,res] = await handle(this.$axios.$get(url));
  100. if(err) {
  101. console.log(err);
  102. return alert(err.message);
  103. }
  104. console.log(typeof res.rcode)
  105. if(res.rcode === 1){
  106. // this.solutionDetail.hits = res.data;
  107. console.log('page add hits ok')
  108. }else{
  109. console.log('not match result');
  110. console.log(res);
  111. }
  112. },
  113. }
  114. }
  115. </script>
  116. <style scoped>
  117. .big-title {
  118. margin: 5px auto;
  119. justify-content: left;
  120. }
  121. .solution-info{
  122. /* 两边布局*/
  123. display: flex;
  124. flex-direction: row;
  125. justify-content: space-between;
  126. align-items: flex-start;
  127. flex-wrap: wrap;
  128. font-size: 0.8rem;
  129. color: #999999;
  130. cursor: default;
  131. }
  132. </style>