index.vue 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  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.solutionId = this.pId;
  57. this.solutionDetail.content = unescapeHtml(this.solutionDetail.content);
  58. this.solutionDetail.date_time = timestampToTime(this.solutionDetail.date_time);
  59. this.timer = setTimeout(()=>{
  60. this.addRead();
  61. },1000*10)
  62. },
  63. mounted() {
  64. this.isPhone = isMediaView(0,1024);
  65. },
  66. beforeDestroy() {
  67. if (this.timer){
  68. clearTimeout(this.timer);
  69. }
  70. },
  71. methods:{
  72. getLangText(str) {
  73. return langMap.getText(this.lang, str);
  74. },
  75. getAbbrText(str) {
  76. return langMap.getAbbrText(this.lang, str);
  77. },
  78. async loadSolutionDetail(){
  79. let err,res;
  80. let url = apiMap.solutionInfo.path;
  81. [err,res] = await handle(this.$axios.$get(url));
  82. if(err) {
  83. console.log(err);
  84. return alert(err.message);
  85. }
  86. console.log(typeof res.code)
  87. if(res.code === 1){
  88. this.solutionDetail = res.data;
  89. // console.log(this.solutionDetail.detail)
  90. this.solutionDetail.content = unescapeHtml(this.solutionDetail.content);
  91. // console.log(this.solutionDetail.detail)
  92. this.solutionDetail.date_time = timestampToTime(this.solutionDetail.date_time);
  93. }else{
  94. console.log('not match result');
  95. console.log(res);
  96. return alert('加载解决方案失败!!!');
  97. }
  98. },
  99. async addRead(){
  100. let err,res;
  101. let url = apiMap.addPageRead.path;
  102. url += `?id=${this.solutionId}`;
  103. [err,res] = await handle(this.$axios.$get(url));
  104. if(err) {
  105. console.log(err);
  106. return alert(err.message);
  107. }
  108. console.log(typeof res.code)
  109. if(res.code === 1){
  110. // this.solutionDetail.hits = res.data;
  111. console.log('page add hits ok')
  112. }else{
  113. console.log('not match result');
  114. console.log(res);
  115. }
  116. },
  117. }
  118. }
  119. </script>
  120. <style scoped>
  121. .big-title {
  122. margin: 5px auto;
  123. justify-content: left;
  124. }
  125. .solution-info{
  126. /* 两边布局*/
  127. display: flex;
  128. flex-direction: row;
  129. justify-content: space-between;
  130. align-items: flex-start;
  131. flex-wrap: wrap;
  132. font-size: 0.8rem;
  133. color: #999999;
  134. cursor: default;
  135. }
  136. </style>