index.vue 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211
  1. <template>
  2. <div>
  3. <lucency-header :lang="lang" :page-key="pageKey" :is-phone="isPhone"></lucency-header>
  4. <item-banner :title="'支持中心'" :sub-title="'需要我们为您提供些什么内容呢?'"></item-banner>
  5. <div class="conBox">
  6. <q-tab :headers="qTabs">
  7. <template v-slot:question>
  8. <support ></support>
  9. </template>
  10. <template v-slot:download>
  11. <downloads :downloads="downloadsType"></downloads>
  12. </template>
  13. </q-tab>
  14. </div>
  15. <default-footer :lang="lang"></default-footer>
  16. <site-bar wechat-src="/image/wechat.jpg"></site-bar>
  17. </div>
  18. </template>
  19. <script>
  20. import qs from "qs";
  21. import lucencyHeader from "~/components/header/lucencyHeader";
  22. import langMap from "@/map/langMap";
  23. import handle from "@/until/handle";
  24. import {unescapeHtml} from "@/until/unescapeHtml";
  25. import {isMediaView} from "@/until/mediaView";
  26. import ItemBanner from "~/components/banner/itemBanner.vue";
  27. import Downloads from "~/components/supportCom/downloads.vue";
  28. import DefaultFooter from "~/components/footer/defaultFooter.vue";
  29. import {apiMap} from "~/map/apiMap";
  30. function getFileIcon(fileName){
  31. // 获取文件后缀
  32. if(!fileName){
  33. return 'unknownfile';
  34. }
  35. const fileSuffix = fileName.split('.').pop();
  36. switch (fileSuffix) {
  37. case 'doc':
  38. return 'doc';
  39. case 'docx':
  40. return 'doc';
  41. case 'pdf':
  42. return 'pdf';
  43. case 'png':
  44. return 'img';
  45. case 'jpg':
  46. return 'img';
  47. case 'jpeg':
  48. return 'img';
  49. default:
  50. return 'unknownfile';
  51. }
  52. }
  53. export default {
  54. name: "index",
  55. props:['uLang'],
  56. components: {DefaultFooter, Downloads, ItemBanner, lucencyHeader },
  57. data(){
  58. return {
  59. lang: this.uLang?this.uLang:langMap.lang.cn,
  60. pageKey: 'support',
  61. qTabs: [
  62. {
  63. text: '技术支持',
  64. content: '技术支持',
  65. key: 'question'
  66. },
  67. {
  68. text: '下载中心',
  69. content: '下载相关技术资料',
  70. key: 'download'
  71. },
  72. ],
  73. downloadsType: [
  74. {
  75. title: "G8100",
  76. key: 1,
  77. subItems: [
  78. {
  79. icon: "doc",
  80. title: "4G低功耗模块G8100B硬件手册",
  81. url: "https://gpscore.net/",
  82. add_time: "1486538906"
  83. },
  84. {
  85. icon: "pdf",
  86. title: "4G低功耗模块G8100B硬件手册",
  87. url: "https://gpscore.net/",
  88. add_time: "1486538906"
  89. },
  90. {
  91. icon: "img",
  92. title: "4G低功耗模块G8100B硬件手册",
  93. url: "https://gpscore.net/",
  94. add_time: "1486538906"
  95. }
  96. ]
  97. },
  98. {
  99. title: "枪机摄像头",
  100. key: 2,
  101. subItems: [
  102. {
  103. icon: "doc",
  104. title: "4G低功耗模块G8100B硬件手册",
  105. url: "https://gpscore.net/",
  106. add_time: "1486538906"
  107. },
  108. {
  109. icon: "pdf",
  110. title: "4G低功耗模块G8100B硬件手册",
  111. url: "https://gpscore.net/",
  112. add_time: "1486538906"
  113. },
  114. {
  115. icon: "img",
  116. title: "4G低功耗模块G8100B硬件手册",
  117. url: "https://gpscore.net/",
  118. add_time: "1486538906"
  119. }
  120. ]
  121. }
  122. ],
  123. isPhone: false
  124. }
  125. },
  126. mounted() {
  127. this.$root.$on('changeLang',this.switchLang);
  128. this.$root.$on('loadDownloadItem',this.loadDownloadItems);
  129. this.isPhone = isMediaView(0,1024);
  130. this.loadDownloads();
  131. },
  132. methods:{
  133. switchLang(nextLang){
  134. if(nextLang){
  135. this.lang = nextLang;
  136. }else{
  137. if(this.lang === langMap.lang.cn){
  138. this.lang = langMap.lang.en
  139. }else{
  140. this.lang = langMap.lang.cn
  141. }
  142. }
  143. },
  144. async loadDownloads(){
  145. let err, res;
  146. let url = apiMap.downloads.path;
  147. [err, res] = await handle(this.$axios.$get(url));
  148. if(err) {
  149. console.log(err);
  150. return 0;
  151. }
  152. if(res.code === 1){
  153. // this.downloadsType = res.data;
  154. this.downloadsType = res.data.map(item=>{
  155. item.key = item.id;
  156. return item;
  157. });
  158. }else{
  159. console.log(res.msg);
  160. console.log(res);
  161. }
  162. },
  163. async loadDownloadItems(downloadId){
  164. console.log(`获取下载项${downloadId}`)
  165. let err, res;
  166. const queryData = {
  167. id: downloadId
  168. };
  169. let url = apiMap.downloadItem.path;
  170. // let data = qs.stringify(queryData);
  171. url += `?id=&${downloadId}`;
  172. [err, res] = await handle(this.$axios.get(
  173. url,
  174. ));
  175. if(err){
  176. console.log(err);
  177. return null;
  178. }
  179. let result = res.data;
  180. console.log(result)
  181. if(result.code === 1){
  182. // 匹配对应的id
  183. let downloadItem = this.downloadsType.find(item => item.id === downloadId);
  184. let arr = result.data?result.data:[];
  185. downloadItem.subItems = arr.map(item=>{
  186. item.title = unescapeHtml(item.remark);
  187. item.icon = getFileIcon(item.files);
  188. item.src = item.files;
  189. return item;
  190. });
  191. }else{
  192. console.error(result.msg);
  193. console.log(result);
  194. }
  195. }
  196. },
  197. }
  198. </script>
  199. <style scoped>
  200. </style>