@kengic/uni 0.5.1 → 0.5.2-beta.1

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 (146) hide show
  1. package/dist/uni/uni-ui/uni-badge/uni-badge.vue +222 -219
  2. package/dist/uni/uni-ui/uni-breadcrumb/uni-breadcrumb.vue +29 -29
  3. package/dist/uni/uni-ui/uni-breadcrumb-item/uni-breadcrumb-item.vue +88 -88
  4. package/dist/uni/uni-ui/uni-calendar/calendar.js +936 -532
  5. package/dist/uni/uni-ui/uni-calendar/i18n/en.json +10 -10
  6. package/dist/uni/uni-ui/uni-calendar/i18n/index.js +8 -7
  7. package/dist/uni/uni-ui/uni-calendar/i18n/zh-Hans.json +10 -10
  8. package/dist/uni/uni-ui/uni-calendar/i18n/zh-Hant.json +10 -10
  9. package/dist/uni/uni-ui/uni-calendar/uni-calendar-item.vue +190 -168
  10. package/dist/uni/uni-ui/uni-calendar/uni-calendar.vue +459 -459
  11. package/dist/uni/uni-ui/uni-calendar/util.js +324 -340
  12. package/dist/uni/uni-ui/uni-card/uni-card.vue +8 -1
  13. package/dist/uni/uni-ui/uni-col/uni-col.vue +294 -287
  14. package/dist/uni/uni-ui/uni-collapse/uni-collapse.vue +139 -140
  15. package/dist/uni/uni-ui/uni-collapse-item/uni-collapse-item.vue +381 -378
  16. package/dist/uni/uni-ui/uni-combox/uni-combox.vue +280 -272
  17. package/dist/uni/uni-ui/uni-countdown/i18n/en.json +4 -4
  18. package/dist/uni/uni-ui/uni-countdown/i18n/index.js +8 -7
  19. package/dist/uni/uni-ui/uni-countdown/i18n/zh-Hans.json +4 -4
  20. package/dist/uni/uni-ui/uni-countdown/i18n/zh-Hant.json +4 -4
  21. package/dist/uni/uni-ui/uni-countdown/uni-countdown.vue +249 -257
  22. package/dist/uni/uni-ui/uni-data-checkbox/uni-data-checkbox.vue +832 -813
  23. package/dist/uni/uni-ui/uni-data-picker/keypress.js +42 -42
  24. package/dist/uni/uni-ui/uni-data-picker/uni-data-picker.vue +535 -516
  25. package/dist/uni/uni-ui/uni-data-pickerview/uni-data-picker.js +623 -618
  26. package/dist/uni/uni-ui/uni-data-pickerview/uni-data-pickerview.vue +293 -288
  27. package/dist/uni/uni-ui/uni-data-select/uni-data-select.vue +495 -509
  28. package/dist/uni/uni-ui/uni-dateformat/date-format.js +181 -184
  29. package/dist/uni/uni-ui/uni-dateformat/uni-dateformat.vue +81 -82
  30. package/dist/uni/uni-ui/uni-datetime-picker/calendar-item.vue +176 -170
  31. package/dist/uni/uni-ui/uni-datetime-picker/calendar.vue +926 -920
  32. package/dist/uni/uni-ui/uni-datetime-picker/i18n/en.json +20 -20
  33. package/dist/uni/uni-ui/uni-datetime-picker/i18n/index.js +8 -7
  34. package/dist/uni/uni-ui/uni-datetime-picker/i18n/zh-Hans.json +21 -21
  35. package/dist/uni/uni-ui/uni-datetime-picker/i18n/zh-Hant.json +21 -21
  36. package/dist/uni/uni-ui/uni-datetime-picker/time-picker.vue +921 -926
  37. package/dist/uni/uni-ui/uni-datetime-picker/uni-datetime-picker.vue +1059 -1012
  38. package/dist/uni/uni-ui/uni-datetime-picker/util.js +366 -377
  39. package/dist/uni/uni-ui/uni-drawer/keypress.js +42 -42
  40. package/dist/uni/uni-ui/uni-drawer/uni-drawer.vue +176 -167
  41. package/dist/uni/uni-ui/uni-easyinput/common.js +40 -42
  42. package/dist/uni/uni-ui/uni-easyinput/uni-easyinput.vue +628 -547
  43. package/dist/uni/uni-ui/uni-fab/uni-fab.vue +507 -483
  44. package/dist/uni/uni-ui/uni-fav/i18n/en.json +2 -2
  45. package/dist/uni/uni-ui/uni-fav/i18n/index.js +8 -7
  46. package/dist/uni/uni-ui/uni-fav/i18n/zh-Hans.json +2 -2
  47. package/dist/uni/uni-ui/uni-fav/i18n/zh-Hant.json +2 -2
  48. package/dist/uni/uni-ui/uni-fav/uni-fav.vue +155 -147
  49. package/dist/uni/uni-ui/uni-file-picker/choose-and-upload-file.js +172 -198
  50. package/dist/uni/uni-ui/uni-file-picker/uni-file-picker.vue +636 -634
  51. package/dist/uni/uni-ui/uni-file-picker/upload-file.vue +294 -293
  52. package/dist/uni/uni-ui/uni-file-picker/upload-image.vue +267 -270
  53. package/dist/uni/uni-ui/uni-file-picker/utils.js +81 -82
  54. package/dist/uni/uni-ui/uni-forms/uni-forms.vue +360 -372
  55. package/dist/uni/uni-ui/uni-forms/utils.js +170 -174
  56. package/dist/uni/uni-ui/uni-forms/validate.js +447 -456
  57. package/dist/uni/uni-ui/uni-forms-item/uni-forms-item.vue +497 -497
  58. package/dist/uni/uni-ui/uni-goods-nav/i18n/en.json +4 -4
  59. package/dist/uni/uni-ui/uni-goods-nav/i18n/index.js +8 -7
  60. package/dist/uni/uni-ui/uni-goods-nav/i18n/zh-Hans.json +4 -4
  61. package/dist/uni/uni-ui/uni-goods-nav/i18n/zh-Hant.json +4 -4
  62. package/dist/uni/uni-ui/uni-goods-nav/uni-goods-nav.vue +238 -222
  63. package/dist/uni/uni-ui/uni-grid/uni-grid.vue +134 -134
  64. package/dist/uni/uni-ui/uni-grid-item/uni-grid-item.vue +121 -119
  65. package/dist/uni/uni-ui/uni-group/uni-group.vue +121 -121
  66. package/dist/uni/uni-ui/uni-icons/icons.js +1170 -1168
  67. package/dist/uni/uni-ui/uni-icons/uni-icons.vue +91 -86
  68. package/dist/uni/uni-ui/uni-icons/uniicons.css +166 -166
  69. package/dist/uni/uni-ui/uni-indexed-list/uni-indexed-list-item.vue +129 -129
  70. package/dist/uni/uni-ui/uni-indexed-list/uni-indexed-list.vue +352 -347
  71. package/dist/uni/uni-ui/uni-link/uni-link.vue +134 -119
  72. package/dist/uni/uni-ui/uni-list/uni-list.vue +119 -110
  73. package/dist/uni/uni-ui/uni-list/uni-refresh.vue +14 -14
  74. package/dist/uni/uni-ui/uni-list/uni-refresh.wxs +14 -14
  75. package/dist/uni/uni-ui/uni-list-ad/uni-list-ad.vue +101 -95
  76. package/dist/uni/uni-ui/uni-list-chat/uni-list-chat.scss +18 -18
  77. package/dist/uni/uni-ui/uni-list-chat/uni-list-chat.vue +602 -586
  78. package/dist/uni/uni-ui/uni-list-item/uni-list-item.vue +507 -503
  79. package/dist/uni/uni-ui/uni-load-more/i18n/en.json +3 -3
  80. package/dist/uni/uni-ui/uni-load-more/i18n/index.js +8 -7
  81. package/dist/uni/uni-ui/uni-load-more/i18n/zh-Hans.json +3 -3
  82. package/dist/uni/uni-ui/uni-load-more/i18n/zh-Hant.json +3 -3
  83. package/dist/uni/uni-ui/uni-load-more/uni-load-more.vue +402 -392
  84. package/dist/uni/uni-ui/uni-nav-bar/uni-nav-bar.vue +328 -330
  85. package/dist/uni/uni-ui/uni-nav-bar/uni-status-bar.vue +17 -17
  86. package/dist/uni/uni-ui/uni-notice-bar/uni-notice-bar.vue +422 -401
  87. package/dist/uni/uni-ui/uni-number-box/uni-number-box.vue +211 -205
  88. package/dist/uni/uni-ui/uni-pagination/i18n/en.json +3 -3
  89. package/dist/uni/uni-ui/uni-pagination/i18n/es.json +3 -3
  90. package/dist/uni/uni-ui/uni-pagination/i18n/fr.json +3 -3
  91. package/dist/uni/uni-ui/uni-pagination/i18n/index.js +12 -11
  92. package/dist/uni/uni-ui/uni-pagination/i18n/zh-Hans.json +3 -3
  93. package/dist/uni/uni-ui/uni-pagination/i18n/zh-Hant.json +3 -3
  94. package/dist/uni/uni-ui/uni-pagination/uni-pagination.vue +450 -433
  95. package/dist/uni/uni-ui/uni-popup/uni-popup.vue +404 -404
  96. package/dist/uni/uni-ui/uni-popup-dialog/keypress.js +42 -42
  97. package/dist/uni/uni-ui/uni-popup-dialog/uni-popup-dialog.vue +1 -0
  98. package/dist/uni/uni-ui/uni-popup-message/uni-popup-message.vue +126 -125
  99. package/dist/uni/uni-ui/uni-popup-share/uni-popup-share.vue +172 -172
  100. package/dist/uni/uni-ui/uni-rate/uni-rate.vue +343 -347
  101. package/dist/uni/uni-ui/uni-row/uni-row.vue +180 -182
  102. package/dist/uni/uni-ui/uni-scss/changelog.md +11 -4
  103. package/dist/uni/uni-ui/uni-scss/package.json +73 -73
  104. package/dist/uni/uni-ui/uni-scss/readme.md +2 -1
  105. package/dist/uni/uni-ui/uni-scss/styles/setting/_border.scss +2 -2
  106. package/dist/uni/uni-ui/uni-scss/styles/setting/_color.scss +46 -47
  107. package/dist/uni/uni-ui/uni-scss/styles/setting/_radius.scss +49 -49
  108. package/dist/uni/uni-ui/uni-scss/styles/setting/_space.scss +52 -53
  109. package/dist/uni/uni-ui/uni-scss/styles/setting/_styles.scss +142 -147
  110. package/dist/uni/uni-ui/uni-scss/styles/setting/_text.scss +20 -20
  111. package/dist/uni/uni-ui/uni-scss/styles/setting/_variables.scss +111 -95
  112. package/dist/uni/uni-ui/uni-scss/styles/tools/functions.scss +28 -18
  113. package/dist/uni/uni-ui/uni-scss/theme.scss +10 -7
  114. package/dist/uni/uni-ui/uni-scss/variables.scss +42 -24
  115. package/dist/uni/uni-ui/uni-search-bar/i18n/en.json +3 -3
  116. package/dist/uni/uni-ui/uni-search-bar/i18n/index.js +8 -7
  117. package/dist/uni/uni-ui/uni-search-bar/i18n/zh-Hans.json +2 -2
  118. package/dist/uni/uni-ui/uni-search-bar/i18n/zh-Hant.json +2 -2
  119. package/dist/uni/uni-ui/uni-search-bar/uni-search-bar.vue +290 -281
  120. package/dist/uni/uni-ui/uni-section/uni-section.vue +149 -146
  121. package/dist/uni/uni-ui/uni-segmented-control/uni-segmented-control.vue +141 -131
  122. package/dist/uni/uni-ui/uni-steps/uni-steps.vue +255 -236
  123. package/dist/uni/uni-ui/uni-swipe-action/uni-swipe-action.vue +51 -51
  124. package/dist/uni/uni-ui/uni-swipe-action-item/bindingx.js +276 -282
  125. package/dist/uni/uni-ui/uni-swipe-action-item/isPC.js +10 -10
  126. package/dist/uni/uni-ui/uni-swipe-action-item/mpalipay.js +182 -187
  127. package/dist/uni/uni-ui/uni-swipe-action-item/mpother.js +235 -244
  128. package/dist/uni/uni-ui/uni-swipe-action-item/mpwxs.js +70 -75
  129. package/dist/uni/uni-ui/uni-swipe-action-item/render.js +238 -247
  130. package/dist/uni/uni-ui/uni-swipe-action-item/uni-swipe-action-item.vue +387 -313
  131. package/dist/uni/uni-ui/uni-swipe-action-item/wx.wxs +206 -215
  132. package/dist/uni/uni-ui/uni-swiper-dot/uni-swiper-dot.vue +241 -197
  133. package/dist/uni/uni-ui/uni-table/uni-table.vue +445 -447
  134. package/dist/uni/uni-ui/uni-tag/uni-tag.vue +234 -244
  135. package/dist/uni/uni-ui/uni-tbody/uni-tbody.vue +20 -23
  136. package/dist/uni/uni-ui/uni-td/uni-td.vue +79 -80
  137. package/dist/uni/uni-ui/uni-th/filter-dropdown.vue +510 -503
  138. package/dist/uni/uni-ui/uni-th/uni-th.vue +289 -273
  139. package/dist/uni/uni-ui/uni-thead/uni-thead.vue +115 -114
  140. package/dist/uni/uni-ui/uni-title/uni-title.vue +151 -154
  141. package/dist/uni/uni-ui/uni-tooltip/uni-tooltip.vue +55 -60
  142. package/dist/uni/uni-ui/uni-tr/table-checkbox.vue +162 -163
  143. package/dist/uni/uni-ui/uni-tr/uni-tr.vue +158 -157
  144. package/dist/uni/uni-ui/uni-transition/createAnimation.js +130 -113
  145. package/dist/uni/uni-ui/uni-transition/uni-transition.vue +274 -272
  146. package/package.json +1 -1
