index.vue 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203
  1. <template>
  2. <div>
  3. <lucency-header :lang="lang" :page-key="pageKey"></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. function getFileIcon(fileName){
  26. // 获取文件后缀
  27. if(!fileName){
  28. return 'unknownfile';
  29. }
  30. const fileSuffix = fileName.split('.').pop();
  31. switch (fileSuffix) {
  32. case 'doc':
  33. return 'doc';
  34. case 'docx':
  35. return 'doc';
  36. case 'pdf':
  37. return 'pdf';
  38. case 'png':
  39. return 'img';
  40. case 'jpg':
  41. return 'img';
  42. case 'jpeg':
  43. return 'img';
  44. default:
  45. return 'unknownfile';
  46. }
  47. }
  48. export default {
  49. name: "index",
  50. props:['uLang'],
  51. components: { lucencyHeader },
  52. data(){
  53. return {
  54. lang: this.uLang?this.uLang:langMap.lang.cn,
  55. pageKey: 'support',
  56. qTabs: [
  57. {
  58. text: '技术支持',
  59. content: '技术支持',
  60. key: 'question'
  61. },
  62. {
  63. text: '下载中心',
  64. content: '下载相关技术资料',
  65. key: 'download'
  66. },
  67. ],
  68. downloadsType: [
  69. {
  70. title: "G8100",
  71. key: 1,
  72. subItems: [
  73. {
  74. icon: "doc",
  75. title: "4G低功耗模块G8100B硬件手册",
  76. url: "https://gpscore.net/",
  77. add_time: "1486538906"
  78. },
  79. {
  80. icon: "pdf",
  81. title: "4G低功耗模块G8100B硬件手册",
  82. url: "https://gpscore.net/",
  83. add_time: "1486538906"
  84. },
  85. {
  86. icon: "img",
  87. title: "4G低功耗模块G8100B硬件手册",
  88. url: "https://gpscore.net/",
  89. add_time: "1486538906"
  90. }
  91. ]
  92. },
  93. {
  94. title: "枪机摄像头",
  95. key: 2,
  96. subItems: [
  97. {
  98. icon: "doc",
  99. title: "4G低功耗模块G8100B硬件手册",
  100. url: "https://gpscore.net/",
  101. add_time: "1486538906"
  102. },
  103. {
  104. icon: "pdf",
  105. title: "4G低功耗模块G8100B硬件手册",
  106. url: "https://gpscore.net/",
  107. add_time: "1486538906"
  108. },
  109. {
  110. icon: "img",
  111. title: "4G低功耗模块G8100B硬件手册",
  112. url: "https://gpscore.net/",
  113. add_time: "1486538906"
  114. }
  115. ]
  116. }
  117. ]
  118. }
  119. },
  120. mounted() {
  121. this.$root.$on('changeLang',this.switchLang);
  122. this.$root.$on('loadDownloadItem',this.loadDownloadItems);
  123. this.loadDownloads();
  124. },
  125. methods:{
  126. switchLang(nextLang){
  127. if(nextLang){
  128. this.lang = nextLang;
  129. }else{
  130. if(this.lang === langMap.lang.cn){
  131. this.lang = langMap.lang.en
  132. }else{
  133. this.lang = langMap.lang.cn
  134. }
  135. }
  136. },
  137. async loadDownloads(){
  138. let err, res;
  139. [err, res] = await handle(this.$axios.$get('/api/getDownloads.php'));
  140. if(err) {
  141. console.log(err);
  142. return 0;
  143. }
  144. if(res.rcode === 1){
  145. // this.downloadsType = res.data;
  146. this.downloadsType = res.data.map(item=>{
  147. item.key = item.id;
  148. return item;
  149. });
  150. }else{
  151. console.log(res.msg);
  152. console.log(res);
  153. }
  154. },
  155. async loadDownloadItems(downloadId){
  156. console.log(`获取下载项${downloadId}`)
  157. let err, res;
  158. const queryData = {
  159. id: downloadId
  160. };
  161. let url = '/api/getDownloadItems.php';
  162. let data = qs.stringify(queryData);
  163. [err, res] = await handle(this.$axios.post(
  164. url,
  165. data
  166. ));
  167. if(err){
  168. console.log(err);
  169. return null;
  170. }
  171. let result = res.data;
  172. console.log(result)
  173. if(result.rcode === 1){
  174. // 匹配对应的id
  175. let downloadItem = this.downloadsType.find(item => item.id === downloadId);
  176. let arr = result.data?result.data:[];
  177. downloadItem.subItems = arr.map(item=>{
  178. item.title = unescapeHtml(item.remark);
  179. item.icon = getFileIcon(item.files);
  180. item.src = item.files;
  181. return item;
  182. });
  183. }else{
  184. console.error(result.msg);
  185. console.log(result);
  186. }
  187. }
  188. },
  189. }
  190. </script>
  191. <style scoped>
  192. </style>