index.vue 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220
  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. head(){
  58. return {
  59. title: `合方圆-支持中心`,
  60. meta: [
  61. { hid: 'description', name: 'description', content: '合方圆支持中心' },
  62. { hid: 'keywords', name: 'keywords', content: '合方圆技术支持,合方圆科技技术支持,合方圆科技-下载中心' },
  63. ]
  64. }
  65. },
  66. data(){
  67. return {
  68. lang: this.uLang?this.uLang:langMap.lang.cn,
  69. pageKey: 'support',
  70. qTabs: [
  71. {
  72. text: '技术支持',
  73. content: '技术支持',
  74. key: 'question'
  75. },
  76. {
  77. text: '下载中心',
  78. content: '下载相关技术资料',
  79. key: 'download'
  80. },
  81. ],
  82. downloadsType: [
  83. {
  84. title: "G8100",
  85. key: 1,
  86. subItems: [
  87. {
  88. icon: "doc",
  89. title: "4G低功耗模块G8100B硬件手册",
  90. url: "https://gpscore.net/",
  91. add_time: "1486538906"
  92. },
  93. {
  94. icon: "pdf",
  95. title: "4G低功耗模块G8100B硬件手册",
  96. url: "https://gpscore.net/",
  97. add_time: "1486538906"
  98. },
  99. {
  100. icon: "img",
  101. title: "4G低功耗模块G8100B硬件手册",
  102. url: "https://gpscore.net/",
  103. add_time: "1486538906"
  104. }
  105. ]
  106. },
  107. {
  108. title: "枪机摄像头",
  109. key: 2,
  110. subItems: [
  111. {
  112. icon: "doc",
  113. title: "4G低功耗模块G8100B硬件手册",
  114. url: "https://gpscore.net/",
  115. add_time: "1486538906"
  116. },
  117. {
  118. icon: "pdf",
  119. title: "4G低功耗模块G8100B硬件手册",
  120. url: "https://gpscore.net/",
  121. add_time: "1486538906"
  122. },
  123. {
  124. icon: "img",
  125. title: "4G低功耗模块G8100B硬件手册",
  126. url: "https://gpscore.net/",
  127. add_time: "1486538906"
  128. }
  129. ]
  130. }
  131. ],
  132. isPhone: false
  133. }
  134. },
  135. mounted() {
  136. this.$root.$on('changeLang',this.switchLang);
  137. this.$root.$on('loadDownloadItem',this.loadDownloadItems);
  138. this.isPhone = isMediaView(0,1024);
  139. this.loadDownloads();
  140. },
  141. methods:{
  142. switchLang(nextLang){
  143. if(nextLang){
  144. this.lang = nextLang;
  145. }else{
  146. if(this.lang === langMap.lang.cn){
  147. this.lang = langMap.lang.en
  148. }else{
  149. this.lang = langMap.lang.cn
  150. }
  151. }
  152. },
  153. async loadDownloads(){
  154. let err, res;
  155. let url = apiMap.downloads.path;
  156. [err, res] = await handle(this.$axios.$get(url));
  157. if(err) {
  158. console.log(err);
  159. return 0;
  160. }
  161. if(res.code === 1){
  162. // this.downloadsType = res.data;
  163. this.downloadsType = res.data.map(item=>{
  164. item.key = item.id;
  165. return item;
  166. });
  167. }else{
  168. console.log(res.msg);
  169. console.log(res);
  170. }
  171. },
  172. async loadDownloadItems(downloadId){
  173. console.log(`获取下载项${downloadId}`)
  174. let err, res;
  175. const queryData = {
  176. id: downloadId
  177. };
  178. let url = apiMap.downloadItem.path;
  179. // let data = qs.stringify(queryData);
  180. url += `?id=&${downloadId}`;
  181. [err, res] = await handle(this.$axios.get(
  182. url,
  183. ));
  184. if(err){
  185. console.log(err);
  186. return null;
  187. }
  188. let result = res.data;
  189. console.log(result)
  190. if(result.code === 1){
  191. // 匹配对应的id
  192. let downloadItem = this.downloadsType.find(item => item.id === downloadId);
  193. let arr = result.data?result.data:[];
  194. downloadItem.subItems = arr.map(item=>{
  195. item.title = unescapeHtml(item.remark);
  196. item.icon = getFileIcon(item.files);
  197. item.src = item.files;
  198. return item;
  199. });
  200. }else{
  201. console.error(result.msg);
  202. console.log(result);
  203. }
  204. }
  205. },
  206. }
  207. </script>
  208. <style scoped>
  209. </style>