h5-file.vue 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. <template>
  2. <div class="content">
  3. <div @click="onClose" class="fixed mask"></div>
  4. <div v-if="showTip" align="center" class="fixed tis">
  5. <div class="tis-content">
  6. <div>
  7. <img :src="logo" />
  8. </div>
  9. <div class="tis-progress">
  10. 努力上传中
  11. <text v-if="progress < 100">..{{ progress }}%</text>
  12. </div>
  13. <div class="cancel">
  14. <button @click="onAbort" type="button" class="cancel-btn">
  15. 取消上传
  16. </button>
  17. </div>
  18. </div>
  19. </div>
  20. <div class="fixed file-content">
  21. <view ref="input" class="btn">
  22. <button type="button" class="btn-bg">打开文件管理器</button>
  23. </view>
  24. </div>
  25. </div>
  26. </template>
  27. <script>
  28. export default {
  29. props: {
  30. logo: {
  31. type: String,
  32. default:
  33. 'https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fbpic.588ku.com%2Felement_origin_min_pic%2F00%2F00%2F07%2F155788a6d8a5c42.jpg&refer=http%3A%2F%2Fbpic.588ku.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=jpeg?sec=1619847627&t=2da40b583002205c204d980b54b35040'
  34. },
  35. progress: {
  36. type: [Number, String],
  37. default: 0
  38. },
  39. showTip: {
  40. type: Boolean,
  41. default: false
  42. }
  43. },
  44. data () {
  45. return {
  46. hFile: ''
  47. }
  48. },
  49. mounted () {
  50. this.hFile = document.createElement('input')
  51. this.hFile.type = 'file'
  52. this.hFile.value = ''
  53. this.hFile.style.position = 'absolute'
  54. this.hFile.style.zIndex = 93
  55. this.hFile.style.left = 0
  56. this.hFile.style.right = 0
  57. this.hFile.style.top = 0
  58. this.hFile.style.bottom = 0
  59. this.hFile.style.height = '60px'
  60. this.hFile.style.width = '100%'
  61. this.hFile.style.opacity = 0
  62. this.$refs.input.$el.appendChild(this.hFile)
  63. },
  64. methods: {
  65. onAbort () {
  66. this.$emit('abort', {})
  67. },
  68. onClose () {
  69. this.$emit('close', {})
  70. }
  71. }
  72. }
  73. </script>
  74. <style scoped>
  75. .content {
  76. background: transparent;
  77. }
  78. .fixed {
  79. position: fixed;
  80. bottom: 0;
  81. left: 0;
  82. right: 0;
  83. width: 100%;
  84. }
  85. .content .mask {
  86. top: 0;
  87. background: rgba(0, 0, 0, 0.4);
  88. z-index: 90;
  89. }
  90. .content .file-content {
  91. z-index: 91;
  92. height: 60px;
  93. background: #fff;
  94. text-align: center;
  95. }
  96. .btn {
  97. position: relative;
  98. }
  99. .btn .file {
  100. position: absolute;
  101. z-index: 93;
  102. left: 0;
  103. right: 0;
  104. top: 0;
  105. bottom: 0;
  106. height: 60px;
  107. width: 100%;
  108. opacity: 0;
  109. }
  110. .btn-bg {
  111. margin-top: 10px;
  112. background: #0066cc;
  113. color: #fff;
  114. width: 80%;
  115. height: 40px;
  116. line-height: 40px;
  117. border: 0;
  118. border-radius: 5px;
  119. }
  120. .tis {
  121. top: 0;
  122. z-index: 95;
  123. display: flex;
  124. justify-content: center;
  125. align-items: center;
  126. }
  127. .tis .tis-content {
  128. background: #fff;
  129. width: 60%;
  130. border-radius: 10px;
  131. padding: 20px 0;
  132. }
  133. .tis .tis-content img {
  134. width: 50px;
  135. height: 50px;
  136. }
  137. .tis-progress {
  138. margin: 10px 0;
  139. color: #999;
  140. }
  141. .cancel-btn {
  142. margin-top: 30px;
  143. height: 30px;
  144. width: 60%;
  145. line-height: 30px;
  146. font-size: 32rpx;
  147. padding: 0 2em;
  148. background: #e3e3e3;
  149. color: #898989;
  150. border: 0 !important;
  151. border-radius: 5px;
  152. }
  153. .cancel-btn:after {
  154. height: 0 !important;
  155. border: 0 !important;
  156. }
  157. </style>