index.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632
  1. <template>
  2. <view class="container">
  3. <view class="page-body uni-content-info">
  4. <view class='cropper-content'>
  5. <view v-if="isShowImg" class="uni-corpper" :style="'width:'+cropperInitW+'px;height:'+cropperInitH+'px;background:#000'">
  6. <view class="uni-corpper-content" :style="'width:'+cropperW+'px;height:'+cropperH+'px;left:'+cropperL+'px;top:'+cropperT+'px'">
  7. <image :src="imageSrc" :style="'width:'+cropperW+'px;height:'+cropperH+'px'"></image>
  8. <view class="uni-corpper-crop-box" @touchstart.stop="contentStartMove" @touchmove.stop="contentMoveing" @touchend.stop="contentTouchEnd"
  9. :style="'left:'+cutL+'px;top:'+cutT+'px;right:'+cutR+'px;bottom:'+cutB+'px'">
  10. <view class="uni-cropper-view-box">
  11. <view class="uni-cropper-dashed-h"></view>
  12. <view class="uni-cropper-dashed-v"></view>
  13. <view class="uni-cropper-line-t" data-drag="top" @touchstart.stop="dragStart" @touchmove.stop="dragMove"></view>
  14. <view class="uni-cropper-line-r" data-drag="right" @touchstart.stop="dragStart" @touchmove.stop="dragMove"></view>
  15. <view class="uni-cropper-line-b" data-drag="bottom" @touchstart.stop="dragStart" @touchmove.stop="dragMove"></view>
  16. <view class="uni-cropper-line-l" data-drag="left" @touchstart.stop="dragStart" @touchmove.stop="dragMove"></view>
  17. <view class="uni-cropper-point point-t" data-drag="top" @touchstart.stop="dragStart" @touchmove.stop="dragMove"></view>
  18. <view class="uni-cropper-point point-tr" data-drag="topTight"></view>
  19. <view class="uni-cropper-point point-r" data-drag="right" @touchstart.stop="dragStart" @touchmove.stop="dragMove"></view>
  20. <view class="uni-cropper-point point-rb" data-drag="rightBottom" @touchstart.stop="dragStart" @touchmove.stop="dragMove"></view>
  21. <view class="uni-cropper-point point-b" data-drag="bottom" @touchstart.stop="dragStart" @touchmove.stop="dragMove" @touchend.stop="dragEnd"></view>
  22. <view class="uni-cropper-point point-bl" data-drag="bottomLeft"></view>
  23. <view class="uni-cropper-point point-l" data-drag="left" @touchstart.stop="dragStart" @touchmove.stop="dragMove"></view>
  24. <view class="uni-cropper-point point-lt" data-drag="leftTop"></view>
  25. </view>
  26. </view>
  27. </view>
  28. </view>
  29. </view>
  30. <view class='cropper-config'>
  31. <button type="primary reverse" @click="getImage" style='margin-top: 30rpx;'> 选择头像 </button>
  32. <button type="warn" @click="getImageInfo" style='margin-top: 30rpx;'> 提交 </button>
  33. </view>
  34. <canvas canvas-id="myCanvas" :style="'position:absolute;border: 1px solid red; width:'+imageW+'px;height:'+imageH+'px;top:-9999px;left:-9999px;'"></canvas>
  35. </view>
  36. </view>
  37. </template>
  38. <script>
  39. import config from '@/config'
  40. import store from "@/store"
  41. import { uploadAvatar } from "@/api/system/user"
  42. const baseUrl = config.baseUrl
  43. let sysInfo = uni.getSystemInfoSync()
  44. let SCREEN_WIDTH = sysInfo.screenWidth
  45. let PAGE_X, // 手按下的x位置
  46. PAGE_Y, // 手按下y的位置
  47. PR = sysInfo.pixelRatio, // dpi
  48. T_PAGE_X, // 手移动的时候x的位置
  49. T_PAGE_Y, // 手移动的时候Y的位置
  50. CUT_L, // 初始化拖拽元素的left值
  51. CUT_T, // 初始化拖拽元素的top值
  52. CUT_R, // 初始化拖拽元素的
  53. CUT_B, // 初始化拖拽元素的
  54. CUT_W, // 初始化拖拽元素的宽度
  55. CUT_H, // 初始化拖拽元素的高度
  56. IMG_RATIO, // 图片比例
  57. IMG_REAL_W, // 图片实际的宽度
  58. IMG_REAL_H, // 图片实际的高度
  59. DRAFG_MOVE_RATIO = 1, //移动时候的比例,
  60. INIT_DRAG_POSITION = 100, // 初始化屏幕宽度和裁剪区域的宽度之差,用于设置初始化裁剪的宽度
  61. DRAW_IMAGE_W = sysInfo.screenWidth // 设置生成的图片宽度
  62. export default {
  63. /**
  64. * 页面的初始数据
  65. */
  66. data() {
  67. return {
  68. imageSrc: store.getters.avatar,
  69. isShowImg: false,
  70. // 初始化的宽高
  71. cropperInitW: SCREEN_WIDTH,
  72. cropperInitH: SCREEN_WIDTH,
  73. // 动态的宽高
  74. cropperW: SCREEN_WIDTH,
  75. cropperH: SCREEN_WIDTH,
  76. // 动态的left top值
  77. cropperL: 0,
  78. cropperT: 0,
  79. transL: 0,
  80. transT: 0,
  81. // 图片缩放值
  82. scaleP: 0,
  83. imageW: 0,
  84. imageH: 0,
  85. // 裁剪框 宽高
  86. cutL: 0,
  87. cutT: 0,
  88. cutB: SCREEN_WIDTH,
  89. cutR: '100%',
  90. qualityWidth: DRAW_IMAGE_W,
  91. innerAspectRadio: DRAFG_MOVE_RATIO
  92. }
  93. },
  94. /**
  95. * 生命周期函数--监听页面初次渲染完成
  96. */
  97. onReady: function () {
  98. this.loadImage()
  99. },
  100. methods: {
  101. setData: function (obj) {
  102. let that = this
  103. Object.keys(obj).forEach(function (key) {
  104. that.$set(that.$data, key, obj[key])
  105. })
  106. },
  107. getImage: function () {
  108. var _this = this
  109. uni.chooseImage({
  110. success: function (res) {
  111. _this.setData({
  112. imageSrc: res.tempFilePaths[0],
  113. })
  114. _this.loadImage()
  115. },
  116. })
  117. },
  118. loadImage: function () {
  119. var _this = this
  120. uni.getImageInfo({
  121. src: _this.imageSrc,
  122. success: function success(res) {
  123. IMG_RATIO = 1 / 1
  124. if (IMG_RATIO >= 1) {
  125. IMG_REAL_W = SCREEN_WIDTH
  126. IMG_REAL_H = SCREEN_WIDTH / IMG_RATIO
  127. } else {
  128. IMG_REAL_W = SCREEN_WIDTH * IMG_RATIO
  129. IMG_REAL_H = SCREEN_WIDTH
  130. }
  131. let minRange = IMG_REAL_W > IMG_REAL_H ? IMG_REAL_W : IMG_REAL_H
  132. INIT_DRAG_POSITION = minRange > INIT_DRAG_POSITION ? INIT_DRAG_POSITION : minRange
  133. // 根据图片的宽高显示不同的效果 保证图片可以正常显示
  134. if (IMG_RATIO >= 1) {
  135. let cutT = Math.ceil((SCREEN_WIDTH / IMG_RATIO - (SCREEN_WIDTH / IMG_RATIO - INIT_DRAG_POSITION)) / 2)
  136. let cutB = cutT
  137. let cutL = Math.ceil((SCREEN_WIDTH - SCREEN_WIDTH + INIT_DRAG_POSITION) / 2)
  138. let cutR = cutL
  139. _this.setData({
  140. cropperW: SCREEN_WIDTH,
  141. cropperH: SCREEN_WIDTH / IMG_RATIO,
  142. // 初始化left right
  143. cropperL: Math.ceil((SCREEN_WIDTH - SCREEN_WIDTH) / 2),
  144. cropperT: Math.ceil((SCREEN_WIDTH - SCREEN_WIDTH / IMG_RATIO) / 2),
  145. cutL: cutL,
  146. cutT: cutT,
  147. cutR: cutR,
  148. cutB: cutB,
  149. // 图片缩放值
  150. imageW: IMG_REAL_W,
  151. imageH: IMG_REAL_H,
  152. scaleP: IMG_REAL_W / SCREEN_WIDTH,
  153. qualityWidth: DRAW_IMAGE_W,
  154. innerAspectRadio: IMG_RATIO
  155. })
  156. } else {
  157. let cutL = Math.ceil((SCREEN_WIDTH * IMG_RATIO - (SCREEN_WIDTH * IMG_RATIO)) / 2)
  158. let cutR = cutL
  159. let cutT = Math.ceil((SCREEN_WIDTH - INIT_DRAG_POSITION) / 2)
  160. let cutB = cutT
  161. _this.setData({
  162. cropperW: SCREEN_WIDTH * IMG_RATIO,
  163. cropperH: SCREEN_WIDTH,
  164. // 初始化left right
  165. cropperL: Math.ceil((SCREEN_WIDTH - SCREEN_WIDTH * IMG_RATIO) / 2),
  166. cropperT: Math.ceil((SCREEN_WIDTH - SCREEN_WIDTH) / 2),
  167. cutL: cutL,
  168. cutT: cutT,
  169. cutR: cutR,
  170. cutB: cutB,
  171. // 图片缩放值
  172. imageW: IMG_REAL_W,
  173. imageH: IMG_REAL_H,
  174. scaleP: IMG_REAL_W / SCREEN_WIDTH,
  175. qualityWidth: DRAW_IMAGE_W,
  176. innerAspectRadio: IMG_RATIO
  177. })
  178. }
  179. _this.setData({
  180. isShowImg: true
  181. })
  182. uni.hideLoading()
  183. }
  184. })
  185. },
  186. // 拖动时候触发的touchStart事件
  187. contentStartMove(e) {
  188. PAGE_X = e.touches[0].pageX
  189. PAGE_Y = e.touches[0].pageY
  190. },
  191. // 拖动时候触发的touchMove事件
  192. contentMoveing(e) {
  193. var _this = this
  194. var dragLengthX = (PAGE_X - e.touches[0].pageX) * DRAFG_MOVE_RATIO
  195. var dragLengthY = (PAGE_Y - e.touches[0].pageY) * DRAFG_MOVE_RATIO
  196. // 左移
  197. if (dragLengthX > 0) {
  198. if (this.cutL - dragLengthX < 0) dragLengthX = this.cutL
  199. } else {
  200. if (this.cutR + dragLengthX < 0) dragLengthX = -this.cutR
  201. }
  202. if (dragLengthY > 0) {
  203. if (this.cutT - dragLengthY < 0) dragLengthY = this.cutT
  204. } else {
  205. if (this.cutB + dragLengthY < 0) dragLengthY = -this.cutB
  206. }
  207. this.setData({
  208. cutL: this.cutL - dragLengthX,
  209. cutT: this.cutT - dragLengthY,
  210. cutR: this.cutR + dragLengthX,
  211. cutB: this.cutB + dragLengthY
  212. })
  213. PAGE_X = e.touches[0].pageX
  214. PAGE_Y = e.touches[0].pageY
  215. },
  216. contentTouchEnd() {
  217. },
  218. // 获取图片
  219. getImageInfo() {
  220. var _this = this
  221. uni.showLoading({
  222. title: '图片生成中...',
  223. })
  224. // 将图片写入画布
  225. const ctx = uni.createCanvasContext('myCanvas')
  226. ctx.drawImage(_this.imageSrc, 0, 0, IMG_REAL_W, IMG_REAL_H)
  227. ctx.draw(true, () => {
  228. // 获取画布要裁剪的位置和宽度 均为百分比 * 画布中图片的宽度 保证了在微信小程序中裁剪的图片模糊 位置不对的问题 canvasT = (_this.cutT / _this.cropperH) * (_this.imageH / pixelRatio)
  229. var canvasW = ((_this.cropperW - _this.cutL - _this.cutR) / _this.cropperW) * IMG_REAL_W
  230. var canvasH = ((_this.cropperH - _this.cutT - _this.cutB) / _this.cropperH) * IMG_REAL_H
  231. var canvasL = (_this.cutL / _this.cropperW) * IMG_REAL_W
  232. var canvasT = (_this.cutT / _this.cropperH) * IMG_REAL_H
  233. uni.canvasToTempFilePath({
  234. x: canvasL,
  235. y: canvasT,
  236. width: canvasW,
  237. height: canvasH,
  238. destWidth: canvasW,
  239. destHeight: canvasH,
  240. quality: 0.5,
  241. canvasId: 'myCanvas',
  242. success: function (res) {
  243. uni.hideLoading()
  244. console.log("res.tempFilePath",res.tempFilePath);
  245. let data = {name: 'avatarFile', filePath: res.tempFilePath}
  246. uploadAvatar(data).then(response => {
  247. store.commit('SET_AVATAR', response.data)
  248. uni.showToast({ title: "修改成功", icon: 'success' })
  249. uni.navigateBack()
  250. })
  251. }
  252. })
  253. })
  254. },
  255. // 设置大小的时候触发的touchStart事件
  256. dragStart(e) {
  257. T_PAGE_X = e.touches[0].pageX
  258. T_PAGE_Y = e.touches[0].pageY
  259. CUT_L = this.cutL
  260. CUT_R = this.cutR
  261. CUT_B = this.cutB
  262. CUT_T = this.cutT
  263. },
  264. // 设置大小的时候触发的touchMove事件
  265. dragMove(e) {
  266. var _this = this
  267. var dragType = e.target.dataset.drag
  268. switch (dragType) {
  269. case 'right':
  270. var dragLength = (T_PAGE_X - e.touches[0].pageX) * DRAFG_MOVE_RATIO
  271. if (CUT_R + dragLength < 0) dragLength = -CUT_R
  272. this.setData({
  273. cutR: CUT_R + dragLength
  274. })
  275. break
  276. case 'left':
  277. var dragLength = (T_PAGE_X - e.touches[0].pageX) * DRAFG_MOVE_RATIO
  278. if (CUT_L - dragLength < 0) dragLength = CUT_L
  279. if ((CUT_L - dragLength) > (this.cropperW - this.cutR)) dragLength = CUT_L - (this.cropperW - this.cutR)
  280. this.setData({
  281. cutL: CUT_L - dragLength
  282. })
  283. break
  284. case 'top':
  285. var dragLength = (T_PAGE_Y - e.touches[0].pageY) * DRAFG_MOVE_RATIO
  286. if (CUT_T - dragLength < 0) dragLength = CUT_T
  287. if ((CUT_T - dragLength) > (this.cropperH - this.cutB)) dragLength = CUT_T - (this.cropperH - this.cutB)
  288. this.setData({
  289. cutT: CUT_T - dragLength
  290. })
  291. break
  292. case 'bottom':
  293. var dragLength = (T_PAGE_Y - e.touches[0].pageY) * DRAFG_MOVE_RATIO
  294. if (CUT_B + dragLength < 0) dragLength = -CUT_B
  295. this.setData({
  296. cutB: CUT_B + dragLength
  297. })
  298. break
  299. case 'rightBottom':
  300. var dragLengthX = (T_PAGE_X - e.touches[0].pageX) * DRAFG_MOVE_RATIO
  301. var dragLengthY = (T_PAGE_Y - e.touches[0].pageY) * DRAFG_MOVE_RATIO
  302. if (CUT_B + dragLengthY < 0) dragLengthY = -CUT_B
  303. if (CUT_R + dragLengthX < 0) dragLengthX = -CUT_R
  304. let cutB = CUT_B + dragLengthY
  305. let cutR = CUT_R + dragLengthX
  306. this.setData({
  307. cutB: cutB,
  308. cutR: cutR
  309. })
  310. break
  311. default:
  312. break
  313. }
  314. }
  315. }
  316. }
  317. </script>
  318. <style>
  319. /* pages/uni-cropper/index.wxss */
  320. .uni-content-info {
  321. /* position: fixed;
  322. top: 0;
  323. left: 0;
  324. right: 0;
  325. bottom: 0;
  326. display: block;
  327. align-items: center;
  328. flex-direction: column; */
  329. }
  330. .cropper-config {
  331. padding: 20rpx 40rpx;
  332. }
  333. .cropper-content {
  334. min-height: 750rpx;
  335. width: 100%;
  336. }
  337. .uni-corpper {
  338. position: relative;
  339. overflow: hidden;
  340. -webkit-user-select: none;
  341. -moz-user-select: none;
  342. -ms-user-select: none;
  343. user-select: none;
  344. -webkit-tap-highlight-color: transparent;
  345. -webkit-touch-callout: none;
  346. box-sizing: border-box;
  347. }
  348. .uni-corpper-content {
  349. position: relative;
  350. }
  351. .uni-corpper-content image {
  352. display: block;
  353. width: 100%;
  354. min-width: 0 !important;
  355. max-width: none !important;
  356. height: 100%;
  357. min-height: 0 !important;
  358. max-height: none !important;
  359. image-orientation: 0deg !important;
  360. margin: 0 auto;
  361. }
  362. /* 移动图片效果 */
  363. .uni-cropper-drag-box {
  364. position: absolute;
  365. top: 0;
  366. right: 0;
  367. bottom: 0;
  368. left: 0;
  369. cursor: move;
  370. background: rgba(0, 0, 0, 0.6);
  371. z-index: 1;
  372. }
  373. /* 内部的信息 */
  374. .uni-corpper-crop-box {
  375. position: absolute;
  376. background: rgba(255, 255, 255, 0.3);
  377. z-index: 2;
  378. }
  379. .uni-corpper-crop-box .uni-cropper-view-box {
  380. position: relative;
  381. display: block;
  382. width: 100%;
  383. height: 100%;
  384. overflow: visible;
  385. outline: 1rpx solid #69f;
  386. outline-color: rgba(102, 153, 255, .75)
  387. }
  388. /* 横向虚线 */
  389. .uni-cropper-dashed-h {
  390. position: absolute;
  391. top: 33.33333333%;
  392. left: 0;
  393. width: 100%;
  394. height: 33.33333333%;
  395. border-top: 1rpx dashed rgba(255, 255, 255, 0.5);
  396. border-bottom: 1rpx dashed rgba(255, 255, 255, 0.5);
  397. }
  398. /* 纵向虚线 */
  399. .uni-cropper-dashed-v {
  400. position: absolute;
  401. left: 33.33333333%;
  402. top: 0;
  403. width: 33.33333333%;
  404. height: 100%;
  405. border-left: 1rpx dashed rgba(255, 255, 255, 0.5);
  406. border-right: 1rpx dashed rgba(255, 255, 255, 0.5);
  407. }
  408. /* 四个方向的线 为了之后的拖动事件*/
  409. .uni-cropper-line-t {
  410. position: absolute;
  411. display: block;
  412. width: 100%;
  413. background-color: #69f;
  414. top: 0;
  415. left: 0;
  416. height: 1rpx;
  417. opacity: 0.1;
  418. cursor: n-resize;
  419. }
  420. .uni-cropper-line-t::before {
  421. content: '';
  422. position: absolute;
  423. top: 50%;
  424. right: 0rpx;
  425. width: 100%;
  426. -webkit-transform: translate3d(0, -50%, 0);
  427. transform: translate3d(0, -50%, 0);
  428. bottom: 0;
  429. height: 41rpx;
  430. background: transparent;
  431. z-index: 11;
  432. }
  433. .uni-cropper-line-r {
  434. position: absolute;
  435. display: block;
  436. background-color: #69f;
  437. top: 0;
  438. right: 0rpx;
  439. width: 1rpx;
  440. opacity: 0.1;
  441. height: 100%;
  442. cursor: e-resize;
  443. }
  444. .uni-cropper-line-r::before {
  445. content: '';
  446. position: absolute;
  447. top: 0;
  448. left: 50%;
  449. width: 41rpx;
  450. -webkit-transform: translate3d(-50%, 0, 0);
  451. transform: translate3d(-50%, 0, 0);
  452. bottom: 0;
  453. height: 100%;
  454. background: transparent;
  455. z-index: 11;
  456. }
  457. .uni-cropper-line-b {
  458. position: absolute;
  459. display: block;
  460. width: 100%;
  461. background-color: #69f;
  462. bottom: 0;
  463. left: 0;
  464. height: 1rpx;
  465. opacity: 0.1;
  466. cursor: s-resize;
  467. }
  468. .uni-cropper-line-b::before {
  469. content: '';
  470. position: absolute;
  471. top: 50%;
  472. right: 0rpx;
  473. width: 100%;
  474. -webkit-transform: translate3d(0, -50%, 0);
  475. transform: translate3d(0, -50%, 0);
  476. bottom: 0;
  477. height: 41rpx;
  478. background: transparent;
  479. z-index: 11;
  480. }
  481. .uni-cropper-line-l {
  482. position: absolute;
  483. display: block;
  484. background-color: #69f;
  485. top: 0;
  486. left: 0;
  487. width: 1rpx;
  488. opacity: 0.1;
  489. height: 100%;
  490. cursor: w-resize;
  491. }
  492. .uni-cropper-line-l::before {
  493. content: '';
  494. position: absolute;
  495. top: 0;
  496. left: 50%;
  497. width: 41rpx;
  498. -webkit-transform: translate3d(-50%, 0, 0);
  499. transform: translate3d(-50%, 0, 0);
  500. bottom: 0;
  501. height: 100%;
  502. background: transparent;
  503. z-index: 11;
  504. }
  505. .uni-cropper-point {
  506. width: 5rpx;
  507. height: 5rpx;
  508. background-color: #69f;
  509. opacity: .75;
  510. position: absolute;
  511. z-index: 3;
  512. }
  513. .point-t {
  514. top: -3rpx;
  515. left: 50%;
  516. margin-left: -3rpx;
  517. cursor: n-resize;
  518. }
  519. .point-tr {
  520. top: -3rpx;
  521. left: 100%;
  522. margin-left: -3rpx;
  523. cursor: n-resize;
  524. }
  525. .point-r {
  526. top: 50%;
  527. left: 100%;
  528. margin-left: -3rpx;
  529. margin-top: -3rpx;
  530. cursor: n-resize;
  531. }
  532. .point-rb {
  533. left: 100%;
  534. top: 100%;
  535. -webkit-transform: translate3d(-50%, -50%, 0);
  536. transform: translate3d(-50%, -50%, 0);
  537. cursor: n-resize;
  538. width: 36rpx;
  539. height: 36rpx;
  540. background-color: #69f;
  541. position: absolute;
  542. z-index: 1112;
  543. opacity: 1;
  544. }
  545. .point-b {
  546. left: 50%;
  547. top: 100%;
  548. margin-left: -3rpx;
  549. margin-top: -3rpx;
  550. cursor: n-resize;
  551. }
  552. .point-bl {
  553. left: 0%;
  554. top: 100%;
  555. margin-left: -3rpx;
  556. margin-top: -3rpx;
  557. cursor: n-resize;
  558. }
  559. .point-l {
  560. left: 0%;
  561. top: 50%;
  562. margin-left: -3rpx;
  563. margin-top: -3rpx;
  564. cursor: n-resize;
  565. }
  566. .point-lt {
  567. left: 0%;
  568. top: 0%;
  569. margin-left: -3rpx;
  570. margin-top: -3rpx;
  571. cursor: n-resize;
  572. }
  573. /* 裁剪框预览内容 */
  574. .uni-cropper-viewer {
  575. position: relative;
  576. width: 100%;
  577. height: 100%;
  578. overflow: hidden;
  579. }
  580. .uni-cropper-viewer image {
  581. position: absolute;
  582. z-index: 2;
  583. }
  584. </style>