@10yun/cv-mobile-ui 0.5.19 → 0.5.21

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 (137) hide show
  1. package/other/mpvue-picker/mpvuePicker.vue +402 -0
  2. package/{uni-ui/lib → other}/mpvue-picker/style.css +0 -1
  3. package/{uni-ui/lib → other}/tab-nvue/style.css +0 -1
  4. package/other/uParse/components/style.css +1 -0
  5. package/other/uParse/components/wxParseAudio.vue +1 -0
  6. package/other/uParse/components/wxParseImg.vue +86 -0
  7. package/other/uParse/components/wxParseTable.vue +54 -0
  8. package/other/uParse/components/wxParseTemplate0.vue +98 -0
  9. package/other/uParse/components/wxParseTemplate1.vue +81 -0
  10. package/other/uParse/components/wxParseTemplate10.vue +81 -0
  11. package/other/uParse/components/wxParseTemplate11.vue +79 -0
  12. package/other/uParse/components/wxParseTemplate2.vue +81 -0
  13. package/other/uParse/components/wxParseTemplate3.vue +81 -0
  14. package/other/uParse/components/wxParseTemplate4.vue +81 -0
  15. package/other/uParse/components/wxParseTemplate5.vue +81 -0
  16. package/other/uParse/components/wxParseTemplate6.vue +81 -0
  17. package/other/uParse/components/wxParseTemplate7.vue +81 -0
  18. package/other/uParse/components/wxParseTemplate8.vue +81 -0
  19. package/other/uParse/components/wxParseTemplate9.vue +81 -0
  20. package/other/uParse/components/wxParseVideo.vue +14 -0
  21. package/other/uParse/editor.css +495 -0
  22. package/{uni-ui/lib/uParse/src → other/uParse}/libs/html2json.js +19 -22
  23. package/{uni-ui/lib/uParse/src → other/uParse}/libs/htmlparser.js +12 -5
  24. package/{uni-ui/lib/uParse/src → other/uParse}/libs/wxDiscode.js +2 -2
  25. package/other/uParse/wxParse.vue +196 -0
  26. package/package.json +1 -1
  27. package/plugins/map/amqp-wx.js +173 -0
  28. package/{uni-ui/lib/mpvueGestureLock/index.vue → ui-cv/components/cv-draw-gesture-lock/cv-draw-gesture-lock.vue} +4 -1
  29. package/ui-cv/components/cv-draw-gesture-lock/gestureLock.js +169 -0
  30. package/{uni-ui/lib/mpvueGestureLock → ui-cv/components/cv-draw-gesture-lock}/style.css +0 -1
  31. package/{uni-ui/lib/mpvue-citypicker → ui-cv/components/cv-geo-region}/style.css +0 -1
  32. package/ui-cv/components/cv-grid-item/cv-grid-item.vue +1 -1
  33. package/uni-ui/lib/uni-badge/uni-badge.vue +150 -1
  34. package/uni-ui/lib/uni-breadcrumb/uni-breadcrumb.vue +37 -1
  35. package/uni-ui/lib/uni-breadcrumb-item/uni-breadcrumb-item.vue +83 -1
  36. package/uni-ui/lib/uni-calendar/uni-calendar-item.vue +122 -1
  37. package/uni-ui/lib/uni-calendar/uni-calendar.vue +366 -1
  38. package/uni-ui/lib/uni-card/uni-card.vue +124 -1
  39. package/uni-ui/lib/uni-col/uni-col.vue +1 -1
  40. package/uni-ui/lib/uni-collapse/uni-collapse.vue +135 -1
  41. package/uni-ui/lib/uni-collapse-item/uni-collapse-item.vue +266 -1
  42. package/uni-ui/lib/uni-combox/uni-combox.vue +1 -1
  43. package/uni-ui/lib/uni-countdown/uni-countdown.vue +239 -1
  44. package/uni-ui/lib/uni-data-checkbox/uni-data-checkbox.vue +487 -1
  45. package/uni-ui/lib/uni-data-picker/uni-data-picker.vue +530 -1
  46. package/uni-ui/lib/uni-data-pickerview/uni-data-picker.js +157 -150
  47. package/uni-ui/lib/uni-data-pickerview/uni-data-pickerview.vue +166 -1
  48. package/uni-ui/lib/uni-data-select/uni-data-select.vue +289 -1
  49. package/uni-ui/lib/uni-datetime-picker/calendar-item.vue +70 -1
  50. package/uni-ui/lib/uni-datetime-picker/calendar.vue +629 -1
  51. package/uni-ui/lib/uni-datetime-picker/time-picker.vue +741 -1
  52. package/uni-ui/lib/uni-datetime-picker/uni-datetime-picker.vue +847 -1
  53. package/uni-ui/lib/uni-drawer/uni-drawer.vue +115 -1
  54. package/uni-ui/lib/uni-easyinput/uni-easyinput.vue +515 -1
  55. package/uni-ui/lib/uni-fab/uni-fab.vue +257 -1
  56. package/uni-ui/lib/uni-fav/uni-fav.vue +123 -1
  57. package/uni-ui/lib/uni-file-picker/uni-file-picker.vue +642 -1
  58. package/uni-ui/lib/uni-file-picker/upload-file.vue +177 -1
  59. package/uni-ui/lib/uni-file-picker/upload-image.vue +176 -1
  60. package/uni-ui/lib/uni-forms/uni-forms.vue +375 -1
  61. package/uni-ui/lib/uni-forms-item/uni-forms-item.vue +429 -1
  62. package/uni-ui/lib/uni-goods-nav/uni-goods-nav.vue +129 -1
  63. package/uni-ui/lib/uni-grid/uni-grid.vue +115 -1
  64. package/uni-ui/lib/uni-grid-item/uni-grid-item.vue +78 -1
  65. package/uni-ui/lib/uni-group/uni-group.vue +85 -1
  66. package/uni-ui/lib/uni-icons/uni-icons.vue +85 -1
  67. package/uni-ui/lib/uni-indexed-list/uni-indexed-list-item.vue +68 -1
  68. package/uni-ui/lib/uni-indexed-list/uni-indexed-list.vue +294 -1
  69. package/uni-ui/lib/uni-list/uni-list.vue +81 -1
  70. package/uni-ui/lib/uni-list-ad/uni-list-ad.vue +77 -1
  71. package/uni-ui/lib/uni-list-chat/uni-list-chat.vue +294 -1
  72. package/uni-ui/lib/uni-list-item/uni-list-item.vue +346 -1
  73. package/uni-ui/lib/uni-load-more/uni-load-more.vue +172 -1
  74. package/uni-ui/lib/uni-nav-bar/uni-nav-bar.vue +205 -1
  75. package/uni-ui/lib/uni-nav-bar/uni-status-bar.vue +18 -1
  76. package/uni-ui/lib/uni-notice-bar/uni-notice-bar.vue +331 -1
  77. package/uni-ui/lib/uni-number-box/uni-number-box.vue +166 -1
  78. package/uni-ui/lib/uni-pagination/uni-pagination.vue +323 -1
  79. package/uni-ui/lib/uni-popup/uni-popup.vue +1 -1
  80. package/uni-ui/lib/uni-popup-dialog/uni-popup-dialog.vue +173 -1
  81. package/uni-ui/lib/uni-popup-message/uni-popup-message.vue +74 -1
  82. package/uni-ui/lib/uni-popup-share/uni-popup-share.vue +106 -1
  83. package/uni-ui/lib/uni-rate/uni-rate.vue +322 -1
  84. package/uni-ui/lib/uni-row/uni-row.vue +1 -1
  85. package/uni-ui/lib/uni-search-bar/uni-search-bar.vue +236 -1
  86. package/uni-ui/lib/uni-section/uni-section.vue +109 -1
  87. package/uni-ui/lib/uni-segmented-control/uni-segmented-control.vue +103 -1
  88. package/uni-ui/lib/uni-status-bar/uni-status-bar.vue +1 -1
  89. package/uni-ui/lib/uni-steps/uni-steps.vue +120 -1
  90. package/uni-ui/lib/uni-swipe-action-item/uni-swipe-action-item.vue +226 -3
  91. package/uni-ui/lib/uni-swiper-dot/uni-swiper-dot.vue +167 -1
  92. package/uni-ui/lib/uni-table/uni-table.vue +297 -1
  93. package/uni-ui/lib/uni-tag/uni-tag.vue +100 -1
  94. package/uni-ui/lib/uni-td/uni-td.vue +78 -1
  95. package/uni-ui/lib/uni-th/filter-dropdown.vue +1 -1
  96. package/uni-ui/lib/uni-th/uni-th.vue +224 -1
  97. package/uni-ui/lib/uni-thead/uni-thead.vue +77 -1
  98. package/uni-ui/lib/uni-tr/table-checkbox.vue +79 -1
  99. package/uni-ui/lib/uni-tr/uni-tr.vue +135 -1
  100. package/uni-ui/lib/amap-wx/js/util.js +0 -181
  101. package/uni-ui/lib/marked/index.js +0 -1
  102. package/uni-ui/lib/mpvue-citypicker/city-data/area.js +0 -12542
  103. package/uni-ui/lib/mpvue-citypicker/city-data/city.js +0 -1503
  104. package/uni-ui/lib/mpvue-citypicker/city-data/province.js +0 -139
  105. package/uni-ui/lib/mpvue-picker/mpvuePicker.vue +0 -3
  106. package/uni-ui/lib/mpvueGestureLock/gestureLock.js +0 -175
  107. package/uni-ui/lib/uParse/src/components/style.css +0 -2
  108. package/uni-ui/lib/uParse/src/components/wxParseAudio.vue +0 -1
  109. package/uni-ui/lib/uParse/src/components/wxParseImg.vue +0 -1
  110. package/uni-ui/lib/uParse/src/components/wxParseTable.vue +0 -3
  111. package/uni-ui/lib/uParse/src/components/wxParseTemplate0.vue +0 -1
  112. package/uni-ui/lib/uParse/src/components/wxParseTemplate1.vue +0 -1
  113. package/uni-ui/lib/uParse/src/components/wxParseTemplate10.vue +0 -1
  114. package/uni-ui/lib/uParse/src/components/wxParseTemplate11.vue +0 -1
  115. package/uni-ui/lib/uParse/src/components/wxParseTemplate2.vue +0 -1
  116. package/uni-ui/lib/uParse/src/components/wxParseTemplate3.vue +0 -1
  117. package/uni-ui/lib/uParse/src/components/wxParseTemplate4.vue +0 -1
  118. package/uni-ui/lib/uParse/src/components/wxParseTemplate5.vue +0 -1
  119. package/uni-ui/lib/uParse/src/components/wxParseTemplate6.vue +0 -1
  120. package/uni-ui/lib/uParse/src/components/wxParseTemplate7.vue +0 -1
  121. package/uni-ui/lib/uParse/src/components/wxParseTemplate8.vue +0 -1
  122. package/uni-ui/lib/uParse/src/components/wxParseTemplate9.vue +0 -1
  123. package/uni-ui/lib/uParse/src/components/wxParseVideo.vue +0 -1
  124. package/uni-ui/lib/uParse/src/editor.css +0 -495
  125. package/uni-ui/lib/uParse/src/wxParse.vue +0 -1
  126. /package/{uni-ui/lib → other}/api-set-tabbar.nvue +0 -0
  127. /package/{uni-ui/lib → other}/mpvue-echarts/src/echarts.vue +0 -0
  128. /package/{uni-ui/lib → other}/mpvue-echarts/src/style.css +0 -0
  129. /package/{uni-ui/lib → other}/mpvue-echarts/src/wx-canvas.js +0 -0
  130. /package/{uni-ui/lib → other}/product.vue +0 -0
  131. /package/{uni-ui/lib → other}/style.css +0 -0
  132. /package/{uni-ui/lib → other}/tab-nvue/mediaList.vue +0 -0
  133. /package/{uni-ui/lib → other}/u-charts/u-charts.js +0 -0
  134. /package/{uni-ui/lib/uParse/src → other/uParse}/wxParse.css +0 -0
  135. /package/{uni-ui/lib/amap-wx → plugins/map}/lib/amap-wx.js +0 -0
  136. /package/{uni-ui/lib/mpvue-citypicker → ui-cv/components/cv-geo-region}/mpvueCityPicker.vue +0 -0
  137. /package/{uni-ui/lib/marked → ui-cv/components/cv-markdown-show}/lib/marked.js +0 -0
