u-upload-file-all.vue 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720
  1. <template>
  2. <view class="u-upload" v-if="!disabled">
  3. <view
  4. v-if="showUploadList"
  5. class="u-list-item u-preview-wrap"
  6. v-for="(item, index) in lists"
  7. :key="index"
  8. :style="{
  9. //width: $u.addUnit(width),
  10. height: $u.addUnit(height)
  11. }"
  12. >
  13. <view
  14. v-if="deletable&&isedit"
  15. class="u-delete-icon"
  16. @tap.stop="deleteItem(index)"
  17. :style="{
  18. background: delBgColor
  19. }"
  20. >
  21. <u-icon class="u-icon" :name="delIcon" size="20" :color="delColor"></u-icon>
  22. </view>
  23. <view
  24. v-if="!isedit"
  25. class="u-download-icon"
  26. @tap.stop="viewItem(item)"
  27. >
  28. <u-icon class="u-icon" name="download" size="20" :color="delColor"></u-icon>
  29. </view>
  30. <u-line-progress
  31. v-if="showProgress && item.progress > 0 && item.progress != 100 && !item.error"
  32. :show-percent="false"
  33. height="16"
  34. class="u-progress"
  35. ></u-line-progress>
  36. <template v-if="isedit">
  37. <view @tap.stop="retry(index)" v-if="item.error" class="u-error-btn2 u-error-btn">点<br/>击<br/>重<br/>试</view>
  38. <view v-else-if="item.view||item.progress==100&&item.response&&item.response.result" class="u-error-btn2 u-primary-btn">上<br/>传<br/>成<br/>功<br/></view>
  39. <view v-else-if="!item.error" class="u-error-btn2 u-warning-btn">上<br/>传<br/>中</view>
  40. </template>
  41. <view class="file">{{item.file?item.file.name:item.name}}</view>
  42. </view>
  43. <slot name="file" :file="lists"></slot>
  44. <view style="display: inline-block;" @tap="selectFile" v-if="maxCount > lists.length&&isedit">
  45. <slot name="addBtn"></slot>
  46. <view
  47. v-if="!customBtn"
  48. class="u-list-item u-add-wrap"
  49. hover-class="u-add-wrap__hover"
  50. hover-stay-time="150"
  51. :style="{
  52. 'justify-content': 'flex-start',
  53. width: $u.addUnit(width),
  54. height: $u.addUnit(height)
  55. }"
  56. >
  57. <view class="u-add-tips">
  58. <u-icon name="file-text"></u-icon>
  59. {{ uploadText }}</view>
  60. </view>
  61. </view>
  62. </view>
  63. </template>
  64. <script>
  65. /**
  66. * upload 图片上传
  67. * @description 该组件用于上传图片场景
  68. * @tutorial https://www.uviewui.com/components/upload.html
  69. * @property {String} action 服务器上传地址
  70. * @property {String Number} max-count 最大选择图片的数量(默认99)
  71. * @property {Boolean} custom-btn 如果需要自定义选择图片的按钮,设置为true(默认false)
  72. * @property {Boolean} show-progress 是否显示进度条(默认true)
  73. * @property {Boolean} disabled 是否启用(显示/移仓)组件(默认false)
  74. * @property {String} image-mode 预览图片等显示模式,可选值为uni的image的mode属性值(默认aspectFill)
  75. * @property {String} del-icon 右上角删除图标名称,只能为uView内置图标
  76. * @property {String} del-bg-color 右上角关闭按钮的背景颜色
  77. * @property {String | Number} index 在各个回调事件中的最后一个参数返回,用于区别是哪一个组件的事件
  78. * @property {String} del-color 右上角关闭按钮图标的颜色
  79. * @property {Object} header 上传携带的头信息,对象形式
  80. * @property {Object} form-data 上传额外携带的参数
  81. * @property {String} name 上传文件的字段名,供后端获取使用(默认file)
  82. * @property {Array<String>} size-type original 原图,compressed 压缩图,默认二者都有(默认['original', 'compressed'])
  83. * @property {Array<String>} source-type 选择图片的来源,album-从相册选图,camera-使用相机,默认二者都有(默认['album', 'camera'])
  84. * @property {Boolean} preview-full-image 是否可以通过uni.previewImage预览已选择的图片(默认true)
  85. * @property {Boolean} multiple 是否开启图片多选,部分安卓机型不支持(默认true)
  86. * @property {Boolean} deletable 是否显示删除图片的按钮(默认true)
  87. * @property {String Number} max-size 选择单个文件的最大大小,单位B(byte),默认不限制(默认Number.MAX_VALUE)
  88. * @property {Array<Object>} file-list 默认显示的图片列表,数组元素为对象,必须提供url属性
  89. * @property {Boolean} upload-text 选择图片按钮的提示文字(默认“选择图片”)
  90. * @property {Boolean} auto-upload 选择完图片是否自动上传,见上方说明(默认true)
  91. * @property {Boolean} show-tips 特殊情况下是否自动提示toast,见上方说明(默认true)
  92. * @property {Boolean} show-upload-list 是否显示组件内部的图片预览(默认true)
  93. * @event {Function} on-oversize 图片大小超出最大允许大小
  94. * @event {Function} on-preview 全屏预览图片时触发
  95. * @event {Function} on-remove 移除图片时触发
  96. * @event {Function} on-success 图片上传成功时触发
  97. * @event {Function} on-change 图片上传后,无论成功或者失败都会触发
  98. * @event {Function} on-error 图片上传失败时触发
  99. * @event {Function} on-progress 图片上传过程中的进度变化过程触发
  100. * @event {Function} on-uploaded 所有图片上传完毕触发
  101. * @event {Function} on-choose-complete 每次选择图片后触发,只是让外部可以得知每次选择后,内部的文件列表
  102. * @example <u-upload :action="action" :file-list="fileList" ></u-upload>
  103. */
  104. export default {
  105. name: 'u-upload',
  106. props: {
  107. //是否显示组件自带的图片预览功能
  108. showUploadList: {
  109. type: Boolean,
  110. default: true
  111. },
  112. // 后端地址
  113. action: {
  114. type: String,
  115. default: ''
  116. },
  117. // 最大上传数量
  118. maxCount: {
  119. type: [String, Number],
  120. default: 9
  121. },
  122. // 是否显示进度条
  123. showProgress: {
  124. type: Boolean,
  125. default: true
  126. },
  127. // 是否启用
  128. disabled: {
  129. type: Boolean,
  130. default: false
  131. },
  132. // 预览上传的图片时的裁剪模式,和image组件mode属性一致
  133. imageMode: {
  134. type: String,
  135. default: 'aspectFill'
  136. },
  137. // 头部信息
  138. header: {
  139. type: Object,
  140. default() {
  141. return {};
  142. }
  143. },
  144. // 额外携带的参数
  145. formData: {
  146. type: Object,
  147. default() {
  148. return {};
  149. }
  150. },
  151. // 上传的文件字段名
  152. name: {
  153. type: String,
  154. default: 'photoFile'
  155. },
  156. // 所选的图片的尺寸, 可选值为original compressed
  157. sizeType: {
  158. type: Array,
  159. default() {
  160. return ['original', 'compressed'];
  161. }
  162. },
  163. sourceType: {
  164. type: Array,
  165. default() {
  166. return ['album', 'camera'];
  167. }
  168. },
  169. // 是否在点击预览图后展示全屏图片预览
  170. previewFullImage: {
  171. type: Boolean,
  172. default: true
  173. },
  174. // 是否开启图片多选,部分安卓机型不支持
  175. multiple: {
  176. type: Boolean,
  177. default: false
  178. },
  179. // 是否展示删除按钮
  180. deletable: {
  181. type: Boolean,
  182. default: true
  183. },
  184. // 文件大小限制,单位为byte
  185. maxSize: {
  186. type: [String, Number],
  187. default: Number.MAX_VALUE
  188. },
  189. // 显示已上传的文件列表
  190. fileList: {
  191. type: Array,
  192. default() {
  193. return [];
  194. }
  195. },
  196. // 上传区域的提示文字
  197. uploadText: {
  198. type: String,
  199. default: '上传附件'
  200. },
  201. // 是否自动上传
  202. autoUpload: {
  203. type: Boolean,
  204. default: true
  205. },
  206. // 是否显示toast消息提示
  207. showTips: {
  208. type: Boolean,
  209. default: true
  210. },
  211. // 是否通过slot自定义传入选择图标的按钮
  212. customBtn: {
  213. type: Boolean,
  214. default: false
  215. },
  216. // 内部预览图片区域和选择图片按钮的区域宽度
  217. width: {
  218. type: [String, Number],
  219. default: 200
  220. },
  221. // 内部预览图片区域和选择图片按钮的区域高度
  222. height: {
  223. type: [String, Number],
  224. default: 80
  225. },
  226. // 右上角关闭按钮的背景颜色
  227. delBgColor: {
  228. type: String,
  229. default: '#fa3534'
  230. },
  231. // 右上角关闭按钮的叉号图标的颜色
  232. delColor: {
  233. type: String,
  234. default: '#ffffff'
  235. },
  236. // 右上角删除图标名称,只能为uView内置图标
  237. delIcon: {
  238. type: String,
  239. default: 'close'
  240. },
  241. // 如果上传后的返回值为json字符串,是否自动转json
  242. toJson: {
  243. type: Boolean,
  244. default: true
  245. },
  246. // 上传前的钩子,每个文件上传前都会执行
  247. beforeUpload: {
  248. type: Function,
  249. default: null
  250. },
  251. // 移除文件前的钩子
  252. beforeRemove: {
  253. type: Function,
  254. default: null
  255. },
  256. // 允许上传的图片后缀
  257. limitType:{
  258. type: Array,
  259. default() {
  260. // 支付宝小程序真机选择图片的后缀为"image"
  261. // https://opendocs.alipay.com/mini/api/media-image
  262. return ['png', 'jpg', 'jpeg', 'webp', 'gif', 'image'];
  263. }
  264. },
  265. // 在各个回调事件中的最后一个参数返回,用于区别是哪一个组件的事件
  266. index: {
  267. type: [Number, String],
  268. default: ''
  269. },
  270. isedit:{
  271. type: [Number, String],
  272. default: 1
  273. },
  274. },
  275. mounted() {},
  276. data() {
  277. return {
  278. lists: [],
  279. isInCount: true,
  280. uploading: false
  281. };
  282. },
  283. watch: {
  284. fileList: {
  285. immediate: true,
  286. handler(val) {
  287. console.log(val)
  288. val.map(value => {
  289. // 首先检查内部是否已经添加过这张图片,因为外部绑定了一个对象给fileList的话(对象引用),进行修改外部fileList
  290. // 时,会触发watch,导致重新把原来的图片再次添加到this.lists
  291. // 数组的some方法意思是,只要数组元素有任意一个元素条件符合,就返回true,而另一个数组的every方法的意思是数组所有元素都符合条件才返回true
  292. let tmp = this.lists.some(val => {
  293. return val.url == value.url;
  294. })
  295. // 如果内部没有这个图片(tmp为false),则添加到内部
  296. !tmp && this.lists.push({ url: value.url,name:value.name,view:value.view, error: false, progress: 100 });
  297. });
  298. }
  299. },
  300. // 监听lists的变化,发出事件
  301. lists(n) {
  302. this.$emit('on-list-change', n, this.index);
  303. }
  304. },
  305. methods: {
  306. // 清除列表
  307. clear() {
  308. this.lists = [];
  309. },
  310. // 重新上传队列中上传失败的所有文件
  311. reUpload() {
  312. this.uploadFile();
  313. },
  314. // 选择图片
  315. selectFile() {
  316. if (this.disabled) return;
  317. const { name = '', maxCount, multiple, maxSize, sizeType, lists, camera, compressed, maxDuration, sourceType } = this;
  318. let chooseFile = null;
  319. const newMaxCount = maxCount - lists.length;
  320. // 设置为只选择图片的时候使用 chooseImage 来实现
  321. chooseFile = new Promise((resolve, reject) => {
  322. uni.chooseFile({
  323. count: multiple ? (newMaxCount > 9 ? 9 : newMaxCount) : 1,
  324. sourceType: sourceType,
  325. sizeType,
  326. success: resolve,
  327. fail: reject
  328. });
  329. });
  330. chooseFile
  331. .then(res => {
  332. let file = null;
  333. let listOldLength = this.lists.length;
  334. res.tempFiles.map((val, index) => {
  335. // 检查文件后缀是否允许,如果不在this.limitType内,就会返回false
  336. //if(!this.checkFileExt(val)) return ;
  337. // 如果是非多选,index大于等于1或者超出最大限制数量时,不处理
  338. if (!multiple && index >= 1) return;
  339. if (val.size > maxSize) {
  340. this.$emit('on-oversize', val, this.lists, this.index);
  341. this.showToast('超出允许的文件大小');
  342. } else {
  343. if (maxCount <= lists.length) {
  344. this.$emit('on-exceed', val, this.lists, this.index);
  345. this.showToast('超出最大允许的文件个数');
  346. return;
  347. }
  348. lists.push({
  349. url: val.path,
  350. progress: 0,
  351. error: false,
  352. file: val
  353. });
  354. }
  355. });
  356. // 每次图片选择完,抛出一个事件,并将当前内部选择的图片数组抛出去
  357. this.$emit('on-choose-complete', this.lists, this.index);
  358. if (this.autoUpload) this.uploadFile(listOldLength);
  359. })
  360. .catch(error => {
  361. this.$emit('on-choose-fail', error);
  362. });
  363. },
  364. // 提示用户消息
  365. showToast(message, force = false) {
  366. if (this.showTips || force) {
  367. uni.showToast({
  368. title: message,
  369. icon: 'none'
  370. });
  371. }
  372. },
  373. // 该方法供用户通过ref调用,手动上传
  374. upload() {
  375. this.uploadFile();
  376. },
  377. // 对失败的图片重新上传
  378. retry(index) {
  379. this.lists[index].progress = 0;
  380. this.lists[index].error = false;
  381. this.lists[index].response = null;
  382. uni.showLoading({
  383. title: '重新上传'
  384. });
  385. this.uploadFile(index);
  386. },
  387. // 上传图片
  388. async uploadFile(index = 0) {
  389. if (this.disabled) return;
  390. if (this.uploading) return;
  391. // 全部上传完成
  392. if (index >= this.lists.length) {
  393. this.$emit('on-uploaded', this.lists, this.index);
  394. return;
  395. }
  396. // 检查是否是已上传或者正在上传中
  397. if (this.lists[index].progress == 100) {
  398. if (this.autoUpload == false) this.uploadFile(index + 1);
  399. return;
  400. }
  401. // 执行before-upload钩子
  402. if(this.beforeUpload && typeof(this.beforeUpload) === 'function') {
  403. // 执行回调,同时传入索引和文件列表当作参数
  404. // 在微信,支付宝等环境(H5正常),会导致父组件定义的customBack()函数体中的this变成子组件的this
  405. // 通过bind()方法,绑定父组件的this,让this.customBack()的this为父组件的上下文
  406. // 因为upload组件可能会被嵌套在其他组件内,比如u-form,这时this.$parent其实为u-form的this,
  407. // 非页面的this,所以这里需要往上历遍,一直寻找到最顶端的$parent,这里用了this.$u.$parent.call(this)
  408. // 明白意思即可,无需纠结this.$u.$parent.call(this)的细节
  409. let beforeResponse = this.beforeUpload.bind(this.$u.$parent.call(this))(index, this.lists);
  410. // 判断是否返回了promise
  411. if (!!beforeResponse && typeof beforeResponse.then === 'function') {
  412. await beforeResponse.then(res => {
  413. // promise返回成功,不进行动作,继续上传
  414. }).catch(err => {
  415. // 进入catch回调的话,继续下一张
  416. return this.uploadFile(index + 1);
  417. })
  418. } else if(beforeResponse === false) {
  419. // 如果返回false,继续下一张图片的上传
  420. return this.uploadFile(index + 1);
  421. } else {
  422. // 此处为返回"true"的情形,这里不写代码,就跳过此处,继续执行当前的上传逻辑
  423. }
  424. }
  425. // 检查上传地址
  426. if (!this.action) {
  427. this.showToast('请配置上传地址', true);
  428. return;
  429. }
  430. this.lists[index].error = false;
  431. this.uploading = true;
  432. // 创建上传对象
  433. const task = uni.uploadFile({
  434. url: this.action,
  435. filePath: this.lists[index].url,
  436. name: this.name,
  437. formData: this.formData,
  438. header: this.header,
  439. // #ifdef MP-ALIPAY
  440. fileType:'image',
  441. // #endif
  442. success: res => {
  443. // 判断是否json字符串,将其转为json格式
  444. let data = this.toJson && this.$u.test.jsonString(res.data) ? JSON.parse(res.data) : res.data;
  445. if (![200, 201, 204].includes(res.statusCode)) {
  446. this.uploadError(index, data);
  447. } else {
  448. // 上传成功
  449. this.lists[index].response = data;
  450. this.lists[index].progress = 100;
  451. this.lists[index].error = false;
  452. this.$forceUpdate()
  453. this.$emit('on-success', data, index, this.lists, this.index);
  454. }
  455. },
  456. fail: e => {
  457. this.uploadError(index, e);
  458. },
  459. complete: res => {
  460. uni.hideLoading();
  461. this.uploading = false;
  462. this.uploadFile(index + 1);
  463. this.$emit('on-change', res, index, this.lists, this.index);
  464. }
  465. });
  466. task.onProgressUpdate(res => {
  467. if (res.progress > 0) {
  468. this.lists[index].progress = res.progress;
  469. this.$emit('on-progress', res, index, this.lists, this.index);
  470. }
  471. });
  472. },
  473. // 上传失败
  474. uploadError(index, err) {
  475. this.lists[index].progress = 0;
  476. this.lists[index].error = true;
  477. this.lists[index].response = null;
  478. this.$emit('on-error', err, index, this.lists, this.index);
  479. this.showToast('上传失败,请重试');
  480. },
  481. viewItem(item){
  482. console.log(item)
  483. window.location.href=item.url;
  484. },
  485. // 删除一个图片
  486. deleteItem(index) {
  487. uni.showModal({
  488. title: '提示',
  489. content: '您确定要删除此项吗?',
  490. success: async (res) => {
  491. if (res.confirm) {
  492. // 先检查是否有定义before-remove移除前钩子
  493. // 执行before-remove钩子
  494. if(this.beforeRemove && typeof(this.beforeRemove) === 'function') {
  495. // 此处钩子执行 原理同before-remove参数,见上方注释
  496. let beforeResponse = this.beforeRemove.bind(this.$u.$parent.call(this))(index, this.lists);
  497. // 判断是否返回了promise
  498. if (!!beforeResponse && typeof beforeResponse.then === 'function') {
  499. await beforeResponse.then(res => {
  500. // promise返回成功,不进行动作,继续上传
  501. this.handlerDeleteItem(index);
  502. }).catch(err => {
  503. // 如果进入promise的reject,终止删除操作
  504. this.showToast('已终止移除');
  505. })
  506. } else if(beforeResponse === false) {
  507. // 返回false,终止删除
  508. this.showToast('已终止移除');
  509. } else {
  510. // 如果返回true,执行删除操作
  511. this.handlerDeleteItem(index);
  512. }
  513. } else {
  514. // 如果不存在before-remove钩子,
  515. this.handlerDeleteItem(index);
  516. }
  517. }
  518. }
  519. });
  520. },
  521. // 执行移除图片的动作,上方代码只是判断是否可以移除
  522. handlerDeleteItem(index) {
  523. // 如果文件正在上传中,终止上传任务,进度在0 < progress < 100则意味着正在上传
  524. if (this.lists[index].progress < 100 && this.lists[index].progress > 0) {
  525. typeof this.lists[index].uploadTask != 'undefined' && this.lists[index].uploadTask.abort();
  526. }
  527. this.lists.splice(index, 1);
  528. this.$forceUpdate();
  529. this.$emit('on-remove', index, this.lists, this.index);
  530. this.showToast('移除成功');
  531. },
  532. // 用户通过ref手动的形式,移除一张图片
  533. remove(index) {
  534. // 判断索引的合法范围
  535. if (index >= 0 && index < this.lists.length) {
  536. this.lists.splice(index, 1);
  537. this.$emit('on-list-change', this.lists, this.index);
  538. }
  539. },
  540. // 预览图片
  541. doPreviewImage(url, index) {
  542. if (!this.previewFullImage) return;
  543. const images = this.lists.map(item => item.url || item.path);
  544. uni.previewImage({
  545. urls: images,
  546. current: url,
  547. success: () => {
  548. this.$emit('on-preview', url, this.lists, this.index);
  549. },
  550. fail: () => {
  551. uni.showToast({
  552. title: '预览图片失败',
  553. icon: 'none'
  554. });
  555. }
  556. });
  557. },
  558. // 判断文件后缀是否允许
  559. checkFileExt(file) {
  560. // 检查是否在允许的后缀中
  561. let noArrowExt = false;
  562. // 获取后缀名
  563. let fileExt = '';
  564. const reg = /.+\./;
  565. // 如果是H5,需要从name中判断
  566. // #ifdef H5
  567. fileExt = file.name.replace(reg, "").toLowerCase();
  568. // #endif
  569. // 非H5,需要从path中读取后缀
  570. // #ifndef H5
  571. fileExt = file.path.replace(reg, "").toLowerCase();
  572. // #endif
  573. // 使用数组的some方法,只要符合limitType中的一个,就返回true
  574. noArrowExt = this.limitType.some(ext => {
  575. // 转为小写
  576. return ext.toLowerCase() === fileExt;
  577. })
  578. if(!noArrowExt) this.showToast(`不允许选择${fileExt}格式的文件`);
  579. return noArrowExt;
  580. }
  581. }
  582. };
  583. </script>
  584. <style lang="scss" scoped>
  585. @import '../../libs/css/style.components.scss';
  586. .file{
  587. padding-right: 40px;
  588. }
  589. .u-upload {
  590. @include vue-flex;
  591. flex-direction: column;
  592. flex-wrap: wrap;
  593. align-items: flex-start;
  594. }
  595. .u-list-item {
  596. //width: 200rpx;
  597. height: 200rpx;
  598. overflow: hidden;
  599. margin: 10rpx;
  600. background: rgb(244, 245, 246);
  601. position: relative;
  602. border-radius: 10rpx;
  603. /* #ifndef APP-NVUE */
  604. display: flex;
  605. /* #endif */
  606. align-items: center;
  607. width: 80%;
  608. justify-content: flex-start;
  609. }
  610. .u-preview-wrap {
  611. border: 1px solid rgb(235, 236, 238);
  612. }
  613. .u-add-wrap {
  614. flex-direction: column;
  615. color: $u-content-color;
  616. font-size: 26rpx;
  617. }
  618. .u-add-tips {
  619. margin-top: 20rpx;
  620. line-height: 40rpx;
  621. display: flex;
  622. }
  623. .u-add-wrap__hover {
  624. background-color: rgb(235, 236, 238);
  625. }
  626. .u-preview-image {
  627. display: block;
  628. width: 100%;
  629. height: 100%;
  630. border-radius: 10rpx;
  631. }
  632. .u-delete-icon {
  633. position: absolute;
  634. top: 10rpx;
  635. right: 10rpx;
  636. z-index: 10;
  637. background-color: $u-type-error;
  638. border-radius: 100rpx;
  639. width: 44rpx;
  640. height: 44rpx;
  641. @include vue-flex;
  642. align-items: center;
  643. justify-content: center;
  644. }
  645. .u-download-icon {
  646. position: absolute;
  647. top: 10rpx;
  648. right: 10rpx;
  649. z-index: 10;
  650. background-color: #4CAF50;
  651. border-radius: 100rpx;
  652. width: 44rpx;
  653. height: 44rpx;
  654. @include vue-flex;
  655. align-items: center;
  656. justify-content: center;
  657. }
  658. .u-icon {
  659. @include vue-flex;
  660. align-items: center;
  661. justify-content: center;
  662. }
  663. .u-progress {
  664. position: absolute;
  665. bottom: 10rpx;
  666. left: 8rpx;
  667. right: 8rpx;
  668. z-index: 9;
  669. width: auto;
  670. }
  671. .u-error-btn {
  672. background-color: $u-type-error;
  673. }
  674. .u-primary-btn {
  675. background-color: #59ba73;
  676. }
  677. .u-warning-btn {
  678. background-color: #e6a23c;
  679. }
  680. .u-error-btn2 {
  681. color: #ffffff;
  682. font-size: 20rpx;
  683. //padding: 4px 0;
  684. text-align: center;
  685. min-width: 20px;
  686. //position: absolute;
  687. bottom: 0;
  688. left: 0;
  689. right: 0;
  690. z-index: 9;
  691. line-height: 1;
  692. }
  693. </style>