@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,461 @@
1
+ <template>
2
+ <view class="uv-index-list">
3
+ <!-- #ifdef APP-NVUE -->
4
+ <list
5
+ :scrollTop="scrollTop"
6
+ enable-back-to-top
7
+ :offset-accuracy="1"
8
+ :style="{
9
+ maxHeight: $uv.addUnit(scrollViewHeight,'px')
10
+ }"
11
+ @scroll="scrollHandler"
12
+ ref="uvList"
13
+ >
14
+ <cell ref="header">
15
+ <slot name="header" />
16
+ </cell>
17
+ <slot />
18
+ <cell>
19
+ <slot name="footer" />
20
+ </cell>
21
+ </list>
22
+ <!-- #endif -->
23
+ <!-- #ifndef APP-NVUE -->
24
+ <scroll-view
25
+ :scrollTop="scrollTop"
26
+ :scrollIntoView="scrollIntoView"
27
+ :offset-accuracy="1"
28
+ :style="{
29
+ maxHeight: $uv.addUnit(scrollViewHeight,'px')
30
+ }"
31
+ scroll-y
32
+ @scroll="scrollHandler"
33
+ ref="uvList"
34
+ >
35
+ <view>
36
+ <slot name="header" />
37
+ </view>
38
+ <slot />
39
+ <view>
40
+ <slot name="footer" />
41
+ </view>
42
+ </scroll-view>
43
+ <!-- #endif -->
44
+ <view
45
+ class="uv-index-list__letter"
46
+ ref="uv-index-list__letter"
47
+ :style="{ top: $uv.addUnit(letterInfo.top || 100 ,'px') }"
48
+ @touchstart="touchStart"
49
+ @touchmove.stop.prevent="touchMove"
50
+ @touchend.stop.prevent="touchEnd"
51
+ @touchcancel.stop.prevent="touchEnd"
52
+ >
53
+ <view
54
+ class="uv-index-list__letter__item"
55
+ v-for="(item, index) in uIndexList"
56
+ :key="index"
57
+ :style="{
58
+ backgroundColor: activeIndex === index ? activeColor : 'transparent'
59
+ }"
60
+ >
61
+ <text
62
+ class="uv-index-list__letter__item__index"
63
+ :style="{color: activeIndex === index ? '#fff' : inactiveColor}"
64
+ >{{ item }}</text>
65
+ </view>
66
+ </view>
67
+ <uv-transition
68
+ mode="fade"
69
+ :show="touching"
70
+ :customStyle="{
71
+ position: 'fixed',
72
+ right: '40px',
73
+ top: $uv.addUnit(indicatorTop,'px'),
74
+ zIndex: 2
75
+ }"
76
+ >
77
+ <view class="uv-index-list__indicator__box">
78
+ <view
79
+ class="uv-index-list__indicator"
80
+ :class="['uv-index-list__indicator--show']"
81
+ :style="{
82
+ height: $uv.addUnit(indicatorHeight,'px'),
83
+ width: $uv.addUnit(indicatorHeight,'px')
84
+ }"
85
+ >
86
+ <text class="uv-index-list__indicator__text">{{ uIndexList[activeIndex] }}</text>
87
+ </view>
88
+ </view>
89
+ </uv-transition>
90
+ </view>
91
+ </template>
92
+
93
+ <script>
94
+ const indexList = () => {
95
+ const indexList = [];
96
+ const charCodeOfA = 'A'.charCodeAt(0);
97
+ for (let i = 0; i < 26; i++) {
98
+ indexList.push(String.fromCharCode(charCodeOfA + i));
99
+ }
100
+ return indexList;
101
+ }
102
+ import mpMixin from '../../libs/mixin/mpMixin.js'
103
+ import mixin from '../../libs/mixin/mixin.js'
104
+ import props from './props.js';
105
+ // #ifdef APP-NVUE
106
+ // 由于weex为阿里的KPI业绩考核的产物,所以不支持百分比单位,这里需要通过dom查询组件的宽度
107
+ const dom = uni.requireNativePlugin('dom')
108
+ // #endif
109
+ /**
110
+ * IndexList 索引列表
111
+ * @description 通过折叠面板收纳内容区域
112
+ * @tutorial https://www.uvui.cn/components/indexList.html
113
+ * @property {String} inactiveColor 右边锚点非激活的颜色 ( 默认 '#606266' )
114
+ * @property {String} activeColor 右边锚点激活的颜色 ( 默认 '#5677fc' )
115
+ * @property {Array} indexList 索引字符列表,数组形式
116
+ * @property {Boolean} sticky 是否开启锚点自动吸顶 ( 默认 true )
117
+ * @property {String | Number} customNavHeight 自定义导航栏的高度 ( 默认 0 )
118
+ * */
119
+ export default {
120
+ name: 'uv-index-list',
121
+ mixins: [mpMixin, mixin, props],
122
+ // #ifdef MP-WEIXIN
123
+ // 将自定义节点设置成虚拟的,更加接近Vue组件的表现,能更好的使用flex属性
124
+ options: {
125
+ virtualHost: true
126
+ },
127
+ // #endif
128
+ data() {
129
+ return {
130
+ // 当前正在被选中的字母索引
131
+ activeIndex: -1,
132
+ touchmoveIndex: 1,
133
+ // 索引字母的信息
134
+ letterInfo: {
135
+ height: 0,
136
+ itemHeight: 0,
137
+ top: 0
138
+ },
139
+ // 设置字母指示器的高度,后面为了让指示器跟随字母,并将尖角部分指向字母的中部,需要依赖此值
140
+ indicatorHeight: 50,
141
+ // 字母放大指示器的top值,为了让其指向当前激活的字母
142
+ // indicatorTop: 0
143
+ // 当前是否正在被触摸状态
144
+ touching: false,
145
+ // 滚动条顶部top值
146
+ scrollTop: 0,
147
+ // scroll-view的高度
148
+ scrollViewHeight: 0,
149
+ // 系统信息
150
+ sys: '',
151
+ scrolling: false,
152
+ scrollIntoView: '',
153
+ hasHeight: 0,
154
+ timer: 0,
155
+ disTap: false
156
+ }
157
+ },
158
+ computed: {
159
+ // 如果有传入外部的indexList锚点数组则使用,否则使用内部生成A-Z字母
160
+ uIndexList() {
161
+ return this.indexList.length ? this.indexList : indexList()
162
+ },
163
+ // 字母放大指示器的top值,为了让其指向当前激活的字母
164
+ indicatorTop() {
165
+ const {
166
+ top,
167
+ itemHeight
168
+ } = this.letterInfo
169
+ return Math.floor(top + itemHeight * this.activeIndex + itemHeight / 2 - this.indicatorHeight / 2) - 8
170
+ }
171
+ },
172
+ watch: {
173
+ // 监听字母索引的变化,重新设置尺寸
174
+ uIndexList: {
175
+ immediate: true,
176
+ handler() {
177
+ this.$uv.sleep().then(() => {
178
+ this.setIndexListLetterInfo()
179
+ })
180
+ }
181
+ }
182
+ },
183
+ created() {
184
+ this.sys = this.$uv.sys()
185
+ this.children = []
186
+ this.anchors = []
187
+ this.init()
188
+ },
189
+ mounted() {
190
+ this.setIndexListLetterInfo()
191
+ },
192
+ methods: {
193
+ init() {
194
+ // 设置列表的高度为整个屏幕的高度
195
+ //减去this.customNavHeight,并将this.scrollViewHeight设置为maxHeight
196
+ //解决当uv-index-list组件放在tabbar页面时,scroll-view内容较少时,还能滚动
197
+ this.scrollViewHeight = this.sys.windowHeight - this.$uv.getPx(this.customNavHeight)
198
+ },
199
+ // 索引列表被触摸
200
+ touchStart(e) {
201
+ // 获取触摸点信息
202
+ const touchStart = e.changedTouches[0]
203
+ if (!touchStart || this.disTap) return
204
+ this.touching = true
205
+ const {
206
+ pageY
207
+ } = touchStart
208
+ // 根据当前触摸点的坐标,获取当前触摸的为第几个字母
209
+ const currentIndex = this.getIndexListLetter(pageY)
210
+ this.setValueForTouch(currentIndex)
211
+ },
212
+ // 索引字母列表被触摸滑动中
213
+ touchMove(e) {
214
+ // 获取触摸点信息
215
+ let touchMove = e.changedTouches[0]
216
+ if (!touchMove || this.disTap) return;
217
+
218
+ // 滑动结束后迅速开始第二次滑动时候 touching 为 false 造成不显示 indicator 问题
219
+ if (!this.touching) {
220
+ this.touching = true
221
+ }
222
+ const {
223
+ pageY
224
+ } = touchMove
225
+ const currentIndex = this.getIndexListLetter(pageY)
226
+ this.setValueForTouch(currentIndex)
227
+ },
228
+ // 触摸结束
229
+ touchEnd(e) {
230
+ // 延时一定时间后再隐藏指示器,为了让用户看的更直观,同时也是为了消除快速切换uv-transition的show带来的影响
231
+ this.$uv.sleep(300).then(() => {
232
+ this.touching = false
233
+ })
234
+ this.$emit('select',this.activeIndex);
235
+ },
236
+ // 获取索引列表的尺寸以及单个字符的尺寸信息
237
+ getIndexListLetterRect() {
238
+ return new Promise(resolve => {
239
+ // 延时一定时间,以获取dom尺寸
240
+ // #ifndef APP-NVUE
241
+ this.$uvGetRect('.uv-index-list__letter').then(size => {
242
+ resolve(size)
243
+ })
244
+ // #endif
245
+
246
+ // #ifdef APP-NVUE
247
+ const ref = this.$refs['uv-index-list__letter']
248
+ dom.getComponentRect(ref, res => {
249
+ resolve(res.size)
250
+ })
251
+ // #endif
252
+ })
253
+ },
254
+ // 设置indexList索引的尺寸信息
255
+ setIndexListLetterInfo() {
256
+ this.getIndexListLetterRect().then(size => {
257
+ const {
258
+ top,
259
+ height
260
+ } = size
261
+ const windowHeight = this.$uv.sys().windowHeight;
262
+ let customNavHeight = 0
263
+ // 消除各端导航栏非原生和原生导致的差异,让索引列表字母对屏幕垂直居中
264
+ if (this.customNavHeight == 0) {
265
+ // #ifdef H5
266
+ customNavHeight = this.$uv.sys().windowTop
267
+ // #endif
268
+ // #ifndef H5
269
+ // 在非H5中,为原生导航栏,其高度不算在windowHeight内,这里设置为负值,后面相加时变成减去其高度的一半
270
+ customNavHeight = 0
271
+ // #endif
272
+ } else {
273
+ customNavHeight = this.$uv.getPx(this.customNavHeight)
274
+ }
275
+ this.letterInfo = {
276
+ height,
277
+ // 为了让字母列表对屏幕绝对居中,让其对导航栏进行修正,也即往上偏移导航栏的一半高度
278
+ top: (windowHeight - height) / 2 + customNavHeight / 2,
279
+ itemHeight: Math.floor(height / this.uIndexList.length)
280
+ }
281
+ })
282
+ },
283
+ // 获取当前被触摸的索引字母
284
+ getIndexListLetter(pageY) {
285
+ const {
286
+ top,
287
+ height,
288
+ itemHeight
289
+ } = this.letterInfo
290
+ // 对H5的pageY进行修正,这是由于uni-app自作多情在H5中将触摸点的坐标跟H5的导航栏结合导致的问题
291
+ // #ifdef H5
292
+ pageY += this.$uv.sys().windowTop
293
+ // #endif
294
+ // #ifdef APP-NVUE
295
+ pageY += top
296
+ // #endif
297
+ // 对第一和最后一个字母做边界处理,因为用户可能在字母列表上触摸到两端的尽头后依然继续滑动
298
+ if (pageY < top) {
299
+ return 0
300
+ } else if (pageY >= top + height) {
301
+ // 如果超出了,取最后一个字母
302
+ return this.uIndexList.length - 1
303
+ } else {
304
+ // 将触摸点的Y轴偏移值,减去索引字母的top值,除以每个字母的高度,即可得到当前触摸点落在哪个字母上
305
+ return Math.floor((pageY - top) / itemHeight);
306
+ }
307
+ },
308
+ // 设置各项由触摸而导致变化的值
309
+ setValueForTouch(currentIndex) {
310
+ // 如果偏移量太小,前后得出的会是同一个索引字母,为了防抖,进行返回
311
+ if (currentIndex === this.activeIndex) return
312
+ this.activeIndex = currentIndex
313
+ // #ifndef APP-NVUE || MP-WEIXIN
314
+ // 在非nvue中,由于anchor和item都在uv-index-item中,所以需要对index-item进行偏移
315
+ this.scrollIntoView = `uv-index-item-${this.uIndexList[currentIndex].charCodeAt(0)}`
316
+ // #endif
317
+ // #ifdef MP-WEIXIN
318
+ // 微信小程序下,scroll-view的scroll-into-view属性无法对slot中的内容的id生效,只能通过设置scrollTop的形式去移动滚动条
319
+ this.scrollTop = this.children[currentIndex].top
320
+ // #endif
321
+ // #ifdef APP-NVUE
322
+ // 在nvue中,由于cell和header为同级元素,所以实际是需要对header(anchor)进行偏移
323
+ const anchor = `uv-index-anchor-${this.uIndexList[currentIndex]}`
324
+ dom.scrollToElement(this.anchors[currentIndex].$refs[anchor], {
325
+ offset: 0,
326
+ animated: false
327
+ })
328
+ // #endif
329
+ },
330
+ getHeaderRect() {
331
+ // 获取header slot的高度,因为list组件中获取元素的尺寸是没有top值的
332
+ return new Promise(resolve => {
333
+ dom.getComponentRect(this.$refs.header, res => {
334
+ resolve(res.size)
335
+ })
336
+ })
337
+ },
338
+ // scroll-view的滚动事件
339
+ async scrollHandler(e) {
340
+ if (this.touching || this.scrolling) return
341
+ // 每过一定时间取样一次,减少资源损耗以及可能带来的卡顿
342
+ this.scrolling = true
343
+ this.disTap = true;
344
+ clearTimeout(this.timer);
345
+ this.timer = setTimeout(()=>{
346
+ this.disTap = false;
347
+ },200)
348
+ this.$uv.sleep(30).then(() => {
349
+ this.scrolling = false
350
+ })
351
+ let scrollTop = 0
352
+ const len = this.children.length
353
+ let children = this.children
354
+ const anchors = this.anchors
355
+ const customNavHeight = this.$uv.getPx(this.customNavHeight);
356
+ // #ifdef APP-NVUE
357
+ // nvue下获取的滚动条偏移为负数,需要转为正数
358
+ scrollTop = Math.abs(e.contentOffset.y)
359
+ // 获取header slot的尺寸信息
360
+ const header = await this.getHeaderRect()
361
+ // item的top值,在nvue下,模拟出的anchor的top,类似非nvue下的index-item的top
362
+ let top = header.height
363
+ // 由于list组件无法获取cell的top值,这里通过header slot和各个item之间的height,模拟出类似非nvue下的位置信息
364
+ children = this.children.map((item, index) => {
365
+ if(item.height>0) this.hasHeight = item.height;
366
+ item.height = item.height>0?item.height:this.hasHeight;
367
+ const child = {
368
+ height: item.height,
369
+ top
370
+ }
371
+ // 进行累加,给下一个item提供计算依据
372
+ top += item.height + anchors[index].height
373
+ return child
374
+ })
375
+ // #endif
376
+ // #ifndef APP-NVUE
377
+ // 非nvue通过detail获取滚动条位移
378
+ scrollTop = e.detail.scrollTop
379
+ // #endif
380
+ for (let i = 0; i < len; i++) {
381
+ const item = children[i],
382
+ nextItem = children[i + 1]
383
+ // 如果滚动条高度小于第一个item的top值,此时无需设置任意字母为高亮
384
+ if (scrollTop + customNavHeight <= children[0].top || scrollTop >= children[len - 1].top + children[len -
385
+ 1].height) {
386
+ this.activeIndex = -1
387
+ break
388
+ } else if (!nextItem) {
389
+ // 当不存在下一个item时,意味着历遍到了最后一个
390
+ this.activeIndex = len - 1
391
+ break
392
+ } else if (scrollTop + customNavHeight > item.top && scrollTop + customNavHeight < nextItem.top) {
393
+ this.activeIndex = i
394
+ break
395
+ }
396
+ }
397
+ },
398
+ },
399
+ }
400
+ </script>
401
+
402
+ <style lang="scss" scoped>
403
+ @import '../../libs/css/components.scss';
404
+ @import '../../libs/css/color.scss';
405
+ .uv-index-list {
406
+
407
+ &__letter {
408
+ position: fixed;
409
+ right: 0;
410
+ text-align: center;
411
+ z-index: 3;
412
+ padding: 0 6px;
413
+
414
+ &__item {
415
+ width: 16px;
416
+ height: 16px;
417
+ border-radius: 100px;
418
+ margin: 1px 0;
419
+ @include flex;
420
+ align-items: center;
421
+ justify-content: center;
422
+
423
+ &--active {
424
+ background-color: $uv-primary;
425
+ }
426
+
427
+ &__index {
428
+ font-size: 12px;
429
+ text-align: center;
430
+ line-height: 12px;
431
+ }
432
+ }
433
+ }
434
+ &__indicator__box {
435
+ width: 65px;
436
+ height: 65px;
437
+ padding: 6px;
438
+ transform: rotate(-45deg);
439
+ }
440
+ &__indicator {
441
+ width: 50px;
442
+ height: 50px;
443
+ border-radius: 100px 100px 0 100px;
444
+ text-align: center;
445
+ color: #ffffff;
446
+ background-color: #c9c9c9;
447
+ @include flex;
448
+ justify-content: center;
449
+ align-items: center;
450
+
451
+ &__text {
452
+ font-size: 28px;
453
+ line-height: 28px;
454
+ font-weight: bold;
455
+ color: #fff;
456
+ transform: rotate(45deg);
457
+ text-align: center;
458
+ }
459
+ }
460
+ }
461
+ </style>
@@ -0,0 +1,175 @@
1
+ export default {
2
+ props: {
3
+ value: {
4
+ type: [String, Number],
5
+ default: ''
6
+ },
7
+ modelValue: {
8
+ type: [String, Number],
9
+ default: ''
10
+ },
11
+ // 输入框类型
12
+ // number-数字输入键盘,app-vue下可以输入浮点数,app-nvue和小程序平台下只能输入整数
13
+ // idcard-身份证输入键盘,微信、支付宝、百度、QQ小程序
14
+ // digit-带小数点的数字键盘,App的nvue页面、微信、支付宝、百度、头条、QQ小程序
15
+ // text-文本输入键盘
16
+ type: {
17
+ type: String,
18
+ default: 'text'
19
+ },
20
+ // 是否禁用输入框
21
+ disabled: {
22
+ type: Boolean,
23
+ default: false
24
+ },
25
+ // 禁用状态时的背景色
26
+ disabledColor: {
27
+ type: String,
28
+ default: '#f5f7fa'
29
+ },
30
+ // 是否显示清除控件
31
+ clearable: {
32
+ type: Boolean,
33
+ default: false
34
+ },
35
+ // 是否密码类型
36
+ password: {
37
+ type: Boolean,
38
+ default: false
39
+ },
40
+ // 最大输入长度,设置为 -1 的时候不限制最大长度
41
+ maxlength: {
42
+ type: [String, Number],
43
+ default: -1
44
+ },
45
+ // 输入框为空时的占位符
46
+ placeholder: {
47
+ type: String,
48
+ default: null
49
+ },
50
+ // 指定placeholder的样式类,注意页面或组件的style中写了scoped时,需要在类名前写/deep/
51
+ placeholderClass: {
52
+ type: String,
53
+ default: 'input-placeholder'
54
+ },
55
+ // 指定placeholder的样式
56
+ placeholderStyle: {
57
+ type: [String, Object],
58
+ default: 'color: #c0c4cc'
59
+ },
60
+ // 设置右下角按钮的文字,有效值:send|search|next|go|done,兼容性详见uni-app文档
61
+ // https://uniapp.dcloud.io/component/input
62
+ // https://uniapp.dcloud.io/component/textarea
63
+ confirmType: {
64
+ type: String,
65
+ default: 'done'
66
+ },
67
+ // 点击键盘右下角按钮时是否保持键盘不收起,H5无效
68
+ confirmHold: {
69
+ type: Boolean,
70
+ default: false
71
+ },
72
+ // focus时,点击页面的时候不收起键盘,微信小程序有效
73
+ holdKeyboard: {
74
+ type: Boolean,
75
+ default: false
76
+ },
77
+ // 自动获取焦点
78
+ // 在 H5 平台能否聚焦以及软键盘是否跟随弹出,取决于当前浏览器本身的实现。nvue 页面不支持,需使用组件的 focus()、blur() 方法控制焦点
79
+ focus: {
80
+ type: Boolean,
81
+ default: false
82
+ },
83
+ // 键盘收起时,是否自动失去焦点,目前仅App3.0.0+有效
84
+ autoBlur: {
85
+ type: Boolean,
86
+ default: false
87
+ },
88
+ // 指定focus时光标的位置
89
+ cursor: {
90
+ type: [String, Number],
91
+ default: -1
92
+ },
93
+ // 输入框聚焦时底部与键盘的距离
94
+ cursorSpacing: {
95
+ type: [String, Number],
96
+ default: 30
97
+ },
98
+ // 光标起始位置,自动聚集时有效,需与selection-end搭配使用
99
+ selectionStart: {
100
+ type: [String, Number],
101
+ default: -1
102
+ },
103
+ // 光标结束位置,自动聚集时有效,需与selection-start搭配使用
104
+ selectionEnd: {
105
+ type: [String, Number],
106
+ default: -1
107
+ },
108
+ // 键盘弹起时,是否自动上推页面
109
+ adjustPosition: {
110
+ type: Boolean,
111
+ default: true
112
+ },
113
+ // 输入框内容对齐方式,可选值为:left|center|right
114
+ inputAlign: {
115
+ type: String,
116
+ default: 'left'
117
+ },
118
+ // 输入框字体的大小
119
+ fontSize: {
120
+ type: [String, Number],
121
+ default: '14px'
122
+ },
123
+ // 输入框字体颜色
124
+ color: {
125
+ type: String,
126
+ default: '#303133'
127
+ },
128
+ // 输入框前置图标
129
+ prefixIcon: {
130
+ type: String,
131
+ default: ''
132
+ },
133
+ // 前置图标样式,对象或字符串
134
+ prefixIconStyle: {
135
+ type: [String, Object],
136
+ default: ''
137
+ },
138
+ // 输入框后置图标
139
+ suffixIcon: {
140
+ type: String,
141
+ default: ''
142
+ },
143
+ // 后置图标样式,对象或字符串
144
+ suffixIconStyle: {
145
+ type: [String, Object],
146
+ default: ''
147
+ },
148
+ // 边框类型,surround-四周边框,bottom-底部边框,none-无边框
149
+ border: {
150
+ type: String,
151
+ default: 'surround'
152
+ },
153
+ // 是否只读,与disabled不同之处在于disabled会置灰组件,而readonly则不会
154
+ readonly: {
155
+ type: Boolean,
156
+ default: false
157
+ },
158
+ // 输入框形状,circle-圆形,square-方形
159
+ shape: {
160
+ type: String,
161
+ default: 'square'
162
+ },
163
+ // 用于处理或者过滤输入框内容的方法
164
+ formatter: {
165
+ type: [Function, null],
166
+ default: null
167
+ },
168
+ // 是否忽略组件内对文本合成系统事件的处理
169
+ ignoreCompositionEvent: {
170
+ type: Boolean,
171
+ default: true
172
+ },
173
+ ...uni.$uv?.props?.input
174
+ }
175
+ }