@10yun/cv-mobile-ui 0.5.29 → 0.5.30

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (260) hide show
  1. package/package.json +1 -1
  2. package/plugins/luch-request/adapters/index.js +131 -0
  3. package/plugins/luch-request/core/InterceptorManager.js +50 -0
  4. package/plugins/luch-request/core/Request.js +199 -0
  5. package/plugins/luch-request/core/buildFullPath.js +20 -0
  6. package/plugins/luch-request/core/defaults.js +32 -0
  7. package/plugins/luch-request/core/dispatchRequest.js +5 -0
  8. package/plugins/luch-request/core/mergeConfig.js +125 -0
  9. package/plugins/luch-request/core/settle.js +16 -0
  10. package/plugins/luch-request/helpers/buildURL.js +71 -0
  11. package/plugins/luch-request/helpers/combineURLs.js +12 -0
  12. package/plugins/luch-request/helpers/isAbsoluteURL.js +14 -0
  13. package/plugins/luch-request/index.d.ts +197 -0
  14. package/plugins/luch-request/index.js +2 -0
  15. package/plugins/luch-request/readme.md +3 -0
  16. package/plugins/luch-request/utils/clone.js +264 -0
  17. package/plugins/luch-request/utils.js +131 -0
  18. package/plugins/request.js +2 -2
  19. package/ui-cv/components/cv-form-item/cv-form-item.vue +1 -1
  20. package/ui-fireui/fui-actionsheet/fui-actionsheet.vue +202 -0
  21. package/ui-fireui/fui-alert/fui-alert.vue +141 -0
  22. package/ui-fireui/fui-badge/fui-badge.vue +158 -0
  23. package/ui-fireui/fui-bottom-navigation/fui-bottom-navigation.vue +390 -0
  24. package/ui-fireui/fui-bottom-popup/fui-bottom-popup.vue +100 -0
  25. package/ui-fireui/fui-bubble-popup/fui-bubble-popup.vue +236 -0
  26. package/ui-fireui/fui-button/fui-button.vue +424 -0
  27. package/ui-fireui/fui-calendar/fui-calendar.js +915 -0
  28. package/ui-fireui/fui-calendar/fui-calendar.vue +868 -0
  29. package/ui-fireui/fui-card/fui-card.vue +231 -0
  30. package/ui-fireui/fui-cascade-selection/fui-cascade-selection.vue +538 -0
  31. package/ui-fireui/fui-circular-progress/fui-circular-progress.vue +261 -0
  32. package/ui-fireui/fui-collapse/fui-collapse.vue +179 -0
  33. package/ui-fireui/fui-countdown/fui-countdown.vue +301 -0
  34. package/ui-fireui/fui-datetime/fui-datetime.vue +570 -0
  35. package/ui-fireui/fui-divider/fui-divider.vue +118 -0
  36. package/ui-fireui/fui-drawer/fui-drawer.vue +103 -0
  37. package/ui-fireui/fui-dropdown-list/fui-dropdown-list.vue +70 -0
  38. package/ui-fireui/fui-fab/fui-fab.vue +284 -0
  39. package/ui-fireui/fui-footer/fui-footer.vue +131 -0
  40. package/ui-fireui/fui-grid/fui-grid.vue +42 -0
  41. package/ui-fireui/fui-grid-item/fui-grid-item.vue +142 -0
  42. package/ui-fireui/fui-icon/fui-icon.vue +820 -0
  43. package/ui-fireui/fui-image-cropper/fui-image-cropper.vue +1058 -0
  44. package/ui-fireui/fui-image-group/fui-image-group.vue +149 -0
  45. package/ui-fireui/fui-keyboard/fui-keyboard.vue +254 -0
  46. package/ui-fireui/fui-keyboard-input/fui-keyboard-input.vue +78 -0
  47. package/ui-fireui/fui-list-cell/fui-list-cell.vue +178 -0
  48. package/ui-fireui/fui-list-view/fui-list-view.vue +87 -0
  49. package/ui-fireui/fui-loading/fui-loading.vue +78 -0
  50. package/ui-fireui/fui-loadmore/fui-loadmore.vue +163 -0
  51. package/ui-fireui/fui-modal/fui-modal.vue +392 -0
  52. package/ui-fireui/fui-navigation-bar/fui-navigation-bar.vue +180 -0
  53. package/ui-fireui/fui-no-data/fui-no-data.vue +116 -0
  54. package/ui-fireui/fui-nomore/fui-nomore.vue +116 -0
  55. package/ui-fireui/fui-numberbox/fui-numberbox.vue +234 -0
  56. package/ui-fireui/fui-numberbox-border/fui-numberbox-border.vue +232 -0
  57. package/ui-fireui/fui-picture-cropper/fui-picture-cropper.vue +682 -0
  58. package/ui-fireui/fui-picture-cropper/fui-picture-cropper.wxs +560 -0
  59. package/ui-fireui/fui-rate/fui-rate.vue +167 -0
  60. package/ui-fireui/fui-round-progress/fui-round-progress.vue +306 -0
  61. package/ui-fireui/fui-scroll-top/fui-scroll-top.vue +189 -0
  62. package/ui-fireui/fui-sharemodel/fui-sharemodel.vue +181 -0
  63. package/ui-fireui/fui-skeleton/fui-skeleton.vue +248 -0
  64. package/ui-fireui/fui-steps/fui-steps.vue +214 -0
  65. package/ui-fireui/fui-sticky/fui-sticky.vue +155 -0
  66. package/ui-fireui/fui-sticky-wxs/fui-sticky-wxs.vue +133 -0
  67. package/ui-fireui/fui-sticky-wxs/fui-sticky.wxs +44 -0
  68. package/ui-fireui/fui-swipe-action/fui-swipe-action.vue +301 -0
  69. package/ui-fireui/fui-tabbar/fui-tabbar.vue +283 -0
  70. package/ui-fireui/fui-tabs/fui-tabs.vue +284 -0
  71. package/ui-fireui/fui-tabs2/fui-tabs2.vue +284 -0
  72. package/ui-fireui/fui-tag/fui-tag.vue +374 -0
  73. package/ui-fireui/fui-time-axis/fui-time-axis.vue +36 -0
  74. package/ui-fireui/fui-timeaxis-item/fui-timeaxis-item.vue +48 -0
  75. package/ui-fireui/fui-tips/fui-tips.vue +161 -0
  76. package/ui-fireui/fui-toast/fui-toast.vue +117 -0
  77. package/ui-fireui/fui-top-dropdown/fui-top-dropdown.vue +129 -0
  78. package/ui-fireui/fui-upload/fui-upload.vue +446 -0
  79. package/ui-fireui/fui-uploadsamll/fui-uploadsamll.vue +472 -0
  80. package/uview-plus/README.md +1 -1
  81. package/uview-plus/changelog-wu-tool.md +21 -0
  82. package/uview-plus/changelog-wu.md +91 -0
  83. package/uview-plus/components/u-action-sheet/_doc/changelog.md +12 -0
  84. package/uview-plus/components/u-action-sheet/_doc/package.json +92 -0
  85. package/uview-plus/components/u-action-sheet/_doc/readme.md +16 -0
  86. package/uview-plus/components/u-app-update/_doc/changelog.md +26 -0
  87. package/uview-plus/components/u-app-update/_doc/package.json +89 -0
  88. package/uview-plus/components/u-app-update/_doc/readme.md +16 -0
  89. package/uview-plus/components/u-app-update/config.js +120 -0
  90. package/uview-plus/components/u-app-update/img/act.png +0 -0
  91. package/uview-plus/components/u-app-update/img/appUploadAlertBoxBg.png +0 -0
  92. package/uview-plus/components/u-app-update/img/close.png +0 -0
  93. package/uview-plus/components/u-app-update/js-sdk/checkVersion.js +81 -0
  94. package/uview-plus/components/u-app-update/js-sdk/silentlyAppUpdate.js +41 -0
  95. package/uview-plus/components/u-app-update/pages/index.vue +8 -0
  96. package/uview-plus/components/u-app-update/u-app-update.vue +583 -0
  97. package/uview-plus/components/u-button-wu/_doc/changelog.md +6 -0
  98. package/uview-plus/components/u-button-wu/_doc/package.json +89 -0
  99. package/uview-plus/components/u-button-wu/_doc/readme.md +16 -0
  100. package/uview-plus/components/u-button-wu/u-button-wu.vue +522 -0
  101. package/uview-plus/components/u-button-wu/vue.scss +81 -0
  102. package/uview-plus/components/u-calendar-wu/_doc/changelog.md +145 -0
  103. package/uview-plus/components/u-calendar-wu/_doc/package.json +90 -0
  104. package/uview-plus/components/u-calendar-wu/_doc/readme.md +16 -0
  105. package/uview-plus/components/u-calendar-wu/calendar.js +664 -0
  106. package/uview-plus/components/u-calendar-wu/i18n/en.json +14 -0
  107. package/uview-plus/components/u-calendar-wu/i18n/index.js +8 -0
  108. package/uview-plus/components/u-calendar-wu/i18n/zh-Hans.json +14 -0
  109. package/uview-plus/components/u-calendar-wu/i18n/zh-Hant.json +14 -0
  110. package/uview-plus/components/u-calendar-wu/props.js +166 -0
  111. package/uview-plus/components/u-calendar-wu/style.css +196 -0
  112. package/uview-plus/components/u-calendar-wu/u-calendar-wu.vue +921 -0
  113. package/uview-plus/components/u-calendar-wu/util.js +552 -0
  114. package/uview-plus/components/u-calendar-wu/wu-calendar-block/props.js +73 -0
  115. package/uview-plus/components/u-calendar-wu/wu-calendar-block/wu-calendar-block.vue +122 -0
  116. package/uview-plus/components/u-calendar-wu/wu-calendar-item/props.js +55 -0
  117. package/uview-plus/components/u-calendar-wu/wu-calendar-item/wu-calendar-item.vue +293 -0
  118. package/uview-plus/components/u-cell/_doc/changelog.md +6 -0
  119. package/uview-plus/components/u-cell/_doc/package.json +89 -0
  120. package/uview-plus/components/u-cell/_doc/readme.md +25 -0
  121. package/uview-plus/components/u-checkbox/_doc/changelog.md +8 -0
  122. package/uview-plus/components/u-checkbox/_doc/package.json +88 -0
  123. package/uview-plus/components/u-checkbox/_doc/readme.md +25 -0
  124. package/uview-plus/components/u-code/_doc/changelog.md +6 -0
  125. package/uview-plus/components/u-code/_doc/package.json +86 -0
  126. package/uview-plus/components/u-code/_doc/readme.md +16 -0
  127. package/uview-plus/components/u-drag-sort/_doc/changelog.md +0 -0
  128. package/uview-plus/components/u-drag-sort/_doc/package.json +85 -0
  129. package/uview-plus/components/u-drag-sort/_doc/readme.md +16 -0
  130. package/uview-plus/components/u-drag-sort/u-drag-sort.vue +3 -0
  131. package/uview-plus/components/u-empty/u-empty.vue +27 -1
  132. package/uview-plus/components/u-gap/_doc/changelog.md +4 -0
  133. package/uview-plus/components/u-gap/_doc/package.json +86 -0
  134. package/uview-plus/components/u-gap/_doc/readme.md +22 -0
  135. package/uview-plus/components/u-icon/_doc/changelog.md +10 -0
  136. package/uview-plus/components/u-icon/_doc/package.json +85 -0
  137. package/uview-plus/components/u-icon/_doc/readme.md +10 -0
  138. package/uview-plus/components/u-icon/icon.js +23 -25
  139. package/uview-plus/components/u-icon/icons.js +213 -213
  140. package/uview-plus/components/u-icon/style.css +3 -3
  141. package/uview-plus/components/u-icon/u-icon2.vue +149 -0
  142. package/uview-plus/components/u-image-wu/_doc/changelog.md +21 -0
  143. package/uview-plus/components/u-image-wu/_doc/package.json +88 -0
  144. package/uview-plus/components/u-image-wu/_doc/readme.md +11 -0
  145. package/uview-plus/components/u-image-wu/props.js +94 -0
  146. package/uview-plus/components/u-image-wu/u-image-wu.vue +243 -0
  147. package/uview-plus/components/u-input/_doc/changelog.md +6 -0
  148. package/uview-plus/components/u-input/_doc/package.json +88 -0
  149. package/uview-plus/components/u-input/_doc/readme.md +16 -0
  150. package/uview-plus/components/u-line/_doc/changelog.md +8 -0
  151. package/uview-plus/components/u-line/_doc/package.json +86 -0
  152. package/uview-plus/components/u-line/_doc/readme.md +16 -0
  153. package/uview-plus/components/u-link/_doc/changelog.md +8 -0
  154. package/uview-plus/components/u-link/_doc/package.json +86 -0
  155. package/uview-plus/components/u-link/_doc/readme.md +20 -0
  156. package/uview-plus/components/u-loading-icon/_doc/changelog.md +12 -0
  157. package/uview-plus/components/u-loading-icon/_doc/package.json +86 -0
  158. package/uview-plus/components/u-loading-icon/_doc/readme.md +16 -0
  159. package/uview-plus/components/u-loading-icon/props.js +1 -1
  160. package/uview-plus/components/u-navbar/_doc/changelog.md +6 -0
  161. package/uview-plus/components/u-navbar/_doc/package.json +89 -0
  162. package/uview-plus/components/u-navbar/_doc/readme.md +16 -0
  163. package/uview-plus/components/u-navbar-wu/props.js +102 -0
  164. package/uview-plus/components/u-navbar-wu/u-navbar-wu.vue +196 -0
  165. package/uview-plus/components/u-number-box/_doc/changelog.md +19 -0
  166. package/uview-plus/components/u-number-box/_doc/package.json +88 -0
  167. package/uview-plus/components/u-number-box/_doc/readme.md +16 -0
  168. package/uview-plus/components/u-overlay/_doc/changelog.md +4 -0
  169. package/uview-plus/components/u-overlay/_doc/package.json +88 -0
  170. package/uview-plus/components/u-overlay/_doc/readme.md +16 -0
  171. package/uview-plus/components/u-popup/_doc/changelog.md +4 -0
  172. package/uview-plus/components/u-popup/_doc/package.json +92 -0
  173. package/uview-plus/components/u-popup/_doc/readme.md +16 -0
  174. package/uview-plus/components/u-popup-wu/keypress.js +45 -0
  175. package/uview-plus/components/u-popup-wu/u-popup-wu.vue +519 -0
  176. package/uview-plus/components/u-radio/_doc/changelog.md +6 -0
  177. package/uview-plus/components/u-radio/_doc/package.json +88 -0
  178. package/uview-plus/components/u-radio/_doc/readme.md +25 -0
  179. package/uview-plus/components/u-row/_doc/changelog.md +8 -0
  180. package/uview-plus/components/u-row/_doc/package.json +86 -0
  181. package/uview-plus/components/u-row/_doc/readme.md +16 -0
  182. package/uview-plus/components/u-safe-bottom/_doc/changelog.md +6 -0
  183. package/uview-plus/components/u-safe-bottom/_doc/package.json +86 -0
  184. package/uview-plus/components/u-safe-bottom/_doc/readme.md +16 -0
  185. package/uview-plus/components/u-sku-wu/_doc/changelog.md +27 -0
  186. package/uview-plus/components/u-sku-wu/_doc/package.json +93 -0
  187. package/uview-plus/components/u-sku-wu/_doc/readme.md +16 -0
  188. package/uview-plus/components/u-sku-wu/props.js +86 -0
  189. package/uview-plus/components/u-sku-wu/style.css +271 -0
  190. package/uview-plus/components/u-sku-wu/u-sku-wu.vue +864 -0
  191. package/uview-plus/components/u-status-bar/_doc/changelog.md +4 -0
  192. package/uview-plus/components/u-status-bar/_doc/package.json +86 -0
  193. package/uview-plus/components/u-status-bar/_doc/readme.md +16 -0
  194. package/uview-plus/components/u-text/_doc/changelog.md +10 -0
  195. package/uview-plus/components/u-text/_doc/package.json +89 -0
  196. package/uview-plus/components/u-text/_doc/readme.md +20 -0
  197. package/uview-plus/components/u-textarea/_doc/changelog.md +6 -0
  198. package/uview-plus/components/u-textarea/_doc/package.json +86 -0
  199. package/uview-plus/components/u-textarea/_doc/readme.md +25 -0
  200. package/uview-plus/components/u-transition/_doc/changelog.md +14 -0
  201. package/uview-plus/components/u-transition/_doc/package.json +86 -0
  202. package/uview-plus/components/u-transition/_doc/readme.md +16 -0
  203. package/uview-plus/components/u-transition-wu/createAnimation.js +148 -0
  204. package/uview-plus/components/u-transition-wu/props.js +32 -0
  205. package/uview-plus/components/u-transition-wu/u-transition.vue +300 -0
  206. package/uview-plus/components/u-verification-code/u-verification-code.vue +161 -0
  207. package/uview-plus/index.js +107 -94
  208. package/uview-plus/libs/config/config.js +46 -48
  209. package/uview-plus/libs/css/color.scss +32 -311
  210. package/uview-plus/libs/css/components-wu.scss +30 -0
  211. package/uview-plus/libs/css/vue.scss +10 -10
  212. package/uview-plus/libs/function/calc.js +61 -55
  213. package/uview-plus/libs/function/cc.js +66 -0
  214. package/uview-plus/libs/function/color/color-convert/CHANGELOG.md +54 -0
  215. package/uview-plus/libs/function/color/color-convert/LICENSE +21 -0
  216. package/uview-plus/libs/function/color/color-convert/README.md +68 -0
  217. package/uview-plus/libs/function/color/color-convert/conversions.js +839 -0
  218. package/uview-plus/libs/function/color/color-convert/index.js +81 -0
  219. package/uview-plus/libs/function/color/color-convert/package.json +48 -0
  220. package/uview-plus/libs/function/color/color-convert/route.js +97 -0
  221. package/uview-plus/libs/function/color/color-name/LICENSE +8 -0
  222. package/uview-plus/libs/function/color/color-name/README.md +11 -0
  223. package/uview-plus/libs/function/color/color-name/index.js +152 -0
  224. package/uview-plus/libs/function/color/color-name/package.json +28 -0
  225. package/uview-plus/libs/function/color/color-string/LICENSE +21 -0
  226. package/uview-plus/libs/function/color/color-string/README.md +62 -0
  227. package/uview-plus/libs/function/color/color-string/index.js +244 -0
  228. package/uview-plus/libs/function/color/color-string/package.json +39 -0
  229. package/uview-plus/libs/function/color/color.js +496 -0
  230. package/uview-plus/libs/function/color/index.js +158 -0
  231. package/uview-plus/libs/function/color/is-arrayish/LICENSE +21 -0
  232. package/uview-plus/libs/function/color/is-arrayish/README.md +16 -0
  233. package/uview-plus/libs/function/color/is-arrayish/index.js +9 -0
  234. package/uview-plus/libs/function/color/is-arrayish/package.json +45 -0
  235. package/uview-plus/libs/function/color/is-arrayish/yarn-error.log +1443 -0
  236. package/uview-plus/libs/function/color/simple-swizzle/LICENSE +21 -0
  237. package/uview-plus/libs/function/color/simple-swizzle/README.md +39 -0
  238. package/uview-plus/libs/function/color/simple-swizzle/index.js +29 -0
  239. package/uview-plus/libs/function/color/simple-swizzle/package.json +36 -0
  240. package/uview-plus/libs/function/colorGradient.js +108 -106
  241. package/uview-plus/libs/function/debounce.js +17 -17
  242. package/uview-plus/libs/function/digit.js +1 -3
  243. package/uview-plus/libs/function/http.js +3 -3
  244. package/uview-plus/libs/function/index-wu.js +231 -0
  245. package/uview-plus/libs/function/index.js +579 -566
  246. package/uview-plus/libs/function/platform.js +18 -18
  247. package/uview-plus/libs/function/test.js +135 -137
  248. package/uview-plus/libs/function/throttle.js +17 -17
  249. package/uview-plus/libs/luch-request/core/Request.js +199 -199
  250. package/uview-plus/libs/mixin/mpMixin.js +1 -0
  251. package/uview-plus/libs/mixin/openType.js +33 -0
  252. package/uview-plus/libs/util/async-validator.js +1343 -1343
  253. package/uview-plus/libs/util/dayjs.js +404 -0
  254. package/uview-plus/libs/util/route.js +101 -105
  255. package/uview-plus/package-wu-tool.json +84 -0
  256. package/uview-plus/package-wu.json +112 -0
  257. package/uview-plus/package.json +106 -95
  258. package/uview-plus/readme-wu.md +148 -0
  259. package/uview-ui/index.js +51 -52
  260. package/plugins/uni-upgrade.js +0 -294
