uview-plus 3.2.8 → 3.2.10

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 (120) hide show
  1. package/changelog.md +10 -0
  2. package/components/u--form/u--form.vue +7 -7
  3. package/components/u--image/u--image.vue +3 -3
  4. package/components/u--input/u--input.vue +9 -9
  5. package/components/u--textarea/u--textarea.vue +3 -3
  6. package/components/u-action-sheet/u-action-sheet.vue +5 -4
  7. package/components/u-album/u-album.vue +9 -7
  8. package/components/u-alert/u-alert.vue +9 -6
  9. package/components/u-avatar/props.js +2 -1
  10. package/components/u-avatar/u-avatar.vue +15 -11
  11. package/components/u-avatar-group/u-avatar-group.vue +9 -5
  12. package/components/u-back-top/u-back-top.vue +9 -8
  13. package/components/u-badge/u-badge.vue +10 -6
  14. package/components/u-button/u-button.vue +13 -9
  15. package/components/u-calendar/header.vue +3 -3
  16. package/components/u-calendar/month.vue +17 -15
  17. package/components/u-calendar/u-calendar.vue +26 -10
  18. package/components/u-car-keyboard/u-car-keyboard.vue +7 -6
  19. package/components/u-cell/u-cell.vue +9 -6
  20. package/components/u-cell-group/u-cell-group.vue +8 -4
  21. package/components/u-checkbox/u-checkbox.vue +13 -11
  22. package/components/u-checkbox-group/u-checkbox-group.vue +3 -3
  23. package/components/u-circle-progress/u-circle-progress.vue +5 -4
  24. package/components/u-code/u-code.vue +3 -3
  25. package/components/u-code-input/u-code-input.vue +9 -8
  26. package/components/u-col/u-col.vue +9 -8
  27. package/components/u-collapse/u-collapse.vue +3 -3
  28. package/components/u-collapse-item/u-collapse-item.vue +32 -15
  29. package/components/u-column-notice/u-column-notice.vue +8 -6
  30. package/components/u-count-down/u-count-down.vue +3 -3
  31. package/components/u-count-to/u-count-to.vue +6 -4
  32. package/components/u-datetime-picker/u-datetime-picker.vue +16 -15
  33. package/components/u-divider/u-divider.vue +7 -5
  34. package/components/u-dropdown/u-dropdown.vue +12 -10
  35. package/components/u-dropdown-item/u-dropdown-item.vue +7 -5
  36. package/components/u-empty/u-empty.vue +12 -8
  37. package/components/u-form/u-form.vue +12 -10
  38. package/components/u-form-item/u-form-item.vue +17 -11
  39. package/components/u-gap/u-gap.vue +3 -3
  40. package/components/u-grid/u-grid.vue +18 -7
  41. package/components/u-grid-item/u-grid-item.vue +14 -9
  42. package/components/u-icon/u-icon.vue +21 -19
  43. package/components/u-image/u-image.vue +18 -16
  44. package/components/u-index-anchor/u-index-anchor.vue +11 -9
  45. package/components/u-index-item/u-index-item.vue +6 -5
  46. package/components/u-index-list/u-index-list.vue +20 -18
  47. package/components/u-input/u-input.vue +19 -12
  48. package/components/u-keyboard/u-keyboard.vue +3 -3
  49. package/components/u-line/u-line.vue +7 -6
  50. package/components/u-line-progress/u-line-progress.vue +11 -8
  51. package/components/u-link/u-link.vue +9 -8
  52. package/components/u-list/u-list.vue +9 -9
  53. package/components/u-list-item/u-list-item.vue +5 -4
  54. package/components/u-loading-icon/u-loading-icon.vue +14 -10
  55. package/components/u-loading-page/u-loading-page.vue +10 -7
  56. package/components/u-loadmore/u-loadmore.vue +12 -10
  57. package/components/u-modal/u-modal.vue +7 -5
  58. package/components/u-navbar/u-navbar.vue +12 -7
  59. package/components/u-no-network/u-no-network.vue +6 -6
  60. package/components/u-notice-bar/u-notice-bar.vue +6 -5
  61. package/components/u-notify/u-notify.vue +19 -15
  62. package/components/u-number-box/u-number-box.vue +8 -7
  63. package/components/u-number-keyboard/u-number-keyboard.vue +7 -7
  64. package/components/u-overlay/u-overlay.vue +5 -5
  65. package/components/u-picker/u-picker.vue +19 -15
  66. package/components/u-picker-column/u-picker-column.vue +3 -3
  67. package/components/u-popup/u-popup.vue +13 -13
  68. package/components/u-radio/u-radio.vue +12 -12
  69. package/components/u-radio-group/u-radio-group.vue +3 -3
  70. package/components/u-rate/u-rate.vue +16 -14
  71. package/components/u-read-more/u-read-more.vue +9 -7
  72. package/components/u-row/u-row.vue +8 -7
  73. package/components/u-row-notice/u-row-notice.vue +14 -12
  74. package/components/u-safe-bottom/u-safe-bottom.vue +5 -4
  75. package/components/u-scroll-list/nvue.js +4 -4
  76. package/components/u-scroll-list/u-scroll-list.vue +13 -10
  77. package/components/u-search/u-search.vue +8 -6
  78. package/components/u-skeleton/u-skeleton.vue +20 -17
  79. package/components/u-slider/mpwxs.js +3 -2
  80. package/components/u-slider/nvue - /345/211/257/346/234/254.js" +2 -2
  81. package/components/u-slider/nvue.js +2 -2
  82. package/components/u-slider/u-slider.vue +8 -5
  83. package/components/u-status-bar/u-status-bar.vue +6 -5
  84. package/components/u-steps/u-steps.vue +5 -4
  85. package/components/u-steps-item/u-steps-item.vue +9 -7
  86. package/components/u-sticky/u-sticky.vue +12 -10
  87. package/components/u-subsection/u-subsection.vue +8 -6
  88. package/components/u-swipe-action/u-swipe-action.vue +3 -3
  89. package/components/u-swipe-action-item/nvue - backup.js +3 -3
  90. package/components/u-swipe-action-item/nvue.js +3 -3
  91. package/components/u-swipe-action-item/u-swipe-action-item.vue +8 -5
  92. package/components/u-swiper/u-swiper.vue +35 -24
  93. package/components/u-swiper-indicator/u-swiper-indicator.vue +10 -7
  94. package/components/u-switch/u-switch.vue +15 -13
  95. package/components/u-tabbar/u-tabbar.vue +6 -5
  96. package/components/u-tabbar-item/u-tabbar-item.vue +7 -5
  97. package/components/u-table/u-table.vue +3 -3
  98. package/components/u-tabs/u-tabs.vue +18 -14
  99. package/components/u-tabs-item/u-tabs-item.vue +3 -3
  100. package/components/u-tag/u-tag.vue +6 -4
  101. package/components/u-td/u-td.vue +3 -3
  102. package/components/u-text/u-text.vue +12 -10
  103. package/components/u-text/value.js +14 -12
  104. package/components/u-textarea/u-textarea.vue +11 -8
  105. package/components/u-toast/u-toast.vue +12 -9
  106. package/components/u-toolbar/u-toolbar.vue +3 -3
  107. package/components/u-tooltip/u-tooltip.vue +18 -17
  108. package/components/u-tr/u-tr.vue +3 -3
  109. package/components/u-transition/transition.js +2 -2
  110. package/components/u-transition/u-transition.vue +6 -5
  111. package/components/u-upload/mixin.js +4 -3
  112. package/components/u-upload/u-upload.vue +20 -17
  113. package/index.js +0 -5
  114. package/libs/function/index.js +27 -20
  115. package/libs/function/throttle.js +2 -2
  116. package/libs/mixin/mixin.js +14 -6
  117. package/libs/mixin/style.js +23 -4
  118. package/libs/util/route.js +6 -6
  119. package/package.json +1 -1
  120. package/types/index.d.ts +0 -1
