index.vue 5.0 KB

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