@@ -1,426 +1,447 @@
1
1
  <template>
2
- <view v-if="show" class="uni-noticebar" :style="{ backgroundColor }" @click="onClick">
3
- <uni-icons v-if="showIcon === true || showIcon === 'true'" class="uni-noticebar-icon" type="sound"
4
- :color="color" :size="fontSize * 1.5" />
5
- <view ref="textBox" class="uni-noticebar__content-wrapper"
6
- :class="{
7
- 'uni-noticebar__content-wrapper--scrollable': scrollable,
8
- 'uni-noticebar__content-wrapper--single': !scrollable && (single || moreText)
9
- }"
10
- :style="{ height: scrollable ? fontSize * 1.5 + 'px' : 'auto' }"
11
- >
12
- <view :id="elIdBox" class="uni-noticebar__content"
13
- :class="{
14
- 'uni-noticebar__content--scrollable': scrollable,
15
- 'uni-noticebar__content--single': !scrollable && (single || moreText)
16
- }"
17
- >
18
- <text :id="elId" ref="animationEle" class="uni-noticebar__content-text"
19
- :class="{
20
- 'uni-noticebar__content-text--scrollable': scrollable,
21
- 'uni-noticebar__content-text--single': !scrollable && (single || showGetMore)
22
- }"
23
- :style="{
24
- color: color,
25
- fontSize: fontSize + 'px',
26
- lineHeight: fontSize * 1.5 + 'px',
27
- width: wrapWidth + 'px',
28
- 'animationDuration': animationDuration,
29
- '-webkit-animationDuration': animationDuration,
30
- animationPlayState: webviewHide ? 'paused' : animationPlayState,
31
- '-webkit-animationPlayState': webviewHide ? 'paused' : animationPlayState,
32
- animationDelay: animationDelay,
33
- '-webkit-animationDelay': animationDelay
34
- }"
35
- >{{text}}</text>
36
- </view>
37
- </view>
38
- <view v-if="isShowGetMore" class="uni-noticebar__more uni-cursor-point"
39
- @click="clickMore">
40
- <text v-if="moreText.length > 0" :style="{ color: moreColor, fontSize: fontSize + 'px' }">{{ moreText }}</text>
41
- <uni-icons v-else type="right" :color="moreColor" :size="fontSize * 1.1" />
42
- </view>
43
- <view class="uni-noticebar-close uni-cursor-point" v-if="isShowClose">
44
- <uni-icons type="closeempty" :color="color" :size="fontSize * 1.1" @click="close" />
45
- </view>
46
- </view>
2
+ <view v-if="show" class="uni-noticebar" :style="{ backgroundColor }" @click="onClick">
3
+ <uni-icons v-if="showIcon === true || showIcon === 'true'" class="uni-noticebar-icon" type="sound" :color="color" :size="fontSize * 1.5" />
4
+ <view
5
+ ref="textBox"
6
+ class="uni-noticebar__content-wrapper"
7
+ :class="{
8
+ 'uni-noticebar__content-wrapper--scrollable': scrollable,
9
+ 'uni-noticebar__content-wrapper--single': !scrollable && (single || moreText),
10
+ }"
11
+ :style="{ height: scrollable ? fontSize * 1.5 + 'px' : 'auto' }"
12
+ >
13
+ <view
14
+ :id="elIdBox"
15
+ class="uni-noticebar__content"
16
+ :class="{
17
+ 'uni-noticebar__content--scrollable': scrollable,
18
+ 'uni-noticebar__content--single': !scrollable && (single || moreText),
19
+ }"
20
+ >
21
+ <text
22
+ :id="elId"
23
+ ref="animationEle"
24
+ class="uni-noticebar__content-text"
25
+ :class="{
26
+ 'uni-noticebar__content-text--scrollable': scrollable,
27
+ 'uni-noticebar__content-text--single': !scrollable && (single || showGetMore),
28
+ }"
29
+ :style="{
30
+ color: color,
31
+ fontSize: fontSize + 'px',
32
+ lineHeight: fontSize * 1.5 + 'px',
33
+ width: wrapWidth + 'px',
34
+ animationDuration: animationDuration,
35
+ '-webkit-animationDuration': animationDuration,
36
+ animationPlayState: webviewHide ? 'paused' : animationPlayState,
37
+ '-webkit-animationPlayState': webviewHide ? 'paused' : animationPlayState,
38
+ animationDelay: animationDelay,
39
+ '-webkit-animationDelay': animationDelay,
40
+ }"
41
+ >{{ text }}</text
42
+ >
43
+ </view>
44
+ </view>
45
+ <view v-if="isShowGetMore" class="uni-noticebar__more uni-cursor-point" @click="clickMore">
46
+ <text v-if="moreText.length > 0" :style="{ color: moreColor, fontSize: fontSize + 'px' }">{{ moreText }}</text>
47
+ <uni-icons v-else type="right" :color="moreColor" :size="fontSize * 1.1" />
48
+ </view>
49
+ <view class="uni-noticebar-close uni-cursor-point" v-if="isShowClose">
50
+ <uni-icons type="closeempty" :color="color" :size="fontSize * 1.1" @click="close" />
51
+ </view>
52
+ </view>
47
53
  </template>