@@ -1 +1,331 @@
1
- <template>
2
1
  <view v-if="show" class="uni-noticebar" :style="{ backgroundColor }" @click="onClick">
3
2
  <uni-icons
4
3
  v-if="showIcon === true || showIcon === 'true'"
5
4
  class="uni-noticebar-icon"
6
5
  type="sound"
7
6
  :color="color"
8
7
  :size="fontSize * 1.5"
9
8
  />
10
9
  <view
11
10
  ref="textBox"
12
11
  class="uni-noticebar__content-wrapper"
13
12
  :class="{
14
13
  'uni-noticebar__content-wrapper--scrollable': scrollable,
15
14
  'uni-noticebar__content-wrapper--single': !scrollable && (single || moreText)
16
15
  }"
17
16
  :style="{ height: scrollable ? fontSize * 1.5 + 'px' : 'auto' }"
18
17
  >
19
18
  <view
20
19
  :id="elIdBox"
21
20
  class="uni-noticebar__content"
22
21
  :class="{
23
22
  'uni-noticebar__content--scrollable': scrollable,
24
23
  'uni-noticebar__content--single': !scrollable && (single || moreText)
25
24
  }"
26
25
  >
27
26
  <text
28
27
  :id="elId"
29
28
  ref="animationEle"
30
29
  class="uni-noticebar__content-text"
