uview-plus 3.8.49 → 3.8.86

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 (170) hide show
  1. package/changelog.md +2043 -1827
  2. package/components/u-action-sheet/props.js +3 -1
  3. package/components/u-action-sheet/u-action-sheet.vue +1 -0
  4. package/components/u-album/props.js +3 -1
  5. package/components/u-alert/props.js +4 -2
  6. package/components/u-avatar/props.js +4 -1
  7. package/components/u-avatar-group/props.js +4 -1
  8. package/components/u-back-top/props.js +4 -1
  9. package/components/u-badge/props.js +4 -1
  10. package/components/u-barcode/u-barcode.vue +46 -15
  11. package/components/u-box/props.js +5 -2
  12. package/components/u-button/props.js +4 -1
  13. package/components/u-button/vue.scss +3 -3
  14. package/components/u-calendar/calendar.js +14 -2
  15. package/components/u-calendar/month.vue +41 -6
  16. package/components/u-calendar/props.js +63 -1
  17. package/components/u-calendar/u-calendar.vue +311 -2
  18. package/components/u-calendar-strip/props.js +3 -1
  19. package/components/u-canvas/u-canvas.vue +734 -423
  20. package/components/u-car-keyboard/props.js +3 -1
  21. package/components/u-card/props.js +3 -1
  22. package/components/u-cell/props.js +4 -1
  23. package/components/u-cell/u-cell.vue +1 -1
  24. package/components/u-cell-group/props.js +4 -1
  25. package/components/u-checkbox/props.js +4 -1
  26. package/components/u-checkbox/u-checkbox.vue +7 -3
  27. package/components/u-checkbox-group/props.js +3 -1
  28. package/components/u-circle-progress/props.js +4 -1
  29. package/components/u-code/props.js +4 -1
  30. package/components/u-code-input/props.js +4 -1
  31. package/components/u-col/props.js +4 -1
  32. package/components/u-collapse/props.js +4 -1
  33. package/components/u-collapse-item/props.js +4 -1
  34. package/components/u-color-picker/u-color-picker.vue +1 -0
  35. package/components/u-column-notice/props.js +4 -1
  36. package/components/u-count-down/props.js +4 -1
  37. package/components/u-count-to/props.js +4 -1
  38. package/components/u-cropper/u-cropper.vue +95 -51
  39. package/components/u-datetime-picker/props.js +4 -1
  40. package/components/u-divider/props.js +4 -1
  41. package/components/u-dragsort/u-dragsort.vue +2 -1
  42. package/components/u-dropdown/props.js +3 -1
  43. package/components/u-dropdown-item/props.js +3 -1
  44. package/components/u-empty/props.js +4 -1
  45. package/components/u-form/props.js +4 -1
  46. package/components/u-form-item/props.js +4 -1
  47. package/components/u-gap/props.js +4 -1
  48. package/components/u-grid/props.js +4 -1
  49. package/components/u-grid-item/props.js +4 -1
  50. package/components/u-guide/props.js +3 -1
  51. package/components/u-icon/props.js +4 -1
  52. package/components/u-icon/u-icon.vue +2 -2
  53. package/components/u-icon/upicon.ttf +0 -0
  54. package/components/u-icon/util.js +29 -7
  55. package/components/u-image/props.js +4 -1
  56. package/components/u-image/u-image.vue +280 -267
  57. package/components/u-index-anchor/props.js +4 -1
  58. package/components/u-index-item/props.js +2 -1
  59. package/components/u-index-list/props.js +4 -1
  60. package/components/u-input/props.js +3 -1
  61. package/components/u-input/u-input.vue +10 -1
  62. package/components/u-keyboard/props.js +4 -1
  63. package/components/u-line/props.js +4 -1
  64. package/components/u-line-progress/props.js +6 -3
  65. package/components/u-link/props.js +4 -1
  66. package/components/u-list/props.js +4 -1
  67. package/components/u-list-item/props.js +4 -1
  68. package/components/u-loading-icon/props.js +4 -1
  69. package/components/u-loading-page/props.js +3 -1
  70. package/components/u-loadmore/props.js +4 -1
  71. package/components/u-markdown/u-markdown.vue +45 -3
  72. package/components/u-modal/props.js +4 -1
  73. package/components/u-navbar/props.js +4 -2
  74. package/components/u-navbar/u-navbar.vue +15 -9
  75. package/components/u-no-network/props.js +4 -1
  76. package/components/u-notice-bar/props.js +4 -1
  77. package/components/u-notify/props.js +4 -1
  78. package/components/u-number-box/props.js +4 -1
  79. package/components/u-number-box/u-number-box.vue +2 -2
  80. package/components/u-number-keyboard/props.js +4 -1
  81. package/components/u-overlay/props.js +4 -1
  82. package/components/u-pagination/u-pagination.vue +60 -39
  83. package/components/u-parse/props.js +4 -1
  84. package/components/u-picker/props.js +4 -1
  85. package/components/u-picker/u-picker.vue +15 -0
  86. package/components/u-picker-column/props.js +3 -1
  87. package/components/u-popover/props.js +2 -1
  88. package/components/u-popup/props.js +4 -1
  89. package/components/u-poster/u-poster.vue +29 -14
  90. package/components/u-qrcode/qrcode.js +88 -87
  91. package/components/u-qrcode/u-qrcode.vue +138 -256
  92. package/components/u-radio/props.js +4 -1
  93. package/components/u-radio/u-radio.vue +7 -3
  94. package/components/u-radio-group/props.js +4 -1
  95. package/components/u-rate/props.js +4 -1
  96. package/components/u-read-more/props.js +4 -1
  97. package/components/u-row/props.js +4 -1
  98. package/components/u-row-notice/props.js +4 -1
  99. package/components/u-safe-bottom/props.js +2 -1
  100. package/components/u-scroll-list/props.js +4 -1
  101. package/components/u-search/props.js +3 -1
  102. package/components/u-skeleton/props.js +4 -1
  103. package/components/u-slider/props.js +3 -1
  104. package/components/u-slider/u-slider.vue +70 -28
  105. package/components/u-status-bar/props.js +4 -1
  106. package/components/u-steps/props.js +4 -1
  107. package/components/u-steps-item/props.js +4 -1
  108. package/components/u-sticky/props.js +4 -1
  109. package/components/u-sticky/u-sticky.vue +11 -0
  110. package/components/u-subsection/props.js +3 -1
  111. package/components/u-swipe-action/props.js +4 -1
  112. package/components/u-swipe-action-item/props.js +4 -1
  113. package/components/u-swipe-action-item/u-swipe-action-item.vue +14 -0
  114. package/components/u-swiper/props.js +9 -1
  115. package/components/u-swiper/swiper.js +1 -0
  116. package/components/u-swiper/u-swiper.vue +2 -0
  117. package/components/u-swiper-indicator/props.js +4 -1
  118. package/components/u-switch/props.js +4 -1
  119. package/components/u-tabbar/props.js +3 -1
  120. package/components/u-tabbar-item/props.js +4 -1
  121. package/components/u-table/props.js +3 -1
  122. package/components/u-table2/tableRow.vue +155 -69
  123. package/components/u-table2/u-table2.vue +328 -140
  124. package/components/u-tabs/props.js +4 -1
  125. package/components/u-tabs-item/props.js +3 -1
  126. package/components/u-tag/props.js +4 -1
  127. package/components/u-td/props.js +3 -1
  128. package/components/u-text/props.js +4 -1
  129. package/components/u-textarea/props.js +3 -1
  130. package/components/u-textarea/u-textarea.vue +16 -5
  131. package/components/u-th/props.js +3 -1
  132. package/components/u-toolbar/props.js +4 -1
  133. package/components/u-tooltip/props.js +10 -2
  134. package/components/u-tooltip/tooltip.js +2 -1
  135. package/components/u-tooltip/u-tooltip.vue +31 -3
  136. package/components/u-tr/props.js +3 -1
  137. package/components/u-transition/nvue-ani-map.js +75 -68
  138. package/components/u-transition/props.js +4 -1
  139. package/components/u-transition/transitionMixin.js +164 -163
  140. package/components/u-upload/props.js +4 -1
  141. package/components/u-upload/u-upload.vue +47 -40
  142. package/components/u-waterfall/u-waterfall.vue +50 -51
  143. package/index.js +65 -8
  144. package/libs/config/props.js +179 -204
  145. package/libs/css/components.scss +3 -0
  146. package/libs/function/uni-api-shims.js +29 -0
  147. package/libs/i18n/index.js +71 -36
  148. package/libs/i18n/locale-packs.js +11 -0
  149. package/libs/i18n/locales/all.js +23 -0
  150. package/libs/i18n/locales/{de.json → de.js} +1 -1
  151. package/libs/i18n/locales/{en.json → en.js} +2 -2
  152. package/libs/i18n/locales/{es.json → es.js} +1 -1
  153. package/libs/i18n/locales/{fr.json → fr.js} +2 -2
  154. package/libs/i18n/locales/{ja.json → ja.js} +1 -1
  155. package/libs/i18n/locales/{ko.json → ko.js} +1 -1
  156. package/libs/i18n/locales/{ru.json → ru.js} +1 -1
  157. package/libs/i18n/locales/{th.json → th.js} +1 -1
  158. package/libs/i18n/locales/{zh-Hans.json → zh-Hans.js} +1 -1
  159. package/libs/i18n/locales/{zh-Hant.json → zh-Hant.js} +1 -1
  160. package/libs/mixin/mixin.js +14 -4
  161. package/libs/util/gcanvas/bridge/bridge-weex.js +10 -5
  162. package/package.json +4 -5
  163. package/tsconfig.json +18 -0
  164. package/types/comps/calendar.d.ts +57 -0
  165. package/types/comps/checkbox.d.ts +12 -0
  166. package/types/comps/lineProgress.d.ts +5 -0
  167. package/types/comps/navbar.d.ts +3 -3
  168. package/types/comps/swiper.d.ts +5 -0
  169. package/types/comps/tooltip.d.ts +36 -1
  170. /package/components/u-markdown/{marked.esm.js → marked.esm.mjs} +0 -0