48
54
 
49
55
  <script>
50
- // #ifdef APP-NVUE
51
- const dom = weex.requireModule('dom');
52
- const animation = weex.requireModule('animation');
53
- // #endif
56
+ // #ifdef APP-NVUE
57
+ const dom = weex.requireModule('dom');
58
+ const animation = weex.requireModule('animation');
59
+ // #endif
54
60
 
55
- /**
56
- * NoticeBar 自定义导航栏
57
- * @description 通告栏组件
58
- * @tutorial https://ext.dcloud.net.cn/plugin?id=30
59
- * @property {Number} speed 文字滚动的速度,默认100px/秒
60
- * @property {String} text 显示文字
61
- * @property {String} backgroundColor 背景颜色
62
- * @property {String} color 文字颜色
63
- * @property {String} moreColor 查看更多文字的颜色
64
- * @property {String} moreText 设置“查看更多”的文本
65
- * @property {Boolean} single = [true|false] 是否单行
66
- * @property {Boolean} scrollable = [true|false] 是否滚动,为true时,NoticeBar为单行
67
- * @property {Boolean} showIcon = [true|false] 是否显示左侧喇叭图标
68
- * @property {Boolean} showClose = [true|false] 是否显示左侧关闭按钮
69
- * @property {Boolean} showGetMore = [true|false] 是否显示右侧查看更多图标,为true时,NoticeBar为单行
70
- * @event {Function} click 点击 NoticeBar 触发事件
71
- * @event {Function} close 关闭 NoticeBar 触发事件
72
- * @event {Function} getmore 点击”查看更多“时触发事件
73
- */
61
+ /**
62
+ * NoticeBar 自定义导航栏
63
+ * @description 通告栏组件
64
+ * @tutorial https://ext.dcloud.net.cn/plugin?id=30
65
+ * @property {Number} speed 文字滚动的速度,默认100px/秒
66
+ * @property {String} text 显示文字
67
+ * @property {String} backgroundColor 背景颜色
68
+ * @property {String} color 文字颜色
69
+ * @property {String} moreColor 查看更多文字的颜色
70
+ * @property {String} moreText 设置“查看更多”的文本
71
+ * @property {Boolean} single = [true|false] 是否单行
72
+ * @property {Boolean} scrollable = [true|false] 是否滚动,为true时,NoticeBar为单行
73
+ * @property {Boolean} showIcon = [true|false] 是否显示左侧喇叭图标
74
+ * @property {Boolean} showClose = [true|false] 是否显示左侧关闭按钮
75
+ * @property {Boolean} showGetMore = [true|false] 是否显示右侧查看更多图标,为true时,NoticeBar为单行
76
+ * @event {Function} click 点击 NoticeBar 触发事件
77
+ * @event {Function} close 关闭 NoticeBar 触发事件
78
+ * @event {Function} getmore 点击”查看更多“时触发事件
79
+ */
74
80
 