31
30
  :class="{
32
31
  'uni-noticebar__content-text--scrollable': scrollable,
33
32
  'uni-noticebar__content-text--single': !scrollable && (single || showGetMore)
34
33
  }"
35
34
  :style="{
36
35
  color: color,
37
36
  fontSize: fontSize + 'px',
38
37
  lineHeight: fontSize * 1.5 + 'px',
39
38
  width: wrapWidth + 'px',
40
39
  animationDuration: animationDuration,
41
40
  '-webkit-animationDuration': animationDuration,
42
41
  animationPlayState: webviewHide ? 'paused' : animationPlayState,
43
42
  '-webkit-animationPlayState': webviewHide ? 'paused' : animationPlayState,
44
43
  animationDelay: animationDelay,
45
44
  '-webkit-animationDelay': animationDelay
46
45
  }"
47
46
  >
48
47
  {{ text }}
49
48
  </text>
50
49
  </view>
51
50
  </view>
52
51
  <view v-if="isShowGetMore" class="uni-noticebar__more uni-cursor-point" @click="clickMore">
53
52
  <text v-if="moreText.length > 0" :style="{ color: moreColor, fontSize: fontSize + 'px' }">{{ moreText }}</text>
54
53
  <uni-icons v-else type="right" :color="moreColor" :size="fontSize * 1.1" />
