index.vue 5.3 KB

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