75
- export default {
76
- name: 'UniNoticeBar',
77
- emits: ['click', 'getmore', 'close'],
78
- props: {
79
- text: {
80
- type: String,
81
- default: ''
82
- },
83
- moreText: {
84
- type: String,
85
- default: ''
86
- },
87
- backgroundColor: {
88
- type: String,
89
- default: '#FFF9EA'
90
- },
91
- speed: {
92
- // 默认1s滚动100px
93
- type: Number,
94
- default: 100
95
- },
96
- color: {
97
- type: String,
98
- default: '#FF9A43'
99
- },
100
- fontSize: {
101
- type: Number,
102
- default: 14
103
- },
104
- moreColor: {
105
- type: String,
106
- default: '#FF9A43'
107
- },
108
- single: {
109
- // 是否单行
110
- type: [Boolean, String],
111
- default: false
112
- },
113
- scrollable: {
114
- // 是否滚动,添加后控制单行效果取消
115
- type: [Boolean, String],
116
- default: false
117
- },
118
- showIcon: {
119
- // 是否显示左侧icon
120
- type: [Boolean, String],
121
- default: false
122
- },
123
- showGetMore: {
124
- // 是否显示右侧查看更多
125
- type: [Boolean, String],
126
- default: false
127
- },
128
- showClose: {
129
- // 是否显示左侧关闭按钮
130
- type: [Boolean, String],
131
- default: false
132
- }
133
- },
134
- data() {
135
- const elId = `Uni_${Math.ceil(Math.random() * 10e5).toString(36)}`
136
- const elIdBox = `Uni_${Math.ceil(Math.random() * 10e5).toString(36)}`
137
- return {
138
- textWidth: 0,
139
- boxWidth: 0,
140
- wrapWidth: '',
141
- webviewHide: false,
142
- // #ifdef APP-NVUE
143
- stopAnimation: false,
144
- // #endif
145
- elId: elId,
146
- elIdBox: elIdBox,
147
- show: true,
148
- animationDuration: 'none',
149
- animationPlayState: 'paused',
150
- animationDelay: '0s'
151
- }
152
- },
153
- computed: {
154
- isShowGetMore() {
155
- return this.showGetMore === true || this.showGetMore === 'true'
156
- },
157
- isShowClose() {
158
- return (this.showClose === true || this.showClose === 'true')
159
- && (this.showGetMore === false || this.showGetMore === 'false')
160
- }
161
- },
162
- mounted() {
163
- // #ifdef APP-PLUS
164
- var pages = getCurrentPages();
165
- var page = pages[pages.length - 1];
166
- var currentWebview = page.$getAppWebview();
167
- currentWebview.addEventListener('hide', () => {
168
- this.webviewHide = true
169
- })
170
- currentWebview.addEventListener('show', () => {
171
- this.webviewHide = false
172
- })
173
- // #endif
174
- this.$nextTick(() => {
175
- this.initSize()
176
- })
177
- },
178
- // #ifdef APP-NVUE
179
- beforeDestroy() {
180
- this.stopAnimation = true
181
- },
182
- // #endif
183
- methods: {
184
- initSize() {
185
- if (this.scrollable) {
186
- // #ifndef APP-NVUE
187
- let query = [],
188
- boxWidth = 0,
189
- textWidth = 0;
190
- let textQuery = new Promise((resolve, reject) => {
191
- uni.createSelectorQuery()
192
- // #ifndef MP-ALIPAY
193
- .in(this)
194
- // #endif
195
- .select(`#${this.elId}`)
196
- .boundingClientRect()
197
- .exec(ret => {
198
- this.textWidth = ret[0].width
199
- resolve()
200
- })
201
- })
202
- let boxQuery = new Promise((resolve, reject) => {
203
- uni.createSelectorQuery()
204
- // #ifndef MP-ALIPAY
205
- .in(this)
206
- // #endif
207
- .select(`#${this.elIdBox}`)
208
- .boundingClientRect()
209
- .exec(ret => {
210
- this.boxWidth = ret[0].width
211
- resolve()
212
- })
213
- })
214
- query.push(textQuery)
215
- query.push(boxQuery)
216
- Promise.all(query).then(() => {
217
- this.animationDuration = `${this.textWidth / this.speed}s`
218
- this.animationDelay = `-${this.boxWidth / this.speed}s`
219
- setTimeout(() => {
220
- this.animationPlayState = 'running'
221
- }, 1000)
222
- })
223
- // #endif
224
- // #ifdef APP-NVUE
225
- dom.getComponentRect(this.$refs['animationEle'], (res) => {
226
- let winWidth = uni.getSystemInfoSync().windowWidth
227
- this.textWidth = res.size.width
228
- animation.transition(this.$refs['animationEle'], {
229
- styles: {
230
- transform: `translateX(-${winWidth}px)`
231
- },
232
- duration: 0,
233
- timingFunction: 'linear',
234
- delay: 0
235
- }, () => {
236
- if (!this.stopAnimation) {
237
- animation.transition(this.$refs['animationEle'], {
238
- styles: {
239
- transform: `translateX(-${this.textWidth}px)`
240
- },
241
- timingFunction: 'linear',
242
- duration: (this.textWidth - winWidth) / this.speed * 1000,
243
- delay: 1000
244
- }, () => {
245
- if (!this.stopAnimation) {
246
- this.loopAnimation()
247
- }
248
- });
249
- }
250
- });
251
- })
252
- // #endif
253
- }
254
- // #ifdef APP-NVUE
255
- if (!this.scrollable && (this.single || this.moreText)) {
256
- dom.getComponentRect(this.$refs['textBox'], (res) => {
257
- this.wrapWidth = res.size.width
258
- })
259
- }
260
- // #endif
261
- },
262
- loopAnimation() {
263
- // #ifdef APP-NVUE
264
- animation.transition(this.$refs['animationEle'], {
265
- styles: {
266
- transform: `translateX(0px)`
267
- },
268
- duration: 0
269
- }, () => {
270
- if (!this.stopAnimation) {
271
- animation.transition(this.$refs['animationEle'], {
272
- styles: {
273
- transform: `translateX(-${this.textWidth}px)`
274
- },
275
- duration: this.textWidth / this.speed * 1000,
276
- timingFunction: 'linear',
277
- delay: 0
278
- }, () => {
279
- if (!this.stopAnimation) {
280
- this.loopAnimation()
281
- }
282
- });
283
- }
284
- });
285
- // #endif
286
- },
287
- clickMore() {
288
- this.$emit('getmore')
289
- },
290
- close() {
291
- this.show = false;
292
- this.$emit('close')
293
- },
294
- onClick() {
295
- this.$emit('click')
296
- }
297
- }
298
- }
81
+ export default {
82
+ name: 'UniNoticeBar',
83
+ emits: ['click', 'getmore', 'close'],
84
+ props: {
85
+ text: {
86
+ type: String,
87
+ default: '',
88
+ },
89
+ moreText: {
90
+ type: String,
91
+ default: '',
92
+ },
93
+ backgroundColor: {
94
+ type: String,
95
+ default: '#FFF9EA',
96
+ },
97
+ speed: {
98
+ // 默认1s滚动100px
99
+ type: Number,
100
+ default: 100,
101
+ },
102
+ color: {
103
+ type: String,
104
+ default: '#FF9A43',
105
+ },
106
+ fontSize: {
107
+ type: Number,
108
+ default: 14,
109
+ },
110
+ moreColor: {
111
+ type: String,
112
+ default: '#FF9A43',
113
+ },
114
+ single: {
115
+ // 是否单行
116
+ type: [Boolean, String],
117
+ default: false,
118
+ },
119
+ scrollable: {
120
+ // 是否滚动,添加后控制单行效果取消
121
+ type: [Boolean, String],
122
+ default: false,
123
+ },
124
+ showIcon: {
125
+ // 是否显示左侧icon
126
+ type: [Boolean, String],
127
+ default: false,
128
+ },
129
+ showGetMore: {
130
+ // 是否显示右侧查看更多
131
+ type: [Boolean, String],
132
+ default: false,
133
+ },
134
+ showClose: {
135
+ // 是否显示左侧关闭按钮
136
+ type: [Boolean, String],
137
+ default: false,
138
+ },
139
+ },
140
+ data() {
141
+ const elId = `Uni_${Math.ceil(Math.random() * 10e5).toString(36)}`;
142
+ const elIdBox = `Uni_${Math.ceil(Math.random() * 10e5).toString(36)}`;
143
+ return {
144
+ textWidth: 0,
145
+ boxWidth: 0,
146
+ wrapWidth: '',
147
+ webviewHide: false,
148
+ // #ifdef APP-NVUE
149
+ stopAnimation: false,
150
+ // #endif
151
+ elId: elId,
152
+ elIdBox: elIdBox,
153
+ show: true,
154
+ animationDuration: 'none',
155
+ animationPlayState: 'paused',
156
+ animationDelay: '0s',
157
+ };
158
+ },
159
+ computed: {
160
+ isShowGetMore() {
161
+ return this.showGetMore === true || this.showGetMore === 'true';
162
+ },
163
+ isShowClose() {
164
+ return (this.showClose === true || this.showClose === 'true') && (this.showGetMore === false || this.showGetMore === 'false');
165
+ },
166
+ },
167
+ mounted() {
168
+ // #ifdef APP-PLUS
169
+ var pages = getCurrentPages();
170
+ var page = pages[pages.length - 1];
171
+ var currentWebview = page.$getAppWebview();
172
+ currentWebview.addEventListener('hide', () => {
173
+ this.webviewHide = true;
174
+ });
175
+ currentWebview.addEventListener('show', () => {
176
+ this.webviewHide = false;
177
+ });
178
+ // #endif
179
+ this.$nextTick(() => {
180
+ this.initSize();
181
+ });
182
+ },
183
+ // #ifdef APP-NVUE
184
+ beforeDestroy() {
185
+ this.stopAnimation = true;
186
+ },
187
+ // #endif
188
+ methods: {
189
+ initSize() {
190
+ if (this.scrollable) {
191
+ // #ifndef APP-NVUE
192
+ let query = [],
193
+ boxWidth = 0,
194
+ textWidth = 0;
195
+ let textQuery = new Promise((resolve, reject) => {
196
+ uni.createSelectorQuery()
197
+ // #ifndef MP-ALIPAY
198
+ .in(this)
199
+ // #endif
200
+ .select(`#${this.elId}`)
201
+ .boundingClientRect()
202
+ .exec((ret) => {
203
+ this.textWidth = ret[0].width;
204
+ resolve();
205
+ });
206
+ });
207
+ let boxQuery = new Promise((resolve, reject) => {
208
+ uni.createSelectorQuery()
209
+ // #ifndef MP-ALIPAY
210
+ .in(this)
211
+ // #endif
212
+ .select(`#${this.elIdBox}`)
213
+ .boundingClientRect()
214
+ .exec((ret) => {
215
+ this.boxWidth = ret[0].width;
216
+ resolve();
217
+ });
218
+ });
219
+ query.push(textQuery);
220
+ query.push(boxQuery);
221
+ Promise.all(query).then(() => {
222
+ this.animationDuration = `${this.textWidth / this.speed}s`;
223
+ this.animationDelay = `-${this.boxWidth / this.speed}s`;
224
+ setTimeout(() => {
225
+ this.animationPlayState = 'running';
226
+ }, 1000);
227
+ });
228
+ // #endif
229
+ // #ifdef APP-NVUE
230
+ dom.getComponentRect(this.$refs['animationEle'], (res) => {
231
+ let winWidth = uni.getSystemInfoSync().windowWidth;
232
+ this.textWidth = res.size.width;
233
+ animation.transition(
234
+ this.$refs['animationEle'],
235
+ {
236
+ styles: {
237
+ transform: `translateX(-${winWidth}px)`,
238
+ },
239
+ duration: 0,
240
+ timingFunction: 'linear',
241
+ delay: 0,
242
+ },
243
+ () => {
244
+ if (!this.stopAnimation) {
245
+ animation.transition(
246
+ this.$refs['animationEle'],
247
+ {
248
+ styles: {
249
+ transform: `translateX(-${this.textWidth}px)`,
250
+ },
251
+ timingFunction: 'linear',
252
+ duration: ((this.textWidth - winWidth) / this.speed) * 1000,
253
+ delay: 1000,
254
+ },
255
+ () => {
256
+ if (!this.stopAnimation) {
257
+ this.loopAnimation();
258
+ }
259
+ },
260
+ );
261
+ }
262
+ },
263
+ );
264
+ });
265
+ // #endif
266
+ }
267
+ // #ifdef APP-NVUE
268
+ if (!this.scrollable && (this.single || this.moreText)) {
269
+ dom.getComponentRect(this.$refs['textBox'], (res) => {
270
+ this.wrapWidth = res.size.width;
271
+ });
272
+ }
273
+ // #endif
274
+ },
275
+ loopAnimation() {
276
+ // #ifdef APP-NVUE
277
+ animation.transition(
278
+ this.$refs['animationEle'],
279
+ {
280
+ styles: {
281
+ transform: `translateX(0px)`,
282
+ },
283
+ duration: 0,
284
+ },
285
+ () => {
286
+ if (!this.stopAnimation) {
287
+ animation.transition(
288
+ this.$refs['animationEle'],
289
+ {
290
+ styles: {
291
+ transform: `translateX(-${this.textWidth}px)`,
292
+ },
293
+ duration: (this.textWidth / this.speed) * 1000,
294
+ timingFunction: 'linear',
295
+ delay: 0,
296
+ },
297
+ () => {
298
+ if (!this.stopAnimation) {
299
+ this.loopAnimation();
300
+ }
301
+ },
302
+ );
303
+ }
304
+ },
305
+ );
306
+ // #endif
307
+ },
308
+ clickMore() {
309
+ this.$emit('getmore');
310
+ },
311
+ close() {
312
+ this.show = false;
313
+ this.$emit('close');
314
+ },
315
+ onClick() {
316
+ this.$emit('click');
317
+ },
318
+ },
319
+ };
299
320
  </script>
