u-upload-file.vue 20 KB

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