index.vue 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  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 {unescape, unescapeHtml} from "~/until/unescapeHtml";
  32. import {isMediaView} from "@/until/mediaView";
  33. import BigTitle from "~/components/public/bigTitle.vue";
  34. import ItemBanner from "~/components/banner/itemBanner.vue";
  35. import LucencyHeader from "~/components/header/lucencyHeader.vue";
  36. import {apiMap} from "~/map/apiMap";
  37. export default {
  38. name: "solutionItemIndex",
  39. props:['uLang', 'pType', 'pInfo', "pId"],
  40. components:{LucencyHeader, ItemBanner, BigTitle, defaultFooter},
  41. data(){
  42. return {
  43. langType: langMap.lang,
  44. lang: this.uLang?this.uLang:langMap.lang.cn,
  45. solutionId: this.pId,
  46. solutionDetail: {},
  47. productTypeText: getTypeText(this.pType),
  48. productTypeSubText: getTypeSubText(this.pType),
  49. timer: null,
  50. isPhone: false
  51. }
  52. },
  53. beforeMount() {
  54. console.log(this.pInfo);
  55. this.solutionDetail = this.pInfo;
  56. this.solutionDetail.content = unescapeHtml(this.solutionDetail.content);
  57. this.solutionDetail.date_time = timestampToTime(this.solutionDetail.date_time);
  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 = apiMap.solutionInfo.path;
  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 = apiMap.addPageRead;
  101. url += `?id=${this.solutionId}`
  102. [err,res] = await handle(this.$axios.$get(url));
  103. if(err) {
  104. console.log(err);
  105. return alert(err.message);
  106. }
  107. console.log(typeof res.code)
  108. if(res.code === 1){
  109. // this.solutionDetail.hits = res.data;
  110. console.log('page add hits ok')
  111. }else{
  112. console.log('not match result');
  113. console.log(res);
  114. }
  115. },
  116. }
  117. }
  118. </script>
  119. <style scoped>
  120. .big-title {
  121. margin: 5px auto;
  122. justify-content: left;
  123. }
  124. .solution-info{
  125. /* 两边布局*/
  126. display: flex;
  127. flex-direction: row;
  128. justify-content: space-between;
  129. align-items: flex-start;
  130. flex-wrap: wrap;
  131. font-size: 0.8rem;
  132. color: #999999;
  133. cursor: default;
  134. }
  135. </style>