index.vue 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. <template>
  2. <div class="content">
  3. <lucency-header :lang="lang" page-key="solution" :is-phone="isPhone"/>
  4. <item-banner :title="productTypeText" :sub-title="productTypeSubText"></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/solutionMap";
  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. export default {
  34. name: "solutionItemIndex",
  35. props:['uLang','pType'],
  36. components:{defaultFooter},
  37. data(){
  38. return {
  39. langType: langMap.lang,
  40. lang: this.uLang?this.uLang:langMap.lang.cn,
  41. solutionId: null,
  42. solutionDetail: {},
  43. productTypeText: getTypeText(this.pType),
  44. productTypeSubText: getTypeSubText(this.pType),
  45. timer: null,
  46. isPhone: false
  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. mounted() {
  63. this.isPhone = isMediaView(0,1024);
  64. },
  65. beforeDestroy() {
  66. if (this.timer){
  67. clearTimeout(this.timer);
  68. }
  69. },
  70. methods:{
  71. getLangText(str) {
  72. return langMap.getText(this.lang, str);
  73. },
  74. getAbbrText(str) {
  75. return langMap.getAbbrText(this.lang, str);
  76. },
  77. async loadSolutionDetail(){
  78. let err,res;
  79. let url = `/api/getSolution.php?id=${this.solutionId}`;
  80. [err,res] = await handle(this.$axios.$get(url));
  81. if(err) {
  82. console.log(err);
  83. return alert(err.message);
  84. }
  85. console.log(typeof res.code)
  86. if(res.code === 1){
  87. this.solutionDetail = res.data;
  88. // console.log(this.solutionDetail.detail)
  89. this.solutionDetail.content = unescapeHtml(this.solutionDetail.content);
  90. // console.log(this.solutionDetail.detail)
  91. this.solutionDetail.date_time = timestampToTime(this.solutionDetail.date_time);
  92. }else{
  93. console.log('not match result');
  94. console.log(res);
  95. return alert('加载解决方案失败!!!');
  96. }
  97. },
  98. async addRead(){
  99. let err,res;
  100. let url = `/api/addNewsRead.php?id=${this.solutionId}`;
  101. [err,res] = await handle(this.$axios.$get(url));
  102. if(err) {
  103. console.log(err);
  104. return alert(err.message);
  105. }
  106. console.log(typeof res.code)
  107. if(res.code === 1){
  108. // this.solutionDetail.hits = res.data;
  109. console.log('page add hits ok')
  110. }else{
  111. console.log('not match result');
  112. console.log(res);
  113. }
  114. },
  115. }
  116. }
  117. </script>
  118. <style scoped>
  119. .big-title {
  120. margin: 5px auto;
  121. justify-content: left;
  122. }
  123. .solution-info{
  124. /* 两边布局*/
  125. display: flex;
  126. flex-direction: row;
  127. justify-content: space-between;
  128. align-items: flex-start;
  129. flex-wrap: wrap;
  130. font-size: 0.8rem;
  131. color: #999999;
  132. cursor: default;
  133. }
  134. </style>