300
321
 
301
322
  <style lang="scss" scoped>
302
- .uni-noticebar {
303
- /* #ifndef APP-NVUE */
304
- display: flex;
305
- width: 100%;
306
- box-sizing: border-box;
307
- /* #endif */
308
- flex-direction: row;
309
- align-items: center;
310
- padding: 10px 12px;
311
- margin-bottom: 10px;
312
- }
323
+ .uni-noticebar {
324
+ /* #ifndef APP-NVUE */
325
+ display: flex;
326
+ width: 100%;
327
+ box-sizing: border-box;
328
+ /* #endif */
329
+ flex-direction: row;
330
+ align-items: center;
331
+ padding: 10px 12px;
332
+ margin-bottom: 10px;
333
+ }
313
334
 
314
- .uni-cursor-point {
315
- /* #ifdef H5 */
316
- cursor: pointer;
317
- /* #endif */
318
- }
335
+ .uni-cursor-point {
336
+ /* #ifdef H5 */
337
+ cursor: pointer;
338
+ /* #endif */
339
+ }
319
340
 
320
- .uni-noticebar-close {
321
- margin-left: 8px;
322
- margin-right: 5px;
323
- }
341
+ .uni-noticebar-close {
342
+ margin-left: 8px;
343
+ margin-right: 5px;
344
+ }
324
345
 
