downloads.vue 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266
  1. <template>
  2. <div class="content">
  3. <div class="downloads">
  4. <div class="download-types noScroll">
  5. <div class="searchType">
  6. <input type="text" placeholder="在此处搜索文件" v-model="searchKey" @input="filterTypeChangeHandle" >
  7. <span class="close" @click="clearSearchText" >
  8. x
  9. </span>
  10. </div>
  11. <div class="d-type"
  12. v-for="item in filterTypes"
  13. :key="item.key"
  14. @click="switchType(item.key)"
  15. >
  16. {{item.title}}
  17. </div>
  18. </div>
  19. <div class="download-type-items">
  20. <div class="title">
  21. <span class="text-m text-b">[</span>
  22. <span class="mark-gold">{{nowTitle}}</span>
  23. <span class="text-b">]</span>
  24. 资料下载
  25. </div>
  26. <div class="d-type-item"
  27. v-for="(item,i) in subItems"
  28. :key="nowKey+'_'+i"
  29. >
  30. <a :href="item.src" target="_blank">
  31. <span class="file">
  32. <svg-icon class="icon" :icon-class="item.icon?item.icon:'unknownFile'"></svg-icon>
  33. {{item.title}}
  34. </span>
  35. <span class="time">
  36. {{timestampToTime(item.add_time)}}
  37. </span>
  38. </a>
  39. </div>
  40. </div>
  41. </div>
  42. <div class="downloads-more">
  43. <div class="more-text">
  44. 没有找到您需要的资料?
  45. 请联系我们,我们将竭诚为您服务。
  46. </div>
  47. </div>
  48. </div>
  49. </template>
  50. <script>
  51. import langMap from "@/map/langMap";
  52. import {timestampToTime} from "@/until/time";
  53. export default {
  54. name: "downloads",
  55. props: {
  56. lang:{
  57. default: langMap.lang.cn
  58. },
  59. downloads:{
  60. default: []
  61. }
  62. },
  63. data(){
  64. return {
  65. langType: langMap.lang,
  66. searchKey: '',
  67. filterTypes: [],
  68. subItems: [],
  69. nowTitle: '',
  70. nowKey: '',
  71. waitTimer: null,
  72. }
  73. },
  74. created(){
  75. this.filterTypes = this.downloads;
  76. this.switchType(this.downloads[0].key);
  77. },
  78. watch:{
  79. downloads(){
  80. this.filterTypeChangeHandle();
  81. }
  82. },
  83. methods:{
  84. timestampToTime(){
  85. return timestampToTime(...arguments);
  86. },
  87. switchType(key){
  88. if (this.nowKey !== key){
  89. this.nowKey = key;
  90. let items = this.downloads.find(item=>item.key === key);
  91. this.subItems = items?items.subItems:[];
  92. this.nowTitle = `${items?items.title:''}`;
  93. }
  94. },
  95. filterTypeChangeHandle(){
  96. // 等待700毫秒,防抖
  97. if (this.waitTimer){
  98. clearTimeout(this.waitTimer);
  99. }
  100. this.waitTimer = setTimeout(()=>{
  101. this.waitTimer = null;
  102. let key = this.searchKey;
  103. if (key){
  104. // 忽略大小写
  105. // key = key.toLowerCase();
  106. this.filterTypes = this.downloads.filter(item=> item.title.indexOf(key) !== -1);
  107. }else{
  108. this.filterTypes = this.downloads;
  109. }
  110. },700);
  111. },
  112. clearSearchText(){
  113. this.searchKey = '';
  114. this.filterTypeChangeHandle();
  115. }
  116. },
  117. }
  118. </script>
  119. <style scoped>
  120. .downloads{
  121. width: 100%;
  122. height: 100%;
  123. display: flex;
  124. flex-direction: row;
  125. justify-content: space-between;
  126. align-items: flex-start;
  127. }
  128. .download-types{
  129. width: 20%;
  130. height: 100%;
  131. display: flex;
  132. flex-direction: column;
  133. justify-content: flex-start;
  134. align-items: center;
  135. border-right: 1px solid #e5e5e5;
  136. overflow: auto;
  137. }
  138. .download-types .searchType{
  139. width: 100%;
  140. height: 40px;
  141. display: flex;
  142. flex-direction: row;
  143. justify-content: center;
  144. align-items: center;
  145. position: relative;
  146. font-size: 0.95rem;
  147. }
  148. .download-types .searchType input{
  149. width: 100%;
  150. height: 30px;
  151. border: 1px solid #e5e5e5;
  152. border-radius: 5px;
  153. padding: 0 10px;
  154. outline: none;
  155. position: relative;
  156. }
  157. .download-types .searchType .close{
  158. width: 20px;
  159. height: 20px;
  160. display: flex;
  161. flex-direction: row;
  162. justify-content: center;
  163. align-items: center;
  164. margin-left: 10px;
  165. cursor: pointer;
  166. position: absolute;
  167. right: 10px;
  168. color: #c54949;
  169. }
  170. .download-types .searchType .close:hover{
  171. color: #ff0000;
  172. font-size: 1.15rem;
  173. }
  174. .d-type{
  175. width: 100%;
  176. height: 40px;
  177. display: flex;
  178. flex-direction: row;
  179. justify-content: center;
  180. align-items: center;
  181. border-bottom: 1px solid #e5e5e5;
  182. cursor: pointer;
  183. }
  184. .d-type:hover{
  185. background-color: #f5f5f5;
  186. }
  187. .download-type-items{
  188. width: 80%;
  189. height: 100%;
  190. display: flex;
  191. flex-direction: column;
  192. justify-content: flex-start;
  193. align-items: flex-start;
  194. padding: 10px;
  195. }
  196. .download-type-items .title{
  197. width: 100%;
  198. height: 40px;
  199. display: flex;
  200. flex-direction: row;
  201. justify-content: flex-start;
  202. align-items: center;
  203. font-size: 1.2rem;
  204. font-weight: bold;
  205. color: #333333;
  206. }
  207. .download-type-items .d-type-item{
  208. width: 100%;
  209. height: 100%;
  210. display: flex;
  211. flex-direction: column;
  212. justify-content: flex-start;
  213. align-items: flex-start;
  214. }
  215. .download-type-items .d-type-item a{
  216. width: 100%;
  217. height: 40px;
  218. display: flex;
  219. flex-direction: row;
  220. justify-content: space-between;
  221. align-items: center;
  222. border-bottom: 1px solid #e5e5e5;
  223. text-decoration: none;
  224. color: #333333;
  225. cursor: pointer;
  226. padding: 0 10px;
  227. box-sizing: border-box;
  228. }
  229. .download-type-items .d-type-item a:hover{
  230. background-color: #ce5e5e;
  231. color: #ffffff;
  232. }
  233. .download-type-items .d-type-item a .file{
  234. width: calc(100% - 200px);
  235. height: 100%;
  236. display: flex;
  237. flex-direction: row;
  238. justify-content: flex-start;
  239. align-items: center;
  240. }
  241. .download-type-items .d-type-item a .file .icon{
  242. width: 20px;
  243. height: 20px;
  244. display: flex;
  245. flex-direction: row;
  246. justify-content: center;
  247. align-items: center;
  248. margin-right: 10px;
  249. }
  250. .download-type-items .d-type-item a .time{
  251. width: 200px;
  252. height: 100%;
  253. display: flex;
  254. flex-direction: row;
  255. justify-content: flex-end;
  256. align-items: center;
  257. }
  258. </style>