55
54
  </view>
56
55
  <view class="uni-noticebar-close uni-cursor-point" v-if="isShowClose">
57
56
  <uni-icons type="closeempty" :color="color" :size="fontSize * 1.1" @click="close" />
58
57
  </view>
59
58
  </view>
60
59
  * NoticeBar 自定义导航栏
61
60
  * @description 通告栏组件
62
61
  * @tutorial https://ext.dcloud.net.cn/plugin?id=30
63
62
  * @property {Number} speed 文字滚动的速度,默认100px/秒
64
63
  * @property {String} text 显示文字
65
64
  * @property {String} backgroundColor 背景颜色
66
65
  * @property {String} color 文字颜色
67
66
  * @property {String} moreColor 查看更多文字的颜色
68
67
  * @property {String} moreText 设置“查看更多”的文本
69
68
  * @property {Boolean} single = [true|false] 是否单行
70
69
  * @property {Boolean} scrollable = [true|false] 是否滚动,为true时,NoticeBar为单行
71
70
  * @property {Boolean} showIcon = [true|false] 是否显示左侧喇叭图标
72
71
  * @property {Boolean} showClose = [true|false] 是否显示左侧关闭按钮
73
72
  * @property {Boolean} showGetMore = [true|false] 是否显示右侧查看更多图标,为true时,NoticeBar为单行
74
73
  * @event {Function} click 点击 NoticeBar 触发事件
75
74
  * @event {Function} close 关闭 NoticeBar 触发事件
76
75
  * @event {Function} getmore 点击”查看更多“时触发事件
77
76
  */
78
77
  name: 'UniNoticeBar',
79
78
  emits: ['click', 'getmore', 'close'],
80
79
  props: {
81
80
  text: {
82
81
  type: String,
83
82
  default: ''
84
83
  },
85
84
  moreText: {
86
85
  type: String,
87
86
  default: ''
88
87
  },
89
88
  backgroundColor: {
90
89
  type: String,
91
90
  default: '#FFF9EA'
92
91
  },
93
92
  speed: {
94
93
  // 默认1s滚动100px
95
94
  type: Number,
96
95
  default: 100
97
96
  },
98
97
  color: {
99
98
  type: String,
100
99
  default: '#FF9A43'
101
100
  },
102
101
  fontSize: {
103
102
  type: Number,
104
103
  default: 14
105
104
  },
106
105
  moreColor: {
107
106
  type: String,
108
107
  default: '#FF9A43'
109
108
  },
110
109
  single: {
111
110
  // 是否单行
112
111
  type: [Boolean, String],
113
112
  default: false
114
113
  },
115
114
  scrollable: {
116
115
  // 是否滚动,添加后控制单行效果取消
117
116
  type: [Boolean, String],
118
117
  default: false
119
118
  },
120
119
  showIcon: {
121
120
  // 是否显示左侧icon
122
121
  type: [Boolean, String],
123
122
  default: false
124
123
  },
125
124
  showGetMore: {
126
125
  // 是否显示右侧查看更多
127
126
  type: [Boolean, String],
128
127
  default: false
129
128
  },
130
129
  showClose: {
131
130
  // 是否显示左侧关闭按钮
132
131
  type: [Boolean, String],
133
132
  default: false
134
133
  }
135
134
  },
