index.uvue 18 KB

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