@@ -28,8 +28,8 @@
28
28
  @scrolltoupper="wxs.scrolltoupper"
29
29
  @scrolltolower="wxs.scrolltolower"
30
30
  :data-scrollWidth="scrollWidth"
31
- :data-barWidth="$u.getPx(indicatorBarWidth)"
32
- :data-indicatorWidth="$u.getPx(indicatorWidth)"
31
+ :data-barWidth="getPx(indicatorBarWidth)"
32
+ :data-indicatorWidth="getPx(indicatorWidth)"
33
33
  :show-scrollbar="false"
34
34
  :upper-threshold="0"
35
35
  :lower-threshold="0"
@@ -56,7 +56,7 @@
56
56
  <view
57
57
  class="u-scroll-list__indicator"
58
58
  v-if="indicator"
59
- :style="[$u.addStyle(indicatorStyle)]"
59
+ :style="[addStyle(indicatorStyle)]"
60
60
  >
61
61
  <view
62
62
  class="u-scroll-list__indicator__line"
@@ -97,9 +97,10 @@
97
97
  const dom = uni.requireNativePlugin('dom')
98
98
  import nvueMixin from "./nvue.js"
99
99
  // #endif
100
- import props from './props.js';
101
- import mpMixin from '../../libs/mixin/mpMixin.js';
102
- import mixin from '../../libs/mixin/mixin.js';
100
+ import props from './props';
101
+ import mpMixin from '../../libs/mixin/mpMixin';
102
+ import mixin from '../../libs/mixin/mixin';
103
+ import { addStyle, addUnit, getPx, sleep } from '../../libs/function/index';
103
104
  export default {
104
105
  name: 'u-scroll-list',
105
106
  // #ifndef APP-NVUE
@@ -132,14 +133,14 @@ export default {
132
133
  style.transform = `translateX(${ x }px)`
133
134
  // #endif
134
135
  // 设置滑块的宽度和背景色,是每个平台都需要的
135
- style.width = uni.$u.addUnit(this.indicatorBarWidth)
136
+ style.width = addUnit(this.indicatorBarWidth)
136
137
  style.backgroundColor = this.indicatorActiveColor
137
138
  return style
138
139
  },
139
140
  lineStyle() {
140
141
  const style = {}
141
142
  // 指示器整体的样式,需要设置其宽度和背景色
142
- style.width = uni.$u.addUnit(this.indicatorWidth)
143
+ style.width = addUnit(this.indicatorWidth)
143
144
  style.backgroundColor = this.indicatorColor
144
145
  return style
145
146
  }
@@ -149,6 +150,8 @@ export default {
149
150
  },
150
151
  emits: ["left", "right"],
151
152
  methods: {
153
+ addStyle,
154
+ getPx,
152
155
  init() {
153
156
  this.getComponentWidth()
154
157
  },
@@ -165,7 +168,7 @@ export default {
165
168
  this.scrollEvent('right')
166
169
  // 在普通js方案中,滚动到右边时,通过设置this.scrollInfo,模拟出滚动到右边的情况
167
170
  // 因为上方是用过computed计算的,设置后,会自动调整滑块的位置
168
- this.scrollInfo.scrollLeft = uni.$u.getPx(this.indicatorWidth) - uni.$u.getPx(this.indicatorBarWidth)
171
+ this.scrollInfo.scrollLeft = getPx(this.indicatorWidth) - getPx(this.indicatorBarWidth)
169
172
  },
170
173
  // #endif
171
174
  //
@@ -175,7 +178,7 @@ export default {
175
178
  // 获取组件的宽度
176
179
  async getComponentWidth() {
177
180
  // 延时一定时间,以获取dom尺寸
178
- await uni.$u.sleep(30)
181
+ await sleep(30)
179
182
  // #ifndef APP-NVUE
180
183
  this.$uGetRect('.u-scroll-list').then(size => {
181
184
  this.scrollWidth = size.width
@@ -4,7 +4,7 @@
4
4
  @tap="clickHandler"
5
5
  :style="[{
6
6
  margin: margin,
7
- }, $u.addStyle(customStyle)]"
7
+ }, addStyle(customStyle)]"
8
8
  >
9
9
  <view
10
10
  class="u-search__content"
@@ -46,7 +46,7 @@
46
46
  textAlign: inputAlign,
47
47
  color: color,
48
48
  backgroundColor: bgColor,
49
- height: $u.addUnit(height)
49
+ height: addUnit(height)
50
50
  }, inputStyle]"