325
- .uni-noticebar-icon {
326
- margin-right: 5px;
327
- }
346
+ .uni-noticebar-icon {
347
+ margin-right: 5px;
348
+ }
328
349
 
329
- .uni-noticebar__content-wrapper {
330
- flex: 1;
331
- flex-direction: column;
332
- overflow: hidden;
333
- }
350
+ .uni-noticebar__content-wrapper {
351
+ flex: 1;
352
+ flex-direction: column;
353
+ overflow: hidden;
354
+ }
334
355
 
335
- .uni-noticebar__content-wrapper--single {
336
- /* #ifndef APP-NVUE */
337
- line-height: 18px;
338
- /* #endif */
339
- }
356
+ .uni-noticebar__content-wrapper--single {
357
+ /* #ifndef APP-NVUE */
358
+ line-height: 18px;
359
+ /* #endif */
360
+ }
340
361
 
341
- .uni-noticebar__content-wrapper--single,
342
- .uni-noticebar__content-wrapper--scrollable {
343
- flex-direction: row;
344
- }
362
+ .uni-noticebar__content-wrapper--single,
363
+ .uni-noticebar__content-wrapper--scrollable {
364
+ flex-direction: row;
365
+ }
345
366
 
346
- /* #ifndef APP-NVUE */
347
- .uni-noticebar__content-wrapper--scrollable {
348
- position: relative;
349
- }
367
+ /* #ifndef APP-NVUE */
368
+ .uni-noticebar__content-wrapper--scrollable {
369
+ position: relative;
370
+ }
350
371
 
