u-upload.vue 21 KB

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