51
51
  />
52
52
  <view
@@ -72,10 +72,10 @@
72
72
  </template>
73
73
 
74
74
  <script>
75
- import props from './props.js';
76
- import mpMixin from '../../libs/mixin/mpMixin.js';
77
- import mixin from '../../libs/mixin/mixin.js';
78
-
75
+ import props from './props';
76
+ import mpMixin from '../../libs/mixin/mpMixin';
77
+ import mixin from '../../libs/mixin/mixin';
78
+ import { addUnit, addStyle } from '../../libs/function/index';
79
79
  /**
80
80
  * search 搜索框
81
81
  * @description 搜索组件,集成了常见搜索框所需功能,用户可以一键引入,开箱即用。
@@ -161,6 +161,8 @@
161
161
  },
162
162
  emits: ['clear', 'search', 'custom', 'focus', 'blur', 'click', 'clickIcon', 'update:modelValue', 'change'],
163
163
  methods: {
164
+ addStyle,
165
+ addUnit,
164
166
  // 目前HX2.6.9 v-model双向绑定无效,故监听input事件获取输入框内容的变化
165
167
  inputChange(e) {
166
168
  this.keyword = e.detail.value;
@@ -11,8 +11,8 @@
11
11
  v-if="avatar"
12
12
  :class="[`u-skeleton__wrapper__avatar--${avatarShape}`, animate && 'animate']"
13
13
  :style="{
14
- height: $u.addUnit(avatarSize),
15
- width: $u.addUnit(avatarSize)
14
+ height: addUnit(avatarSize),
15
+ width: addUnit(avatarSize)
16
16
  }"
17
17
  ></view>
18
18
  <view
@@ -25,7 +25,7 @@
25
25
  v-if="title"
26
26
  :style="{
27
27
  width: uTitleWidth,
28
- height: $u.addUnit(titleHeight),
28
+ height: addUnit(titleHeight),
29
29
  }"
30
30
  :class="[animate && 'animate']"
31
31
  ></view>
@@ -49,9 +49,11 @@
49
49
  </template>
50
50
 
51
51
  <script>
52
- import props from './props.js';
53
- import mpMixin from '../../libs/mixin/mpMixin.js';
54
- import mixin from '../../libs/mixin/mixin.js';
52
+ import props from './props';
53
+ import mpMixin from '../../libs/mixin/mpMixin';
54
+ import mixin from '../../libs/mixin/mixin';
55
+ import { addUnit, sleep, error } from '../../libs/function/index';
56
+ import test from '../../libs/function/test';
55
57
  // #ifdef APP-NVUE
56
58
  // 由于weex为阿里的KPI业绩考核的产物,所以不支持百分比单位,这里需要通过dom查询组件的宽度
57
59
  const dom = uni.requireNativePlugin('dom')
@@ -90,26 +92,26 @@
90
92
  computed: {
91
93
  rowsArray() {
92
94
  if (/%$/.test(this.rowsHeight)) {
93
- uni.$u.error('rowsHeight参数不支持百分比单位')
95
+ error('rowsHeight参数不支持百分比单位')
94
96
  }
95
97
  const rows = []
96
98
  for (let i = 0; i < this.rows; i++) {
97
99
  let item = {},
98
100
  // 需要预防超出数组边界的情况
99
- rowWidth = uni.$u.test.array(this.rowsWidth) ? (this.rowsWidth[i] || (i === this.rows - 1 ? '70%' : '100%')) : i ===
101
+ rowWidth = test.array(this.rowsWidth) ? (this.rowsWidth[i] || (i === this.rows - 1 ? '70%' : '100%')) : i ===
100
102
  this.rows - 1 ? '70%' : this.rowsWidth,
101
- rowHeight = uni.$u.test.array(this.rowsHeight) ? (this.rowsHeight[i] || '18px') : this.rowsHeight
103
+ rowHeight = test.array(this.rowsHeight) ? (this.rowsHeight[i] || '18px') : this.rowsHeight
102
104
  // 如果有title占位图,第一个段落占位图的外边距需要大一些,如果没有title占位图,第一个段落占位图则无需外边距
103
105
  // 之所以需要这么做,是因为weex的无能,以提升性能为借口不支持css的一些伪类
104
106
  item.marginTop = !this.title && i === 0 ? 0 : this.title && i === 0 ? '20px' : '12px'
105
107
  // 如果设置的为百分比的宽度,转换为px值,因为nvue不支持百分比单位
106
108
  if (/%$/.test(rowWidth)) {
107
109
  // 通过parseInt提取出百分比单位中的数值部分,除以100得到百分比的小数值
108
- item.width = uni.$u.addUnit(this.width * parseInt(rowWidth) / 100)
110
+ item.width = addUnit(this.width * parseInt(rowWidth) / 100)
109
111
  } else {
110
- item.width = uni.$u.addUnit(rowWidth)
112
+ item.width = addUnit(rowWidth)
111
113
  }
112
- item.height = uni.$u.addUnit(rowHeight)
114
+ item.height = addUnit(rowHeight)
113
115
  rows.push(item)
114
116
  }
115
117
  // console.log(rows);
@@ -119,11 +121,11 @@
119
121
  let tWidth = 0
120
122
  if (/%$/.test(this.titleWidth)) {
121
123
  // 通过parseInt提取出百分比单位中的数值部分,除以100得到百分比的小数值
122
- tWidth = uni.$u.addUnit(this.width * parseInt(this.titleWidth) / 100)
124
+ tWidth = addUnit(this.width * parseInt(this.titleWidth) / 100)
123
125
  } else {
124
- tWidth = uni.$u.addUnit(this.titleWidth)
126
+ tWidth = addUnit(this.titleWidth)
125
127
  }
126
- return uni.$u.addUnit(tWidth)
128
+ return addUnit(tWidth)
127
129
  },
128
130
 
129
131
  },
@@ -131,6 +133,7 @@
131
133
  this.init()
132
134
  },
133
135
  methods: {
136
+ addUnit,
134
137
  init() {
135
138
  this.getComponentWidth()
136
139
  // #ifdef APP-NVUE
@@ -140,7 +143,7 @@
140
143
  async setNvueAnimation() {
141
144
  // #ifdef APP-NVUE
142
145
  // 为了让opacity:1的状态保持一定时间,这里做一个延时
143
- await uni.$u.sleep(500)
146
+ await sleep(500)
144
147
  const skeleton = this.$refs['u-skeleton__wrapper'];
145
148
  skeleton && this.loading && this.animate && animation.transition(skeleton, {
146
149
  styles: {
@@ -165,7 +168,7 @@
165
168
  // 获取组件的宽度
166
169
  async getComponentWidth() {
167
170
  // 延时一定时间,以获取dom尺寸
168
- await uni.$u.sleep(20)
171
+ await sleep(20)
169
172
  // #ifndef APP-NVUE
170
173
  this.$uGetRect('.u-skeleton__wrapper__content').then(size => {
171
174
  this.width = size.width
@@ -1,3 +1,4 @@
1
+ import { sleep } from '../../libs/function/index';
1
2
  export default {
2
3
  data() {
3
4
  return {
@@ -23,7 +24,7 @@ export default {
23
24
  // 获取slider尺寸
24
25
  getSliderRect() {
25
26
  // 获取滑块条的尺寸信息
26
- uni.$u.sleep().then(() => {
27
+ sleep().then(() => {
27
28
  this.$uGetRect('.u-slider').then((rect) => {
28
29
  this.info.width = rect.width
29
30
  this.info.left = rect.left
@@ -39,4 +40,4 @@ export default {
39
40
  this.$emit(e.event, e.value ? e.value : this.value)
40
41
  }
41
42
  }
42
- }
43
+ }
@@ -8,7 +8,7 @@ const BindingX = uni.requireNativePlugin('bindingx')
8
8
  const dom = uni.requireNativePlugin('dom')
9
9
  // nvue中用于操作元素动画的库,类似于uni.animation,只不过uni.animation不能用于nvue
10
10
  const animation = uni.requireNativePlugin('animation')
11
-
11
+ import { range } from '../../libs/function/index';
12
12
  export default {
13
13
  data() {
14
14
  return {
@@ -141,7 +141,7 @@ export default {
141
141
  }, (e) => {
142
142
  if (e.state === 'end' || e.state === 'exit') {
143
143
  //
144
- this.x = uni.$u.range(0, left + width, e.deltaX + this.x)
144
+ this.x = range(0, left + width, e.deltaX + this.x)
145
145
  // 根据偏移值,得出移动的百分比,进而修改双向绑定的v-model的值
146
146
  const value = (this.x / width) * 100
147
147
  const percent = this.formatStep(value)
@@ -8,7 +8,7 @@ const BindingX = uni.requireNativePlugin('bindingx')
8
8
  const dom = uni.requireNativePlugin('dom')
9
9
  // nvue中用于操作元素动画的库,类似于uni.animation,只不过uni.animation不能用于nvue
10
10
  const animation = uni.requireNativePlugin('animation')
11
-
11
+ import { range } from '../../libs/function/index';
12
12
  export default {
13
13
  data() {
14
14
  return {
@@ -180,7 +180,7 @@ export default {
180
180
  // 移动点占总长度的百分比,此处需要先除以step,是为了保证step大于1时,比如10,那么在滑动11,12px这样的
181
181
  // 距离时,实际上滑块是不会滑动的,到了16,17px,经过四舍五入后,就变成了20px,进行了下一个跳变
182
182
  format(value) {
183
- return Math.round(uni.$u.range(this.min, this.max, value) / this.step) * this.step
183
+ return Math.round(range(this.min, this.max, value) / this.step) * this.step
184
184
  },
185
185
  getRange() {
186
186
  const {
@@ -20,15 +20,18 @@
20
20
  </view>
21
21
  </template>
22
22
 
23
- <script>
24
- import props from './props.js';
25
- import mpMixin from '../../libs/mixin/mpMixin.js';
26
- import mixin from '../../libs/mixin/mixin.js';
23
+ <script>
24
+ import props from './props';
25
+ import mpMixin from '../../libs/mixin/mpMixin';
26
+ import mixin from '../../libs/mixin/mixin';
27
+ import { addStyle, getPx } from '../../libs/function/index.js';
27
28
  export default {
28
29
  name: 'up-slider',
29
30
  mixins: [mpMixin, mixin, props],
30
31
  emits: ["changing", "change", "update:modelValue"],
31
- methods: {
32
+ methods: {
33
+ addStyle,
34
+ getPx,
32
35
  // 拖动过程中触发
33
36
  changingHandler(e) {
34
37
  const {
@@ -8,9 +8,10 @@
8
8
  </template>
9
9
 
10
10
  <script>
11
- import props from './props.js';
12
- import mpMixin from '../../libs/mixin/mpMixin.js';
13
- import mixin from '../../libs/mixin/mixin.js';
11
+ import props from './props';
12
+ import mpMixin from '../../libs/mixin/mpMixin';
13
+ import mixin from '../../libs/mixin/mixin';
14
+ import { addUnit, addStyle, deepMerge, sys } from '../../libs/function/index';
14
15
  /**
15
16
  * StatbusBar 状态栏占位
16
17
  * @description 本组件主要用于状态填充,比如在自定导航栏的时候,它会自动适配一个恰当的状态栏高度。
@@ -30,9 +31,9 @@
30
31
  style() {
31
32
  const style = {}
32
33
  // 状态栏高度,由于某些安卓和微信开发工具无法识别css的顶部状态栏变量,所以使用js获取的方式
33
- style.height = uni.$u.addUnit(uni.$u.sys().statusBarHeight, 'px')
34
+ style.height = addUnit(sys().statusBarHeight, 'px')
34
35
  style.backgroundColor = this.bgColor
35
- return uni.$u.deepMerge(style, uni.$u.addStyle(this.customStyle))
36
+ return deepMerge(style, addStyle(this.customStyle))
36
37
  }
37
38
  },
38
39
  }
@@ -8,9 +8,10 @@
8
8
  </template>
9
9
 
10
10
  <script>
11
- import props from './props.js';
12
- import mpMixin from '../../libs/mixin/mpMixin.js';
13
- import mixin from '../../libs/mixin/mixin.js';
11
+ import props from './props';
12
+ import mpMixin from '../../libs/mixin/mpMixin';
13
+ import mixin from '../../libs/mixin/mixin';
14
+ import test from '../../libs/function/test';
14
15
  /**
15
16
  * Steps 步骤条
16
17
  * @description 该组件一般用于完成一个任务要分几个步骤,标识目前处于第几步的场景。
@@ -50,7 +51,7 @@
50
51
  updateChildData() {
51
52
  this.children.map(child => {
52
53
  // 先判断子组件是否存在对应的方法
53
- uni.$u.test.func((child || {}).updateFromParent()) && child.updateFromParent()
54
+ test.func((child || {}).updateFromParent()) && child.updateFromParent()
54
55
  })
55
56
  },
56
57
  // 接受子组件的通知,去修改其他子组件的数据
@@ -47,9 +47,11 @@
47
47
  </template>
48
48
 
49
49
  <script>
50
- import props from './props.js';
51
- import mpMixin from '../../libs/mixin/mpMixin.js';
52
- import mixin from '../../libs/mixin/mixin.js';
50
+ import props from './props';
51
+ import mpMixin from '../../libs/mixin/mpMixin';
52
+ import mixin from '../../libs/mixin/mixin';
53
+ import { sleep, error } from '../../libs/function/index';
54
+ import color from '../../libs/config/color';
53
55
  // #ifdef APP-NVUE
54
56
  const dom = uni.requireNativePlugin('dom')
55
57
  // #endif
@@ -103,7 +105,7 @@
103
105
  style.height = this.size.height + 'px'
104
106
  // style.top = this.size.height / 2 + 'px'
105
107
  }
106
- style.backgroundColor = this.parent.children?.[this.index + 1]?.error ? uni.$u.color.error : this.index <
108
+ style.backgroundColor = this.parent.children?.[this.index + 1]?.error ? color.error : this.index <
107
109
  this
108
110
  .parentData
109
111
  .current ? this.parentData.activeColor : this.parentData.inactiveColor
@@ -134,7 +136,7 @@
134
136
  color = this.parentData.activeColor
135
137
  break
136
138
  case 'error':
137
- color = uni.$u.color.error
139
+ color = color.error
138
140
  break
139
141
  case 'process':
140
142
  color = this.parentData.dot ? this.parentData.activeColor : 'transparent'
@@ -160,7 +162,7 @@
160
162
  },
161
163
  mounted() {
162
164
  this.parent && this.parent.updateFromChild()
163
- uni.$u.sleep().then(() => {
165
+ sleep().then(() => {
164
166
  this.getStepsItemRect()
165
167
  })
166
168
  },
@@ -169,7 +171,7 @@
169
171
  // 初始化数据
170
172
  this.updateParentData()
171
173
  if (!this.parent) {
172
- return uni.$u.error('u-steps-item必须要搭配u-steps组件使用')
174
+ return error('u-steps-item必须要搭配u-steps组件使用')
173
175
  }
174
176
  this.index = this.parent.children.indexOf(this)
175
177
  this.childLength = this.parent.children.length
@@ -14,9 +14,11 @@
14
14
  </template>
15
15
 
16
16
  <script>
17
- import props from './props.js';
18
- import mpMixin from '../../libs/mixin/mpMixin.js';
19
- import mixin from '../../libs/mixin/mixin.js';
17
+ import props from './props';
18
+ import mpMixin from '../../libs/mixin/mpMixin';
19
+ import mixin from '../../libs/mixin/mixin';
20
+ import { addUnit, addStyle, deepMerge, getPx, guid, sys, os } from '../../libs/function/index';
21
+ import zIndex from '../../libs/config/zIndex';
20
22
  /**
21
23
  * sticky 吸顶
22
24
  * @description 该组件与CSS中position: sticky属性实现的效果一致,当组件达到预设的到顶部距离时, 就会固定在指定位置,组件位置大于预设的顶部距离时,会重新按照正常的布局排列。
@@ -39,7 +41,7 @@
39
41
  return {
40
42
  cssSticky: false, // 是否使用css的sticky实现
41
43
  stickyTop: 0, // 吸顶的top值,因为可能受自定义导航栏影响,最终的吸顶值非offsetTop值
42
- elId: uni.$u.guid(),
44
+ elId: guid(),
43
45
  left: 0, // js模式时,吸顶的内容因为处于postition: fixed模式,为了和原来保持一致的样式,需要记录并重新设置它的left,height,width属性
44
46
  width: 'auto',
45
47
  height: 'auto',
@@ -53,7 +55,7 @@
53
55
  if (this.cssSticky) {
54
56
  style.position = 'sticky'
55
57
  style.zIndex = this.uZindex
56
- style.top = uni.$u.addUnit(this.stickyTop)
58
+ style.top = addUnit(this.stickyTop)
57
59
  } else {
58
60
  style.height = this.fixed ? this.height + 'px' : 'auto'
59
61
  }
@@ -67,7 +69,7 @@
67
69
  // #endif
68
70
  }
69
71
  style.backgroundColor = this.bgColor
70
- return uni.$u.deepMerge(uni.$u.addStyle(this.customStyle), style)
72
+ return deepMerge(addStyle(this.customStyle), style)
71
73
  },
72
74
  // 吸顶内容的样式
73
75
  stickyContent() {
@@ -82,7 +84,7 @@
82
84
  return style
83
85
  },
84
86
  uZindex() {
85
- return this.zIndex ? this.zIndex : uni.$u.zIndex.sticky
87
+ return this.zIndex ? this.zIndex : zIndex.sticky
86
88
  }
87
89
  },
88
90
  mounted() {
@@ -137,7 +139,7 @@
137
139
  observer && observer.disconnect()
138
140
  },
139
141
  getStickyTop() {
140
- this.stickyTop = uni.$u.getPx(this.offsetTop) + uni.$u.getPx(this.customNavHeight)
142
+ this.stickyTop = getPx(this.offsetTop) + getPx(this.customNavHeight)
141
143
  },
142
144
  async checkSupportCssSticky() {
143
145
  // #ifdef H5
@@ -148,7 +150,7 @@
148
150
  // #endif
149
151
 
150
152
  // 如果安卓版本高于8.0,依然认为是支持css sticky的(因为安卓7在某些机型,可能不支持sticky)
151
- if (uni.$u.os() === 'android' && Number(uni.$u.sys().system) > 8) {
153
+ if (os() === 'android' && Number(sys().system) > 8) {
152
154
  this.cssSticky = true
153
155
  }
154
156
 
@@ -158,7 +160,7 @@
158
160
  // #endif
159
161
 
160
162
  // ios上,从ios6开始,都是支持css sticky的
161
- if (uni.$u.os() === 'ios') {
163
+ if (os() === 'ios') {
162
164
  this.cssSticky = true
163
165
  }
164
166
 
@@ -3,7 +3,7 @@
3
3
  class="u-subsection"
4
4
  ref="u-subsection"
5
5
  :class="[`u-subsection--${mode}`]"
6
- :style="[$u.addStyle(customStyle), wrapperStyle]"
6
+ :style="[addStyle(customStyle), wrapperStyle]"
7
7
  >
8
8
  <view
9
9
  class="u-subsection__bar cursor-pointer"
@@ -53,8 +53,9 @@ const dom = uni.requireNativePlugin("dom");
53
53
  const animation = uni.requireNativePlugin("animation");
54
54
  // #endif
55
55
  import props from "./props.js";
56
- import mpMixin from '../../libs/mixin/mpMixin.js';
57
- import mixin from '../../libs/mixin/mixin.js';
56
+ import mpMixin from '../../libs/mixin/mpMixin';
57
+ import mixin from '../../libs/mixin/mixin';
58
+ import { addStyle, addUnit, sleep } from '../../libs/function/index';
58
59
  /**
59
60
  * Subsection 分段器
60
61
  * @description 该分段器一般用于用户从几个选项中选择某一个的场景
@@ -102,7 +103,7 @@ export default {
102
103
  // 故用animation模块进行位移
103
104
  const ref = this.$refs?.["u-subsection__bar"]?.ref;
104
105
  // 不存在ref的时候(理解为第一次初始化时,需要渲染dom,进行一定延时再获取ref),这里的100ms是经过测试得出的结果(某些安卓需要延时久一点),勿随意修改
105
- uni.$u.sleep(ref ? 0 : 100).then(() => {
106
+ sleep(ref ? 0 : 100).then(() => {
106
107
  animation.transition(this.$refs["u-subsection__bar"].ref, {
107
108
  styles: {
108
109
  transform: `translateX(${
@@ -162,7 +163,7 @@ export default {
162
163
  const style = {};
163
164
  style.fontWeight =
164
165
  this.bold && this.innerCurrent === index ? "bold" : "normal";
165
- style.fontSize = uni.$u.addUnit(this.fontSize);
166
+ style.fontSize = addUnit(this.fontSize);
166
167
  // subsection模式下,激活时默认为白色的文字
167
168
  if (this.mode === "subsection") {
168
169
  style.color =
@@ -190,9 +191,10 @@ export default {
190
191
  },
191
192
  emits: ["change"],
192
193
  methods: {
194
+ addStyle,
193
195
  init() {
194
196
  this.innerCurrent = this.current
195
- uni.$u.sleep().then(() => this.getRect());
197
+ sleep().then(() => this.getRect());
196
198
  },
197
199
  // 判断展示文本
198
200
  getText(item) {
@@ -5,9 +5,9 @@
5
5
  </template>
6
6
 
7
7
  <script>
8
- import props from './props.js';
9
- import mpMixin from '../../libs/mixin/mpMixin.js';
10
- import mixin from '../../libs/mixin/mixin.js';
8
+ import props from './props';
9
+ import mpMixin from '../../libs/mixin/mpMixin';
10
+ import mixin from '../../libs/mixin/mixin';
11
11
  /**
12
12
  * SwipeAction 滑动单元格
13
13
  * @description 该组件一般用于左滑唤出操作菜单的场景,用的最多的是左滑删除操作
@@ -2,7 +2,7 @@
2
2
  const dom = uni.requireNativePlugin('dom')
3
3
  // nvue中用于操作元素动画的库,类似于uni.animation,只不过uni.animation不能用于nvue
4
4
  const animation = uni.requireNativePlugin('animation')
5
-
5
+ import { sleep } from '../../libs/function/index';
6
6
  export default {
7
7
  data() {
8
8
  return {
@@ -41,7 +41,7 @@ export default {
41
41
  immediate: true,
42
42
  handler(n) {
43
43
  // if(n === true) {
44
- // uni.$u.sleep(50).then(() => {
44
+ // sleep(50).then(() => {
45
45
  // this.openSwipeAction()
46
46
  // })
47
47
  // } else {
@@ -51,7 +51,7 @@ export default {
51
51
  }
52
52
  },
53
53
  mounted() {
54
- uni.$u.sleep(20).then(() => {
54
+ sleep(20).then(() => {
55
55
  this.queryRect()
56
56
  })
57
57
  },
@@ -2,7 +2,7 @@
2
2
  const dom = uni.requireNativePlugin('dom');
3
3
  const bindingX = uni.requireNativePlugin('bindingx');
4
4
  const animation = uni.requireNativePlugin('animation');
5
-
5
+ import { getPx, getDuration } from '../../libs/function/index';
6
6
  export default {
7
7
  data() {
8
8
  return {
@@ -99,7 +99,7 @@ export default {
99
99
  this.$nextTick(() => {
100
100
  this.status = deltaX <= -this.buttonsWidth ? 'open' : 'close'
101
101
  })
102
- } else if(Math.abs(deltaX) > uni.$u.getPx(this.threshold)) {
102
+ } else if(Math.abs(deltaX) > getPx(this.threshold)) {
103
103
  // 在移动大于阈值、并且小于总按钮宽度时,进行自动打开或者关闭
104
104
  // 移动距离大于0时,意味着需要关闭状态
105
105
  if(Math.abs(deltaX) < this.buttonsWidth) {
@@ -155,7 +155,7 @@ export default {
155
155
  styles: {
156
156
  transform: `translateX(${x}px)`,
157
157
  },
158
- duration: uni.$u.getDuration(this.duration, false),
158
+ duration: getDuration(this.duration, false),
159
159
  timingFunction: 'ease-in-out'
160
160
  }, () => {
161
161
  this.moving = false
@@ -16,7 +16,7 @@
16
16
  }, item.style]">
17
17
  <u-icon v-if="item.icon" :name="item.icon"
18
18
  :color="item.style && item.style.color ? item.style.color : '#ffffff'"
19
- :size="item.iconSize ? $u.addUnit(item.iconSize) : item.style && item.style.fontSize ? $u.getPx(item.style.fontSize) * 1.2 : 17"
19
+ :size="item.iconSize ? addUnit(item.iconSize) : item.style && item.style.fontSize ? getPx(item.style.fontSize) * 1.2 : 17"
20
20
  :customStyle="{
21
21
  marginRight: item.text ? '2px' : 0
22
22
  }"></u-icon>
@@ -60,9 +60,10 @@
60
60
  <!-- #endif -->
61
61
  <script>
62
62
  import touch from '../../libs/mixin/touch.js'
63
- import props from './props.js';
64
- import mpMixin from '../../libs/mixin/mpMixin.js';
65
- import mixin from '../../libs/mixin/mixin.js';
63
+ import props from './props';
64
+ import mpMixin from '../../libs/mixin/mpMixin';
65
+ import mixin from '../../libs/mixin/mixin';
66
+ import { addUnit, getPx, sleep } from '../../libs/function/index';
66
67
  // #ifdef APP-NVUE
67
68
  import nvue from './nvue.js';
68
69
  // #endif
@@ -138,11 +139,13 @@
138
139
  this.init()
139
140
  },
140
141
  methods: {
142
+ addUnit,
143
+ getPx,
141
144
  init() {
142
145
  // 初始化父组件数据
143
146
  this.updateParentData()
144
147
  // #ifndef APP-NVUE
145
- uni.$u.sleep().then(() => {
148
+ sleep().then(() => {
146
149
  this.queryRect()
147
150
  })
148
151
  // #endif