@@ -1,6 +1,8 @@
1
1
  import { defineMixin } from '../../libs/vue'
2
- import defProps from '../../libs/config/props.js'
2
+ import CarKeyboardDefaultProps from './carKeyboard'
3
+ import { registerComponentProps } from '../../libs/config/props.js'
3
4
 
5
+ const defProps = registerComponentProps(CarKeyboardDefaultProps)
4
6
  export const props = defineMixin({
5
7
  props: {
6
8
  // 是否打乱键盘按键的顺序
@@ -1,6 +1,8 @@
1
1
  import { defineMixin } from '../../libs/vue'
2
- import defProps from '../../libs/config/props.js'
2
+ import CardDefaultProps from './card'
3
+ import { registerComponentProps } from '../../libs/config/props.js'
3
4
 
5
+ const defProps = registerComponentProps(CardDefaultProps)
4
6
  export const propsCard = defineMixin({
5
7
  props: {
6
8
  // 与屏幕两侧是否留空隙
@@ -1,5 +1,8 @@
1
1
  import { defineMixin } from '../../libs/vue'
2
- import defProps from '../../libs/config/props.js'
2
+ import CellDefaultProps from './cell'
3
+ import { registerComponentProps } from '../../libs/config/props.js'
4
+
5
+ const defProps = registerComponentProps(CellDefaultProps)
3
6
  export const props = defineMixin({
4
7
  props: {
5
8
  // 标题
@@ -15,7 +15,7 @@
15
15
  <!-- 将slot与默认内容用if/else分开主要是因为微信小程序不支持slot嵌套传递,这样才能解决collapse组件的slot不失效问题,label暂时未用到。 -->
16
16
  <slot name="title" v-if="$slots.title || !title">
17
17
  </slot>
18
- <text v-else class="u-cell__title-text" :style="[titleTextStyle, cellTitleDynamicStyle]"
18
+ <text v-else class="u-cell__title-text" :style="[cellTitleDynamicStyle, titleTextStyle]"
19
19
  :class="[required && 'u-cell--required', disabled && 'u-cell--disabled', size === 'large' && 'u-cell__title-text--large']">{{ title }}</text>
20
20
  <slot name="label">
21
21
  <text class="u-cell__label" v-if="label"
@@ -1,5 +1,8 @@
1
1
  import { defineMixin } from '../../libs/vue'
2
- import defProps from '../../libs/config/props.js'
2
+ import CellGroupDefaultProps from './cellGroup'
3
+ import { registerComponentProps } from '../../libs/config/props.js'
4
+
5
+ const defProps = registerComponentProps(CellGroupDefaultProps)
3
6
  export const props = defineMixin({
4
7
  props: {
5
8
  // 分组标题
@@ -1,5 +1,8 @@
1
1
  import { defineMixin } from '../../libs/vue'
2
- import defProps from '../../libs/config/props.js'
2
+ import CheckboxDefaultProps from './checkbox'
3
+ import { registerComponentProps } from '../../libs/config/props.js'
4
+
5
+ const defProps = registerComponentProps(CheckboxDefaultProps)
3
6
  export const props = defineMixin({
4
7
  props: {
5
8
  // checkbox的名称
@@ -11,7 +11,7 @@
11
11
  :class="iconClasses"
12
12
  :style="[iconWrapStyle]"
13
13
  >
14
- <slot name="icon" :elIconSize="elIconSize" :elIconColor="elIconColor">
14
+ <slot name="icon" :elIconSize="elIconSize" :elIconColor="elIconColor" :checked="isChecked" :elDisabled="elDisabled">
15
15
  <up-icon
16
16
  class="u-checkbox__icon-wrap__icon"
17
17
  name="checkbox-mark"
@@ -149,8 +149,12 @@
149
149
  if (this.elDisabled) {
150
150
  classes.push('u-checkbox__icon-wrap--disabled')
151
151
  }
152
- if (this.isChecked && this.elDisabled) {
153
- classes.push('u-checkbox__icon-wrap--disabled--checked')
152
+ if (this.isChecked) {
153
+ if (this.elDisabled) {
154
+ classes.push('u-checkbox__icon-wrap--disabled--checked')
155
+ } else {
156
+ classes.push('u-checkbox__icon-wrap--checked')
157
+ }
154
158
  }
155
159
  // 支付宝,头条小程序无法动态绑定一个数组类名,否则解析出来的结果会带有",",而导致失效
156
160
  // #ifdef MP-ALIPAY || MP-TOUTIAO
@@ -1,6 +1,8 @@
1
1
  import { defineMixin } from '../../libs/vue'
2
- import defProps from '../../libs/config/props.js'
2
+ import CheckboxGroupDefaultProps from './checkboxGroup'
3
+ import { registerComponentProps } from '../../libs/config/props.js'
3
4
 
5
+ const defProps = registerComponentProps(CheckboxGroupDefaultProps)
4
6
  export const props = defineMixin({
5
7
  props: {
6
8
  // 标识符
@@ -1,5 +1,8 @@
1
1
  import { defineMixin } from '../../libs/vue'
2
- import defProps from '../../libs/config/props.js'
2
+ import CircleProgressDefaultProps from './circleProgress'
3
+ import { registerComponentProps } from '../../libs/config/props.js'
4
+
5
+ const defProps = registerComponentProps(CircleProgressDefaultProps)
3
6
  export const props = defineMixin({
4
7
  props: {
5
8
  percentage: {
@@ -1,5 +1,8 @@
1
1
  import { defineMixin } from '../../libs/vue'
2
- import defProps from '../../libs/config/props.js'
2
+ import CodeDefaultProps from './code'
3
+ import { registerComponentProps } from '../../libs/config/props.js'
4
+
5
+ const defProps = registerComponentProps(CodeDefaultProps)
3
6
  export const props = defineMixin({
4
7
  props: {
5
8
  // 倒计时总秒数
@@ -1,5 +1,8 @@
1
1
  import { defineMixin } from '../../libs/vue'
2
- import defProps from '../../libs/config/props.js'
2
+ import CodeInputDefaultProps from './codeInput'
3
+ import { registerComponentProps } from '../../libs/config/props.js'
4
+
5
+ const defProps = registerComponentProps(CodeInputDefaultProps)
3
6
  export const props = defineMixin({
4
7
  props: {
5
8
  // 键盘弹起时,是否自动上推页面
@@ -1,5 +1,8 @@
1
1
  import { defineMixin } from '../../libs/vue'
2
- import defProps from '../../libs/config/props.js'
2
+ import ColDefaultProps from './col'
3
+ import { registerComponentProps } from '../../libs/config/props.js'
4
+
5
+ const defProps = registerComponentProps(ColDefaultProps)
3
6
  export const props = defineMixin({
4
7
  props: {
5
8
  // 占父容器宽度的多少等分,总分为12份
@@ -1,5 +1,8 @@
1
1
  import { defineMixin } from '../../libs/vue'
2
- import defProps from '../../libs/config/props.js'
2
+ import CollapseDefaultProps from './collapse'
3
+ import { registerComponentProps } from '../../libs/config/props.js'
4
+
5
+ const defProps = registerComponentProps(CollapseDefaultProps)
3
6
  export const props = defineMixin({
4
7
  props: {
5
8
  // 当前展开面板的name,非手风琴模式:[<string | number>],手风琴模式:string | number
@@ -1,5 +1,8 @@
1
1
  import { defineMixin } from '../../libs/vue'
2
- import defProps from '../../libs/config/props.js'
2
+ import CollapseItemDefaultProps from './collapseItem'
3
+ import { registerComponentProps } from '../../libs/config/props.js'
4
+
5
+ const defProps = registerComponentProps(CollapseItemDefaultProps)
3
6
  export const props = defineMixin({
4
7
  props: {
5
8
  // 标题
@@ -801,6 +801,7 @@ export default {
801
801
  width: 100%;
802
802
  padding: 20px;
803
803
  background-color: var(--up-card-bg-color, #fff);
804
+ box-sizing: border-box;
804
805
  }
805
806
 
806
807
  &__header {
@@ -1,5 +1,8 @@
1
1
  import { defineMixin } from '../../libs/vue'
2
- import defProps from '../../libs/config/props.js'
2
+ import ColumnNoticeDefaultProps from './columnNotice'
3
+ import { registerComponentProps } from '../../libs/config/props.js'
4
+
5
+ const defProps = registerComponentProps(ColumnNoticeDefaultProps)
3
6
  export const props = defineMixin({
4
7
  props: {
5
8
  // 显示的内容,字符串
@@ -1,5 +1,8 @@
1
1
  import { defineMixin } from '../../libs/vue'
2
- import defProps from '../../libs/config/props.js'
2
+ import CountDownDefaultProps from './countDown'
3
+ import { registerComponentProps } from '../../libs/config/props.js'
4
+
5
+ const defProps = registerComponentProps(CountDownDefaultProps)
3
6
  export const props = defineMixin({
4
7
  props: {
5
8
  // 倒计时时长,单位ms
@@ -1,5 +1,8 @@
1
1
  import { defineMixin } from '../../libs/vue'
2
- import defProps from '../../libs/config/props.js'
2
+ import CountToDefaultProps from './countTo'
3
+ import { registerComponentProps } from '../../libs/config/props.js'
4
+
5
+ const defProps = registerComponentProps(CountToDefaultProps)
3
6
  export const props = defineMixin({
4
7
  props: {
5
8
  // 开始的数值,默认从0增长到某一个数
@@ -1,9 +1,9 @@
1
1
  <template>
2
2
  <view class="u-cropper">
3
3
  <!-- <image :src="imgSrc.imgSrc" @click="select" :style="[ imgStyle ]" class="my-avatar"></image> -->
4
- <canvas :canvas-id="'avatar-canvas-' + instanceId" :id="'avatar-canvas-' + instanceId" class="my-canvas" :style="{ top: styleTop, height: cvsStyleHeight }" disable-scroll="false"></canvas>
5
- <canvas :canvas-id="'oper-canvas-' + instanceId" :id="'oper-canvas-' + instanceId" class="oper-canvas" :style="{ top: styleTop, height: cvsStyleHeight }" disable-scroll="false" @touchstart="start" @touchmove="move" @touchend="end"></canvas>
6
- <canvas :canvas-id="'prv-canvas-' + instanceId" :id="'prv-canvas-' + instanceId" class="prv-canvas" disable-scroll="false" @touchstart="hideImg" :style="{ height: cvsStyleHeight, top: prvTop }"></canvas>
4
+ <up-canvas ref="avatarCanvas" :canvas-id="'avatar-canvas-' + instanceId" class="my-canvas" :width="windowWidth || 0" :height="windowHeight || 0" :style="{ top: styleTop, height: cvsStyleHeight }" bg-color="transparent"></up-canvas>
5
+ <up-canvas ref="operCanvas" :canvas-id="'oper-canvas-' + instanceId" class="oper-canvas" :width="windowWidth || 0" :height="windowHeight || 0" :style="{ top: styleTop, height: cvsStyleHeight }" bg-color="transparent" @touchstart="start" @touchmove="move" @touchend="end"></up-canvas>
6
+ <up-canvas ref="prvCanvas" :canvas-id="'prv-canvas-' + instanceId" class="prv-canvas" :width="windowWidth || 0" :height="windowHeight || 0" bg-color="transparent" @touchstart="hideImg" :style="{ height: cvsStyleHeight, top: prvTop }"></up-canvas>
7
7
  <view class="oper-wrapper" :style="{ display: styleDisplay }">
8
8
  <view class="oper">
9
9
  <view class="btn-wrapper" v-if="showOper">
@@ -108,9 +108,9 @@
108
108
  },
109
109
  },
110
110
  created() {
111
- this.ctxCanvas = uni.createCanvasContext('avatar-canvas-' + this.instanceId, this);
112
- this.ctxCanvasOper = uni.createCanvasContext('oper-canvas-' + this.instanceId, this);
113
- this.ctxCanvasPrv = uni.createCanvasContext('prv-canvas-' + this.instanceId, this);
111
+ this.ctxCanvas = null;
112
+ this.ctxCanvasOper = null;
113
+ this.ctxCanvasPrv = null;
114
114
  this.qlty = parseInt(this.quality) || 0.9;
115
115
  this.imgSrc.imgSrc = this.imageSrc;
116
116
  this.letRotate = (this.canRotate === false || this.inner === true) ? 0 : 1;
@@ -144,8 +144,27 @@
144
144
  });
145
145
  }
146
146
  },
147
+ mounted() {
148
+ this.initCanvasRefs(true);
149
+ },
147
150
  methods: {
148
151
  t,
152
+ async initCanvasRefs(force = false) {
153
+ await this.$nextTick();
154
+ const avatarCanvas = this.$refs.avatarCanvas;
155
+ const operCanvas = this.$refs.operCanvas;
156
+ const prvCanvas = this.$refs.prvCanvas;
157
+ if (!avatarCanvas || !operCanvas || !prvCanvas) return false;
158
+ await Promise.all([
159
+ avatarCanvas.initCanvas(force),
160
+ operCanvas.initCanvas(force),
161
+ prvCanvas.initCanvas(force)
162
+ ]);
163
+ this.ctxCanvas = avatarCanvas;
164
+ this.ctxCanvasOper = operCanvas;
165
+ this.ctxCanvasPrv = prvCanvas;
166
+ return true;
167
+ },
149
168
  windowResize() {
150
169
  let sysInfo = uni.getSystemInfoSync();
151
170
  this.platform = sysInfo.platform;
@@ -264,7 +283,7 @@
264
283
  }
265
284
  })
266
285
  },
267
- confirm() {
286
+ async confirm() {
268
287
  if (this.fUploading) return;
269
288
  this.fUploading = true;
270
289
  setTimeout(() => { this.fUploading = false; }, 1000)
@@ -289,35 +308,34 @@
289
308
  this.styleTop = '-10000px';
290
309
  this.hasSel = false;
291
310
  this.hideImg();
292
- uni.canvasToTempFilePath({
311
+ await this.initCanvasRefs();
312
+ this.ctxCanvas.toTempFilePath({
293
313
  x: x,
294
314
  y: y,
295
315
  width: width,
296
316
  height: height,
297
317
  destWidth: expWidth,
298
318
  destHeight: expHeight,
299
- canvasId: 'avatar-canvas-' + this.instanceId,
300
319
  fileType: 'png',
301
320
  quality: this.qlty,
302
321
  success: (r) => {
303
322
  r = r.tempFilePath;
304
323
  // #ifdef H5
305
- this.btop(r).then((r) => {
324
+ this.btop(r).then(async (r) => {
306
325
  if (this.expWidth && this.expHeight) {
307
326
  let ctxCanvas = this.ctxCanvas;
308
327
  expWidth = this.expWidth,
309
328
  expHeight = this.expHeight;
310
329
 
311
- ctxCanvas.drawImage(r, 0, 0, expWidth, expHeight);
330
+ await ctxCanvas.drawImage(r, 0, 0, expWidth, expHeight);
312
331
  ctxCanvas.draw(false, () => {
313
- uni.canvasToTempFilePath({
332
+ ctxCanvas.toTempFilePath({
314
333
  x: 0,
315
334
  y: 0,
316
335
  width: expWidth,
317
336
  height: expHeight,
318
337
  destWidth: expWidth,
319
338
  destHeight: expHeight,
320
- canvasId: 'avatar-canvas-' + this.instanceId,
321
339
  fileType: 'png',
322
340
  quality: this.qlty,
323
341
  success: (r) => {
@@ -353,10 +371,10 @@
353
371
  uni.hideLoading();
354
372
  this.noBar || uni.showTabBar();
355
373
  }
356
- }, this);
374
+ });
357
375
  },
358
376
  // 用户点击"预览"模式下的"确认"按钮时被调用,用于将预览的裁剪结果上传
359
- prvUpload() {
377
+ async prvUpload() {
360
378
  if (this.fPrvUploading) return;
361
379
  this.fPrvUploading = true;
362
380
  setTimeout(() => { this.fPrvUploading = false; }, 1000)
@@ -384,35 +402,34 @@
384
402
  this.styleTop = '-10000px';
385
403
  this.hasSel = false;
386
404
  this.hideImg();
387
- uni.canvasToTempFilePath({
405
+ await this.initCanvasRefs();
406
+ this.ctxCanvasPrv.toTempFilePath({
388
407
  x: prvX,
389
408
  y: prvY,
390
409
  width: prvWidth,
391
410
  height: prvHeight,
392
411
  destWidth: expWidth,
393
412
  destHeight: expHeight,
394
- canvasId: 'prv-canvas-' + this.instanceId,
395
413
  fileType: 'png',
396
414
  quality: this.qlty,
397
415
  success: (r) => {
398
416
  r = r.tempFilePath;
399
417
  // #ifdef H5
400
- this.btop(r).then((r) => {
418
+ this.btop(r).then(async (r) => {
401
419
  if (this.expWidth && this.expHeight) {
402
420
  let ctxCanvas = this.ctxCanvas;
403
421
  expWidth = this.expWidth,
404
422
  expHeight = this.expHeight;
405
423
 
406
- ctxCanvas.drawImage(r, 0, 0, expWidth, expHeight);
424
+ await ctxCanvas.drawImage(r, 0, 0, expWidth, expHeight);
407
425
  ctxCanvas.draw(false, () => {
408
- uni.canvasToTempFilePath({
426
+ ctxCanvas.toTempFilePath({
409
427
  x: 0,
410
428
  y: 0,
411
429
  width: expWidth,
412
430
  height: expHeight,
413
431
  destWidth: expWidth,
414
432
  destHeight: expHeight,
415
- canvasId: 'avatar-canvas-' + this.instanceId,
416
433
  fileType: 'png',
417
434
  quality: this.qlty,
418
435
  success: (r) => {
@@ -448,9 +465,10 @@
448
465
  uni.hideLoading();
449
466
  this.noBar || uni.showTabBar();
450
467
  }
451
- }, this);
468
+ });
452
469
  },
453
- drawInit(ini = false) {
470
+ async drawInit(ini = false) {
471
+ await this.initCanvasRefs();
454
472
  let allWidth = this.windowWidth,
455
473
  allHeight = this.windowHeight,
456
474
  imgWidth = this.imgWidth,
@@ -597,7 +615,8 @@
597
615
 
598
616
  this.$emit("avtinit");
599
617
  },
600
- drawImage() {
618
+ async drawImage() {
619
+ await this.initCanvasRefs();
601
620
  let tm_now = Date.now();
602
621
  if (tm_now - this.drawTm < 20) return;
603
622
  this.drawTm = tm_now;
@@ -605,10 +624,12 @@
605
624
  if (this.fillColor && this.fillColor !== 'transparent') {
606
625
  ctxCanvas.fillRect(0, 0, this.windowWidth, this.windowHeight - tabHeight);
607
626
  }
627
+ ctxCanvas.save();
608
628
  ctxCanvas.translate(this.posWidth + this.useWidth / 2, this.posHeight + this.useHeight / 2);
609
629
  ctxCanvas.scale(this.scaleSize, this.scaleSize);
610
630
  ctxCanvas.rotate(this.rotateDeg * Math.PI / 180);
611
- ctxCanvas.drawImage(this.imgPath, -this.useWidth / 2, -this.useHeight / 2, this.useWidth, this.useHeight);
631
+ await ctxCanvas.drawImage(this.imgPath, -this.useWidth / 2, -this.useHeight / 2, this.useWidth, this.useHeight);
632
+ ctxCanvas.restore();
612
633
  ctxCanvas.draw(false);
613
634
  },
614
635
  hideImg() {
@@ -628,7 +649,7 @@
628
649
  this.noBar || uni.showTabBar();
629
650
  this.$emit('cancel');
630
651
  },
631
- preview() {
652
+ async preview() {
632
653
  if (this.fPreviewing) return;
633
654
  this.fPreviewing = true;
634
655
  setTimeout(() => { this.fPreviewing = false; }, 1000);
@@ -640,15 +661,15 @@
640
661
 
641
662
  uni.showLoading({ mask: true });
642
663
  // console.log('size', x, y, width, height)
643
- uni.canvasToTempFilePath({
664
+ await this.initCanvasRefs();
665
+ this.ctxCanvas.toTempFilePath({
644
666
  x: x,
645
667
  y: y,
646
668
  width: width,
647
669
  height: height,
648
- canvasId: 'avatar-canvas-' + this.instanceId,
649
670
  fileType: 'png',
650
671
  quality: this.qlty,
651
- success: (r) => {
672
+ success: async (r) => {
652
673
  // console.log(r)
653
674
  this.prvImgTmp = r = r.tempFilePath;
654
675
 
@@ -678,7 +699,7 @@
678
699
  this.prvY = prvY = (prvY - prvHeight) / 2;
679
700
  this.prvWidth = prvWidth;
680
701
  this.prvHeight = prvHeight;
681
- ctxCanvasPrv.drawImage(r, prvX, prvY, prvWidth, prvHeight);
702
+ await ctxCanvasPrv.drawImage(r, prvX, prvY, prvWidth, prvHeight);
682
703
  ctxCanvasPrv.draw(false, () => {
683
704
  // #ifdef H5
684
705
  this.btop(this.prvImgTmp).then((r) => {
@@ -703,7 +724,7 @@
703
724
  complete: () => {
704
725
  uni.hideLoading();
705
726
  }
706
- }, this);
727
+ });
707
728
  },
708
729
  chooseImage(index = undefined, params = undefined, data = undefined) {
709
730
  if (params) {
@@ -725,7 +746,8 @@
725
746
 
726
747
  expWidth && (this.expWidth = expWidth.indexOf('rpx') >= 0 ? parseInt(expWidth) * this.pxRatio : parseInt(expWidth));
727
748
  expHeight && (this.expHeight = expHeight.indexOf('rpx') >= 0 ? parseInt(expHeight) * this.pxRatio : parseInt(expHeight));
728
- this.letRotate = canRotate === false ? 0 : 1;
749
+ this.isin = inner === true ? 1 : 0;
750
+ this.letRotate = (canRotate === false || this.isin) ? 0 : 1;
729
751
  this.letScale = canScale === false ? 0 : 1;
730
752
  // 设置是否允许调整裁剪框大小
731
753
  this.letChangeSize = canChangeSize || false;
@@ -733,7 +755,6 @@
733
755
  this.mnScale = minScale || 0.3;
734
756
  this.mxScale = maxScale || 4;
735
757
  this.stc = stretch;
736
- this.isin = inner === true ? 1 : 0;
737
758
  this.lck = lock;
738
759
  if (this.isin) {
739
760
  this.btnWidth = '24%';
@@ -893,17 +914,41 @@
893
914
  break;
894
915
  }
895
916
 
896
- // 确保最小尺寸
897
- if (parseInt(style.width) >= minWidth && parseInt(style.height) >= minHeight) {
898
- // 确保裁剪框不超出屏幕边界
899
- if (parseInt(style.left) >= 0 &&
900
- parseInt(style.top) >= 0 &&
901
- (parseInt(style.left) + parseInt(style.width)) <= this.windowWidth &&
902
- (parseInt(style.top) + parseInt(style.height)) <= (this.windowHeight - tabHeight)) {
903
- this.selStyle = style;
904
- // 重新绘制操作层
905
- this.drawInit();
906
- }
917
+ // 约束裁剪框:最小尺寸、屏幕边界,inner 模式下再限制在图片内
918
+ let nl = parseInt(style.left);
919
+ let nt = parseInt(style.top);
920
+ let nw = parseInt(style.width);
921
+ let nh = parseInt(style.height);
922
+
923
+ // 屏幕边界
924
+ if (nl < 0) nl = 0;
925
+ if (nt < 0) nt = 0;
926
+ if (nl + nw > this.windowWidth) nw = this.windowWidth - nl;
927
+ if (nt + nh > this.windowHeight - tabHeight) nh = this.windowHeight - tabHeight - nt;
928
+
929
+ if (this.isin) {
930
+ const imgWidth = this.useWidth * this.scaleSize;
931
+ const imgHeight = this.useHeight * this.scaleSize;
932
+ const rx0 = this.posWidth + this.useWidth / 2;
933
+ const ry0 = this.posHeight + this.useHeight / 2;
934
+ const imgL = rx0 - imgWidth / 2;
935
+ const imgT = ry0 - imgHeight / 2;
936
+ const imgR = imgL + imgWidth;
937
+ const imgB = imgT + imgHeight;
938
+ if (nl < imgL) nl = imgL;
939
+ if (nt < imgT) nt = imgT;
940
+ if (nl + nw > imgR) nw = imgR - nl;
941
+ if (nt + nh > imgB) nh = imgB - nt;
942
+ }
943
+
944
+ if (nw >= minWidth && nh >= minHeight) {
945
+ style.left = nl + 'px';
946
+ style.top = nt + 'px';
947
+ style.width = nw + 'px';
948
+ style.height = nh + 'px';
949
+ this.selStyle = style;
950
+ // 重新绘制操作层
951
+ this.drawInit();
907
952
  }
908
953
  } else {
909
954
  // 原有的移动图片逻辑
@@ -962,7 +1007,8 @@
962
1007
  this.resizeHandle = null; // 重置调整手柄
963
1008
  }
964
1009
  },
965
- getImgData() {
1010
+ async getImgData() {
1011
+ await this.initCanvasRefs();
966
1012
  return new Promise((resolve, reject) => {
967
1013
  let prvX = this.prvX,
968
1014
  prvY = this.prvY,
@@ -974,8 +1020,7 @@
974
1020
  prvWidth *= this.pixelRatio;
975
1021
  prvHeight *= this.pixelRatio;
976
1022
  // #endif
977
- uni.canvasGetImageData({
978
- canvasId: 'prv-canvas-' + this.instanceId,
1023
+ this.ctxCanvasPrv.getImageData({
979
1024
  x: prvX,
980
1025
  y: prvY,
981
1026
  width: prvWidth,
@@ -986,7 +1031,7 @@
986
1031
  fail(err) {
987
1032
  reject(err);
988
1033
  }
989
- }, this);
1034
+ });
990
1035
  });
991
1036
  },
992
1037
  async colorChange(e) {
@@ -1110,8 +1155,7 @@
1110
1155
  prvWidth *= this.pixelRatio;
1111
1156
  prvHeight *= this.pixelRatio;
1112
1157
  // #endif
1113
- uni.canvasPutImageData({
1114
- canvasId: 'prv-canvas-' + this.instanceId,
1158
+ this.ctxCanvasPrv.putImageData({
1115
1159
  x: prvX,
1116
1160
  y: prvY,
1117
1161
  width: prvWidth,
@@ -1126,7 +1170,7 @@
1126
1170
  complete() {
1127
1171
  uni.hideLoading();
1128
1172
  }
1129
- }, this);
1173
+ });
1130
1174
  },
1131
1175
  btop(base64) {
1132
1176
  return new Promise(function (resolve, reject) {
@@ -1,5 +1,8 @@
1
1
  import { defineMixin } from '../../libs/vue'
2
- import defProps from '../../libs/config/props.js'
2
+ import DatetimePickerDefaultProps from './datetimePicker'
3
+ import { registerComponentProps } from '../../libs/config/props.js'
4
+
5
+ const defProps = registerComponentProps(DatetimePickerDefaultProps)
3
6
  export const props = defineMixin({
4
7
  props: {
5
8
  // 是否显示input
@@ -1,5 +1,8 @@
1
1
  import { defineMixin } from '../../libs/vue'
2
- import defProps from '../../libs/config/props.js'
2
+ import DividerDefaultProps from './divider'
3
+ import { registerComponentProps } from '../../libs/config/props.js'
4
+
5
+ const defProps = registerComponentProps(DividerDefaultProps)
3
6
  export const props = defineMixin({
4
7
  props: {
5
8
  // 是否虚线
@@ -212,7 +212,8 @@ export default {
212
212
  if (this.$slots.handler && e.currentTarget.dataset.action !== 'handler') {
213
213
  return
214
214
  }
215
- if (this.list[index]?.draggable === false) return;
215
+ // 全局禁用或单项禁用时,不进入拖拽态,避免 Android 上小范围漂浮/阴影
216
+ if (!this.draggable || this.list[index]?.draggable === false) return;
216
217
  if (this.timer) clearTimeout(this.timer);
217
218
  this.sortChanged = false;
218
219
  this.dragIndex = index;
@@ -1,5 +1,7 @@
1
1
  import { defineMixin } from '../../libs/vue'
2
- import defProps from '../../libs/config/props.js'
2
+ import { registerComponentProps } from '../../libs/config/props.js'
3
+
4
+ const defProps = registerComponentProps({ dropdown: {} })
3
5
  export const props = defineMixin({
4
6
  props: {
5
7
  // 菜单标题和选项的激活态颜色
@@ -1,5 +1,7 @@
1
1
  import { defineMixin } from '../../libs/vue'
2
- import defProps from '../../libs/config/props.js'
2
+ import { registerComponentProps } from '../../libs/config/props.js'
3
+
4
+ const defProps = registerComponentProps({ dropdownItem: {} })
3
5
  export const props = defineMixin({
4
6
  props: {
5
7
  // #ifdef VUE3
@@ -1,5 +1,8 @@
1
1
  import { defineMixin } from '../../libs/vue'
2
- import defProps from '../../libs/config/props.js'
2
+ import EmptyDefaultProps from './empty'
3
+ import { registerComponentProps } from '../../libs/config/props.js'
4
+
5
+ const defProps = registerComponentProps(EmptyDefaultProps)
3
6
  export const props = defineMixin({
4
7
  props: {
5
8
  // 内置图标名称,或图片路径,建议绝对路径
@@ -1,5 +1,8 @@
1
1
  import { defineMixin } from '../../libs/vue'
2
- import defProps from '../../libs/config/props.js'
2
+ import FormDefaultProps from './form'
3
+ import { registerComponentProps } from '../../libs/config/props.js'
4
+
5
+ const defProps = registerComponentProps(FormDefaultProps)
3
6
  export const props = defineMixin({
4
7
  props: {
5
8
  // 当前form的需要验证字段的集合
@@ -1,5 +1,8 @@
1
1
  import { defineMixin } from '../../libs/vue'
2
- import defProps from '../../libs/config/props.js'
2
+ import FormItemDefaultProps from './formItem'
3
+ import { registerComponentProps } from '../../libs/config/props.js'
4
+
5
+ const defProps = registerComponentProps(FormItemDefaultProps)
3
6
  export const props = defineMixin({
4
7
  props: {
5
8
  // input的label提示语