upload.vue 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864
  1. <template>
  2. <view class="u-upload" v-if="!disabled">
  3. <view v-if="showUploadList" class="u-list-item u-preview-wrap" :class="{'customPreviewStyle':custom}"
  4. v-for="(item, index) in lists" :key="index" :style="{
  5. width: width + 'rpx',
  6. height: width + 'rpx'
  7. }">
  8. <view v-if="deletable" class="u-delete-icon" @tap.stop="deleteItem(index)" :style="{
  9. background: delBgColor,
  10. }">
  11. <u-icon class="u-icon" :name="delIcon" :size="delIconSize" :color="delColor"></u-icon>
  12. </view>
  13. <view v-if="showProgress && item.progress > 0 && !item.error" class="u-check-icon" @tap.stop="deleteItem(index)" :style="{
  14. background: checkBgColor,
  15. }">
  16. <u-icon class="u-icon" :name="checkIcon" :size="checkIconSize" :color="checkColor"></u-icon>
  17. </view>
  18. <!-- <u-line-progress v-if="showProgress && item.progress > 0 && !item.error" :show-percent="false" height="16"
  19. class="u-progress" :percent="item.progress"></u-line-progress> -->
  20. <view @tap.stop="retry(index)" v-if="item.error" class="u-error-btn">点击重试</view>
  21. <image @tap.stop="doPreviewImage(item.url || item.path, index)" class="u-preview-image" v-if="!item.isImage"
  22. :src="item.url || item.path" :mode="imageMode"></image>
  23. </view>
  24. <slot name="file" :file="lists"></slot>
  25. <view style="display: inline-block;" :style="{
  26. background:custom?customBack:'transparent',
  27. border:custom?customBorder:'1px solid transparent'
  28. }" :class="custom?'customStyle':'default'"
  29. @tap="selectFile" v-if="maxCount > lists.length">
  30. <slot name="addBtn"></slot>
  31. <img v-if="custom&&options.bgc!=''" :src="options.bgc" alt="" class="imgstyle">
  32. <view class="u-list-item u-add-wrap" hover-class="u-add-wrap__hover" hover-stay-time="150" :style="{
  33. width: width + 'rpx',
  34. height: width + 'rpx'
  35. }">
  36. <u-icon v-if="custom&&!customBtn" name="camera-fill" class="" size="100" color="#617E8B"></u-icon>
  37. <image v-if="custom&&customBtn" :style="{
  38. width: customBtnWidth + 'px',
  39. height: customBtnHeight + 'px'
  40. }" :src="customBtnImage" mode=""></image>
  41. <image v-if="!custom" style='width:23px;height:23px;' src="../static/img/liangmai/xiangji-2.png" mode=""></image>
  42. <view v-if="!custom" class="u-add-tips">{{ uploadText }}</view>
  43. <view v-if="custom" :style="{
  44. color: customBtnColor,
  45. 'font-size':customBtnFontSize+'px',
  46. }" class="u-add-tips">{{ options.text }}</view>
  47. </view>
  48. </view>
  49. <view @click='imgShow=false' v-if="imgShow" class="shade">
  50. <image style='position:absolute;top:0;left:0;right:0;bottom:0;margin:auto;' :src="url" mode=""></image>
  51. </view>
  52. <!-- <view class="custom-style" v-if="custom"
  53. :style="{backgroundImage: 'url(' + options.bgc + ')', backgroundSize:'100% 100%'}">
  54. </view> -->
  55. </view>
  56. </template>
  57. <script>
  58. /**
  59. * upload 图片上传
  60. * @description 该组件用于上传图片场景
  61. * @tutorial https://www.uviewui.com/components/upload.html
  62. * @property {String} action 服务器上传地址
  63. * @property {String Number} max-count 最大选择图片的数量(默认99)
  64. * @property {Boolean} custom-btn 如果需要自定义选择图片的按钮,设置为true(默认false)
  65. * @property {Boolean} show-progress 是否显示进度条(默认true)
  66. * @property {Boolean} disabled 是否启用(显示/移仓)组件(默认false)
  67. * @property {String} image-mode 预览图片等显示模式,可选值为uni的image的mode属性值(默认aspectFill)
  68. * @property {String} del-icon 右上角删除图标名称,只能为uView内置图标
  69. * @property {String} del-bg-color 右上角关闭按钮的背景颜色
  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. import uploadImage from '@/components/ossutil/uploadFile.js';
  97. export default {
  98. name: 'upload',
  99. props: {
  100. //是否显示组件自带的图片预览功能
  101. showUploadList: {
  102. type: Boolean,
  103. default: true
  104. },
  105. // 后端地址
  106. action: {
  107. type: String,
  108. default: ''
  109. },
  110. isAction: {
  111. type: Boolean,
  112. default: true
  113. },
  114. // 最大上传数量
  115. maxCount: {
  116. type: [String, Number],
  117. default: 52,
  118. },
  119. // 删除图标大小
  120. delIconSize:{
  121. type: String,
  122. default: '20'
  123. },
  124. // 是否显示进度条
  125. showProgress: {
  126. type: Boolean,
  127. default: true
  128. },
  129. // 是否启用
  130. disabled: {
  131. type: Boolean,
  132. default: false
  133. },
  134. // 预览上传的图片时的裁剪模式,和image组件mode属性一致
  135. imageMode: {
  136. type: String,
  137. default: 'aspectFill'
  138. },
  139. // 头部信息
  140. header: {
  141. type: Object,
  142. default () {
  143. return {};
  144. }
  145. },
  146. // 额外携带的参数
  147. formData: {
  148. type: Object,
  149. default () {
  150. return {};
  151. }
  152. },
  153. // 上传的文件字段名
  154. name: {
  155. type: String,
  156. default: 'file'
  157. },
  158. // 所选的图片的尺寸, 可选值为original compressed
  159. sizeType: {
  160. type: Array,
  161. default () {
  162. return ['original', 'compressed'];
  163. }
  164. },
  165. sourceType: {
  166. type: Array,
  167. default () {
  168. return ['album', 'camera'];
  169. }
  170. },
  171. // 成功背景颜色
  172. checkBgColor:{
  173. type: String,
  174. default: '#22C572'
  175. },
  176. // 成功icon颜色
  177. checkColor:{
  178. type: String,
  179. default: '#fff'
  180. },
  181. // 成功icon颜色
  182. checkIcon:{
  183. type: String,
  184. default: 'checkbox-mark'
  185. },
  186. // 成功icon颜色
  187. checkIconSize:{
  188. type: String,
  189. default: '20'
  190. },
  191. // 是否在点击预览图后展示全屏图片预览
  192. previewFullImage: {
  193. type: Boolean,
  194. default: true
  195. },
  196. // 是否开启图片多选,部分安卓机型不支持
  197. multiple: {
  198. type: Boolean,
  199. default: true
  200. },
  201. // 是否展示删除按钮
  202. deletable: {
  203. type: Boolean,
  204. default: true
  205. },
  206. // 文件大小限制,单位为byte
  207. maxSize: {
  208. type: [String, Number],
  209. default: Number.MAX_VALUE
  210. },
  211. // 显示已上传的文件列表
  212. fileList: {
  213. type: Array,
  214. default () {
  215. return [];
  216. }
  217. },
  218. // 上传区域的提示文字
  219. uploadText: {
  220. type: String,
  221. default: '选择图片'
  222. },
  223. // 是否自动上传
  224. autoUpload: {
  225. type: Boolean,
  226. default: true
  227. },
  228. // 是否显示toast消息提示
  229. showTips: {
  230. type: Boolean,
  231. default: true
  232. },
  233. // 是否通过slot自定义传入选择图标的按钮
  234. customBtn: {
  235. type: Boolean,
  236. default: false
  237. },
  238. customBtnImage: {
  239. type: String,
  240. default: ''
  241. },
  242. customBtnWidth: {
  243. type: Number,
  244. default: 0
  245. },
  246. customBtnHeight: {
  247. type: Number,
  248. default: 0
  249. },
  250. customBtnColor: {
  251. type: String,
  252. default: '#617E8B'
  253. },
  254. customBack:{
  255. type: String,
  256. default: '#F5F6FA'
  257. },
  258. customBorder:{
  259. type: String,
  260. // default: '2px dashed #C6CBCE'
  261. },
  262. customBtnFontSize:{
  263. type: String,
  264. default: '18'
  265. },
  266. // 内部预览图片区域和选择图片按钮的区域宽度,高等于宽
  267. width: {
  268. type: [String, Number],
  269. default: 200
  270. },
  271. // 右上角关闭按钮的背景颜色
  272. delBgColor: {
  273. type: String,
  274. default: '#fa3534'
  275. },
  276. // 右上角关闭按钮的叉号图标的颜色
  277. delColor: {
  278. type: String,
  279. default: '#ffffff'
  280. },
  281. // 右上角删除图标名称,只能为uView内置图标
  282. delIcon: {
  283. type: String,
  284. default: 'close'
  285. },
  286. // 如果上传后的返回值为json字符串,是否自动转json
  287. toJson: {
  288. type: Boolean,
  289. default: true
  290. },
  291. // 上传前的钩子,每个文件上传前都会执行
  292. beforeUpload: {
  293. type: Function,
  294. default: null
  295. },
  296. options: {
  297. type: Object,
  298. default: null
  299. },
  300. custom: {
  301. type: Boolean,
  302. default: false
  303. },
  304. imgIndex:{
  305. type: Number,
  306. default: 0
  307. }
  308. },
  309. mounted() {},
  310. data() {
  311. return {
  312. lists: [],
  313. isInCount: true,
  314. uploading: false,
  315. isSelectFile: false,
  316. imgShow:false,
  317. url:''
  318. };
  319. },
  320. watch: {
  321. fileList: {
  322. immediate: true,
  323. handler(val) {
  324. val.map(value => {
  325. this.lists.push({
  326. url: value.url,
  327. error: false,
  328. progress: 100
  329. });
  330. });
  331. }
  332. }
  333. },
  334. methods: {
  335. // 清除列表
  336. clear() {
  337. this.lists = [];
  338. // 如果是清空形式的话,发出"on-list-change"事件
  339. this.$emit('on-list-change', this.lists);
  340. },
  341. // 重新上传队列中上传失败的所有文件
  342. reUpload() {
  343. this.uploadFile();
  344. },
  345. // 选择图片
  346. selectFile() {
  347. if (this.disabled) return;
  348. const {
  349. name = '', maxCount, multiple, maxSize, sizeType, lists, camera, compressed, maxDuration, sourceType
  350. } = this;
  351. let chooseFile = null;
  352. const newMaxCount = maxCount - lists.length;
  353. // 设置为只选择图片的时候使用 chooseImage 来实现
  354. chooseFile = new Promise((resolve, reject) => {
  355. uni.chooseImage({
  356. count: multiple ? (newMaxCount > 9 ? 9 : newMaxCount) : 1,
  357. sourceType: sourceType,
  358. sizeType,
  359. success: resolve,
  360. fail: reject
  361. });
  362. });
  363. chooseFile
  364. .then(res => {
  365. let file = null;
  366. let listOldLength = this.lists.length;
  367. res.tempFiles.map((val, index) => {
  368. // 如果是非多选,index大于等于1或者超出最大限制数量时,不处理
  369. if (!multiple && index >= 1) return;
  370. if (val.size > maxSize) {
  371. this.$emit('on-oversize', val, this.lists);
  372. this.showToast('超出允许的文件大小');
  373. } else {
  374. if (maxCount <= lists.length) {
  375. this.$emit('on-exceed', val, this.lists);
  376. this.showToast('超出最大允许的文件个数');
  377. return;
  378. }
  379. let fileName = '';
  380. let fileNameLength = '';
  381. let fileFormat = '';
  382. //#ifdef H5
  383. fileName = val.name.lastIndexOf(".");
  384. fileNameLength = val.name.length;
  385. fileFormat = val.name.substring(fileName + 1, fileNameLength).toLowerCase();
  386. //#endif
  387. //#ifndef H5
  388. fileName = val.path.lastIndexOf(".");
  389. fileNameLength = val.path.length;
  390. fileFormat = val.path.substring(fileName + 1, fileNameLength).toLowerCase();
  391. //#endif
  392. lists.push({
  393. url: val.path,
  394. fileType: fileFormat,
  395. progress: 0,
  396. error: false
  397. });
  398. // 列表发生改变,发出事件,第二个参数为当前发生变化的项的索引
  399. this.$emit('on-list-change', this.lists);
  400. }
  401. });
  402. // 每次图片选择完,抛出一个事件,并将当前内部选择的图片数组抛出去
  403. this.$emit('on-choose-complete', this.lists);
  404. if (this.autoUpload) this.uploadFile(listOldLength);
  405. })
  406. .catch(error => {
  407. this.$emit('on-error', error);
  408. });
  409. },
  410. // 提示用户消息
  411. showToast(message, force = false) {
  412. if (this.showTips || force) {
  413. uni.showToast({
  414. title: message,
  415. icon: 'none'
  416. });
  417. }
  418. },
  419. // 该方法供用户通过ref调用,手动上传
  420. upload() {
  421. this.uploadFile();
  422. },
  423. // 对失败的图片重新上传
  424. retry(index) {
  425. this.lists[index].progress = 0;
  426. this.lists[index].error = false;
  427. this.lists[index].response = null;
  428. uni.showLoading({
  429. title: '重新上传'
  430. });
  431. this.uploadFile(index);
  432. },
  433. // 上传图片
  434. async uploadFile(index = 0) {
  435. if (this.disabled) return;
  436. if (this.uploading) return;
  437. // 全部上传完成
  438. if (index >= this.lists.length) {
  439. this.isSelectFile = true
  440. this.$emit('on-uploaded', this.lists);
  441. return;
  442. }
  443. // 检查上传地址
  444. if (!this.action&&this.isAction) {
  445. this.showToast('请配置上传地址', true);
  446. return;
  447. }
  448. // 检查是否是已上传或者正在上传中
  449. if (this.lists[index].progress == 100) {
  450. if (this.autoUpload == false) this.uploadFile(index + 1);
  451. return;
  452. }
  453. // 执行before-upload钩子
  454. if (this.beforeUpload && typeof(this.beforeUpload) === 'function') {
  455. // 执行回调,同时传入索引和文件列表当作参数
  456. let beforeResponse = this.beforeUpload(index, this.lists);
  457. // 判断是否返回了promise
  458. if (!!beforeResponse && typeof beforeResponse.then === 'function') {
  459. await beforeResponse.then(res => {
  460. // promise返回成功,不进行动作,继续上传
  461. }).catch(err => {
  462. // 进入catch回调的话,继续下一张
  463. return this.uploadFile(index + 1);
  464. })
  465. } else if (beforeResponse === false) {
  466. // 如果返回false,继续下一张图片的上传
  467. return this.uploadFile(index + 1);
  468. }
  469. }
  470. this.lists[index].error = false;
  471. this.uploading = true;
  472. if(!this.action){
  473. uploadImage(this.lists[index].url, 'appData/',
  474. result => {
  475. console.log
  476. // 上传成功
  477. this.lists[index].response = result;
  478. this.lists[index].progress = 100;
  479. this.lists[index].error = false;
  480. let data = result
  481. this.$emit('on-success', data, index, this.lists,this.imgIndex);
  482. uni.hideLoading();
  483. this.uploading = false;
  484. this.uploadFile(index + 1);
  485. this.$emit('on-change', data, index, this.lists,this.imgIndex);
  486. }
  487. )
  488. }else{
  489. uni.uploadFile({
  490. url: this.action,
  491. // url: baseUrlNew+'appendix/api/uploadFiles', //仅为示例,非真实的接口地址
  492. // files: files[i],
  493. filePath: this.lists[index].url,
  494. name: 'fileName',
  495. formData: {
  496. // fileName: chooseImageRes.tempFiles[0],
  497. companyId: uni.getStorageSync('pcUserInfo').compId,
  498. modelId: '',
  499. vesselId: '',
  500. },
  501. success: (uploadFileRes) => {
  502. console.log(JSON.parse(uploadFileRes.data))
  503. this.$emit('on-success', JSON.parse(uploadFileRes.data), index, this.lists,this.imgIndex);
  504. uni.hideLoading();
  505. this.uploading = false;
  506. this.uploadFile(index + 1);
  507. this.$emit('on-change', JSON.parse(uploadFileRes.data), index, this.lists,this.imgIndex);
  508. },
  509. fail(res) {
  510. console.log(res);
  511. }
  512. });
  513. }
  514. // 创建上传对象
  515. // const task = uni.uploadFile({
  516. // url: this.action,
  517. // filePath: this.lists[index].url,
  518. // name: this.name,
  519. // formData: this.formData,
  520. // header: this.header,
  521. // success: res => {
  522. // // 判断是否json字符串,将其转为json格式
  523. // let data = this.toJson && this.checkIsJSON(res.data) ? JSON.parse(res.data) : res
  524. // .data;
  525. // if (![200, 201].includes(res.statusCode)) {
  526. // this.uploadError(index, data);
  527. // } else {
  528. // // 上传成功
  529. // this.lists[index].response = data;
  530. // this.lists[index].progress = 100;
  531. // this.lists[index].error = false;
  532. // // this.$emit('on-success', data, index, this.lists);
  533. // }
  534. // },
  535. // fail: e => {
  536. // this.uploadError(index, e);
  537. // },
  538. // complete: res => {
  539. // uni.hideLoading();
  540. // this.uploading = false;
  541. // this.uploadFile(index + 1);
  542. // this.$emit('on-change', res, index, this.lists);
  543. // }
  544. // });
  545. // task.onProgressUpdate(res => {
  546. // if (res.progress > 0) {
  547. // this.lists[index].progress = res.progress;
  548. // this.$emit('on-progress', res, index, this.lists);
  549. // }
  550. // });
  551. },
  552. // 上传失败
  553. uploadError(index, err) {
  554. this.lists[index].progress = 0;
  555. this.lists[index].error = true;
  556. this.lists[index].response = null;
  557. this.$emit('on-error', err, index, this.lists);
  558. this.showToast('上传失败,请重试');
  559. },
  560. // 删除一个图片
  561. deleteItem(index) {
  562. uni.showModal({
  563. title: '提示',
  564. content: '您确定要删除此项吗?',
  565. success: res => {
  566. if (res.confirm) {
  567. this.isSelectFile = false
  568. if (this.lists[index].process < 100 && this.lists[index].process > 0) {
  569. typeof this.lists[index].uploadTask != 'undefined' && this.lists[index]
  570. .uploadTask.abort();
  571. }
  572. this.lists.splice(index, 1);
  573. this.$forceUpdate();
  574. this.$emit('on-remove', index, this.lists);
  575. this.showToast('移除成功');
  576. // 列表发生改变,发出事件
  577. this.$emit('on-list-change', this.lists);
  578. }
  579. }
  580. });
  581. },
  582. // 用户通过ref手动的形式,移除一张图片
  583. remove(index) {
  584. // 判断索引的合法范围
  585. if (index >= 0 && index < this.lists.length) {
  586. this.lists.splice(index, 1);
  587. this.$emit('on-list-change', this.lists);
  588. }
  589. },
  590. // 预览图片
  591. doPreviewImage(url, index) {
  592. console.log(this.lists,url,index)
  593. if (!this.previewFullImage) return;
  594. const images = this.lists.map(item => item.url || item.path);
  595. this.url=url
  596. this.imgShow=true
  597. // 图片预览调用onShow清空数据
  598. // uni.previewImage({
  599. // urls: images,
  600. // current: url,
  601. // success: () => {
  602. // this.$emit('on-preview', url, this.lists);
  603. // },
  604. // fail: () => {
  605. // uni.showToast({
  606. // title: '预览图片失败',
  607. // icon: 'none'
  608. // });
  609. // }
  610. // });
  611. },
  612. // 判断是否json字符串
  613. checkIsJSON(str) {
  614. if (typeof str == 'string') {
  615. try {
  616. var obj = JSON.parse(str);
  617. if (typeof obj == 'object' && obj) {
  618. return true;
  619. } else {
  620. return false;
  621. }
  622. } catch (e) {
  623. return false;
  624. }
  625. }
  626. return false;
  627. }
  628. }
  629. };
  630. </script>
  631. <style lang="scss" scoped>
  632. // nvue不能用标签命名样式
  633. /* #ifndef APP-NVUE */
  634. image {
  635. display: inline-block;
  636. // 解决图片加载时可能会瞬间变形的问题
  637. will-change: transform;
  638. }
  639. view,
  640. text {
  641. box-sizing: border-box;
  642. flex-direction: row;
  643. }
  644. /* #endif */
  645. .u-upload {
  646. display: flex;
  647. flex-wrap: wrap;
  648. align-items: center;
  649. }
  650. .u-list-item {
  651. width: 200rpx;
  652. height: 200rpx;
  653. overflow: hidden;
  654. margin: 10rpx;
  655. background: rgb(244, 245, 246);
  656. position: relative;
  657. border-radius: 10rpx;
  658. display: inline-flex;
  659. align-items: center;
  660. justify-content: center;
  661. }
  662. .u-preview-wrap {
  663. border: 1px solid rgb(235, 236, 238);
  664. }
  665. .u-add-wrap {
  666. flex-direction: column;
  667. color: $u-content-color;
  668. font-size: 28rpx;
  669. }
  670. .u-add-tips {
  671. margin-top: 20rpx;
  672. }
  673. .u-add-wrap__hover {
  674. background-color: rgb(235, 236, 238);
  675. }
  676. .u-preview-image {
  677. display: block;
  678. width: 100%;
  679. height: 100%;
  680. border-radius: 10rpx;
  681. }
  682. .u-delete-icon {
  683. position: absolute;
  684. top: 0rpx;
  685. right: 0rpx;
  686. z-index: 10;
  687. background-color: $u-type-error;
  688. border-radius:0 0 0 10rpx;
  689. width: 44rpx;
  690. height: 44rpx;
  691. display: flex;
  692. align-items: center;
  693. justify-content: center;
  694. }
  695. .u-icon {
  696. display: flex;
  697. align-items: center;
  698. justify-content: center;
  699. }
  700. .u-progress {
  701. position: absolute;
  702. bottom: 10rpx;
  703. left: 8rpx;
  704. right: 8rpx;
  705. z-index: 9;
  706. width: auto;
  707. }
  708. .u-error-btn {
  709. color: #ffffff;
  710. background-color: $u-type-error;
  711. font-size: 20rpx;
  712. padding: 4px 0;
  713. text-align: center;
  714. position: absolute;
  715. bottom: 0;
  716. left: 0;
  717. right: 0;
  718. z-index: 9;
  719. line-height: 1;
  720. }
  721. // .custom-style {
  722. // background: #F5F6FA;
  723. // width: 100%;
  724. // height: 480rpx;
  725. // display: flex;
  726. // justify-content: center;
  727. // align-items: center;
  728. // background: #F2F5FA;
  729. // border-radius: 20rpx;
  730. // border: 2px dashed #C6CBCE;
  731. // }
  732. // .custom-img {
  733. // width: 120rpx;
  734. // height: 100rpx;
  735. // }
  736. // .text {
  737. // font-size: 18px;
  738. // font-weight: 600;
  739. // color: #617E8B;
  740. // }
  741. // .content {
  742. // display: flex;
  743. // justify-content: center;
  744. // flex-direction: column;
  745. // align-items: center;
  746. // }
  747. // .u-preview {
  748. // width: 100%;
  749. // height: 100%;
  750. // // position: absolute;
  751. // background: #F5F6FA;
  752. // }
  753. // .u-list-item-custom {
  754. // margin: 0 !important;
  755. // width: 100% !important;
  756. // height: 100% !important;
  757. // }
  758. .customStyleBgc {
  759. width: 100% !important;
  760. height: 440rpx !important;
  761. display: flex !important;
  762. justify-content: center;
  763. align-items: center;
  764. position: relative;
  765. .u-add-wrap {
  766. width: 100% !important;
  767. height: 100% !important;
  768. background: transparent;
  769. }
  770. .u-add-tips {
  771. font-size: 18px;
  772. font-weight: 600;
  773. color: #617E8B;
  774. }
  775. }
  776. .customStyle {
  777. width: 712rpx !important;
  778. height: 440rpx !important;
  779. background: #F5F6FA;
  780. border-radius: 20rpx;
  781. // border: 2px dashed #C6CBCE;
  782. display: flex !important;
  783. justify-content: center;
  784. align-items: center;
  785. position: relative;
  786. .u-add-wrap {
  787. width: 100% !important;
  788. height: 100% !important;
  789. background: transparent;
  790. }
  791. .u-add-tips {
  792. font-size: 18px;
  793. font-weight: 600;
  794. color: #617E8B;
  795. }
  796. }
  797. .customPreviewStyle {
  798. width: 100% !important;
  799. height: 440rpx !important;
  800. }
  801. .imgstyle {
  802. width: 100% !important;
  803. height: 440rpx !important;
  804. position: absolute;
  805. }
  806. .default{
  807. .u-list-item.u-add-wrap{
  808. background:#fff;
  809. border:1px dashed #AFB3BF;
  810. }
  811. }
  812. .shade{
  813. background:#000;
  814. position:fixed;
  815. top:0;left:0;
  816. width:100%;height:100%;
  817. z-index:10000;
  818. }
  819. .u-check-icon{
  820. position: absolute;
  821. bottom: 0rpx;
  822. left: 0rpx;
  823. z-index: 10;
  824. background-color: $u-type-error;
  825. border-radius:0 0 0 10rpx;
  826. width: 44rpx;
  827. height: 44rpx;
  828. display: flex;
  829. align-items: center;
  830. justify-content: center;
  831. }
  832. </style>