uview-plus 3.2.8 → 3.2.9
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.
- package/changelog.md +5 -0
- package/components/u--form/u--form.vue +7 -7
- package/components/u--image/u--image.vue +3 -3
- package/components/u--input/u--input.vue +9 -9
- package/components/u--textarea/u--textarea.vue +3 -3
- package/components/u-action-sheet/u-action-sheet.vue +5 -4
- package/components/u-album/u-album.vue +9 -7
- package/components/u-alert/u-alert.vue +9 -6
- package/components/u-avatar/props.js +2 -1
- package/components/u-avatar/u-avatar.vue +15 -11
- package/components/u-avatar-group/u-avatar-group.vue +9 -5
- package/components/u-back-top/u-back-top.vue +9 -8
- package/components/u-badge/u-badge.vue +10 -6
- package/components/u-button/u-button.vue +13 -9
- package/components/u-calendar/header.vue +3 -3
- package/components/u-calendar/month.vue +17 -15
- package/components/u-calendar/u-calendar.vue +10 -8
- package/components/u-car-keyboard/u-car-keyboard.vue +7 -6
- package/components/u-cell/u-cell.vue +9 -6
- package/components/u-cell-group/u-cell-group.vue +8 -4
- package/components/u-checkbox/u-checkbox.vue +13 -11
- package/components/u-checkbox-group/u-checkbox-group.vue +3 -3
- package/components/u-circle-progress/u-circle-progress.vue +5 -4
- package/components/u-code/u-code.vue +3 -3
- package/components/u-code-input/u-code-input.vue +9 -8
- package/components/u-col/u-col.vue +9 -8
- package/components/u-collapse/u-collapse.vue +3 -3
- package/components/u-collapse-item/u-collapse-item.vue +32 -15
- package/components/u-column-notice/u-column-notice.vue +8 -6
- package/components/u-count-down/u-count-down.vue +3 -3
- package/components/u-count-to/u-count-to.vue +6 -4
- package/components/u-datetime-picker/u-datetime-picker.vue +15 -15
- package/components/u-divider/u-divider.vue +7 -5
- package/components/u-dropdown/u-dropdown.vue +12 -10
- package/components/u-dropdown-item/u-dropdown-item.vue +7 -5
- package/components/u-empty/u-empty.vue +12 -8
- package/components/u-form/u-form.vue +12 -10
- package/components/u-form-item/u-form-item.vue +17 -11
- package/components/u-gap/u-gap.vue +3 -3
- package/components/u-grid/u-grid.vue +18 -7
- package/components/u-grid-item/u-grid-item.vue +14 -9
- package/components/u-icon/u-icon.vue +21 -19
- package/components/u-image/u-image.vue +18 -16
- package/components/u-index-anchor/u-index-anchor.vue +11 -9
- package/components/u-index-item/u-index-item.vue +6 -5
- package/components/u-index-list/u-index-list.vue +20 -18
- package/components/u-input/u-input.vue +12 -11
- package/components/u-keyboard/u-keyboard.vue +3 -3
- package/components/u-line/u-line.vue +7 -6
- package/components/u-line-progress/u-line-progress.vue +11 -8
- package/components/u-link/u-link.vue +9 -8
- package/components/u-list/u-list.vue +9 -9
- package/components/u-list-item/u-list-item.vue +5 -4
- package/components/u-loading-icon/u-loading-icon.vue +14 -10
- package/components/u-loading-page/u-loading-page.vue +10 -7
- package/components/u-loadmore/u-loadmore.vue +12 -10
- package/components/u-modal/u-modal.vue +7 -5
- package/components/u-navbar/u-navbar.vue +12 -7
- package/components/u-no-network/u-no-network.vue +6 -6
- package/components/u-notice-bar/u-notice-bar.vue +6 -5
- package/components/u-notify/u-notify.vue +19 -15
- package/components/u-number-box/u-number-box.vue +8 -7
- package/components/u-number-keyboard/u-number-keyboard.vue +7 -7
- package/components/u-overlay/u-overlay.vue +5 -5
- package/components/u-picker/u-picker.vue +19 -15
- package/components/u-picker-column/u-picker-column.vue +3 -3
- package/components/u-popup/u-popup.vue +13 -13
- package/components/u-radio/u-radio.vue +12 -12
- package/components/u-radio-group/u-radio-group.vue +3 -3
- package/components/u-rate/u-rate.vue +16 -14
- package/components/u-read-more/u-read-more.vue +9 -7
- package/components/u-row/u-row.vue +8 -7
- package/components/u-row-notice/u-row-notice.vue +14 -12
- package/components/u-safe-bottom/u-safe-bottom.vue +5 -4
- package/components/u-scroll-list/nvue.js +4 -4
- package/components/u-scroll-list/u-scroll-list.vue +13 -10
- package/components/u-search/u-search.vue +8 -6
- package/components/u-skeleton/u-skeleton.vue +20 -17
- package/components/u-slider/mpwxs.js +3 -2
- package/components/u-slider/nvue - /345/211/257/346/234/254.js" +2 -2
- package/components/u-slider/nvue.js +2 -2
- package/components/u-slider/u-slider.vue +8 -5
- package/components/u-status-bar/u-status-bar.vue +6 -5
- package/components/u-steps/u-steps.vue +5 -4
- package/components/u-steps-item/u-steps-item.vue +9 -7
- package/components/u-sticky/u-sticky.vue +12 -10
- package/components/u-subsection/u-subsection.vue +8 -6
- package/components/u-swipe-action/u-swipe-action.vue +3 -3
- package/components/u-swipe-action-item/nvue - backup.js +3 -3
- package/components/u-swipe-action-item/nvue.js +3 -3
- package/components/u-swipe-action-item/u-swipe-action-item.vue +8 -5
- package/components/u-swiper/u-swiper.vue +35 -24
- package/components/u-swiper-indicator/u-swiper-indicator.vue +10 -7
- package/components/u-switch/u-switch.vue +15 -13
- package/components/u-tabbar/u-tabbar.vue +6 -5
- package/components/u-tabbar-item/u-tabbar-item.vue +7 -5
- package/components/u-table/u-table.vue +3 -3
- package/components/u-tabs/u-tabs.vue +18 -14
- package/components/u-tabs-item/u-tabs-item.vue +3 -3
- package/components/u-tag/u-tag.vue +6 -4
- package/components/u-td/u-td.vue +3 -3
- package/components/u-text/u-text.vue +12 -10
- package/components/u-text/value.js +14 -12
- package/components/u-textarea/u-textarea.vue +11 -8
- package/components/u-toast/u-toast.vue +12 -9
- package/components/u-toolbar/u-toolbar.vue +3 -3
- package/components/u-tooltip/u-tooltip.vue +18 -17
- package/components/u-tr/u-tr.vue +3 -3
- package/components/u-transition/transition.js +2 -2
- package/components/u-transition/u-transition.vue +6 -5
- package/components/u-upload/mixin.js +4 -3
- package/components/u-upload/u-upload.vue +20 -17
- package/index.js +0 -5
- package/libs/function/index.js +27 -20
- package/libs/function/throttle.js +2 -2
- package/libs/mixin/mixin.js +14 -6
- package/libs/mixin/style.js +23 -4
- package/libs/util/route.js +6 -6
- package/package.json +1 -1
|
@@ -45,10 +45,10 @@
|
|
|
45
45
|
</template>
|
|
46
46
|
|
|
47
47
|
<script>
|
|
48
|
-
import props from './props
|
|
49
|
-
import mpMixin from '../../libs/mixin/mpMixin
|
|
50
|
-
import mixin from '../../libs/mixin/mixin
|
|
51
|
-
|
|
48
|
+
import props from './props';
|
|
49
|
+
import mpMixin from '../../libs/mixin/mpMixin';
|
|
50
|
+
import mixin from '../../libs/mixin/mixin';
|
|
51
|
+
import { addUnit, addStyle, deepMerge, sleep, sys } from '../../libs/function/index';
|
|
52
52
|
/**
|
|
53
53
|
* popup 弹窗
|
|
54
54
|
* @description 弹出层容器,用于展示弹窗、信息提示等内容,支持上、下、左、右和中部弹出。组件只提供容器,内部内容由用户自定义
|
|
@@ -100,27 +100,27 @@
|
|
|
100
100
|
}
|
|
101
101
|
style[this.mode] = 0
|
|
102
102
|
if (this.mode === 'left') {
|
|
103
|
-
return
|
|
103
|
+
return deepMerge(style, {
|
|
104
104
|
bottom: 0,
|
|
105
105
|
top: 0,
|
|
106
106
|
})
|
|
107
107
|
} else if (this.mode === 'right') {
|
|
108
|
-
return
|
|
108
|
+
return deepMerge(style, {
|
|
109
109
|
bottom: 0,
|
|
110
110
|
top: 0,
|
|
111
111
|
})
|
|
112
112
|
} else if (this.mode === 'top') {
|
|
113
|
-
return
|
|
113
|
+
return deepMerge(style, {
|
|
114
114
|
left: 0,
|
|
115
115
|
right: 0
|
|
116
116
|
})
|
|
117
117
|
} else if (this.mode === 'bottom') {
|
|
118
|
-
return
|
|
118
|
+
return deepMerge(style, {
|
|
119
119
|
left: 0,
|
|
120
120
|
right: 0,
|
|
121
121
|
})
|
|
122
122
|
} else if (this.mode === 'center') {
|
|
123
|
-
return
|
|
123
|
+
return deepMerge(style, {
|
|
124
124
|
alignItems: 'center',
|
|
125
125
|
'justify-content': 'center',
|
|
126
126
|
top: 0,
|
|
@@ -136,7 +136,7 @@
|
|
|
136
136
|
// 不使用css方案,是因为nvue不支持css的iPhoneX安全区查询属性
|
|
137
137
|
const {
|
|
138
138
|
safeAreaInsets
|
|
139
|
-
} =
|
|
139
|
+
} = sys()
|
|
140
140
|
if (this.mode !== 'center') {
|
|
141
141
|
style.flex = 1
|
|
142
142
|
}
|
|
@@ -145,7 +145,7 @@
|
|
|
145
145
|
style.backgroundColor = this.bgColor
|
|
146
146
|
}
|
|
147
147
|
if(this.round) {
|
|
148
|
-
const value =
|
|
148
|
+
const value = addUnit(this.round)
|
|
149
149
|
if(this.mode === 'top') {
|
|
150
150
|
style.borderBottomLeftRadius = value
|
|
151
151
|
style.borderBottomRightRadius = value
|
|
@@ -156,7 +156,7 @@
|
|
|
156
156
|
style.borderRadius = value
|
|
157
157
|
}
|
|
158
158
|
}
|
|
159
|
-
return
|
|
159
|
+
return deepMerge(style, addStyle(this.customStyle))
|
|
160
160
|
},
|
|
161
161
|
position() {
|
|
162
162
|
if (this.mode === 'center') {
|
|
@@ -213,7 +213,7 @@
|
|
|
213
213
|
// 判断如果在需要重新初始化的组件数组中名中,并且存在init方法的话,则执行
|
|
214
214
|
if (names.includes(child.$options.name) && typeof child?.init === 'function') {
|
|
215
215
|
// 需要进行一定的延时,因为初始化页面需要时间
|
|
216
|
-
|
|
216
|
+
sleep(50).then(() => {
|
|
217
217
|
child.init()
|
|
218
218
|
})
|
|
219
219
|
}
|
|
@@ -33,9 +33,10 @@
|
|
|
33
33
|
</template>
|
|
34
34
|
|
|
35
35
|
<script>
|
|
36
|
-
import props from './props
|
|
37
|
-
import mpMixin from '../../libs/mixin/mpMixin
|
|
38
|
-
import mixin from '../../libs/mixin/mixin
|
|
36
|
+
import props from './props';
|
|
37
|
+
import mpMixin from '../../libs/mixin/mpMixin';
|
|
38
|
+
import mixin from '../../libs/mixin/mixin';
|
|
39
|
+
import { addUnit, addStyle, os, deepMerge, formValidate, error } from '../../libs/function/index';
|
|
39
40
|
/**
|
|
40
41
|
* radio 单选框
|
|
41
42
|
* @description 单选框用于有一个选择,用户只能选择其中一个的场景。搭配u-radio-group使用
|
|
@@ -59,7 +60,6 @@
|
|
|
59
60
|
*/
|
|
60
61
|
export default {
|
|
61
62
|
name: "u-radio",
|
|
62
|
-
|
|
63
63
|
mixins: [mpMixin, mixin,props],
|
|
64
64
|
data() {
|
|
65
65
|
return {
|
|
@@ -121,7 +121,7 @@
|
|
|
121
121
|
},
|
|
122
122
|
// label大小
|
|
123
123
|
elLabelSize() {
|
|
124
|
-
return
|
|
124
|
+
return addUnit(this.labelSize ? this.labelSize : (this.parentData.labelSize ? this.parentData.labelSize :
|
|
125
125
|
'15'))
|
|
126
126
|
},
|
|
127
127
|
elIconColor() {
|
|
@@ -156,8 +156,8 @@
|
|
|
156
156
|
const style = {}
|
|
157
157
|
style.backgroundColor = this.checked && !this.elDisabled ? this.elActiveColor : '#ffffff'
|
|
158
158
|
style.borderColor = this.checked && !this.elDisabled ? this.elActiveColor : this.elInactiveColor
|
|
159
|
-
style.width =
|
|
160
|
-
style.height =
|
|
159
|
+
style.width = addUnit(this.elSize)
|
|
160
|
+
style.height = addUnit(this.elSize)
|
|
161
161
|
// 如果是图标在右边的话,移除它的右边距
|
|
162
162
|
if (this.parentData.iconPlacement === 'right') {
|
|
163
163
|
style.marginRight = 0
|
|
@@ -167,14 +167,14 @@
|
|
|
167
167
|
radioStyle() {
|
|
168
168
|
const style = {}
|
|
169
169
|
if(this.parentData.borderBottom && this.parentData.placement === 'row') {
|
|
170
|
-
|
|
170
|
+
error('检测到您将borderBottom设置为true,需要同时将u-radio-group的placement设置为column才有效')
|
|
171
171
|
}
|
|
172
172
|
// 当父组件设置了显示下边框并且排列形式为纵向时,给内容和边框之间加上一定间隔
|
|
173
173
|
if(this.parentData.borderBottom && this.parentData.placement === 'column') {
|
|
174
174
|
// ios像素密度高,需要多一点的距离
|
|
175
|
-
style.paddingBottom =
|
|
175
|
+
style.paddingBottom = os() === 'ios' ? '12px' : '8px'
|
|
176
176
|
}
|
|
177
|
-
return
|
|
177
|
+
return deepMerge(style, addStyle(this.customStyle))
|
|
178
178
|
}
|
|
179
179
|
},
|
|
180
180
|
mounted() {
|
|
@@ -186,7 +186,7 @@
|
|
|
186
186
|
// 支付宝小程序不支持provide/inject,所以使用这个方法获取整个父组件,在created定义,避免循环引用
|
|
187
187
|
this.updateParentData()
|
|
188
188
|
if (!this.parent) {
|
|
189
|
-
|
|
189
|
+
error('u-radio必须搭配u-radio-group组件使用')
|
|
190
190
|
}
|
|
191
191
|
// 设置初始化时,是否默认选中的状态
|
|
192
192
|
// #ifdef VUE3
|
|
@@ -225,7 +225,7 @@
|
|
|
225
225
|
this.$emit('change', this.name)
|
|
226
226
|
// 尝试调用u-form的验证方法,进行一定延迟,否则微信小程序更新可能会不及时
|
|
227
227
|
this.$nextTick(() => {
|
|
228
|
-
|
|
228
|
+
formValidate(this, 'change')
|
|
229
229
|
})
|
|
230
230
|
}
|
|
231
231
|
},
|
|
@@ -8,9 +8,9 @@
|
|
|
8
8
|
</template>
|
|
9
9
|
|
|
10
10
|
<script>
|
|
11
|
-
import props from './props
|
|
12
|
-
import mpMixin from '../../libs/mixin/mpMixin
|
|
13
|
-
import mixin from '../../libs/mixin/mixin
|
|
11
|
+
import props from './props';
|
|
12
|
+
import mpMixin from '../../libs/mixin/mpMixin';
|
|
13
|
+
import mixin from '../../libs/mixin/mixin';
|
|
14
14
|
|
|
15
15
|
/**
|
|
16
16
|
* radioRroup 单选框父组件
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
class="u-rate"
|
|
4
4
|
:id="elId"
|
|
5
5
|
ref="u-rate"
|
|
6
|
-
:style="[
|
|
6
|
+
:style="[addStyle(customStyle)]"
|
|
7
7
|
>
|
|
8
8
|
<view
|
|
9
9
|
class="u-rate__content"
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
: inactiveColor
|
|
36
36
|
"
|
|
37
37
|
:custom-style="{
|
|
38
|
-
padding: `0 ${
|
|
38
|
+
padding: `0 ${addUnit(gutter / 2)}`,
|
|
39
39
|
}"
|
|
40
40
|
:size="size"
|
|
41
41
|
></u-icon>
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
@tap.stop="clickHandler($event, index + 1)"
|
|
46
46
|
class="u-rate__content__item__icon-wrap u-rate__content__item__icon-wrap--half"
|
|
47
47
|
:style="[{
|
|
48
|
-
width:
|
|
48
|
+
width: addUnit(rateWidth / 2),
|
|
49
49
|
}]"
|
|
50
50
|
ref="u-rate__content__item__icon-wrap"
|
|
51
51
|
>
|
|
@@ -63,7 +63,7 @@
|
|
|
63
63
|
: inactiveColor
|
|
64
64
|
"
|
|
65
65
|
:custom-style="{
|
|
66
|
-
padding: `0 ${
|
|
66
|
+
padding: `0 ${addUnit(gutter / 2)}`
|
|
67
67
|
}"
|
|
68
68
|
:size="size"
|
|
69
69
|
></u-icon>
|
|
@@ -74,10 +74,10 @@
|
|
|
74
74
|
</template>
|
|
75
75
|
|
|
76
76
|
<script>
|
|
77
|
-
import props from './props
|
|
78
|
-
import mpMixin from '../../libs/mixin/mpMixin
|
|
79
|
-
import mixin from '../../libs/mixin/mixin
|
|
80
|
-
|
|
77
|
+
import props from './props';
|
|
78
|
+
import mpMixin from '../../libs/mixin/mpMixin';
|
|
79
|
+
import mixin from '../../libs/mixin/mixin';
|
|
80
|
+
import { addUnit, addStyle, guid, sleep, range, os } from '../../libs/function/index';
|
|
81
81
|
// #ifdef APP-NVUE
|
|
82
82
|
const dom = weex.requireModule("dom");
|
|
83
83
|
// #endif
|
|
@@ -108,8 +108,8 @@
|
|
|
108
108
|
data() {
|
|
109
109
|
return {
|
|
110
110
|
// 生成一个唯一id,否则一个页面多个评分组件,会造成冲突
|
|
111
|
-
elId:
|
|
112
|
-
elClass:
|
|
111
|
+
elId: guid(),
|
|
112
|
+
elClass: guid(),
|
|
113
113
|
rateBoxLeft: 0, // 评分盒子左边到屏幕左边的距离,用于滑动选择时计算距离
|
|
114
114
|
// #ifdef VUE3
|
|
115
115
|
activeIndex: this.modelValue,
|
|
@@ -139,15 +139,17 @@
|
|
|
139
139
|
emits: ['update:modelValue', 'change'],
|
|
140
140
|
// #endif
|
|
141
141
|
methods: {
|
|
142
|
+
addStyle,
|
|
143
|
+
addUnit,
|
|
142
144
|
init() {
|
|
143
|
-
|
|
145
|
+
sleep().then(() => {
|
|
144
146
|
this.getRateItemRect();
|
|
145
147
|
this.getRateIconWrapRect();
|
|
146
148
|
})
|
|
147
149
|
},
|
|
148
150
|
// 获取评分组件盒子的布局信息
|
|
149
151
|
async getRateItemRect() {
|
|
150
|
-
await
|
|
152
|
+
await sleep();
|
|
151
153
|
// uView封装的获取节点的方法,详见文档
|
|
152
154
|
// #ifndef APP-NVUE
|
|
153
155
|
this.$uGetRect("#" + this.elId).then((res) => {
|
|
@@ -200,7 +202,7 @@
|
|
|
200
202
|
// 通过点击,直接选中
|
|
201
203
|
clickHandler(e, index) {
|
|
202
204
|
// ios上,moving状态取消事件触发
|
|
203
|
-
if (
|
|
205
|
+
if (os() === "ios" && this.moving) {
|
|
204
206
|
return;
|
|
205
207
|
}
|
|
206
208
|
this.preventEvent(e);
|
|
@@ -235,7 +237,7 @@
|
|
|
235
237
|
// 判断当前操作的点的x坐标值,是否在允许的边界范围内
|
|
236
238
|
const allRateWidth = this.rateWidth * this.count + this.rateBoxLeft;
|
|
237
239
|
// 如果小于第一个图标的左边界,设置为最小值,如果大于所有图标的宽度,则设置为最大值
|
|
238
|
-
x =
|
|
240
|
+
x = range(this.rateBoxLeft, allRateWidth, x) - this.rateBoxLeft
|
|
239
241
|
// 滑动点相对于评分盒子左边的距离
|
|
240
242
|
const distance = x;
|
|
241
243
|
// 滑动的距离,相当于多少颗星星
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
<view
|
|
4
4
|
class="u-read-more__content"
|
|
5
5
|
:style="{
|
|
6
|
-
height: isLongContent && status === 'close' ?
|
|
6
|
+
height: isLongContent && status === 'close' ? addUnit(showHeight) : addUnit(contentHeight),
|
|
7
7
|
textIndent: textIndent
|
|
8
8
|
}"
|
|
9
9
|
>
|
|
@@ -49,9 +49,10 @@
|
|
|
49
49
|
// #ifdef APP-NVUE
|
|
50
50
|
const dom = uni.requireNativePlugin('dom')
|
|
51
51
|
// #endif
|
|
52
|
-
import props from './props
|
|
53
|
-
import mpMixin from '../../libs/mixin/mpMixin
|
|
54
|
-
import mixin from '../../libs/mixin/mixin
|
|
52
|
+
import props from './props';
|
|
53
|
+
import mpMixin from '../../libs/mixin/mpMixin';
|
|
54
|
+
import mixin from '../../libs/mixin/mixin';
|
|
55
|
+
import { addUnit, guid, getPx, sleep } from '../../libs/function/index';
|
|
55
56
|
/**
|
|
56
57
|
* readMore 阅读更多
|
|
57
58
|
* @description 该组件一般用于内容较长,预先收起一部分,点击展开全部内容的场景。
|
|
@@ -76,7 +77,7 @@
|
|
|
76
77
|
return {
|
|
77
78
|
isLongContent: false, // 是否需要隐藏一部分内容
|
|
78
79
|
status: 'close', // 当前隐藏与显示的状态,close-收起状态,open-展开状态
|
|
79
|
-
elId:
|
|
80
|
+
elId: guid(), // 生成唯一class
|
|
80
81
|
contentHeight: 100, // 内容高度
|
|
81
82
|
}
|
|
82
83
|
},
|
|
@@ -92,11 +93,12 @@
|
|
|
92
93
|
},
|
|
93
94
|
emits: ["open", "close"],
|
|
94
95
|
methods: {
|
|
96
|
+
addUnit,
|
|
95
97
|
async init() {
|
|
96
98
|
this.getContentHeight().then(height => {
|
|
97
99
|
this.contentHeight = height
|
|
98
100
|
// 判断高度,如果真实内容高度大于占位高度,则显示收起与展开的控制按钮
|
|
99
|
-
if (height >
|
|
101
|
+
if (height > getPx(this.showHeight)) {
|
|
100
102
|
this.isLongContent = true
|
|
101
103
|
this.status = 'close'
|
|
102
104
|
} else {
|
|
@@ -109,7 +111,7 @@
|
|
|
109
111
|
// 获取内容的高度
|
|
110
112
|
async getContentHeight() {
|
|
111
113
|
// 延时一定时间再获取节点
|
|
112
|
-
await
|
|
114
|
+
await sleep(30)
|
|
113
115
|
return new Promise(resolve => {
|
|
114
116
|
// #ifndef APP-NVUE
|
|
115
117
|
this.$uGetRect('.' + this.elId).then(res => {
|
|
@@ -13,9 +13,10 @@
|
|
|
13
13
|
// #ifdef APP-NVUE
|
|
14
14
|
const dom = uni.requireNativePlugin('dom')
|
|
15
15
|
// #endif
|
|
16
|
-
import props from './props
|
|
17
|
-
import mpMixin from '../../libs/mixin/mpMixin
|
|
18
|
-
import mixin from '../../libs/mixin/mixin
|
|
16
|
+
import props from './props';
|
|
17
|
+
import mpMixin from '../../libs/mixin/mpMixin';
|
|
18
|
+
import mixin from '../../libs/mixin/mixin';
|
|
19
|
+
import { addUnit, addStyle, deepMerge, sleep } from '../../libs/function/index';
|
|
19
20
|
/**
|
|
20
21
|
* Row 栅格系统中的行
|
|
21
22
|
* @description 通过基础的 12 分栏,迅速简便地创建布局
|
|
@@ -54,10 +55,10 @@
|
|
|
54
55
|
}
|
|
55
56
|
// 通过给u-row左右两边的负外边距,消除u-col在有gutter时,第一个和最后一个元素的左内边距和右内边距造成的影响
|
|
56
57
|
if(this.gutter) {
|
|
57
|
-
style.marginLeft =
|
|
58
|
-
style.marginRight =
|
|
58
|
+
style.marginLeft = addUnit(-Number(this.gutter)/2)
|
|
59
|
+
style.marginRight = addUnit(-Number(this.gutter)/2)
|
|
59
60
|
}
|
|
60
|
-
return
|
|
61
|
+
return deepMerge(style, addStyle(this.customStyle))
|
|
61
62
|
}
|
|
62
63
|
},
|
|
63
64
|
emits: ["click"],
|
|
@@ -67,7 +68,7 @@
|
|
|
67
68
|
},
|
|
68
69
|
async getComponentWidth() {
|
|
69
70
|
// 延时一定时间,以确保节点渲染完成
|
|
70
|
-
await
|
|
71
|
+
await sleep()
|
|
71
72
|
return new Promise(resolve => {
|
|
72
73
|
// uView封装的获取节点的方法,详见文档
|
|
73
74
|
// #ifndef APP-NVUE
|
|
@@ -52,9 +52,11 @@
|
|
|
52
52
|
</view>
|
|
53
53
|
</template>
|
|
54
54
|
<script>
|
|
55
|
-
import props from './props
|
|
56
|
-
import mpMixin from '../../libs/mixin/mpMixin
|
|
57
|
-
import mixin from '../../libs/mixin/mixin
|
|
55
|
+
import props from './props';
|
|
56
|
+
import mpMixin from '../../libs/mixin/mpMixin';
|
|
57
|
+
import mixin from '../../libs/mixin/mixin';
|
|
58
|
+
import { addUnit, error, sleep, getPx } from '../../libs/function/index';
|
|
59
|
+
import test from '../../libs/function/test';
|
|
58
60
|
// #ifdef APP-NVUE
|
|
59
61
|
const animation = uni.requireNativePlugin('animation')
|
|
60
62
|
const dom = uni.requireNativePlugin('dom')
|
|
@@ -99,8 +101,8 @@
|
|
|
99
101
|
this.vue()
|
|
100
102
|
// #endif
|
|
101
103
|
|
|
102
|
-
if(!
|
|
103
|
-
|
|
104
|
+
if(!test.string(newValue)) {
|
|
105
|
+
error('noticebar组件direction为row时,要求text参数为字符串形式')
|
|
104
106
|
}
|
|
105
107
|
}
|
|
106
108
|
},
|
|
@@ -126,7 +128,7 @@
|
|
|
126
128
|
textStyle() {
|
|
127
129
|
let style = {}
|
|
128
130
|
style.color = this.color
|
|
129
|
-
style.fontSize =
|
|
131
|
+
style.fontSize = addUnit(this.fontSize)
|
|
130
132
|
return style
|
|
131
133
|
},
|
|
132
134
|
animationStyle() {
|
|
@@ -177,8 +179,8 @@
|
|
|
177
179
|
this.vue()
|
|
178
180
|
// #endif
|
|
179
181
|
|
|
180
|
-
if(!
|
|
181
|
-
|
|
182
|
+
if(!test.string(this.text)) {
|
|
183
|
+
error('noticebar组件direction为row时,要求text参数为字符串形式')
|
|
182
184
|
}
|
|
183
185
|
},
|
|
184
186
|
// vue版处理
|
|
@@ -187,13 +189,13 @@
|
|
|
187
189
|
let boxWidth = 0,
|
|
188
190
|
textWidth = 0
|
|
189
191
|
// 进行一定的延时
|
|
190
|
-
await
|
|
192
|
+
await sleep()
|
|
191
193
|
// 查询盒子和文字的宽度
|
|
192
194
|
textWidth = (await this.$uGetRect('.u-notice__content__text')).width
|
|
193
195
|
boxWidth = (await this.$uGetRect('.u-notice__content')).width
|
|
194
196
|
// 根据t=s/v(时间=路程/速度),这里为何不需要加上#u-notice-box的宽度,因为中设置了.u-notice-content样式中设置了padding-left: 100%
|
|
195
197
|
// 恰巧计算出来的结果中已经包含了#u-notice-box的宽度
|
|
196
|
-
this.animationDuration = `${textWidth /
|
|
198
|
+
this.animationDuration = `${textWidth / getPx(this.speed)}s`
|
|
197
199
|
// 这里必须这样开始动画,否则在APP上动画速度不会改变
|
|
198
200
|
this.animationPlayState = 'paused'
|
|
199
201
|
setTimeout(() => {
|
|
@@ -208,7 +210,7 @@
|
|
|
208
210
|
let boxWidth = 0,
|
|
209
211
|
textWidth = 0
|
|
210
212
|
// 进行一定的延时
|
|
211
|
-
await
|
|
213
|
+
await sleep()
|
|
212
214
|
// 查询盒子和文字的宽度
|
|
213
215
|
textWidth = (await this.getNvueRect('u-notice__content__text')).width
|
|
214
216
|
boxWidth = (await this.getNvueRect('u-notice__content')).width
|
|
@@ -231,7 +233,7 @@
|
|
|
231
233
|
transform: `translateX(-${textWidth}px)`
|
|
232
234
|
},
|
|
233
235
|
// 滚动时间的计算为,时间 = 路程(boxWidth + textWidth) / 速度,最后转为毫秒
|
|
234
|
-
duration: (boxWidth + textWidth) /
|
|
236
|
+
duration: (boxWidth + textWidth) / getPx(this.speed) * 1000,
|
|
235
237
|
delay: 10
|
|
236
238
|
}, () => {
|
|
237
239
|
animation.transition(this.$refs['u-notice__content__text'], {
|
|
@@ -9,8 +9,9 @@
|
|
|
9
9
|
|
|
10
10
|
<script>
|
|
11
11
|
import props from "./props.js";
|
|
12
|
-
import mpMixin from '../../libs/mixin/mpMixin
|
|
13
|
-
import mixin from '../../libs/mixin/mixin
|
|
12
|
+
import mpMixin from '../../libs/mixin/mpMixin';
|
|
13
|
+
import mixin from '../../libs/mixin/mixin';
|
|
14
|
+
import { addUnit, sys } from '../../libs/function/index';
|
|
14
15
|
/**
|
|
15
16
|
* SafeBottom 底部安全区
|
|
16
17
|
* @description 这个适配,主要是针对IPhone X等一些底部带指示条的机型,指示条的操作区域与页面底部存在重合,容易导致用户误操作,因此我们需要针对这些机型进行底部安全区适配。
|
|
@@ -35,9 +36,9 @@
|
|
|
35
36
|
const style = {};
|
|
36
37
|
// #ifdef APP-NVUE || MP-TOUTIAO
|
|
37
38
|
// nvue下,高度使用js计算填充
|
|
38
|
-
style.height =
|
|
39
|
+
style.height = addUnit(sys().safeAreaInsets.bottom, 'px');
|
|
39
40
|
// #endif
|
|
40
|
-
return
|
|
41
|
+
return deepMerge(style, addStyle(this.customStyle));
|
|
41
42
|
},
|
|
42
43
|
},
|
|
43
44
|
mounted() {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// 引入bindingx,此库类似于微信小程序wxs,目的是让js运行在视图层,减少视图层和逻辑层的通信折损
|
|
2
2
|
const BindingX = uni.requireNativePlugin('bindingx')
|
|
3
|
-
|
|
3
|
+
import { os } from '../../libs/function/index';
|
|
4
4
|
export default {
|
|
5
5
|
methods: {
|
|
6
6
|
// 此处不写注释,请自行体会
|
|
@@ -10,9 +10,9 @@ export default {
|
|
|
10
10
|
const scrollLeft = e.contentOffset.x
|
|
11
11
|
const contentSize = e.contentSize.width
|
|
12
12
|
const { scrollWidth } = this
|
|
13
|
-
const barAllMoveWidth = this.indicatorWidth - this.indicatorBarWidth
|
|
14
|
-
// 在安卓和iOS上,需要除的倍数不一样,iOS需要除以2
|
|
15
|
-
const actionNum =
|
|
13
|
+
const barAllMoveWidth = this.indicatorWidth - this.indicatorBarWidth
|
|
14
|
+
// 在安卓和iOS上,需要除的倍数不一样,iOS需要除以2
|
|
15
|
+
const actionNum = os() === 'ios' ? 2 : 1
|
|
16
16
|
const expression = `(x / ${actionNum}) / ${contentSize - scrollWidth} * ${barAllMoveWidth}`
|
|
17
17
|
BindingX.bind({
|
|
18
18
|
anchor,
|
|
@@ -28,8 +28,8 @@
|
|
|
28
28
|
@scrolltoupper="wxs.scrolltoupper"
|
|
29
29
|
@scrolltolower="wxs.scrolltolower"
|
|
30
30
|
:data-scrollWidth="scrollWidth"
|
|
31
|
-
:data-barWidth="
|
|
32
|
-
:data-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="[
|
|
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
|
|
101
|
-
import mpMixin from '../../libs/mixin/mpMixin
|
|
102
|
-
import mixin from '../../libs/mixin/mixin
|
|
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 =
|
|
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 =
|
|
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 =
|
|
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
|
|
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
|
-
},
|
|
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:
|
|
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
|
|
76
|
-
import mpMixin from '../../libs/mixin/mpMixin
|
|
77
|
-
import mixin from '../../libs/mixin/mixin
|
|
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;
|