136
135
  data() {
137
136
  const elId = `Uni_${Math.ceil(Math.random() * 10e5).toString(36)}`;
138
137
  const elIdBox = `Uni_${Math.ceil(Math.random() * 10e5).toString(36)}`;
139
138
  return {
140
139
  textWidth: 0,
141
140
  boxWidth: 0,
142
141
  wrapWidth: '',
143
142
  webviewHide: false,
144
143
  // #ifdef APP-NVUE
145
144
  stopAnimation: false,
146
145
  // #endif
147
146
  elId: elId,
148
147
  elIdBox: elIdBox,
149
148
  show: true,
150
149
  animationDuration: 'none',
151
150
  animationPlayState: 'paused',
152
151
  animationDelay: '0s'
153
152
  };
154
153
  },
155
154
  computed: {
156
155
  isShowGetMore() {
157
156
  return this.showGetMore === true || this.showGetMore === 'true';
158
157
  },
159
158
  isShowClose() {
160
159
  return (
161
160
  (this.showClose === true || this.showClose === 'true') && (this.showGetMore === false || this.showGetMore === 'false')
162
161
  );
163
162
  }
164
163
  },
165
164
  mounted() {
166
165
  // #ifdef APP-PLUS
167
166
  var pages = getCurrentPages();
168
167
  var page = pages[pages.length - 1];
169
168
  var currentWebview = page.$getAppWebview();
170
169
  currentWebview.addEventListener('hide', () => {
171
170
  this.webviewHide = true;
172
171
  });
173
172
  currentWebview.addEventListener('show', () => {
174
173
  this.webviewHide = false;
175
174
  });
176
175
  // #endif
177
176
  this.$nextTick(() => {
178
177
  this.initSize();
179
178
  });
180
179
  },
181
180
  // #ifdef APP-NVUE
182
181
  beforeDestroy() {
183
182
  this.stopAnimation = true;
184
183
  },
185
184
  // #endif
186
185
  methods: {
187
186
  initSize() {
188
187
  if (this.scrollable) {
189
188
  // #ifndef APP-NVUE
190
189
  let query = [],
191
190
  boxWidth = 0,
192
191
  textWidth = 0;
193
192
  let textQuery = new Promise((resolve, reject) => {
194
193
  uni
195
194
  .createSelectorQuery()
196
195
  // #ifndef MP-ALIPAY
197
196
  .in(this)
198
197
  // #endif
199
198
  .select(`#${this.elId}`)
200
199
  .boundingClientRect()
201
200
  .exec((ret) => {
202
201
  this.textWidth = ret[0].width;
203
202
  resolve();
204
203
  });
205
204
  });
206
205
  let boxQuery = new Promise((resolve, reject) => {
207
206
  uni
208
207
  .createSelectorQuery()
209
208
  // #ifndef MP-ALIPAY
210
209
  .in(this)
211
210
  // #endif
212
211
  .select(`#${this.elIdBox}`)
213
212
  .boundingClientRect()
214
213
  .exec((ret) => {
215
214
  this.boxWidth = ret[0].width;
216
215
  resolve();
217
216
  });
218
217
  });
219
218
  query.push(textQuery);
220
219
  query.push(boxQuery);
221
220
  Promise.all(query).then(() => {
222
221
  this.animationDuration = `${this.textWidth / this.speed}s`;
223
222
  this.animationDelay = `-${this.boxWidth / this.speed}s`;
224
223
  setTimeout(() => {
225
224
  this.animationPlayState = 'running';
226
225
  }, 1000);
227
226
  });
228
227
  // #endif
229
228
  // #ifdef APP-NVUE
230
229
  dom.getComponentRect(this.$refs['animationEle'], (res) => {
231
230
  let winWidth = uni.getSystemInfoSync().windowWidth;
232
231
  this.textWidth = res.size.width;
233
232
  animation.transition(
234
233
  this.$refs['animationEle'],
235
234
  {
236
235
  styles: {
237
236
  transform: `translateX(-${winWidth}px)`
238
237
  },
239
238
  duration: 0,
240
239
  timingFunction: 'linear',
241
240
  delay: 0
242
241
  },
243
242
  () => {
244
243
  if (!this.stopAnimation) {
245
244
  animation.transition(
246
245
  this.$refs['animationEle'],
247
246
  {
248
247
  styles: {
249
248
  transform: `translateX(-${this.textWidth}px)`
250
249
  },
251
250
  timingFunction: 'linear',
252
251
  duration: ((this.textWidth - winWidth) / this.speed) * 1000,
253
252
  delay: 1000
254
253
  },
255
254
  () => {
256
255
  if (!this.stopAnimation) {
257
256
  this.loopAnimation();
258
257
  }
259
258
  }
260
259
  );
261
260
  }
262
261
  }
263
262
  );
264
263
  });
265
264
  // #endif
266
265
  }
267
266
  // #ifdef APP-NVUE
268
267
  if (!this.scrollable && (this.single || this.moreText)) {
269
268
  dom.getComponentRect(this.$refs['textBox'], (res) => {
270
269
  this.wrapWidth = res.size.width;
271
270
  });
272
271
  }
273
272
  // #endif
274
273
  },
275
274
  loopAnimation() {
276
275
  // #ifdef APP-NVUE
277
276
  animation.transition(
278
277
  this.$refs['animationEle'],
279
278
  {
280
279
  styles: {
281
280
  transform: `translateX(0px)`
282
281
  },
283
282
  duration: 0
284
283
  },
285
284
  () => {
286
285
  if (!this.stopAnimation) {
287
286
  animation.transition(
288
287
  this.$refs['animationEle'],
289
288
  {
290
289
  styles: {
291
290
  transform: `translateX(-${this.textWidth}px)`
292
291
  },
293
292
  duration: (this.textWidth / this.speed) * 1000,
294
293
  timingFunction: 'linear',
295
294
  delay: 0
296
295
  },
297
296
  () => {
298
297
  if (!this.stopAnimation) {
299
298
  this.loopAnimation();
300
299
  }
301
300
  }
302
301
  );
303
302
  }
304
303
  }
305
304
  );
306
305
  // #endif
307
306
  },
308
307
  clickMore() {
309
308
  this.$emit('getmore');
310
309
  },
311
310
  close() {
312
311
  this.show = false;
313
312
  this.$emit('close');
314
313
  },
315
314
  onClick() {
316
315
  this.$emit('click');
317
316
  }
318
317
  }
