index.vue 18 KB

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