index.vue 20 KB

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