@@ -0,0 +1,1058 @@
1
+ <template>
2
+ <view class="fui-container" @touchmove.stop.prevent="stop">
3
+ <view class="fui-image-cropper" @touchend="cutTouchEnd" @touchstart="cutTouchStart" @touchmove="cutTouchMove">
4
+ <view class="fui-content">
5
+ <view
6
+ class="fui-content-top fui-bg-transparent"
7
+ :style="{ height: cutY + 'px', transitionProperty: cutAnimation ? '' : 'background' }"
8
+ ></view>
9
+ <view class="fui-content-middle" :style="{ height: canvasHeight + 'px' }">
10
+ <view
11
+ class="fui-bg-transparent"
12
+ :style="{ width: cutX + 'px', transitionProperty: cutAnimation ? '' : 'background' }"
13
+ ></view>
14
+ <view
15
+ class="fui-cropper-box"
16
+ :style="{
17
+ width: canvasWidth + 'px',
18
+ height: canvasHeight + 'px',
19
+ borderColor: borderColor,
20
+ transitionProperty: cutAnimation ? '' : 'background'
21
+ }"
22
+ >
23
+ <view
24
+ v-for="(item, index) in 4"
25
+ :key="index"
26
+ class="fui-edge"
27
+ :class="[`fui-${index < 2 ? 'top' : 'bottom'}-${index === 0 || index === 2 ? 'left' : 'right'}`]"
28
+ :style="{
29
+ width: edgeWidth,
30
+ height: edgeWidth,
31
+ borderColor: edgeColor,
32
+ borderWidth: edgeBorderWidth,
33
+ left: index === 0 || index === 2 ? `-${edgeOffsets}` : 'auto',
34
+ right: index === 1 || index === 3 ? `-${edgeOffsets}` : 'auto',
35
+ top: index < 2 ? `-${edgeOffsets}` : 'auto',
36
+ bottom: index > 1 ? `-${edgeOffsets}` : 'auto'
37
+ }"
38
+ ></view>
39
+ </view>
40
+ <view class="fui-flex-auto fui-bg-transparent" :style="{ transitionProperty: cutAnimation ? '' : 'background' }"></view>
41
+ </view>
42
+ <view class="fui-flex-auto fui-bg-transparent" :style="{ transitionProperty: cutAnimation ? '' : 'background' }"></view>
43
+ </view>
44
+ <image
45
+ @load="imageLoad"
46
+ @error="imageLoad"
47
+ @touchstart="start"
48
+ @touchmove="move"
49
+ @touchend="end"
50
+ :style="{
51
+ width: imgWidth ? imgWidth + 'px' : 'auto',
52
+ height: imgHeight ? imgHeight + 'px' : 'auto',
53
+ transform: imgTransform,
54
+ transitionDuration: (cutAnimation ? 0.35 : 0) + 's'
55
+ }"
56
+ class="fui-cropper-image"
57
+ :src="imageUrl"
58
+ v-if="imageUrl"
59
+ mode="widthFix"
60
+ ></image>
61
+ </view>
62
+ <canvas
63
+ canvas-id="fui-image-cropper"
64
+ id="fui-image-cropper"
65
+ :disable-scroll="true"
66
+ :style="{ width: CROPPER_WIDTH * scaleRatio + 'px', height: CROPPER_HEIGHT * scaleRatio + 'px' }"
67
+ class="fui-cropper-canvas"
68
+ ></canvas>
69
+ <view class="fui-cropper-tabbar" v-if="!custom">
70
+ <view class="fui-op-btn" @tap.stop="back">取消</view>
71
+ <image :src="rotateImg" class="fui-rotate-img" @tap="setAngle"></image>
72
+ <view class="fui-op-btn" @tap.stop="getImage">完成</view>
73
+ </view>
74
+ </view>
75
+ </template>
76
+
77
+ <script>
78
+ /**
79
+ * 注意:组件中使用的图片地址,将文件复制到自己项目中
80
+ * 如果图片位置与组件同级,编译成小程序时图片会丢失
81
+ * 拷贝static下整个components文件夹
82
+ *也可直接转成base64(不建议)
83
+ * */
84
+ export default {
85
+ name: 'fuiImageCropper',
86
+ props: {
87
+ //图片路径
88
+ imageUrl: {
89
+ type: String,
90
+ default: ''
91
+ },
92
+ /*
93
+ 默认正方形,可修改大小控制比例
94
+ 裁剪框高度 px
95
+ */
96
+ height: {
97
+ type: Number,
98
+ default: 280
99
+ },
100
+ //裁剪框宽度 px
101
+ width: {
102
+ type: Number,
103
+ default: 280
104
+ },
105
+ //裁剪框最小宽度 px
106
+ minWidth: {
107
+ type: Number,
108
+ default: 100
109
+ },
110
+ //裁剪框最小高度 px
111
+ minHeight: {
112
+ type: Number,
113
+ default: 100
114
+ },
115
+ //裁剪框最大宽度 px
116
+ maxWidth: {
117
+ type: Number,
118
+ default: 360
119
+ },
120
+ //裁剪框最大高度 px
121
+ maxHeight: {
122
+ type: Number,
123
+ default: 360
124
+ },
125
+ //裁剪框border颜色
126
+ borderColor: {
127
+ type: String,
128
+ default: 'rgba(255,255,255,0.1)'
129
+ },
130
+ //裁剪框边缘线颜色
131
+ edgeColor: {
132
+ type: String,
133
+ default: '#FFFFFF'
134
+ },
135
+ //裁剪框边缘线宽度 w=h
136
+ edgeWidth: {
137
+ type: String,
138
+ default: '34rpx'
139
+ },
140
+ //裁剪框边缘线border宽度
141
+ edgeBorderWidth: {
142
+ type: String,
143
+ default: '6rpx'
144
+ },
145
+ //偏移距离,根据edgeBorderWidth进行调整
146
+ edgeOffsets: {
147
+ type: String,
148
+ default: '6rpx'
149
+ },
150
+ /**
151
+ * 如果宽度和高度都为true则裁剪框禁止拖动
152
+ * 裁剪框宽度锁定
153
+ */
154
+ lockWidth: {
155
+ type: Boolean,
156
+ default: false
157
+ },
158
+ //裁剪框高度锁定
159
+ lockHeight: {
160
+ type: Boolean,
161
+ default: false
162
+ },
163
+ //锁定裁剪框比例(放大或缩小)
164
+ lockRatio: {
165
+ type: Boolean,
166
+ default: false
167
+ },
168
+ //生成的图片尺寸相对剪裁框的比例
169
+ scaleRatio: {
170
+ type: Number,
171
+ default: 2
172
+ },
173
+ //图片的质量,取值范围为 (0, 1],不在范围内时当作1.0处理
174
+ quality: {
175
+ type: Number,
176
+ default: 0.8
177
+ },
178
+ //图片旋转角度
179
+ rotateAngle: {
180
+ type: Number,
181
+ default: 0
182
+ },
183
+ //图片最小缩放比
184
+ minScale: {
185
+ type: Number,
186
+ default: 0.5
187
+ },
188
+ //图片最大缩放比
189
+ maxScale: {
190
+ type: Number,
191
+ default: 2
192
+ },
193
+ //是否禁用触摸旋转(为false则可以触摸转动图片,limitMove为false生效)
194
+ disableRotate: {
195
+ type: Boolean,
196
+ default: true
197
+ },
198
+ //是否限制移动范围(剪裁框只能在图片内,为true不可触摸转动图片)
199
+ limitMove: {
200
+ type: Boolean,
201
+ default: true
202
+ },
203
+ //自定义操作栏(为true时隐藏底部操作栏)
204
+ custom: {
205
+ type: Boolean,
206
+ default: false
207
+ },
208
+ //值发生改变开始裁剪(custom为true时生效)
209
+ startCutting: {
210
+ type: [Number, Boolean],
211
+ default: 0
212
+ },
213
+ /**
214
+ * 是否返回base64(H5端默认base64)
215
+ * 支持平台:App,微信小程序,支付宝小程序,H5(默认url就是base64)
216
+ **/
217
+ isBase64: {
218
+ type: Boolean,
219
+ default: false
220
+ },
221
+ //裁剪时是否显示loadding
222
+ loadding: {
223
+ type: Boolean,
224
+ default: true
225
+ },
226
+ //旋转icon
227
+ rotateImg: {
228
+ type: String,
229
+ default: '/static/components/cropper/img_rotate.png'
230
+ }
231
+ },
232
+ data() {
233
+ return {
234
+ MOVE_THROTTLE: null, //触摸移动节流setTimeout
235
+ MOVE_THROTTLE_FLAG: true, //节流标识
236
+ TIME_CUT_CENTER: null,
237
+ CROPPER_WIDTH: 200, //裁剪框宽
238
+ CROPPER_HEIGHT: 200, //裁剪框高
239
+ CUT_START: null,
240
+ cutX: 0, //画布x轴起点
241
+ cutY: 0, //画布y轴起点0
242
+ touchRelative: [
243
+ {
244
+ x: 0,
245
+ y: 0
246
+ }
247
+ ], //手指或鼠标和图片中心的相对位置
248
+ flagCutTouch: false, //是否是拖动裁剪框
249
+ hypotenuseLength: 0, //双指触摸时斜边长度
250
+ flagEndTouch: false, //是否结束触摸
251
+ canvasWidth: 0,
252
+ canvasHeight: 0,
253
+ imgWidth: 0, //图片宽度
254
+ imgHeight: 0, //图片高度
255
+ scale: 1, //图片缩放比
256
+ angle: 0, //图片旋转角度
257
+ cutAnimation: false, //是否开启图片和裁剪框过渡
258
+ cutAnimationTime: null,
259
+ imgTop: 0, //图片上边距
260
+ imgLeft: 0, //图片左边距
261
+ ctx: null,
262
+ sysInfo: null
263
+ };
264
+ },
265
+ computed: {
266
+ imgTransform() {
267
+ return `translate3d(${this.imgLeft - this.imgWidth / 2}px,${this.imgTop - this.imgHeight / 2}px,0) scale(${
268
+ this.scale
269
+ }) rotate(${this.angle}deg)`;
270
+ }
271
+ },
272
+ watch: {
273
+ imageUrl(val, oldVal) {
274
+ this.imageReset();
275
+ this.showLoading();
276
+ uni.getImageInfo({
277
+ src: val,
278
+ success: (res) => {
279
+ //计算图片尺寸
280
+ this.imgComputeSize(res.width, res.height);
281
+ if (this.limitMove) {
282
+ //限制移动,不留空白处理
283
+ this.imgMarginDetectionScale();
284
+ }
285
+ },
286
+ fail: (err) => {
287
+ this.imgComputeSize();
288
+ if (this.limitMove) {
289
+ this.imgMarginDetectionScale();
290
+ }
291
+ }
292
+ });
293
+ },
294
+ //监听截取框宽高变化
295
+ canvasWidth(val) {
296
+ if (val < this.minWidth) {
297
+ this.canvasWidth = this.minWidth;
298
+ }
299
+ this.computeCutSize();
300
+ },
301
+ canvasHeight(val) {
302
+ if (val < this.minHeight) {
303
+ this.canvasHeight = this.minHeight;
304
+ }
305
+ this.computeCutSize();
306
+ },
307
+ rotateAngle(val) {
308
+ this.cutAnimation = true;
309
+ this.angle = val;
310
+ },
311
+ angle(val) {
312
+ this.moveStop();
313
+ if (this.limitMove && val % 90) {
314
+ this.angle = Math.round(val / 90) * 90;
315
+ }
316
+ this.imgMarginDetectionScale();
317
+ },
318
+ cutAnimation(val) {
319
+ //开启过渡260毫秒之后自动关闭
320
+ clearTimeout(this.cutAnimationTime);
321
+ if (val) {
322
+ this.cutAnimationTime = setTimeout(() => {
323
+ this.cutAnimation = false;
324
+ }, 260);
325
+ }
326
+ },
327
+ limitMove(val) {
328
+ if (val) {
329
+ if (this.angle % 90) {
330
+ this.angle = Math.round(this.angle / 90) * 90;
331
+ }
332
+ this.imgMarginDetectionScale();
333
+ }
334
+ },
335
+ cutY(value) {
336
+ this.cutDetectionPosition();
337
+ },
338
+ cutX(value) {
339
+ this.cutDetectionPosition();
340
+ },
341
+ startCutting(val) {
342
+ if (this.custom && val) {
343
+ this.getImage();
344
+ }
345
+ }
346
+ },
347
+ mounted() {
348
+ this.sysInfo = uni.getSystemInfoSync();
349
+ this.imgTop = this.sysInfo.windowHeight / 2;
350
+ this.imgLeft = this.sysInfo.windowWidth / 2;
351
+ this.CROPPER_WIDTH = this.width;
352
+ this.CROPPER_HEIGHT = this.height;
353
+ this.canvasHeight = this.height;
354
+ this.canvasWidth = this.width;
355
+ this.ctx = uni.createCanvasContext('fui-image-cropper', this);
356
+ this.setCutCenter();
357
+ //设置裁剪框大小>设置图片尺寸>绘制canvas
358
+ this.computeCutSize();
359
+ //检查裁剪框是否在范围内
360
+ this.cutDetectionPosition();
361
+ setTimeout(() => {
362
+ this.$emit('ready', {});
363
+ }, 200);
364
+ },
365
+ methods: {
366
+ //返回裁剪后图片信息
367
+ getImage() {
368
+ if (!this.imageUrl) {
369
+ uni.showToast({
370
+ title: '请选择图片',
371
+ icon: 'none'
372
+ });
373
+ return;
374
+ }
375
+ this.loadding && this.showLoading();
376
+ let draw = () => {
377
+ //图片实际大小
378
+ let imgWidth = this.imgWidth * this.scale * this.scaleRatio;
379
+ let imgHeight = this.imgHeight * this.scale * this.scaleRatio;
380
+ //canvas和图片的相对距离
381
+ let xpos = this.imgLeft - this.cutX;
382
+ let ypos = this.imgTop - this.cutY;
383
+ //旋转画布
384
+ this.ctx.translate(xpos * this.scaleRatio, ypos * this.scaleRatio);
385
+ this.ctx.rotate((this.angle * Math.PI) / 180);
386
+ this.ctx.drawImage(this.imageUrl, -imgWidth / 2, -imgHeight / 2, imgWidth, imgHeight);
387
+ this.ctx.draw(false, () => {
388
+ let params = {
389
+ width: this.canvasWidth * this.scaleRatio,
390
+ height: Math.round(this.canvasHeight * this.scaleRatio),
391
+ destWidth: this.canvasWidth * this.scaleRatio,
392
+ destHeight: Math.round(this.canvasHeight) * this.scaleRatio,
393
+ fileType: 'png',
394
+ quality: this.quality
395
+ };
396
+ let data = {
397
+ url: '',
398
+ base64: '',
399
+ width: this.canvasWidth * this.scaleRatio,
400
+ height: this.canvasHeight * this.scaleRatio
401
+ };
402
+ // #ifdef MP-ALIPAY
403
+
404
+ if (this.isBase64) {
405
+ this.ctx.toDataURL(params).then((dataURL) => {
406
+ data.base64 = dataURL;
407
+ this.loadding && uni.hideLoading();
408
+ this.$emit('cropper', data);
409
+ });
410
+ } else {
411
+ this.ctx.toTempFilePath({
412
+ ...params,
413
+ success: (res) => {
414
+ data.url = res.tempFilePath;
415
+ this.loadding && uni.hideLoading();
416
+ this.$emit('cropper', data);
417
+ }
418
+ });
419
+ }
420
+ // #endif
421
+
422
+ // #ifndef MP-ALIPAY
423
+ // #ifdef MP-BAIDU || MP-TOUTIAO || H5
424
+ this.isBase64 = false;
425
+ // #endif
426
+ if (this.isBase64) {
427
+ uni.canvasGetImageData({
428
+ canvasId: 'fui-image-cropper',
429
+ x: 0,
430
+ y: 0,
431
+ width: this.canvasWidth * this.scaleRatio,
432
+ height: Math.round(this.canvasHeight * this.scaleRatio),
433
+ success: (res) => {
434
+ const arrayBuffer = new Uint8Array(res.data);
435
+ const base64 = uni.arrayBufferToBase64(arrayBuffer);
436
+ data.base64 = base64;
437
+ this.loadding && uni.hideLoading();
438
+ this.$emit('cropper', data);
439
+ }
440
+ });
441
+ } else {
442
+ uni.canvasToTempFilePath(
443
+ {
444
+ ...params,
445
+ canvasId: 'fui-image-cropper',
446
+ success: (res) => {
447
+ data.url = res.tempFilePath;
448
+ // #ifdef H5
449
+ data.base64 = res.tempFilePath;
450
+ // #endif
451
+ this.loadding && uni.hideLoading();
452
+ this.$emit('cropper', data);
453
+ },
454
+ fail(res) {
455
+ console.log(res);
456
+ }
457
+ },
458
+ this
459
+ );
460
+ }
461
+ // #endif
462
+ });
463
+ };
464
+ if (this.CROPPER_WIDTH != this.canvasWidth || this.CROPPER_HEIGHT != this.canvasHeight) {
465
+ this.CROPPER_WIDTH = this.canvasWidth;
466
+ this.CROPPER_HEIGHT = this.canvasHeight;
467
+ this.ctx.draw();
468
+ this.$nextTick(() => {
469
+ setTimeout(() => {
470
+ draw();
471
+ }, 100);
472
+ });
473
+ } else {
474
+ draw();
475
+ }
476
+ },
477
+ /**
478
+ * 设置剪裁框和图片居中
479
+ */
480
+ setCutCenter() {
481
+ let sys = this.sysInfo || uni.getSystemInfoSync();
482
+ let cutY = (sys.windowHeight - this.canvasHeight) * 0.5;
483
+ let cutX = (sys.windowWidth - this.canvasWidth) * 0.5;
484
+ //顺序不能变
485
+ this.imgTop = this.imgTop - this.cutY + cutY;
486
+ this.cutY = cutY; //截取的框上边距
487
+ this.imgLeft = this.imgLeft - this.cutX + cutX;
488
+ this.cutX = cutX; //截取的框左边距
489
+ },
490
+ imageReset() {
491
+ // this.cutAnimation = true;
492
+ this.scale = 1;
493
+ this.angle = 0;
494
+ let sys = this.sysInfo || uni.getSystemInfoSync();
495
+ this.imgTop = sys.windowHeight / 2;
496
+ this.imgLeft = sys.windowWidth / 2;
497
+ },
498
+ imageLoad(e) {
499
+ this.imageReset();
500
+ uni.hideLoading();
501
+ this.$emit('imageLoad', {});
502
+ },
503
+ //检测剪裁框位置是否在允许的范围内(屏幕内)
504
+ cutDetectionPosition() {
505
+ let cutDetectionPositionTop = () => {
506
+ //检测上边距是否在范围内
507
+ if (this.cutY < 0) {
508
+ this.cutY = 0;
509
+ }
510
+ if (this.cutY > this.sysInfo.windowHeight - this.canvasHeight) {
511
+ this.cutY = this.sysInfo.windowHeight - this.canvasHeight;
512
+ }
513
+ },
514
+ cutDetectionPositionLeft = () => {
515
+ //检测左边距是否在范围内
516
+ if (this.cutX < 0) {
517
+ this.cutX = 0;
518
+ }
519
+ if (this.cutX > this.sysInfo.windowWidth - this.canvasWidth) {
520
+ this.cutX = this.sysInfo.windowWidth - this.canvasWidth;
521
+ }
522
+ };
523
+ //裁剪框坐标处理(如果只写一个参数则另一个默认为0,都不写默认居中)
524
+ if (this.cutY == null && this.cutX == null) {
525
+ let cutY = (this.sysInfo.windowHeight - this.canvasHeight) * 0.5;
526
+ let cutX = (this.sysInfo.windowWidth - this.canvasWidth) * 0.5;
527
+ this.cutY = cutY; //截取的框上边距
528
+ this.cutX = cutX; //截取的框左边距
529
+ } else if (this.cutY != null && this.cutX != null) {
530
+ cutDetectionPositionTop();
531
+ cutDetectionPositionLeft();
532
+ } else if (this.cutY != null && this.cutX == null) {
533
+ cutDetectionPositionTop();
534
+ this.cutX = (this.sysInfo.windowWidth - this.canvasWidth) / 2;
535
+ } else if (this.cutY == null && this.cutX != null) {
536
+ cutDetectionPositionLeft();
537
+ this.cutY = (this.sysInfo.windowHeight - this.canvasHeight) / 2;
538
+ }
539
+ },
540
+ /**
541
+ * 图片边缘检测-位置
542
+ */
543
+ imgMarginDetectionPosition(scale) {
544
+ if (!this.limitMove) return;
545
+ let left = this.imgLeft;
546
+ let top = this.imgTop;
547
+ scale = scale || this.scale;
548
+ let imgWidth = this.imgWidth;
549
+ let imgHeight = this.imgHeight;
550
+ if ((this.angle / 90) % 2) {
551
+ imgWidth = this.imgHeight;
552
+ imgHeight = this.imgWidth;
553
+ }
554
+ left = this.cutX + (imgWidth * scale) / 2 >= left ? left : this.cutX + (imgWidth * scale) / 2;
555
+ left =
556
+ this.cutX + this.canvasWidth - (imgWidth * scale) / 2 <= left
557
+ ? left
558
+ : this.cutX + this.canvasWidth - (imgWidth * scale) / 2;
559
+ top = this.cutY + (imgHeight * scale) / 2 >= top ? top : this.cutY + (imgHeight * scale) / 2;
560
+ top =
561
+ this.cutY + this.canvasHeight - (imgHeight * scale) / 2 <= top
562
+ ? top
563
+ : this.cutY + this.canvasHeight - (imgHeight * scale) / 2;
564
+ this.imgLeft = left;
565
+ this.imgTop = top;
566
+ this.scale = scale;
567
+ },
568
+ /**
569
+ * 图片边缘检测-缩放
570
+ */
571
+ imgMarginDetectionScale(scale) {
572
+ if (!this.limitMove) return;
573
+ scale = scale || this.scale;
574
+ let imgWidth = this.imgWidth;
575
+ let imgHeight = this.imgHeight;
576
+ if ((this.angle / 90) % 2) {
577
+ imgWidth = this.imgHeight;
578
+ imgHeight = this.imgWidth;
579
+ }
580
+ if (imgWidth * scale < this.canvasWidth) {
581
+ scale = this.canvasWidth / imgWidth;
582
+ }
583
+ if (imgHeight * scale < this.canvasHeight) {
584
+ scale = Math.max(scale, this.canvasHeight / imgHeight);
585
+ }
586
+ this.imgMarginDetectionPosition(scale);
587
+ },
588
+ /**
589
+ * 计算图片尺寸
590
+ */
591
+ imgComputeSize(width, height) {
592
+ //默认按图片最小边 = 对应裁剪框尺寸
593
+ let imgWidth = width,
594
+ imgHeight = height;
595
+ if (imgWidth && imgHeight) {
596
+ if (imgWidth / imgHeight > (this.canvasWidth || this.width) / (this.canvasHeight || this.height)) {
597
+ imgHeight = this.canvasHeight || this.height;
598
+ imgWidth = (width / height) * imgHeight;
599
+ } else {
600
+ imgWidth = this.canvasWidth || this.width;
601
+ imgHeight = (height / width) * imgWidth;
602
+ }
603
+ } else {
604
+ let sys = this.sysInfo || uni.getSystemInfoSync();
605
+ imgWidth = sys.windowWidth;
606
+ imgHeight = 0;
607
+ }
608
+ this.imgWidth = imgWidth;
609
+ this.imgHeight = imgHeight;
610
+ },
611
+ //改变截取框大小
612
+ computeCutSize() {
613
+ if (this.canvasWidth > this.sysInfo.windowWidth) {
614
+ this.canvasWidth = this.sysInfo.windowWidth;
615
+ } else if (this.canvasWidth + this.cutX > this.sysInfo.windowWidth) {
616
+ this.cutX = this.sysInfo.windowWidth - this.cutX;
617
+ }
618
+ if (this.canvasHeight > this.sysInfo.windowHeight) {
619
+ this.canvasHeight = this.sysInfo.windowHeight;
620
+ } else if (this.canvasHeight + this.cutY > this.sysInfo.windowHeight) {
621
+ this.cutY = this.sysInfo.windowHeight - this.cutY;
622
+ }
623
+ },
624
+ //开始触摸
625
+ start(e) {
626
+ this.flagEndTouch = false;
627
+ if (e.touches.length == 1) {
628
+ //单指拖动
629
+ this.touchRelative[0] = {
630
+ x: e.touches[0].clientX - this.imgLeft,
631
+ y: e.touches[0].clientY - this.imgTop
632
+ };
633
+ } else {
634
+ //双指放大
635
+ let width = Math.abs(e.touches[0].clientX - e.touches[1].clientX);
636
+ let height = Math.abs(e.touches[0].clientY - e.touches[1].clientY);
637
+ this.touchRelative = [
638
+ {
639
+ x: e.touches[0].clientX - this.imgLeft,
640
+ y: e.touches[0].clientY - this.imgTop
641
+ },
642
+ {
643
+ x: e.touches[1].clientX - this.imgLeft,
644
+ y: e.touches[1].clientY - this.imgTop
645
+ }
646
+ ];
647
+ this.hypotenuseLength = Math.sqrt(Math.pow(width, 2) + Math.pow(height, 2));
648
+ }
649
+ },
650
+ moveThrottle() {
651
+ if (this.sysInfo.platform == 'android') {
652
+ clearTimeout(this.MOVE_THROTTLE);
653
+ this.MOVE_THROTTLE = setTimeout(() => {
654
+ this.MOVE_THROTTLE_FLAG = true;
655
+ }, 800 / 40);
656
+ return this.MOVE_THROTTLE_FLAG;
657
+ } else {
658
+ this.MOVE_THROTTLE_FLAG = true;
659
+ }
660
+ },
661
+ move(e) {
662
+ if (this.flagEndTouch || !this.MOVE_THROTTLE_FLAG) return;
663
+ this.MOVE_THROTTLE_FLAG = false;
664
+ this.moveThrottle();
665
+ this.moveDuring();
666
+ if (e.touches.length == 1) {
667
+ //单指拖动
668
+ let left = e.touches[0].clientX - this.touchRelative[0].x,
669
+ top = e.touches[0].clientY - this.touchRelative[0].y;
670
+ //图像边缘检测,防止截取到空白
671
+ this.imgLeft = left;
672
+ this.imgTop = top;
673
+ this.imgMarginDetectionPosition();
674
+ } else {
675
+ //双指放大
676
+ let width = Math.abs(e.touches[0].clientX - e.touches[1].clientX),
677
+ height = Math.abs(e.touches[0].clientY - e.touches[1].clientY),
678
+ hypotenuse = Math.sqrt(Math.pow(width, 2) + Math.pow(height, 2)),
679
+ scale = this.scale * (hypotenuse / this.hypotenuseLength),
680
+ current_deg = 0;
681
+ scale = scale <= this.minScale ? this.minScale : scale;
682
+ scale = scale >= this.maxScale ? this.maxScale : scale;
683
+ //图像边缘检测,防止截取到空白
684
+ // this.scale = scale;
685
+ this.imgMarginDetectionScale(scale);
686
+ //双指旋转(如果没禁用旋转)
687
+ let touchRelative = [
688
+ {
689
+ x: e.touches[0].clientX - this.imgLeft,
690
+ y: e.touches[0].clientY - this.imgTop
691
+ },
692
+ {
693
+ x: e.touches[1].clientX - this.imgLeft,
694
+ y: e.touches[1].clientY - this.imgTop
695
+ }
696
+ ];
697
+ if (!this.disableRotate) {
698
+ let first_atan = (180 / Math.PI) * Math.atan2(touchRelative[0].y, touchRelative[0].x);
699
+ let first_atan_old = (180 / Math.PI) * Math.atan2(this.touchRelative[0].y, this.touchRelative[0].x);
700
+ let second_atan = (180 / Math.PI) * Math.atan2(touchRelative[1].y, touchRelative[1].x);
701
+ let second_atan_old = (180 / Math.PI) * Math.atan2(this.touchRelative[1].y, this.touchRelative[1].x);
702
+ //当前旋转的角度
703
+ let first_deg = first_atan - first_atan_old,
704
+ second_deg = second_atan - second_atan_old;
705
+ if (first_deg != 0) {
706
+ current_deg = first_deg;
707
+ } else if (second_deg != 0) {
708
+ current_deg = second_deg;
709
+ }
710
+ }
711
+ this.touchRelative = touchRelative;
712
+ this.hypotenuseLength = Math.sqrt(Math.pow(width, 2) + Math.pow(height, 2));
713
+ //更新视图
714
+ this.angle = this.angle + current_deg;
715
+ this.scale = this.scale;
716
+ }
717
+ },
718
+ //结束操作
719
+ end(e) {
720
+ this.flagEndTouch = true;
721
+ this.moveStop();
722
+ },
723
+ //裁剪框处理
724
+ cutTouchMove(e) {
725
+ if (this.flagCutTouch && this.MOVE_THROTTLE_FLAG) {
726
+ if (this.lockRatio && (this.lockWidth || this.lockHeight)) return;
727
+ //节流
728
+ this.MOVE_THROTTLE_FLAG = false;
729
+ this.moveThrottle();
730
+ let width = this.canvasWidth,
731
+ height = this.canvasHeight,
732
+ cutY = this.cutY,
733
+ cutX = this.cutX,
734
+ size_correct = () => {
735
+ width = width <= this.maxWidth ? (width >= this.minWidth ? width : this.minWidth) : this.maxWidth;
736
+ height = height <= this.maxHeight ? (height >= this.minHeight ? height : this.minHeight) : this.maxHeight;
737
+ },
738
+ size_inspect = () => {
739
+ if (
740
+ (width > this.maxWidth || width < this.minWidth || height > this.maxHeight || height < this.minHeight) &&
741
+ this.lockRatio
742
+ ) {
743
+ size_correct();
744
+ return false;
745
+ } else {
746
+ size_correct();
747
+ return true;
748
+ }
749
+ };
750
+ height =
751
+ this.CUT_START.height +
752
+ (this.CUT_START.corner > 1 && this.CUT_START.corner < 4 ? 1 : -1) * (this.CUT_START.y - e.touches[0].clientY);
753
+ switch (this.CUT_START.corner) {
754
+ case 1:
755
+ width = this.CUT_START.width - this.CUT_START.x + e.touches[0].clientX;
756
+ if (this.lockRatio) {
757
+ height = width / (this.canvasWidth / this.canvasHeight);
758
+ }
759
+ if (!size_inspect()) return;
760
+ break;
761
+ case 2:
762
+ width = this.CUT_START.width - this.CUT_START.x + e.touches[0].clientX;
763
+ if (this.lockRatio) {
764
+ height = width / (this.canvasWidth / this.canvasHeight);
765
+ }
766
+ if (!size_inspect()) return;
767
+ cutY = this.CUT_START.cutY - (height - this.CUT_START.height);
768
+ break;
769
+ case 3:
770
+ width = this.CUT_START.width + this.CUT_START.x - e.touches[0].clientX;
771
+ if (this.lockRatio) {
772
+ height = width / (this.canvasWidth / this.canvasHeight);
773
+ }
774
+ if (!size_inspect()) return;
775
+ cutY = this.CUT_START.cutY - (height - this.CUT_START.height);
776
+ cutX = this.CUT_START.cutX - (width - this.CUT_START.width);
777
+ break;
778
+ case 4:
779
+ width = this.CUT_START.width + this.CUT_START.x - e.touches[0].clientX;
780
+ if (this.lockRatio) {
781
+ height = width / (this.canvasWidth / this.canvasHeight);
782
+ }
783
+ if (!size_inspect()) return;
784
+ cutX = this.CUT_START.cutX - (width - this.CUT_START.width);
785
+ break;
786
+ default:
787
+ break;
788
+ }
789
+ if (!this.lockWidth && !this.lockHeight) {
790
+ this.canvasWidth = width;
791
+ this.cutX = cutX;
792
+ this.canvasHeight = height;
793
+ this.cutY = cutY;
794
+ } else if (!this.lockWidth) {
795
+ this.canvasWidth = width;
796
+ this.cutX = cutX;
797
+ } else if (!this.lockHeight) {
798
+ this.canvasHeight = height;
799
+ this.cutY = cutY;
800
+ }
801
+ this.imgMarginDetectionScale();
802
+ }
803
+ },
804
+ cutTouchStart(e) {
805
+ let currentX = e.touches[0].clientX;
806
+ let currentY = e.touches[0].clientY;
807
+
808
+ /*
809
+ * (右下-1 右上-2 左上-3 左下-4)
810
+ * left_x [3,4]
811
+ * top_y [2,3]
812
+ * right_x [1,2]
813
+ * bottom_y [1,4]
814
+ */
815
+ let left_x1 = this.cutX - 24;
816
+ let left_x2 = this.cutX + 24;
817
+
818
+ let top_y1 = this.cutY - 24;
819
+ let top_y2 = this.cutY + 24;
820
+
821
+ let right_x1 = this.cutX + this.canvasWidth - 24;
822
+ let right_x2 = this.cutX + this.canvasWidth + 24;
823
+
824
+ let bottom_y1 = this.cutY + this.canvasHeight - 24;
825
+ let bottom_y2 = this.cutY + this.canvasHeight + 24;
826
+
827
+ if (currentX > right_x1 && currentX < right_x2 && currentY > bottom_y1 && currentY < bottom_y2) {
828
+ this.moveDuring();
829
+ this.flagCutTouch = true;
830
+ this.flagEndTouch = true;
831
+ this.CUT_START = {
832
+ width: this.canvasWidth,
833
+ height: this.canvasHeight,
834
+ x: currentX,
835
+ y: currentY,
836
+ corner: 1
837
+ };
838
+ } else if (currentX > right_x1 && currentX < right_x2 && currentY > top_y1 && currentY < top_y2) {
839
+ this.moveDuring();
840
+ this.flagCutTouch = true;
841
+ this.flagEndTouch = true;
842
+ this.CUT_START = {
843
+ width: this.canvasWidth,
844
+ height: this.canvasHeight,
845
+ x: currentX,
846
+ y: currentY,
847
+ cutY: this.cutY,
848
+ cutX: this.cutX,
849
+ corner: 2
850
+ };
851
+ } else if (currentX > left_x1 && currentX < left_x2 && currentY > top_y1 && currentY < top_y2) {
852
+ this.moveDuring();
853
+ this.flagCutTouch = true;
854
+ this.flagEndTouch = true;
855
+ this.CUT_START = {
856
+ width: this.canvasWidth,
857
+ height: this.canvasHeight,
858
+ cutY: this.cutY,
859
+ cutX: this.cutX,
860
+ x: currentX,
861
+ y: currentY,
862
+ corner: 3
863
+ };
864
+ } else if (currentX > left_x1 && currentX < left_x2 && currentY > bottom_y1 && currentY < bottom_y2) {
865
+ this.moveDuring();
866
+ this.flagCutTouch = true;
867
+ this.flagEndTouch = true;
868
+ this.CUT_START = {
869
+ width: this.canvasWidth,
870
+ height: this.canvasHeight,
871
+ cutY: this.cutY,
872
+ cutX: this.cutX,
873
+ x: currentX,
874
+ y: currentY,
875
+ corner: 4
876
+ };
877
+ }
878
+ },
879
+ cutTouchEnd(e) {
880
+ this.moveStop();
881
+ this.flagCutTouch = false;
882
+ },
883
+ //停止移动时需要做的操作
884
+ moveStop() {
885
+ //清空之前的自动居中延迟函数并添加最新的
886
+ clearTimeout(this.TIME_CUT_CENTER);
887
+ this.TIME_CUT_CENTER = setTimeout(() => {
888
+ //动画启动
889
+ if (!this.cutAnimation) {
890
+ this.cutAnimation = true;
891
+ }
892
+ this.setCutCenter();
893
+ }, 800);
894
+ },
895
+ //移动中
896
+ moveDuring() {
897
+ //清空之前的自动居中延迟函数
898
+ clearTimeout(this.TIME_CUT_CENTER);
899
+ },
900
+ showLoading() {
901
+ uni.showLoading({
902
+ title: '请稍候...',
903
+ mask: true
904
+ });
905
+ },
906
+ stop() {},
907
+ back() {
908
+ uni.navigateBack();
909
+ },
910
+ setAngle() {
911
+ this.cutAnimation = true;
912
+ this.angle = this.angle + 90;
913
+ }
914
+ }
915
+ };
916
+ </script>
917
+
918
+ <style scoped>
919
+ .fui-container {
920
+ width: 100vw;
921
+ height: 100vh;
922
+ background-color: rgba(0, 0, 0, 0.6);
923
+ position: fixed;
924
+ top: 0;
925
+ left: 0;
926
+ z-index: 1;
927
+ }
928
+
929
+ .fui-image-cropper {
930
+ width: 100vw;
931
+ height: 100vh;
932
+ position: absolute;
933
+ }
934
+
935
+ .fui-content {
936
+ width: 100vw;
937
+ height: 100vh;
938
+ position: absolute;
939
+ z-index: 9;
940
+ display: flex;
941
+ flex-direction: column;
942
+ pointer-events: none;
943
+ }
944
+
945
+ .fui-bg-transparent {
946
+ background-color: rgba(0, 0, 0, 0.6);
947
+ transition-duration: 0.35s;
948
+ }
949
+
950
+ .fui-content-top {
951
+ pointer-events: none;
952
+ }
953
+
954
+ .fui-content-middle {
955
+ width: 100%;
956
+ height: 200px;
957
+ display: flex;
958
+ box-sizing: border-box;
959
+ }
960
+
961
+ .fui-cropper-box {
962
+ position: relative;
963
+ /* transition-duration: 0.3s; */
964
+ border-style: solid;
965
+ border-width: 1rpx;
966
+ box-sizing: border-box;
967
+ }
968
+
969
+ .fui-flex-auto {
970
+ flex: auto;
971
+ }
972
+
973
+ .fui-cropper-image {
974
+ width: 100%;
975
+ border-style: none;
976
+ position: absolute;
977
+ top: 0;
978
+ left: 0;
979
+ z-index: 2;
980
+ -webkit-backface-visibility: hidden;
981
+ backface-visibility: hidden;
982
+ transform-origin: center;
983
+ }
984
+
985
+ .fui-cropper-canvas {
986
+ position: fixed;
987
+ z-index: 10;
988
+ left: -2000px;
989
+ top: -2000px;
990
+ pointer-events: none;
991
+ }
992
+
993
+ .fui-edge {
994
+ border-style: solid;
995
+ pointer-events: auto;
996
+ position: absolute;
997
+ box-sizing: border-box;
998
+ }
999
+
1000
+ .fui-top-left {
1001
+ border-bottom-width: 0 !important;
1002
+ border-right-width: 0 !important;
1003
+ }
1004
+
1005
+ .fui-top-right {
1006
+ border-bottom-width: 0 !important;
1007
+ border-left-width: 0 !important;
1008
+ }
1009
+
1010
+ .fui-bottom-left {
1011
+ border-top-width: 0 !important;
1012
+ border-right-width: 0 !important;
1013
+ }
1014
+
1015
+ .fui-bottom-right {
1016
+ border-top-width: 0 !important;
1017
+ border-left-width: 0 !important;
1018
+ }
1019
+
1020
+ .fui-cropper-tabbar {
1021
+ width: 100%;
1022
+ height: 120rpx;
1023
+ padding: 0 40rpx;
1024
+ box-sizing: border-box;
1025
+ position: fixed;
1026
+ left: 0;
1027
+ bottom: 0;
1028
+ z-index: 99;
1029
+ display: flex;
1030
+ align-items: center;
1031
+ justify-content: space-between;
1032
+ color: #ffffff;
1033
+ font-size: 32rpx;
1034
+ }
1035
+
1036
+ .fui-cropper-tabbar::after {
1037
+ content: ' ';
1038
+ position: absolute;
1039
+ top: 0;
1040
+ right: 0;
1041
+ left: 0;
1042
+ border-top: 1rpx solid rgba(255, 255, 255, 0.2);
1043
+ -webkit-transform: scaleY(0.5) translateZ(0);
1044
+ transform: scaleY(0.5) translateZ(0);
1045
+ transform-origin: 0 100%;
1046
+ }
1047
+
1048
+ .fui-op-btn {
1049
+ height: 80rpx;
1050
+ display: flex;
1051
+ align-items: center;
1052
+ }
1053
+
1054
+ .fui-rotate-img {
1055
+ width: 44rpx;
1056
+ height: 44rpx;
1057
+ }
1058
+ </style>