351
- /* #endif */
372
+ /* #endif */
352
373
 
353
- .uni-noticebar__content--scrollable {
354
- /* #ifdef APP-NVUE */
355
- flex: 0;
356
- /* #endif */
357
- /* #ifndef APP-NVUE */
358
- flex: 1;
359
- display: block;
360
- overflow: hidden;
361
- /* #endif */
362
- }
374
+ .uni-noticebar__content--scrollable {
375
+ /* #ifdef APP-NVUE */
376
+ flex: 0;
377
+ /* #endif */
378
+ /* #ifndef APP-NVUE */
379
+ flex: 1;
380
+ display: block;
381
+ overflow: hidden;
382
+ /* #endif */
383
+ }
363
384
 
364
- .uni-noticebar__content--single {
365
- /* #ifndef APP-NVUE */
366
- display: flex;
367
- flex: none;
368
- width: 100%;
369
- justify-content: center;
370
- /* #endif */
371
- }
385
+ .uni-noticebar__content--single {
386
+ /* #ifndef APP-NVUE */
387
+ display: flex;
388
+ flex: none;
389
+ width: 100%;
390
+ justify-content: center;
391
+ /* #endif */
392
+ }
372
393
 
373
- .uni-noticebar__content-text {
374
- font-size: 14px;
375
- line-height: 18px;
376
- /* #ifndef APP-NVUE */
377
- word-break: break-all;
378
- /* #endif */
379
- }
394
+ .uni-noticebar__content-text {
395
+ font-size: 14px;
396
+ line-height: 18px;
397
+ /* #ifndef APP-NVUE */
398
+ word-break: break-all;
399
+ /* #endif */
400
+ }
380
401
 