318
+ <template>
319
+ <view v-if="show" class="uni-noticebar" :style="{ backgroundColor }" @click="onClick">
320
+ <uni-icons
321
+ v-if="showIcon === true || showIcon === 'true'"
322
+ class="uni-noticebar-icon"
323
+ type="sound"
324
+ :color="color"
325
+ :size="fontSize * 1.5"
326
+ />
327
+ <view
328
+ ref="textBox"
329
+ class="uni-noticebar__content-wrapper"
330
+ :class="{
331
+ 'uni-noticebar__content-wrapper--scrollable': scrollable,
332
+ 'uni-noticebar__content-wrapper--single': !scrollable && (single || moreText)
333
+ }"
334
+ :style="{ height: scrollable ? fontSize * 1.5 + 'px' : 'auto' }"
335
+ >
336
+ <view
337
+ :id="elIdBox"
338
+ class="uni-noticebar__content"
339
+ :class="{
340
+ 'uni-noticebar__content--scrollable': scrollable,
341
+ 'uni-noticebar__content--single': !scrollable && (single || moreText)
342
+ }"
343
+ >
344
+ <text
345
+ :id="elId"
346
+ ref="animationEle"
347
+ class="uni-noticebar__content-text"
348
+ :class="{
349
+ 'uni-noticebar__content-text--scrollable': scrollable,
350
+ 'uni-noticebar__content-text--single': !scrollable && (single || showGetMore)
351
+ }"
352
+ :style="{
353
+ color: color,
354
+ fontSize: fontSize + 'px',
355
+ lineHeight: fontSize * 1.5 + 'px',
356
+ width: wrapWidth + 'px',
357
+ animationDuration: animationDuration,
358
+ '-webkit-animationDuration': animationDuration,
359
+ animationPlayState: webviewHide ? 'paused' : animationPlayState,
360
+ '-webkit-animationPlayState': webviewHide ? 'paused' : animationPlayState,
361
+ animationDelay: animationDelay,
362
+ '-webkit-animationDelay': animationDelay
363
+ }"
364
+ >
365
+ {{ text }}
366
+ </text>
367
+ </view>
368
+ </view>
369
+ <view v-if="isShowGetMore" class="uni-noticebar__more uni-cursor-point" @click="clickMore">
370
+ <text v-if="moreText.length > 0" :style="{ color: moreColor, fontSize: fontSize + 'px' }">{{ moreText }}</text>
371
+ <uni-icons v-else type="right" :color="moreColor" :size="fontSize * 1.1" />
372
+ </view>
373
+ <view class="uni-noticebar-close uni-cursor-point" v-if="isShowClose">
374
+ <uni-icons type="closeempty" :color="color" :size="fontSize * 1.1" @click="close" />
375
+ </view>
376
+ </view>
377
+ </template>
378
+ <script>
379
+ // #ifdef APP-NVUE
380
+ const dom = weex.requireModule('dom');
381
+ const animation = weex.requireModule('animation');
382
+ // #endif
383
+ /**
384
+ * NoticeBar 自定义导航栏
385
+ * @description 通告栏组件
386
+ * @tutorial https://ext.dcloud.net.cn/plugin?id=30
387
+ * @property {Number} speed 文字滚动的速度,默认100px/秒
388
+ * @property {String} text 显示文字
389
+ * @property {String} backgroundColor 背景颜色
390
+ * @property {String} color 文字颜色
391
+ * @property {String} moreColor 查看更多文字的颜色
392
+ * @property {String} moreText 设置“查看更多”的文本
393
+ * @property {Boolean} single = [true|false] 是否单行
394
+ * @property {Boolean} scrollable = [true|false] 是否滚动,为true时,NoticeBar为单行
395
+ * @property {Boolean} showIcon = [true|false] 是否显示左侧喇叭图标
396
+ * @property {Boolean} showClose = [true|false] 是否显示左侧关闭按钮
397
+ * @property {Boolean} showGetMore = [true|false] 是否显示右侧查看更多图标,为true时,NoticeBar为单行
398
+ * @event {Function} click 点击 NoticeBar 触发事件
399
+ * @event {Function} close 关闭 NoticeBar 触发事件
400
+ * @event {Function} getmore 点击”查看更多“时触发事件
401
+ */
402
+ export default {
403
+ name: 'UniNoticeBar',
404
+ emits: ['click', 'getmore', 'close'],
405
+ props: {
406
+ text: {
407
+ type: String,
408
+ default: ''
409
+ },
410
+ moreText: {
411
+ type: String,
412
+ default: ''
413
+ },
414
+ backgroundColor: {
415
+ type: String,
416
+ default: '#FFF9EA'
417
+ },
418
+ speed: {
419
+ // 默认1s滚动100px
420
+ type: Number,
421
+ default: 100
422
+ },
423
+ color: {
424
+ type: String,
425
+ default: '#FF9A43'
426
+ },
427
+ fontSize: {
428
+ type: Number,
429
+ default: 14
430
+ },
431
+ moreColor: {
432
+ type: String,
433
+ default: '#FF9A43'
434
+ },
435
+ single: {
436
+ // 是否单行
437
+ type: [Boolean, String],
438
+ default: false
439
+ },
440
+ scrollable: {
441
+ // 是否滚动,添加后控制单行效果取消
442
+ type: [Boolean, String],
443
+ default: false
444
+ },
445
+ showIcon: {
446
+ // 是否显示左侧icon
447
+ type: [Boolean, String],
448
+ default: false
449
+ },
450
+ showGetMore: {
451
+ // 是否显示右侧查看更多
452
+ type: [Boolean, String],
453
+ default: false
454
+ },
455
+ showClose: {
456
+ // 是否显示左侧关闭按钮
457
+ type: [Boolean, String],
458
+ default: false
459
+ }
460
+ },
461
+ data() {
462
+ const elId = `Uni_${Math.ceil(Math.random() * 10e5).toString(36)}`;
463
+ const elIdBox = `Uni_${Math.ceil(Math.random() * 10e5).toString(36)}`;
464
+ return {
465
+ textWidth: 0,
466
+ boxWidth: 0,
467
+ wrapWidth: '',
468
+ webviewHide: false,
469
+ // #ifdef APP-NVUE
470
+ stopAnimation: false,
471
+ // #endif
472
+ elId: elId,
473
+ elIdBox: elIdBox,
474
+ show: true,
475
+ animationDuration: 'none',
476
+ animationPlayState: 'paused',
477
+ animationDelay: '0s'
478
+ };
479
+ },
480
+ computed: {
481
+ isShowGetMore() {
482
+ return this.showGetMore === true || this.showGetMore === 'true';
483
+ },
484
+ isShowClose() {
485
+ return (
486
+ (this.showClose === true || this.showClose === 'true') && (this.showGetMore === false || this.showGetMore === 'false')
487
+ );
488
+ }
489
+ },
490
+ mounted() {
491
+ // #ifdef APP-PLUS
492
+ var pages = getCurrentPages();
493
+ var page = pages[pages.length - 1];
494
+ var currentWebview = page.$getAppWebview();
495
+ currentWebview.addEventListener('hide', () => {
496
+ this.webviewHide = true;
497
+ });
498
+ currentWebview.addEventListener('show', () => {
499
+ this.webviewHide = false;
500
+ });
501
+ // #endif
502
+ this.$nextTick(() => {
503
+ this.initSize();
504
+ });
505
+ },
506
+ // #ifdef APP-NVUE
507
+ beforeDestroy() {
508
+ this.stopAnimation = true;
509
+ },
510
+ // #endif
511
+ methods: {
512
+ initSize() {
513
+ if (this.scrollable) {
514
+ // #ifndef APP-NVUE
515
+ let query = [],
516
+ boxWidth = 0,
517
+ textWidth = 0;
518
+ let textQuery = new Promise((resolve, reject) => {
519
+ uni
520
+ .createSelectorQuery()
521
+ // #ifndef MP-ALIPAY
522
+ .in(this)
523
+ // #endif
524
+ .select(`#${this.elId}`)
525
+ .boundingClientRect()
526
+ .exec((ret) => {
527
+ this.textWidth = ret[0].width;
528
+ resolve();
529
+ });
530
+ });
531
+ let boxQuery = new Promise((resolve, reject) => {
532
+ uni
533
+ .createSelectorQuery()
534
+ // #ifndef MP-ALIPAY
535
+ .in(this)
536
+ // #endif
537
+ .select(`#${this.elIdBox}`)
538
+ .boundingClientRect()
539
+ .exec((ret) => {
540
+ this.boxWidth = ret[0].width;
541
+ resolve();
542
+ });
543
+ });
544
+ query.push(textQuery);
545
+ query.push(boxQuery);
546
+ Promise.all(query).then(() => {
547
+ this.animationDuration = `${this.textWidth / this.speed}s`;
548
+ this.animationDelay = `-${this.boxWidth / this.speed}s`;
549
+ setTimeout(() => {
550
+ this.animationPlayState = 'running';
551
+ }, 1000);
552
+ });
553
+ // #endif
554
+ // #ifdef APP-NVUE
555
+ dom.getComponentRect(this.$refs['animationEle'], (res) => {
556
+ let winWidth = uni.getSystemInfoSync().windowWidth;
557
+ this.textWidth = res.size.width;
558
+ animation.transition(
559
+ this.$refs['animationEle'],
560
+ {
561
+ styles: {
562
+ transform: `translateX(-${winWidth}px)`
563
+ },
564
+ duration: 0,
565
+ timingFunction: 'linear',
566
+ delay: 0
567
+ },
568
+ () => {
569
+ if (!this.stopAnimation) {
570
+ animation.transition(
571
+ this.$refs['animationEle'],
572
+ {
573
+ styles: {
574
+ transform: `translateX(-${this.textWidth}px)`
575
+ },
576
+ timingFunction: 'linear',
577
+ duration: ((this.textWidth - winWidth) / this.speed) * 1000,
578
+ delay: 1000
579
+ },
580
+ () => {
581
+ if (!this.stopAnimation) {
582
+ this.loopAnimation();
583
+ }
584
+ }
585
+ );
586
+ }
587
+ }
588
+ );
589
+ });
590
+ // #endif
591
+ }
592
+ // #ifdef APP-NVUE
593
+ if (!this.scrollable && (this.single || this.moreText)) {
594
+ dom.getComponentRect(this.$refs['textBox'], (res) => {
595
+ this.wrapWidth = res.size.width;
596
+ });
597
+ }
598
+ // #endif
599
+ },
600
+ loopAnimation() {
601
+ // #ifdef APP-NVUE
602
+ animation.transition(
603
+ this.$refs['animationEle'],
604
+ {
605
+ styles: {
606
+ transform: `translateX(0px)`
607
+ },
608
+ duration: 0
609
+ },
610
+ () => {
611
+ if (!this.stopAnimation) {
612
+ animation.transition(
613
+ this.$refs['animationEle'],
614
+ {
615
+ styles: {
616
+ transform: `translateX(-${this.textWidth}px)`
617
+ },
618
+ duration: (this.textWidth / this.speed) * 1000,
619
+ timingFunction: 'linear',
620
+ delay: 0
621
+ },
622
+ () => {
623
+ if (!this.stopAnimation) {
624
+ this.loopAnimation();
625
+ }
626
+ }
627
+ );
628
+ }
629
+ }
630
+ );
631
+ // #endif
632
+ },
633
+ clickMore() {
634
+ this.$emit('getmore');
635
+ },
636
+ close() {
637
+ this.show = false;
638
+ this.$emit('close');
639
+ },
640
+ onClick() {
641
+ this.$emit('click');
642
+ }
643
+ }
644
+ };
645
+ </script>
646
+ <style scoped>
647
+ @import 'style.css';
648
+ </style>