index.vue 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. <template>
  2. <div class="index-container">
  3. <NavBar :go="{ type: 'push', path: '/isMy' }"/>
  4. <div class="item-container">
  5. <van-row>
  6. <van-col span="8" class="side_list">
  7. <van-sidebar v-model="activeKey" @change="onChange">
  8. <van-sidebar-item :title="item.sourceName" v-for="item in sources" />
  9. </van-sidebar>
  10. </van-col>
  11. <van-col span="16">
  12. <div class="sidebar-content">
  13. <div class="operator-card" v-for="item in list" :key="item" :title="item.fileName" @click="showFile(item)">
  14. <van-image
  15. width="1rem"
  16. height="1rem"
  17. style="margin-left: 10px;float: left"
  18. :src="getFileType(item.fileType)"
  19. />
  20. <span class="sid-content-title">{{item.fileName}}</span>
  21. </div>
  22. </div>
  23. </van-col>
  24. </van-row>
  25. </div>
  26. </div>
  27. </template>
  28. <script>
  29. import NavBar from '@/components/NavBar'
  30. import { Sidebar, SidebarItem,Notify } from 'vant';
  31. import {getOperatings} from '@/views/menu/operate/api'
  32. import { imgUrl } from '@/utils'
  33. export default {
  34. name: 'operate',
  35. components: {
  36. NavBar,
  37. Sidebar,
  38. SidebarItem,
  39. Notify
  40. },
  41. data() {
  42. return {
  43. activeKey: 0,
  44. sources:[],
  45. list: [],
  46. }
  47. },
  48. created() {
  49. },
  50. mounted() {
  51. this.initData();
  52. },
  53. methods: {
  54. getFileType(type){
  55. if(type === 'pdf'){
  56. return require('@/assets/img/my/Pdf.png');
  57. }
  58. if(type === 'doc' || type === 'docx'){
  59. return require('@/assets/img/my/WORD.png')
  60. }
  61. },
  62. initData(){
  63. getOperatings().then(res => {
  64. this.sources = res.data;
  65. this.onChange(0);
  66. });
  67. },
  68. onChange(index) {
  69. let data = this.sources[index];
  70. this.list = data.list;
  71. },
  72. showFile(item){
  73. let url = item.fileUrl;
  74. let system = this.isAndroidOrIos();
  75. const parms = {
  76. url: url.indexOf('http') > -1 ? url : imgUrl(url),
  77. name: item.fileName
  78. }
  79. if(system === 1){
  80. //android
  81. // 判断当前环境是是否存在 js桥 'sap'
  82. const hasSap = window.hasOwnProperty('sap');
  83. if (hasSap) {
  84. // 判断是否存在方法 ?preview
  85. const fun = sap.hasOwnProperty('preview');
  86. if (fun) {
  87. sap.preview(JSON.stringify(parms));
  88. }
  89. }
  90. }
  91. if(system === 2){
  92. //ios
  93. // 判断 ios是否存在方法 preview
  94. const fun = window.webkit.messageHandlers.hasOwnProperty('preview')
  95. if (fun) {
  96. window.webkit.messageHandlers.preview.postMessage(JSON.stringify(parms))
  97. }
  98. }
  99. },
  100. isAndroidOrIos(){
  101. const urls = navigator.userAgent;
  102. let isAndroid = urls.indexOf('Android') > -1 || urls.indexOf('Linux') > -1;
  103. let isIos = !!urls.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/);
  104. if(isAndroid){
  105. return 1;
  106. }
  107. if(isIos){
  108. return 2;
  109. }
  110. return 3;
  111. },
  112. }
  113. }
  114. </script>
  115. <style lang="scss" scoped>
  116. .item-container{
  117. height: calc(100vh - 94px);
  118. overflow: auto;
  119. -border:1px solid red;
  120. }
  121. .sid-content-title{
  122. font-size: 3.2vw;
  123. line-height: 12vw;
  124. margin-left: 3vw;
  125. }
  126. .index-container {
  127. .van-sidebar-item--select::before {
  128. background-color: #008cd6;
  129. width: 1.066667vw;
  130. height: 15.266667vw;
  131. }
  132. .van-sidebar-item {
  133. background-color:#ffffff
  134. }
  135. .van-sidebar-item--select{
  136. background-color: #f7f7f7;
  137. color: #008cd6;
  138. }
  139. }
  140. .sidebar-content{
  141. margin-left: 2px;
  142. }
  143. .index-container{
  144. height: 100vh;
  145. background-color: #f7f8fa;
  146. }
  147. .side_list{
  148. background-color: #FFFFFF;
  149. height: 100vh;
  150. }
  151. .operator-card{
  152. height: 6vh;
  153. margin-left: 2%;
  154. margin-right: 2%;
  155. margin-top: 2%;
  156. background-color: #fff;
  157. border-radius: 12px;
  158. box-shadow: 0 8px 12px #ebedf0;
  159. }
  160. </style>