index.vue 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  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. </div>
  26. </template>
  27. <script>
  28. import langMap from "~/map/langMap";
  29. import defaultFooter from "~/components/footer/defaultFooter";
  30. import {getTypeSubText, getTypeText} from "~/map/solutionMap";
  31. import handle from "~/until/handle";
  32. import {timestampToTime} from "~/until/time";
  33. import {unescapeHtml} from "~/until/unescapeHtml";
  34. export default {
  35. name: "solutionItemIndex",
  36. props:['uLang','pType'],
  37. components:{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. }
  48. },
  49. beforeMount() {
  50. const queryString = window.location.search;
  51. const params = new URLSearchParams(queryString);
  52. if(params&&params.get('id')){
  53. this.solutionId = params.get('id');
  54. }else{
  55. window.location.href = '/solution'
  56. }
  57. this.loadSolutionDetail();
  58. this.timer = setTimeout(()=>{
  59. this.addRead();
  60. },1000*10)
  61. },
  62. beforeDestroy() {
  63. if (this.timer){
  64. clearTimeout(this.timer);
  65. }
  66. },
  67. methods:{
  68. getLangText(str) {
  69. return langMap.getText(this.lang, str);
  70. },
  71. getAbbrText(str) {
  72. return langMap.getAbbrText(this.lang, str);
  73. },
  74. async loadSolutionDetail(){
  75. let err,res;
  76. let url = `/api/getSolution.php?id=${this.solutionId}`;
  77. [err,res] = await handle(this.$axios.$get(url));
  78. if(err) {
  79. console.log(err);
  80. return alert(err.message);
  81. }
  82. console.log(typeof res.rcode)
  83. if(res.rcode === 1){
  84. this.solutionDetail = res.data;
  85. // console.log(this.solutionDetail.detail)
  86. this.solutionDetail.content = unescapeHtml(this.solutionDetail.content);
  87. // console.log(this.solutionDetail.detail)
  88. this.solutionDetail.date_time = timestampToTime(this.solutionDetail.date_time);
  89. }else{
  90. console.log('not match result');
  91. console.log(res);
  92. return alert('加载解决方案失败!!!');
  93. }
  94. },
  95. async addRead(){
  96. let err,res;
  97. let url = `/api/addNewsRead.php?id=${this.solutionId}`;
  98. [err,res] = await handle(this.$axios.$get(url));
  99. if(err) {
  100. console.log(err);
  101. return alert(err.message);
  102. }
  103. console.log(typeof res.rcode)
  104. if(res.rcode === 1){
  105. // this.solutionDetail.hits = res.data;
  106. console.log('page add hits ok')
  107. }else{
  108. console.log('not match result');
  109. console.log(res);
  110. }
  111. },
  112. }
  113. }
  114. </script>
  115. <style scoped>
  116. .big-title {
  117. margin: 5px auto;
  118. justify-content: left;
  119. }
  120. .solution-info{
  121. /* 两边布局*/
  122. display: flex;
  123. flex-direction: row;
  124. justify-content: space-between;
  125. align-items: flex-start;
  126. flex-wrap: wrap;
  127. font-size: 0.8rem;
  128. color: #999999;
  129. cursor: default;
  130. }
  131. </style>