381
- .uni-noticebar__content-text--single {
382
- /* #ifdef APP-NVUE */
383
- lines: 1;
384
- /* #endif */
385
- /* #ifndef APP-NVUE */
386
- display: block;
387
- width: 100%;
388
- white-space: nowrap;
389
- /* #endif */
390
- overflow: hidden;
391
- text-overflow: ellipsis;
392
- }
402
+ .uni-noticebar__content-text--single {
403
+ /* #ifdef APP-NVUE */
404
+ lines: 1;
405
+ /* #endif */
406
+ /* #ifndef APP-NVUE */
407
+ display: block;
408
+ width: 100%;
409
+ white-space: nowrap;
410
+ /* #endif */
411
+ overflow: hidden;
412
+ text-overflow: ellipsis;
413
+ }
393
414
 
394
- .uni-noticebar__content-text--scrollable {
395
- /* #ifdef APP-NVUE */
396
- lines: 1;
397
- padding-left: 750rpx;
398
- /* #endif */
399
- /* #ifndef APP-NVUE */
400
- position: absolute;
401
- display: block;
402
- height: 18px;
403
- line-height: 18px;
404
- white-space: nowrap;
405
- padding-left: 100%;
406
- animation: notice 10s 0s linear infinite both;
407
- animation-play-state: paused;
408
- /* #endif */
409
- }
415
+ .uni-noticebar__content-text--scrollable {
416
+ /* #ifdef APP-NVUE */
417
+ lines: 1;
418
+ padding-left: 750rpx;
419
+ /* #endif */
420
+ /* #ifndef APP-NVUE */
421
+ position: absolute;
422
+ display: block;
423
+ height: 18px;
424
+ line-height: 18px;
425
+ white-space: nowrap;
426
+ padding-left: 100%;
427
+ animation: notice 10s 0s linear infinite both;
428
+ animation-play-state: paused;
429
+ /* #endif */
430
+ }
410
431
 
411
- .uni-noticebar__more {
412
- /* #ifndef APP-NVUE */
413
- display: inline-flex;
414
- /* #endif */
415
- flex-direction: row;
416
- flex-wrap: nowrap;
417
- align-items: center;
418
- padding-left: 5px;
419
- }
432
+ .uni-noticebar__more {
433
+ /* #ifndef APP-NVUE */
434
+ display: inline-flex;
435
+ /* #endif */
436
+ flex-direction: row;
437
+ flex-wrap: nowrap;
438
+ align-items: center;
439
+ padding-left: 5px;
440
+ }
420
441
 
421
- @keyframes notice {
422
- 100% {
423
- transform: translate3d(-100%, 0, 0);
424
- }
425
- }
442
+ @keyframes notice {
443
+ 100% {
444
+ transform: translate3d(-100%, 0, 0);
445
+ }
446
+ }
426
447
  </style>