@gmcb/uv-ui 0.2.26

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 (285) hide show
  1. package/CHANGELOG.md +295 -0
  2. package/LICENSE +21 -0
  3. package/README.md +164 -0
  4. package/components/uv-action-sheet/props.js +50 -0
  5. package/components/uv-action-sheet/uv-action-sheet.vue +280 -0
  6. package/components/uv-album/uv-album.vue +312 -0
  7. package/components/uv-alert/props.js +45 -0
  8. package/components/uv-alert/uv-alert.vue +246 -0
  9. package/components/uv-avatar/props.js +85 -0
  10. package/components/uv-avatar/uv-avatar.vue +182 -0
  11. package/components/uv-avatar-group/props.js +53 -0
  12. package/components/uv-avatar-group/uv-avatar-group.vue +106 -0
  13. package/components/uv-back-top/props.js +58 -0
  14. package/components/uv-back-top/uv-back-top.vue +116 -0
  15. package/components/uv-badge/props.js +73 -0
  16. package/components/uv-badge/uv-badge.vue +176 -0
  17. package/components/uv-button/nvue.scss +46 -0
  18. package/components/uv-button/props.js +163 -0
  19. package/components/uv-button/uv-button.vue +529 -0
  20. package/components/uv-button/vue.scss +93 -0
  21. package/components/uv-calendar/calendar.js +546 -0
  22. package/components/uv-calendar/header.vue +104 -0
  23. package/components/uv-calendar/month.vue +616 -0
  24. package/components/uv-calendar/props.js +145 -0
  25. package/components/uv-calendar/uv-calendar.vue +390 -0
  26. package/components/uv-calendars/calendar-body.vue +376 -0
  27. package/components/uv-calendars/calendar-item.vue +248 -0
  28. package/components/uv-calendars/calendar.js +546 -0
  29. package/components/uv-calendars/i18n/en.json +12 -0
  30. package/components/uv-calendars/i18n/index.js +8 -0
  31. package/components/uv-calendars/i18n/zh-Hans.json +12 -0
  32. package/components/uv-calendars/i18n/zh-Hant.json +12 -0
  33. package/components/uv-calendars/util.js +435 -0
  34. package/components/uv-calendars/uv-calendars.vue +452 -0
  35. package/components/uv-cell/props.js +116 -0
  36. package/components/uv-cell/uv-cell.vue +209 -0
  37. package/components/uv-cell-group/props.js +15 -0
  38. package/components/uv-cell-group/uv-cell-group.vue +63 -0
  39. package/components/uv-checkbox/props.js +70 -0
  40. package/components/uv-checkbox/uv-checkbox.vue +371 -0
  41. package/components/uv-checkbox-group/props.js +84 -0
  42. package/components/uv-checkbox-group/uv-checkbox-group.vue +119 -0
  43. package/components/uv-code/props.js +35 -0
  44. package/components/uv-code/uv-code.vue +136 -0
  45. package/components/uv-code-input/props.js +83 -0
  46. package/components/uv-code-input/uv-code-input.vue +272 -0
  47. package/components/uv-col/props.js +30 -0
  48. package/components/uv-col/uv-col.vue +165 -0
  49. package/components/uv-collapse/props.js +20 -0
  50. package/components/uv-collapse/uv-collapse.vue +86 -0
  51. package/components/uv-collapse-item/props.js +60 -0
  52. package/components/uv-collapse-item/uv-collapse-item.vue +228 -0
  53. package/components/uv-column-notice/props.js +61 -0
  54. package/components/uv-column-notice/uv-column-notice.vue +176 -0
  55. package/components/uv-count-down/props.js +25 -0
  56. package/components/uv-count-down/utils.js +62 -0
  57. package/components/uv-count-down/uv-count-down.vue +169 -0
  58. package/components/uv-count-to/props.js +60 -0
  59. package/components/uv-count-to/uv-count-to.vue +187 -0
  60. package/components/uv-datetime-picker/props.js +130 -0
  61. package/components/uv-datetime-picker/uv-datetime-picker.vue +355 -0
  62. package/components/uv-divider/props.js +45 -0
  63. package/components/uv-divider/uv-divider.vue +113 -0
  64. package/components/uv-drop-down/uv-drop-down.vue +135 -0
  65. package/components/uv-drop-down-item/uv-drop-down-item.vue +169 -0
  66. package/components/uv-drop-down-popup/uv-drop-down-popup.vue +242 -0
  67. package/components/uv-empty/props.js +60 -0
  68. package/components/uv-empty/uv-empty.vue +126 -0
  69. package/components/uv-form/props.js +46 -0
  70. package/components/uv-form/uv-form.vue +209 -0
  71. package/components/uv-form/valid.js +1343 -0
  72. package/components/uv-form-item/props.js +49 -0
  73. package/components/uv-form-item/uv-form-item.vue +226 -0
  74. package/components/uv-gap/props.js +25 -0
  75. package/components/uv-gap/uv-gap.vue +36 -0
  76. package/components/uv-grid/props.js +20 -0
  77. package/components/uv-grid/uv-grid.vue +100 -0
  78. package/components/uv-grid-item/props.js +15 -0
  79. package/components/uv-grid-item/uv-grid-item.vue +223 -0
  80. package/components/uv-icon/icons.js +160 -0
  81. package/components/uv-icon/props.js +90 -0
  82. package/components/uv-icon/uv-icon.vue +226 -0
  83. package/components/uv-icon/uvicons.ttf +0 -0
  84. package/components/uv-image/props.js +100 -0
  85. package/components/uv-image/uv-image.vue +296 -0
  86. package/components/uv-index-anchor/props.js +30 -0
  87. package/components/uv-index-anchor/uv-index-anchor.vue +98 -0
  88. package/components/uv-index-item/uv-index-item.vue +87 -0
  89. package/components/uv-index-list/props.js +30 -0
  90. package/components/uv-index-list/uv-index-list.vue +461 -0
  91. package/components/uv-input/props.js +175 -0
  92. package/components/uv-input/uv-input.vue +348 -0
  93. package/components/uv-keyboard/props.js +95 -0
  94. package/components/uv-keyboard/uv-keyboard.vue +180 -0
  95. package/components/uv-keyboard-car/props.js +24 -0
  96. package/components/uv-keyboard-car/uv-keyboard-car.vue +347 -0
  97. package/components/uv-keyboard-number/props.js +19 -0
  98. package/components/uv-keyboard-number/uv-keyboard-number.vue +201 -0
  99. package/components/uv-line/props.js +34 -0
  100. package/components/uv-line/uv-line.vue +60 -0
  101. package/components/uv-line-progress/props.js +29 -0
  102. package/components/uv-line-progress/uv-line-progress.vue +146 -0
  103. package/components/uv-link/props.js +40 -0
  104. package/components/uv-link/uv-link.vue +83 -0
  105. package/components/uv-list/uv-list.vue +147 -0
  106. package/components/uv-list-item/uv-list-item.vue +535 -0
  107. package/components/uv-load-more/props.js +95 -0
  108. package/components/uv-load-more/uv-load-more.vue +152 -0
  109. package/components/uv-loading-icon/props.js +67 -0
  110. package/components/uv-loading-icon/uv-loading-icon.vue +347 -0
  111. package/components/uv-loading-page/props.js +55 -0
  112. package/components/uv-loading-page/uv-loading-page.vue +96 -0
  113. package/components/uv-modal/props.js +90 -0
  114. package/components/uv-modal/uv-modal.vue +245 -0
  115. package/components/uv-navbar/props.js +89 -0
  116. package/components/uv-navbar/uv-navbar.vue +245 -0
  117. package/components/uv-no-network/props.js +20 -0
  118. package/components/uv-no-network/uv-no-network.vue +222 -0
  119. package/components/uv-notice-bar/props.js +76 -0
  120. package/components/uv-notice-bar/uv-notice-bar.vue +110 -0
  121. package/components/uv-notify/props.js +45 -0
  122. package/components/uv-notify/uv-notify.vue +220 -0
  123. package/components/uv-number-box/props.js +118 -0
  124. package/components/uv-number-box/uv-number-box.vue +397 -0
  125. package/components/uv-overlay/props.js +25 -0
  126. package/components/uv-overlay/uv-overlay.vue +85 -0
  127. package/components/uv-parse/node/node.vue +576 -0
  128. package/components/uv-parse/parser.js +1335 -0
  129. package/components/uv-parse/uv-parse.vue +498 -0
  130. package/components/uv-pick-color/colors.js +217 -0
  131. package/components/uv-pick-color/props.js +47 -0
  132. package/components/uv-pick-color/uv-pick-color.vue +551 -0
  133. package/components/uv-picker/props.js +95 -0
  134. package/components/uv-picker/uv-picker.vue +329 -0
  135. package/components/uv-popup/keypress.js +45 -0
  136. package/components/uv-popup/uv-popup.vue +537 -0
  137. package/components/uv-preview-video/uv-preview-video.vue +52 -0
  138. package/components/uv-qrcode/cache.js +1 -0
  139. package/components/uv-qrcode/gcanvas/bridge/bridge-weex.js +241 -0
  140. package/components/uv-qrcode/gcanvas/context-2d/FillStyleLinearGradient.js +18 -0
  141. package/components/uv-qrcode/gcanvas/context-2d/FillStylePattern.js +8 -0
  142. package/components/uv-qrcode/gcanvas/context-2d/FillStyleRadialGradient.js +17 -0
  143. package/components/uv-qrcode/gcanvas/context-2d/RenderingContext.js +666 -0
  144. package/components/uv-qrcode/gcanvas/context-webgl/ActiveInfo.js +11 -0
  145. package/components/uv-qrcode/gcanvas/context-webgl/Buffer.js +21 -0
  146. package/components/uv-qrcode/gcanvas/context-webgl/Framebuffer.js +21 -0
  147. package/components/uv-qrcode/gcanvas/context-webgl/GLenum.js +298 -0
  148. package/components/uv-qrcode/gcanvas/context-webgl/GLmethod.js +142 -0
  149. package/components/uv-qrcode/gcanvas/context-webgl/GLtype.js +23 -0
  150. package/components/uv-qrcode/gcanvas/context-webgl/Program.js +21 -0
  151. package/components/uv-qrcode/gcanvas/context-webgl/Renderbuffer.js +21 -0
  152. package/components/uv-qrcode/gcanvas/context-webgl/RenderingContext.js +1191 -0
  153. package/components/uv-qrcode/gcanvas/context-webgl/Shader.js +22 -0
  154. package/components/uv-qrcode/gcanvas/context-webgl/ShaderPrecisionFormat.js +11 -0
  155. package/components/uv-qrcode/gcanvas/context-webgl/Texture.js +22 -0
  156. package/components/uv-qrcode/gcanvas/context-webgl/UniformLocation.js +22 -0
  157. package/components/uv-qrcode/gcanvas/context-webgl/classUtils.js +3 -0
  158. package/components/uv-qrcode/gcanvas/env/canvas.js +74 -0
  159. package/components/uv-qrcode/gcanvas/env/image.js +96 -0
  160. package/components/uv-qrcode/gcanvas/env/tool.js +24 -0
  161. package/components/uv-qrcode/gcanvas/index.js +39 -0
  162. package/components/uv-qrcode/props.js +85 -0
  163. package/components/uv-qrcode/qrcode.js +34 -0
  164. package/components/uv-qrcode/queue.js +41 -0
  165. package/components/uv-qrcode/uv-qrcode.vue +1038 -0
  166. package/components/uv-radio/props.js +65 -0
  167. package/components/uv-radio/uv-radio.vue +349 -0
  168. package/components/uv-radio-group/props.js +89 -0
  169. package/components/uv-radio-group/uv-radio-group.vue +115 -0
  170. package/components/uv-rate/props.js +73 -0
  171. package/components/uv-rate/uv-rate.vue +274 -0
  172. package/components/uv-read-more/props.js +62 -0
  173. package/components/uv-read-more/uv-read-more.vue +162 -0
  174. package/components/uv-row/props.js +20 -0
  175. package/components/uv-row/uv-row.vue +95 -0
  176. package/components/uv-row-notice/props.js +40 -0
  177. package/components/uv-row-notice/uv-row-notice.vue +341 -0
  178. package/components/uv-safe-bottom/uv-safe-bottom.vue +67 -0
  179. package/components/uv-scroll-list/nvue.js +29 -0
  180. package/components/uv-scroll-list/props.js +35 -0
  181. package/components/uv-scroll-list/scrollWxs.wxs +51 -0
  182. package/components/uv-scroll-list/uv-scroll-list.vue +218 -0
  183. package/components/uv-search/props.js +127 -0
  184. package/components/uv-search/uv-search.vue +311 -0
  185. package/components/uv-skeleton/props.js +65 -0
  186. package/components/uv-skeleton/uv-skeleton.vue +250 -0
  187. package/components/uv-skeletons/uv-skeletons.vue +247 -0
  188. package/components/uv-slider/props.js +58 -0
  189. package/components/uv-slider/uv-slider.vue +58 -0
  190. package/components/uv-status-bar/props.js +8 -0
  191. package/components/uv-status-bar/uv-status-bar.vue +54 -0
  192. package/components/uv-steps/props.js +40 -0
  193. package/components/uv-steps/uv-steps.vue +83 -0
  194. package/components/uv-steps-item/props.js +25 -0
  195. package/components/uv-steps-item/uv-steps-item.vue +347 -0
  196. package/components/uv-sticky/props.js +41 -0
  197. package/components/uv-sticky/uv-sticky.vue +223 -0
  198. package/components/uv-subsection/props.js +54 -0
  199. package/components/uv-subsection/uv-subsection.vue +269 -0
  200. package/components/uv-swipe-action/props.js +10 -0
  201. package/components/uv-swipe-action/uv-swipe-action.vue +65 -0
  202. package/components/uv-swipe-action-item/index - backup.wxs +256 -0
  203. package/components/uv-swipe-action-item/index.wxs +225 -0
  204. package/components/uv-swipe-action-item/nvue - backup.js +264 -0
  205. package/components/uv-swipe-action-item/nvue.js +182 -0
  206. package/components/uv-swipe-action-item/props.js +40 -0
  207. package/components/uv-swipe-action-item/uv-swipe-action-item.vue +200 -0
  208. package/components/uv-swipe-action-item/wxs.js +15 -0
  209. package/components/uv-swiper/props.js +136 -0
  210. package/components/uv-swiper/uv-swiper.vue +263 -0
  211. package/components/uv-swiper-indicator/props.js +30 -0
  212. package/components/uv-swiper-indicator/uv-swiper-indicator.vue +112 -0
  213. package/components/uv-switch/props.js +58 -0
  214. package/components/uv-switch/uv-switch.vue +182 -0
  215. package/components/uv-tabbar/props.js +50 -0
  216. package/components/uv-tabbar/uv-tabbar.vue +146 -0
  217. package/components/uv-tabbar-item/props.js +40 -0
  218. package/components/uv-tabbar-item/uv-tabbar-item.vue +146 -0
  219. package/components/uv-tabs/props.js +71 -0
  220. package/components/uv-tabs/uv-tabs.vue +391 -0
  221. package/components/uv-tags/props.js +104 -0
  222. package/components/uv-tags/uv-tags.vue +379 -0
  223. package/components/uv-text/props.js +113 -0
  224. package/components/uv-text/uv-text.vue +218 -0
  225. package/components/uv-text/value.js +87 -0
  226. package/components/uv-textarea/props.js +138 -0
  227. package/components/uv-textarea/uv-textarea.vue +238 -0
  228. package/components/uv-toast/uv-toast.vue +292 -0
  229. package/components/uv-toolbar/props.js +40 -0
  230. package/components/uv-toolbar/uv-toolbar.vue +109 -0
  231. package/components/uv-tooltip/props.js +60 -0
  232. package/components/uv-tooltip/uv-tooltip.vue +372 -0
  233. package/components/uv-transition/createAnimation.js +131 -0
  234. package/components/uv-transition/props.js +31 -0
  235. package/components/uv-transition/uv-transition.vue +320 -0
  236. package/components/uv-upload/mixin.js +22 -0
  237. package/components/uv-upload/props.js +130 -0
  238. package/components/uv-upload/utils.js +151 -0
  239. package/components/uv-upload/uv-upload.vue +488 -0
  240. package/components/uv-vtabs/props.js +79 -0
  241. package/components/uv-vtabs/uv-vtabs.vue +438 -0
  242. package/components/uv-vtabs-item/uv-vtabs-item.vue +68 -0
  243. package/components/uv-waterfall/props.js +69 -0
  244. package/components/uv-waterfall/uv-waterfall.vue +265 -0
  245. package/index.js +82 -0
  246. package/index.scss +7 -0
  247. package/libs/config/config.js +34 -0
  248. package/libs/css/color.scss +32 -0
  249. package/libs/css/common.scss +100 -0
  250. package/libs/css/components.scss +23 -0
  251. package/libs/css/variable.scss +111 -0
  252. package/libs/css/vue.scss +40 -0
  253. package/libs/function/colorGradient.js +134 -0
  254. package/libs/function/compress.js +27 -0
  255. package/libs/function/debounce.js +29 -0
  256. package/libs/function/digit.js +167 -0
  257. package/libs/function/index.js +734 -0
  258. package/libs/function/platform.js +75 -0
  259. package/libs/function/test.js +287 -0
  260. package/libs/function/throttle.js +30 -0
  261. package/libs/luch-request/adapters/index.js +132 -0
  262. package/libs/luch-request/core/InterceptorManager.js +51 -0
  263. package/libs/luch-request/core/Request.js +201 -0
  264. package/libs/luch-request/core/buildFullPath.js +20 -0
  265. package/libs/luch-request/core/defaults.js +33 -0
  266. package/libs/luch-request/core/dispatchRequest.js +6 -0
  267. package/libs/luch-request/core/mergeConfig.js +126 -0
  268. package/libs/luch-request/core/settle.js +16 -0
  269. package/libs/luch-request/helpers/buildURL.js +64 -0
  270. package/libs/luch-request/helpers/combineURLs.js +14 -0
  271. package/libs/luch-request/helpers/isAbsoluteURL.js +14 -0
  272. package/libs/luch-request/index.d.ts +197 -0
  273. package/libs/luch-request/index.js +2 -0
  274. package/libs/luch-request/utils/clone.js +264 -0
  275. package/libs/luch-request/utils.js +135 -0
  276. package/libs/mixin/button.js +13 -0
  277. package/libs/mixin/mixin.js +172 -0
  278. package/libs/mixin/mpMixin.js +8 -0
  279. package/libs/mixin/mpShare.js +13 -0
  280. package/libs/mixin/openType.js +47 -0
  281. package/libs/mixin/touch.js +59 -0
  282. package/libs/util/dayjs.js +216 -0
  283. package/libs/util/route.js +126 -0
  284. package/package.json +28 -0
  285. package/theme.scss +43 -0
