index.vue 18 KB

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