@@ -0,0 +1,86 @@
1
+ <template>
2
+ <view class="uv-collapse">
3
+ <uv-line v-if="border"></uv-line>
4
+ <slot />
5
+ </view>
6
+ </template>
7
+
8
+ <script>
9
+ import mpMixin from '../../libs/mixin/mpMixin.js'
10
+ import mixin from '../../libs/mixin/mixin.js'
11
+ import props from './props.js';
12
+ /**
13
+ * collapse 折叠面板
14
+ * @description 通过折叠面板收纳内容区域
15
+ * @tutorial https://www.uvui.cn/components/collapse.html
16
+ * @property {String | Number | Array} value 当前展开面板的name,非手风琴模式:[<string | number>],手风琴模式:string | number
17
+ * @property {Boolean} accordion 是否手风琴模式( 默认 false )
18
+ * @property {Boolean} border 是否显示外边框 ( 默认 true )
19
+ * @event {Function} change 当前激活面板展开时触发(如果是手风琴模式,参数activeNames类型为String,否则为Array)
20
+ * @example <uv-collapse></uv-collapse>
21
+ */
22
+ export default {
23
+ name: "uv-collapse",
24
+ mixins: [mpMixin, mixin, props],
25
+ watch: {
26
+ needInit() {
27
+ this.init()
28
+ },
29
+ // 当父组件需要子组件需要共享的参数发生了变化,手动通知子组件
30
+ parentData() {
31
+ if (this.children.length) {
32
+ this.children.map(child => {
33
+ // 判断子组件(uv-checkbox)如果有updateParentData方法的话,就就执行(执行的结果是子组件重新从父组件拉取了最新的值)
34
+ typeof(child.updateParentData) === 'function' && child.updateParentData()
35
+ })
36
+ }
37
+ }
38
+ },
39
+ created() {
40
+ this.children = []
41
+ },
42
+ computed: {
43
+ needInit() {
44
+ // 通过computed,同时监听accordion和value值的变化
45
+ // 再通过watch去执行init()方法,进行再一次的初始化
46
+ return [this.accordion, this.value]
47
+ }
48
+ },
49
+ methods: {
50
+ // 重新初始化一次内部的所有子元素
51
+ init() {
52
+ this.children.map(child => {
53
+ child.init()
54
+ })
55
+ },
56
+ /**
57
+ * collapse-item被点击时触发,由collapse统一处理各子组件的状态
58
+ * @param {Object} target 被操作的面板的实例
59
+ */
60
+ onChange(target) {
61
+ let changeArr = []
62
+ this.children.map((child, index) => {
63
+ // 如果是手风琴模式,将其他的折叠面板收起来
64
+ if (this.accordion) {
65
+ child.expanded = child === target ? !target.expanded : false
66
+ child.setContentAnimate()
67
+ } else {
68
+ if(child === target) {
69
+ child.expanded = !child.expanded
70
+ child.setContentAnimate()
71
+ }
72
+ }
73
+ // 拼接change事件中,数组元素的状态
74
+ changeArr.push({
75
+ // 如果没有定义name属性,则默认返回组件的index索引
76
+ name: child.name || index,
77
+ status: child.expanded ? 'open' : 'close'
78
+ })
79
+ })
80
+
81
+ this.$emit('change', changeArr)
82
+ this.$emit(target.expanded ? 'open' : 'close', target.name)
83
+ }
84
+ }
85
+ }
86
+ </script>
@@ -0,0 +1,60 @@
1
+ export default {
2
+ props: {
3
+ // 标题
4
+ title: {
5
+ type: String,
6
+ default: ''
7
+ },
8
+ // 标题右侧内容
9
+ value: {
10
+ type: String,
11
+ default: ''
12
+ },
13
+ // 标题下方的描述信息
14
+ label: {
15
+ type: String,
16
+ default: ''
17
+ },
18
+ // 是否禁用折叠面板
19
+ disabled: {
20
+ type: Boolean,
21
+ default: false
22
+ },
23
+ // 是否展示右侧箭头并开启点击反馈
24
+ isLink: {
25
+ type: Boolean,
26
+ default: true
27
+ },
28
+ // 是否开启点击反馈
29
+ clickable: {
30
+ type: Boolean,
31
+ default: true
32
+ },
33
+ // 是否显示内边框
34
+ border: {
35
+ type: Boolean,
36
+ default: true
37
+ },
38
+ // 标题的对齐方式
39
+ align: {
40
+ type: String,
41
+ default: 'left'
42
+ },
43
+ // 唯一标识符
44
+ name: {
45
+ type: [String, Number],
46
+ default: ''
47
+ },
48
+ // 标题左侧图片,可为绝对路径的图片或内置图标
49
+ icon: {
50
+ type: String,
51
+ default: ''
52
+ },
53
+ // 面板展开收起的过渡时间,单位ms
54
+ duration: {
55
+ type: Number,
56
+ default: 300
57
+ },
58
+ ...uni.$uv?.props?.collapseItem
59
+ }
60
+ }
@@ -0,0 +1,228 @@
1
+ <template>
2
+ <view class="uv-collapse-item">
3
+ <uv-cell
4
+ :title="title"
5
+ :value="value"
6
+ :label="label"
7
+ :icon="icon"
8
+ :isLink="isLink"
9
+ :clickable="clickable"
10
+ :border="parentData.border && showBorder"
11
+ @click="clickHandler"
12
+ :arrowDirection="expanded ? 'up' : 'down'"
13
+ :disabled="disabled"
14
+ >
15
+ <!-- #ifndef MP-WEIXIN -->
16
+ <!-- 微信小程序不支持,因为微信中不支持 <slot name="title" slot="title" />的写法 -->
17
+ <template slot="title">
18
+ <slot name="title"></slot>
19
+ </template>
20
+ <template slot="icon">
21
+ <slot name="icon"></slot>
22
+ </template>
23
+ <template slot="value">
24
+ <slot name="value"></slot>
25
+ </template>
26
+ <template slot="right-icon">
27
+ <slot name="right-icon"></slot>
28
+ </template>
29
+ <!-- #endif -->
30
+ </uv-cell>
31
+ <view
32
+ class="uv-collapse-item__content"
33
+ :animation="animationData"
34
+ ref="animation"
35
+ >
36
+ <view
37
+ class="uv-collapse-item__content__text content-class"
38
+ :id="elId"
39
+ :ref="elId"
40
+ ><slot /></view>
41
+ </view>
42
+ <uv-line v-if="parentData.border"></uv-line>
43
+ </view>
44
+ </template>
45
+
46
+ <script>
47
+ import mpMixin from '../../libs/mixin/mpMixin.js'
48
+ import mixin from '../../libs/mixin/mixin.js'
49
+ import props from './props.js';
50
+ // #ifdef APP-NVUE
51
+ const animation = uni.requireNativePlugin('animation')
52
+ const dom = uni.requireNativePlugin('dom')
53
+ // #endif
54
+ /**
55
+ * collapseItem 折叠面板Item
56
+ * @description 通过折叠面板收纳内容区域(搭配uv-collapse使用)
57
+ * @tutorial https://www.uvui.cn/components/collapse.html
58
+ * @property {String} title 标题
59
+ * @property {String} value 标题右侧内容
60
+ * @property {String} label 标题下方的描述信息
61
+ * @property {Boolean} disbled 是否禁用折叠面板 ( 默认 false )
62
+ * @property {Boolean} isLink 是否展示右侧箭头并开启点击反馈 ( 默认 true )
63
+ * @property {Boolean} clickable 是否开启点击反馈 ( 默认 true )
64
+ * @property {Boolean} border 是否显示内边框 ( 默认 true )
65
+ * @property {String | Number} name 唯一标识符
66
+ * @property {String} icon 标题左侧图片,可为绝对路径的图片或内置图标
67
+ * @event {Function} change 某个item被打开或者收起时触发
68
+ * @example <uv-collapse-item :title="item.head" v-for="(item, index) in itemList" :key="index">{{item.body}}</uv-collapse-item>
69
+ */
70
+ export default {
71
+ name: "uv-collapse-item",
72
+ mixins: [mpMixin, mixin, props],
73
+ data() {
74
+ return {
75
+ elId: '',
76
+ // uni.createAnimation的导出数据
77
+ animationData: {},
78
+ // 是否展开状态
79
+ expanded: false,
80
+ // 根据expanded确定是否显示border,为了控制展开时,cell的下划线更好的显示效果,进行一定时间的延时
81
+ showBorder: false,
82
+ // 是否动画中,如果是则不允许继续触发点击
83
+ animating: false,
84
+ // 父组件uv-collapse的参数
85
+ parentData: {
86
+ accordion: false,
87
+ border: false
88
+ }
89
+ };
90
+ },
91
+ watch: {
92
+ expanded(n) {
93
+ clearTimeout(this.timer)
94
+ this.timer = null
95
+ // 这里根据expanded的值来进行一定的延时,是为了cell的下划线更好的显示效果
96
+ this.timer = setTimeout(() => {
97
+ this.showBorder = n
98
+ }, n ? 10 : 290)
99
+ }
100
+ },
101
+ created() {
102
+ this.elId = this.$uv.guid();
103
+ },
104
+ mounted() {
105
+ this.init()
106
+ },
107
+ methods: {
108
+ // 异步获取内容,或者动态修改了内容时,需要重新初始化
109
+ init() {
110
+ // 初始化数据
111
+ this.updateParentData()
112
+ if (!this.parent) {
113
+ return this.$uv.error('uv-collapse-item必须要搭配uv-collapse组件使用')
114
+ }
115
+ const {
116
+ value,
117
+ accordion,
118
+ children = []
119
+ } = this.parent
120
+
121
+ if (accordion) {
122
+ if (this.$uv.test.array(value)) {
123
+ return this.$uv.error('手风琴模式下,uv-collapse组件的value参数不能为数组')
124
+ }
125
+ this.expanded = this.name == value
126
+ } else {
127
+ if (!this.$uv.test.array(value) && value !== null) {
128
+ return this.$uv.error('非手风琴模式下,uv-collapse组件的value参数必须为数组')
129
+ }
130
+ this.expanded = (value || []).some(item => item == this.name)
131
+ }
132
+ // 设置组件的展开或收起状态
133
+ this.$nextTick(function() {
134
+ this.setContentAnimate()
135
+ })
136
+ },
137
+ updateParentData() {
138
+ // 此方法在mixin中
139
+ this.getParentData('uv-collapse')
140
+ },
141
+ async setContentAnimate() {
142
+ // 每次面板打开或者收起时,都查询元素尺寸
143
+ // 好处是,父组件从服务端获取内容后,变更折叠面板后可以获得最新的高度
144
+ const rect = await this.queryRect()
145
+ const height = this.expanded ? rect.height : 0
146
+ this.animating = true
147
+ // #ifdef APP-NVUE
148
+ const ref = this.$refs['animation'].ref
149
+ animation.transition(ref, {
150
+ styles: {
151
+ height: height + 'px'
152
+ },
153
+ duration: this.duration,
154
+ // 必须设置为true,否则会到面板收起或展开时,页面其他元素不会随之调整它们的布局
155
+ needLayout: true,
156
+ timingFunction: 'ease-in-out',
157
+ }, () => {
158
+ this.animating = false
159
+ })
160
+ // #endif
161
+
162
+ // #ifndef APP-NVUE
163
+ const animation = uni.createAnimation({
164
+ timingFunction: 'ease-in-out',
165
+ });
166
+ animation
167
+ .height(height)
168
+ .step({
169
+ duration: this.duration,
170
+ })
171
+ .step()
172
+ // 导出动画数据给面板的animationData值
173
+ this.animationData = animation.export()
174
+ // 标识动画结束
175
+ this.$uv.sleep(this.duration).then(() => {
176
+ this.animating = false
177
+ })
178
+ // #endif
179
+ },
180
+ // 点击collapsehead头部
181
+ clickHandler() {
182
+ if (this.disabled && this.animating) return
183
+ // 设置本组件为相反的状态
184
+ this.parent && this.parent.onChange(this)
185
+ },
186
+ // 查询内容高度
187
+ queryRect() {
188
+ // #ifndef APP-NVUE
189
+ // 组件内部一般用this.$uvGetRect,对外的为getRect,二者功能一致,名称不同
190
+ return new Promise(resolve => {
191
+ this.$uvGetRect(`#${this.elId}`).then(size => {
192
+ resolve(size)
193
+ })
194
+ })
195
+ // #endif
196
+
197
+ // #ifdef APP-NVUE
198
+ // nvue下,使用dom模块查询元素高度
199
+ // 返回一个promise,让调用此方法的主体能使用then回调
200
+ return new Promise(resolve => {
201
+ dom.getComponentRect(this.$refs[this.elId], res => {
202
+ resolve(res.size)
203
+ })
204
+ })
205
+ // #endif
206
+ }
207
+ },
208
+ };
209
+ </script>
210
+
211
+ <style lang="scss" scoped>
212
+ @import '../../libs/css/components.scss';
213
+ @import '../../libs/css/color.scss';
214
+ .uv-collapse-item {
215
+
216
+ &__content {
217
+ overflow: hidden;
218
+ height: 0;
219
+
220
+ &__text {
221
+ padding: 12px 15px;
222
+ color: $uv-content-color;
223
+ font-size: 14px;
224
+ line-height: 18px;
225
+ }
226
+ }
227
+ }
228
+ </style>
@@ -0,0 +1,61 @@
1
+ export default {
2
+ props: {
3
+ // 显示的内容,字符串
4
+ text: {
5
+ type: [Array],
6
+ default: ''
7
+ },
8
+ // 是否显示左侧的音量图标
9
+ icon: {
10
+ type: [String, Boolean, null],
11
+ default: 'volume'
12
+ },
13
+ // 通告模式,link-显示右箭头,closable-显示右侧关闭图标
14
+ mode: {
15
+ type: String,
16
+ default: ''
17
+ },
18
+ // 文字颜色,各图标也会使用文字颜色
19
+ color: {
20
+ type: String,
21
+ default: '#f9ae3d'
22
+ },
23
+ // 背景颜色
24
+ bgColor: {
25
+ type: String,
26
+ default: '#fdf6ec'
27
+ },
28
+ // 字体大小,单位px
29
+ fontSize: {
30
+ type: [String, Number],
31
+ default: 14
32
+ },
33
+ // 水平滚动时的滚动速度,即每秒滚动多少px(px),这有利于控制文字无论多少时,都能有一个恒定的速度
34
+ speed: {
35
+ type: [String, Number],
36
+ default: 80
37
+ },
38
+ // direction = row时,是否使用步进形式滚动
39
+ step: {
40
+ type: Boolean,
41
+ default: false
42
+ },
43
+ // 滚动一个周期的时间长,单位ms
44
+ duration: {
45
+ type: [String, Number],
46
+ default: 1500
47
+ },
48
+ // 是否禁止用手滑动切换,仅`direction="column"生效`
49
+ // 目前HX2.6.11,只支持App 2.5.5+、H5 2.5.5+、支付宝小程序、字节跳动小程序
50
+ disableTouch: {
51
+ type: Boolean,
52
+ default: true
53
+ },
54
+ // 是否禁止滚动,仅`direction="column"生效`
55
+ disableScroll: {
56
+ type: Boolean,
57
+ default: false
58
+ },
59
+ ...uni.$uv?.props?.columnNotice
60
+ }
61
+ }
@@ -0,0 +1,176 @@
1
+ <template>
2
+ <view
3
+ class="uv-notice"
4
+ @tap="clickHandler"
5
+ >
6
+ <slot name="icon">
7
+ <view
8
+ class="uv-notice__left-icon"
9
+ v-if="icon"
10
+ >
11
+ <uv-icon
12
+ :name="icon"
13
+ :color="color"
14
+ size="19"
15
+ ></uv-icon>
16
+ </view>
17
+ </slot>
18
+ <swiper
19
+ :disable-touch="disableTouch"
20
+ :vertical="step ? false : true"
21
+ circular
22
+ :interval="duration"
23
+ :autoplay="!disableScroll"
24
+ class="uv-notice__swiper"
25
+ :style="[swiperStyle]"
26
+ @change="noticeChange"
27
+ >
28
+ <swiper-item
29
+ v-for="(item, index) in text"
30
+ :key="index"
31
+ class="uv-notice__swiper__item"
32
+ >
33
+ <text
34
+ class="uv-notice__swiper__item__text uv-line-1"
35
+ :style="[textStyle]"
36
+ >{{ item }}</text>
37
+ </swiper-item>
38
+ </swiper>
39
+ <view
40
+ class="uv-notice__right-icon"
41
+ v-if="['link', 'closable'].includes(mode)"
42
+ >
43
+ <uv-icon
44
+ v-if="mode === 'link'"
45
+ name="arrow-right"
46
+ :size="17"
47
+ :color="color"
48
+ ></uv-icon>
49
+ <uv-icon
50
+ v-if="mode === 'closable'"
51
+ name="close"
52
+ :size="16"
53
+ :color="color"
54
+ @click="close"
55
+ ></uv-icon>
56
+ </view>
57
+ </view>
58
+ </template>
59
+
60
+ <script>
61
+ import mpMixin from '../../libs/mixin/mpMixin.js'
62
+ import mixin from '../../libs/mixin/mixin.js'
63
+ import props from './props.js';
64
+ /**
65
+ * ColumnNotice 滚动通知中的垂直滚动 内部组件
66
+ * @description 该组件用于滚动通告场景,是其中的垂直滚动方式
67
+ * @tutorial https://www.uvui.cn/components/noticeBar.html
68
+ * @property {Array} text 显示的内容,字符串
69
+ * @property {String} icon 是否显示左侧的音量图标 ( 默认 'volume' )
70
+ * @property {String} mode 通告模式,link-显示右箭头,closable-显示右侧关闭图标
71
+ * @property {String} color 文字颜色,各图标也会使用文字颜色 ( 默认 '#f9ae3d' )
72
+ * @property {String} bgColor 背景颜色 ( 默认 '#fdf6ec' )
73
+ * @property {String | Number} fontSize 字体大小,单位px ( 默认 14 )
74
+ * @property {String | Number} speed 水平滚动时的滚动速度,即每秒滚动多少px(rpx),这有利于控制文字无论多少时,都能有一个恒定的速度 ( 默认 80 )
75
+ * @property {Boolean} step direction = row时,是否使用步进形式滚动 ( 默认 false )
76
+ * @property {String | Number} duration 滚动一个周期的时间长,单位ms ( 默认 1500 )
77
+ * @property {Boolean} disableTouch 是否禁止用手滑动切换 目前HX2.6.11,只支持App 2.5.5+、H5 2.5.5+、支付宝小程序、字节跳动小程序 ( 默认 true )
78
+ * @example
79
+ */
80
+ export default {
81
+ emits: ['click','close','change'],
82
+ mixins: [mpMixin, mixin, props],
83
+ watch: {
84
+ text: {
85
+ immediate: true,
86
+ handler(newValue, oldValue) {
87
+ if(!this.$uv.test.array(newValue)) {
88
+ this.$uv.error('noticebar组件direction为column时,要求text参数为数组形式')
89
+ }
90
+ }
91
+ }
92
+ },
93
+ computed: {
94
+ // 文字内容的样式
95
+ textStyle() {
96
+ let style = {}
97
+ style.color = this.color
98
+ style.fontSize = this.$uv.addUnit(this.fontSize)
99
+ return style
100
+ },
101
+ // 垂直或者水平滚动
102
+ vertical() {
103
+ if (this.mode == 'horizontal') return false
104
+ else return true
105
+ },
106
+ // NVUE中的swiper在css中样式不生效
107
+ swiperStyle(){
108
+ const style = {};
109
+ // #ifdef APP-NVUE
110
+ style.flex = 1;
111
+ style.height = '16px';
112
+ // #endif
113
+ return style;
114
+ }
115
+ },
116
+ data() {
117
+ return {
118
+ index:0
119
+ }
120
+ },
121
+ methods: {
122
+ noticeChange(e){
123
+ this.index = e.detail.current
124
+ this.$emit('change', this.index);
125
+ },
126
+ // 点击通告栏
127
+ clickHandler() {
128
+ this.$emit('click', this.index)
129
+ },
130
+ // 点击关闭按钮
131
+ close() {
132
+ this.$emit('close')
133
+ }
134
+ }
135
+ };
136
+ </script>
137
+
138
+ <style lang="scss" scoped>
139
+ $show-lines: 1;
140
+ @import '../../libs/css/variable.scss';
141
+ @import '../../libs/css/components.scss';
142
+ @import '../../libs/css/color.scss';
143
+ .uv-notice {
144
+ @include flex;
145
+ align-items: center;
146
+ justify-content: space-between;
147
+
148
+ &__left-icon {
149
+ align-items: center;
150
+ margin-right: 5px;
151
+ }
152
+
153
+ &__right-icon {
154
+ margin-left: 5px;
155
+ align-items: center;
156
+ }
157
+
158
+ &__swiper {
159
+ height: 16px;
160
+ @include flex;
161
+ align-items: center;
162
+ flex: 1;
163
+
164
+ &__item {
165
+ @include flex;
166
+ align-items: center;
167
+ overflow: hidden;
168
+
169
+ &__text {
170
+ font-size: 14px;
171
+ color: $uv-warning;
172
+ }
173
+ }
174
+ }
175
+ }
176
+ </style>
@@ -0,0 +1,25 @@
1
+ export default {
2
+ props: {
3
+ // 倒计时时长,单位ms
4
+ time: {
5
+ type: [String, Number],
6
+ default: 0
7
+ },
8
+ // 时间格式,DD-日,HH-时,mm-分,ss-秒,SSS-毫秒
9
+ format: {
10
+ type: String,
11
+ default: 'HH:mm:ss'
12
+ },
13
+ // 是否自动开始倒计时
14
+ autoStart: {
15
+ type: Boolean,
16
+ default: true
17
+ },
18
+ // 是否展示毫秒倒计时
19
+ millisecond: {
20
+ type: Boolean,
21
+ default: false
22
+ },
23
+ ...uni.$uv?.props?.countDown
24
+ }
25
+ }
@@ -0,0 +1,62 @@
1
+ // 补0,如1 -> 01
2
+ function padZero(num, targetLength = 2) {
3
+ let str = `${num}`
4
+ while (str.length < targetLength) {
5
+ str = `0${str}`
6
+ }
7
+ return str
8
+ }
9
+ const SECOND = 1000
10
+ const MINUTE = 60 * SECOND
11
+ const HOUR = 60 * MINUTE
12
+ const DAY = 24 * HOUR
13
+ export function parseTimeData(time) {
14
+ const days = Math.floor(time / DAY)
15
+ const hours = Math.floor((time % DAY) / HOUR)
16
+ const minutes = Math.floor((time % HOUR) / MINUTE)
17
+ const seconds = Math.floor((time % MINUTE) / SECOND)
18
+ const milliseconds = Math.floor(time % SECOND)
19
+ return {
20
+ days,
21
+ hours,
22
+ minutes,
23
+ seconds,
24
+ milliseconds
25
+ }
26
+ }
27
+ export function parseFormat(format, timeData) {
28
+ let {
29
+ days,
30
+ hours,
31
+ minutes,
32
+ seconds,
33
+ milliseconds
34
+ } = timeData
35
+ // 如果格式化字符串中不存在DD(天),则将天的时间转为小时中去
36
+ if (format.indexOf('DD') === -1) {
37
+ hours += days * 24
38
+ } else {
39
+ // 对天补0
40
+ format = format.replace('DD', padZero(days))
41
+ }
42
+ // 其他同理于DD的格式化处理方式
43
+ if (format.indexOf('HH') === -1) {
44
+ minutes += hours * 60
45
+ } else {
46
+ format = format.replace('HH', padZero(hours))
47
+ }
48
+ if (format.indexOf('mm') === -1) {
49
+ seconds += minutes * 60
50
+ } else {
51
+ format = format.replace('mm', padZero(minutes))
52
+ }
53
+ if (format.indexOf('ss') === -1) {
54
+ milliseconds += seconds * 1000
55
+ } else {
56
+ format = format.replace('ss', padZero(seconds))
57
+ }
58
+ return format.replace('SSS', padZero(milliseconds, 3))
59
+ }
60
+ export function isSameSecond(time1, time2) {
61
+ return Math.floor(time1 / 1000) === Math.floor(time2 / 1000)
62
+ }