@10yun/cv-mobile-ui 0.5.29 → 0.5.30

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 (260) hide show
  1. package/package.json +1 -1
  2. package/plugins/luch-request/adapters/index.js +131 -0
  3. package/plugins/luch-request/core/InterceptorManager.js +50 -0
  4. package/plugins/luch-request/core/Request.js +199 -0
  5. package/plugins/luch-request/core/buildFullPath.js +20 -0
  6. package/plugins/luch-request/core/defaults.js +32 -0
  7. package/plugins/luch-request/core/dispatchRequest.js +5 -0
  8. package/plugins/luch-request/core/mergeConfig.js +125 -0
  9. package/plugins/luch-request/core/settle.js +16 -0
  10. package/plugins/luch-request/helpers/buildURL.js +71 -0
  11. package/plugins/luch-request/helpers/combineURLs.js +12 -0
  12. package/plugins/luch-request/helpers/isAbsoluteURL.js +14 -0
  13. package/plugins/luch-request/index.d.ts +197 -0
  14. package/plugins/luch-request/index.js +2 -0
  15. package/plugins/luch-request/readme.md +3 -0
  16. package/plugins/luch-request/utils/clone.js +264 -0
  17. package/plugins/luch-request/utils.js +131 -0
  18. package/plugins/request.js +2 -2
  19. package/ui-cv/components/cv-form-item/cv-form-item.vue +1 -1
  20. package/ui-fireui/fui-actionsheet/fui-actionsheet.vue +202 -0
  21. package/ui-fireui/fui-alert/fui-alert.vue +141 -0
  22. package/ui-fireui/fui-badge/fui-badge.vue +158 -0
  23. package/ui-fireui/fui-bottom-navigation/fui-bottom-navigation.vue +390 -0
  24. package/ui-fireui/fui-bottom-popup/fui-bottom-popup.vue +100 -0
  25. package/ui-fireui/fui-bubble-popup/fui-bubble-popup.vue +236 -0
  26. package/ui-fireui/fui-button/fui-button.vue +424 -0
  27. package/ui-fireui/fui-calendar/fui-calendar.js +915 -0
  28. package/ui-fireui/fui-calendar/fui-calendar.vue +868 -0
  29. package/ui-fireui/fui-card/fui-card.vue +231 -0
  30. package/ui-fireui/fui-cascade-selection/fui-cascade-selection.vue +538 -0
  31. package/ui-fireui/fui-circular-progress/fui-circular-progress.vue +261 -0
  32. package/ui-fireui/fui-collapse/fui-collapse.vue +179 -0
  33. package/ui-fireui/fui-countdown/fui-countdown.vue +301 -0
  34. package/ui-fireui/fui-datetime/fui-datetime.vue +570 -0
  35. package/ui-fireui/fui-divider/fui-divider.vue +118 -0
  36. package/ui-fireui/fui-drawer/fui-drawer.vue +103 -0
  37. package/ui-fireui/fui-dropdown-list/fui-dropdown-list.vue +70 -0
  38. package/ui-fireui/fui-fab/fui-fab.vue +284 -0
  39. package/ui-fireui/fui-footer/fui-footer.vue +131 -0
  40. package/ui-fireui/fui-grid/fui-grid.vue +42 -0
  41. package/ui-fireui/fui-grid-item/fui-grid-item.vue +142 -0
  42. package/ui-fireui/fui-icon/fui-icon.vue +820 -0
  43. package/ui-fireui/fui-image-cropper/fui-image-cropper.vue +1058 -0
  44. package/ui-fireui/fui-image-group/fui-image-group.vue +149 -0
  45. package/ui-fireui/fui-keyboard/fui-keyboard.vue +254 -0
  46. package/ui-fireui/fui-keyboard-input/fui-keyboard-input.vue +78 -0
  47. package/ui-fireui/fui-list-cell/fui-list-cell.vue +178 -0
  48. package/ui-fireui/fui-list-view/fui-list-view.vue +87 -0
  49. package/ui-fireui/fui-loading/fui-loading.vue +78 -0
  50. package/ui-fireui/fui-loadmore/fui-loadmore.vue +163 -0
  51. package/ui-fireui/fui-modal/fui-modal.vue +392 -0
  52. package/ui-fireui/fui-navigation-bar/fui-navigation-bar.vue +180 -0
  53. package/ui-fireui/fui-no-data/fui-no-data.vue +116 -0
  54. package/ui-fireui/fui-nomore/fui-nomore.vue +116 -0
  55. package/ui-fireui/fui-numberbox/fui-numberbox.vue +234 -0
  56. package/ui-fireui/fui-numberbox-border/fui-numberbox-border.vue +232 -0
  57. package/ui-fireui/fui-picture-cropper/fui-picture-cropper.vue +682 -0
  58. package/ui-fireui/fui-picture-cropper/fui-picture-cropper.wxs +560 -0
  59. package/ui-fireui/fui-rate/fui-rate.vue +167 -0
  60. package/ui-fireui/fui-round-progress/fui-round-progress.vue +306 -0
  61. package/ui-fireui/fui-scroll-top/fui-scroll-top.vue +189 -0
  62. package/ui-fireui/fui-sharemodel/fui-sharemodel.vue +181 -0
  63. package/ui-fireui/fui-skeleton/fui-skeleton.vue +248 -0
  64. package/ui-fireui/fui-steps/fui-steps.vue +214 -0
  65. package/ui-fireui/fui-sticky/fui-sticky.vue +155 -0
  66. package/ui-fireui/fui-sticky-wxs/fui-sticky-wxs.vue +133 -0
  67. package/ui-fireui/fui-sticky-wxs/fui-sticky.wxs +44 -0
  68. package/ui-fireui/fui-swipe-action/fui-swipe-action.vue +301 -0
  69. package/ui-fireui/fui-tabbar/fui-tabbar.vue +283 -0
  70. package/ui-fireui/fui-tabs/fui-tabs.vue +284 -0
  71. package/ui-fireui/fui-tabs2/fui-tabs2.vue +284 -0
  72. package/ui-fireui/fui-tag/fui-tag.vue +374 -0
  73. package/ui-fireui/fui-time-axis/fui-time-axis.vue +36 -0
  74. package/ui-fireui/fui-timeaxis-item/fui-timeaxis-item.vue +48 -0
  75. package/ui-fireui/fui-tips/fui-tips.vue +161 -0
  76. package/ui-fireui/fui-toast/fui-toast.vue +117 -0
  77. package/ui-fireui/fui-top-dropdown/fui-top-dropdown.vue +129 -0
  78. package/ui-fireui/fui-upload/fui-upload.vue +446 -0
  79. package/ui-fireui/fui-uploadsamll/fui-uploadsamll.vue +472 -0
  80. package/uview-plus/README.md +1 -1
  81. package/uview-plus/changelog-wu-tool.md +21 -0
  82. package/uview-plus/changelog-wu.md +91 -0
  83. package/uview-plus/components/u-action-sheet/_doc/changelog.md +12 -0
  84. package/uview-plus/components/u-action-sheet/_doc/package.json +92 -0
  85. package/uview-plus/components/u-action-sheet/_doc/readme.md +16 -0
  86. package/uview-plus/components/u-app-update/_doc/changelog.md +26 -0
  87. package/uview-plus/components/u-app-update/_doc/package.json +89 -0
  88. package/uview-plus/components/u-app-update/_doc/readme.md +16 -0
  89. package/uview-plus/components/u-app-update/config.js +120 -0
  90. package/uview-plus/components/u-app-update/img/act.png +0 -0
  91. package/uview-plus/components/u-app-update/img/appUploadAlertBoxBg.png +0 -0
  92. package/uview-plus/components/u-app-update/img/close.png +0 -0
  93. package/uview-plus/components/u-app-update/js-sdk/checkVersion.js +81 -0
  94. package/uview-plus/components/u-app-update/js-sdk/silentlyAppUpdate.js +41 -0
  95. package/uview-plus/components/u-app-update/pages/index.vue +8 -0
  96. package/uview-plus/components/u-app-update/u-app-update.vue +583 -0
  97. package/uview-plus/components/u-button-wu/_doc/changelog.md +6 -0
  98. package/uview-plus/components/u-button-wu/_doc/package.json +89 -0
  99. package/uview-plus/components/u-button-wu/_doc/readme.md +16 -0
  100. package/uview-plus/components/u-button-wu/u-button-wu.vue +522 -0
  101. package/uview-plus/components/u-button-wu/vue.scss +81 -0
  102. package/uview-plus/components/u-calendar-wu/_doc/changelog.md +145 -0
  103. package/uview-plus/components/u-calendar-wu/_doc/package.json +90 -0
  104. package/uview-plus/components/u-calendar-wu/_doc/readme.md +16 -0
  105. package/uview-plus/components/u-calendar-wu/calendar.js +664 -0
  106. package/uview-plus/components/u-calendar-wu/i18n/en.json +14 -0
  107. package/uview-plus/components/u-calendar-wu/i18n/index.js +8 -0
  108. package/uview-plus/components/u-calendar-wu/i18n/zh-Hans.json +14 -0
  109. package/uview-plus/components/u-calendar-wu/i18n/zh-Hant.json +14 -0
  110. package/uview-plus/components/u-calendar-wu/props.js +166 -0
  111. package/uview-plus/components/u-calendar-wu/style.css +196 -0
  112. package/uview-plus/components/u-calendar-wu/u-calendar-wu.vue +921 -0
  113. package/uview-plus/components/u-calendar-wu/util.js +552 -0
  114. package/uview-plus/components/u-calendar-wu/wu-calendar-block/props.js +73 -0
  115. package/uview-plus/components/u-calendar-wu/wu-calendar-block/wu-calendar-block.vue +122 -0
  116. package/uview-plus/components/u-calendar-wu/wu-calendar-item/props.js +55 -0
  117. package/uview-plus/components/u-calendar-wu/wu-calendar-item/wu-calendar-item.vue +293 -0
  118. package/uview-plus/components/u-cell/_doc/changelog.md +6 -0
  119. package/uview-plus/components/u-cell/_doc/package.json +89 -0
  120. package/uview-plus/components/u-cell/_doc/readme.md +25 -0
  121. package/uview-plus/components/u-checkbox/_doc/changelog.md +8 -0
  122. package/uview-plus/components/u-checkbox/_doc/package.json +88 -0
  123. package/uview-plus/components/u-checkbox/_doc/readme.md +25 -0
  124. package/uview-plus/components/u-code/_doc/changelog.md +6 -0
  125. package/uview-plus/components/u-code/_doc/package.json +86 -0
  126. package/uview-plus/components/u-code/_doc/readme.md +16 -0
  127. package/uview-plus/components/u-drag-sort/_doc/changelog.md +0 -0
  128. package/uview-plus/components/u-drag-sort/_doc/package.json +85 -0
  129. package/uview-plus/components/u-drag-sort/_doc/readme.md +16 -0
  130. package/uview-plus/components/u-drag-sort/u-drag-sort.vue +3 -0
  131. package/uview-plus/components/u-empty/u-empty.vue +27 -1
  132. package/uview-plus/components/u-gap/_doc/changelog.md +4 -0
  133. package/uview-plus/components/u-gap/_doc/package.json +86 -0
  134. package/uview-plus/components/u-gap/_doc/readme.md +22 -0
  135. package/uview-plus/components/u-icon/_doc/changelog.md +10 -0
  136. package/uview-plus/components/u-icon/_doc/package.json +85 -0
  137. package/uview-plus/components/u-icon/_doc/readme.md +10 -0
  138. package/uview-plus/components/u-icon/icon.js +23 -25
  139. package/uview-plus/components/u-icon/icons.js +213 -213
  140. package/uview-plus/components/u-icon/style.css +3 -3
  141. package/uview-plus/components/u-icon/u-icon2.vue +149 -0
  142. package/uview-plus/components/u-image-wu/_doc/changelog.md +21 -0
  143. package/uview-plus/components/u-image-wu/_doc/package.json +88 -0
  144. package/uview-plus/components/u-image-wu/_doc/readme.md +11 -0
  145. package/uview-plus/components/u-image-wu/props.js +94 -0
  146. package/uview-plus/components/u-image-wu/u-image-wu.vue +243 -0
  147. package/uview-plus/components/u-input/_doc/changelog.md +6 -0
  148. package/uview-plus/components/u-input/_doc/package.json +88 -0
  149. package/uview-plus/components/u-input/_doc/readme.md +16 -0
  150. package/uview-plus/components/u-line/_doc/changelog.md +8 -0
  151. package/uview-plus/components/u-line/_doc/package.json +86 -0
  152. package/uview-plus/components/u-line/_doc/readme.md +16 -0
  153. package/uview-plus/components/u-link/_doc/changelog.md +8 -0
  154. package/uview-plus/components/u-link/_doc/package.json +86 -0
  155. package/uview-plus/components/u-link/_doc/readme.md +20 -0
  156. package/uview-plus/components/u-loading-icon/_doc/changelog.md +12 -0
  157. package/uview-plus/components/u-loading-icon/_doc/package.json +86 -0
  158. package/uview-plus/components/u-loading-icon/_doc/readme.md +16 -0
  159. package/uview-plus/components/u-loading-icon/props.js +1 -1
  160. package/uview-plus/components/u-navbar/_doc/changelog.md +6 -0
  161. package/uview-plus/components/u-navbar/_doc/package.json +89 -0
  162. package/uview-plus/components/u-navbar/_doc/readme.md +16 -0
  163. package/uview-plus/components/u-navbar-wu/props.js +102 -0
  164. package/uview-plus/components/u-navbar-wu/u-navbar-wu.vue +196 -0
  165. package/uview-plus/components/u-number-box/_doc/changelog.md +19 -0
  166. package/uview-plus/components/u-number-box/_doc/package.json +88 -0
  167. package/uview-plus/components/u-number-box/_doc/readme.md +16 -0
  168. package/uview-plus/components/u-overlay/_doc/changelog.md +4 -0
  169. package/uview-plus/components/u-overlay/_doc/package.json +88 -0
  170. package/uview-plus/components/u-overlay/_doc/readme.md +16 -0
  171. package/uview-plus/components/u-popup/_doc/changelog.md +4 -0
  172. package/uview-plus/components/u-popup/_doc/package.json +92 -0
  173. package/uview-plus/components/u-popup/_doc/readme.md +16 -0
  174. package/uview-plus/components/u-popup-wu/keypress.js +45 -0
  175. package/uview-plus/components/u-popup-wu/u-popup-wu.vue +519 -0
  176. package/uview-plus/components/u-radio/_doc/changelog.md +6 -0
  177. package/uview-plus/components/u-radio/_doc/package.json +88 -0
  178. package/uview-plus/components/u-radio/_doc/readme.md +25 -0
  179. package/uview-plus/components/u-row/_doc/changelog.md +8 -0
  180. package/uview-plus/components/u-row/_doc/package.json +86 -0
  181. package/uview-plus/components/u-row/_doc/readme.md +16 -0
  182. package/uview-plus/components/u-safe-bottom/_doc/changelog.md +6 -0
  183. package/uview-plus/components/u-safe-bottom/_doc/package.json +86 -0
  184. package/uview-plus/components/u-safe-bottom/_doc/readme.md +16 -0
  185. package/uview-plus/components/u-sku-wu/_doc/changelog.md +27 -0
  186. package/uview-plus/components/u-sku-wu/_doc/package.json +93 -0
  187. package/uview-plus/components/u-sku-wu/_doc/readme.md +16 -0
  188. package/uview-plus/components/u-sku-wu/props.js +86 -0
  189. package/uview-plus/components/u-sku-wu/style.css +271 -0
  190. package/uview-plus/components/u-sku-wu/u-sku-wu.vue +864 -0
  191. package/uview-plus/components/u-status-bar/_doc/changelog.md +4 -0
  192. package/uview-plus/components/u-status-bar/_doc/package.json +86 -0
  193. package/uview-plus/components/u-status-bar/_doc/readme.md +16 -0
  194. package/uview-plus/components/u-text/_doc/changelog.md +10 -0
  195. package/uview-plus/components/u-text/_doc/package.json +89 -0
  196. package/uview-plus/components/u-text/_doc/readme.md +20 -0
  197. package/uview-plus/components/u-textarea/_doc/changelog.md +6 -0
  198. package/uview-plus/components/u-textarea/_doc/package.json +86 -0
  199. package/uview-plus/components/u-textarea/_doc/readme.md +25 -0
  200. package/uview-plus/components/u-transition/_doc/changelog.md +14 -0
  201. package/uview-plus/components/u-transition/_doc/package.json +86 -0
  202. package/uview-plus/components/u-transition/_doc/readme.md +16 -0
  203. package/uview-plus/components/u-transition-wu/createAnimation.js +148 -0
  204. package/uview-plus/components/u-transition-wu/props.js +32 -0
  205. package/uview-plus/components/u-transition-wu/u-transition.vue +300 -0
  206. package/uview-plus/components/u-verification-code/u-verification-code.vue +161 -0
  207. package/uview-plus/index.js +107 -94
  208. package/uview-plus/libs/config/config.js +46 -48
  209. package/uview-plus/libs/css/color.scss +32 -311
  210. package/uview-plus/libs/css/components-wu.scss +30 -0
  211. package/uview-plus/libs/css/vue.scss +10 -10
  212. package/uview-plus/libs/function/calc.js +61 -55
  213. package/uview-plus/libs/function/cc.js +66 -0
  214. package/uview-plus/libs/function/color/color-convert/CHANGELOG.md +54 -0
  215. package/uview-plus/libs/function/color/color-convert/LICENSE +21 -0
  216. package/uview-plus/libs/function/color/color-convert/README.md +68 -0
  217. package/uview-plus/libs/function/color/color-convert/conversions.js +839 -0
  218. package/uview-plus/libs/function/color/color-convert/index.js +81 -0
  219. package/uview-plus/libs/function/color/color-convert/package.json +48 -0
  220. package/uview-plus/libs/function/color/color-convert/route.js +97 -0
  221. package/uview-plus/libs/function/color/color-name/LICENSE +8 -0
  222. package/uview-plus/libs/function/color/color-name/README.md +11 -0
  223. package/uview-plus/libs/function/color/color-name/index.js +152 -0
  224. package/uview-plus/libs/function/color/color-name/package.json +28 -0
  225. package/uview-plus/libs/function/color/color-string/LICENSE +21 -0
  226. package/uview-plus/libs/function/color/color-string/README.md +62 -0
  227. package/uview-plus/libs/function/color/color-string/index.js +244 -0
  228. package/uview-plus/libs/function/color/color-string/package.json +39 -0
  229. package/uview-plus/libs/function/color/color.js +496 -0
  230. package/uview-plus/libs/function/color/index.js +158 -0
  231. package/uview-plus/libs/function/color/is-arrayish/LICENSE +21 -0
  232. package/uview-plus/libs/function/color/is-arrayish/README.md +16 -0
  233. package/uview-plus/libs/function/color/is-arrayish/index.js +9 -0
  234. package/uview-plus/libs/function/color/is-arrayish/package.json +45 -0
  235. package/uview-plus/libs/function/color/is-arrayish/yarn-error.log +1443 -0
  236. package/uview-plus/libs/function/color/simple-swizzle/LICENSE +21 -0
  237. package/uview-plus/libs/function/color/simple-swizzle/README.md +39 -0
  238. package/uview-plus/libs/function/color/simple-swizzle/index.js +29 -0
  239. package/uview-plus/libs/function/color/simple-swizzle/package.json +36 -0
  240. package/uview-plus/libs/function/colorGradient.js +108 -106
  241. package/uview-plus/libs/function/debounce.js +17 -17
  242. package/uview-plus/libs/function/digit.js +1 -3
  243. package/uview-plus/libs/function/http.js +3 -3
  244. package/uview-plus/libs/function/index-wu.js +231 -0
  245. package/uview-plus/libs/function/index.js +579 -566
  246. package/uview-plus/libs/function/platform.js +18 -18
  247. package/uview-plus/libs/function/test.js +135 -137
  248. package/uview-plus/libs/function/throttle.js +17 -17
  249. package/uview-plus/libs/luch-request/core/Request.js +199 -199
  250. package/uview-plus/libs/mixin/mpMixin.js +1 -0
  251. package/uview-plus/libs/mixin/openType.js +33 -0
  252. package/uview-plus/libs/util/async-validator.js +1343 -1343
  253. package/uview-plus/libs/util/dayjs.js +404 -0
  254. package/uview-plus/libs/util/route.js +101 -105
  255. package/uview-plus/package-wu-tool.json +84 -0
  256. package/uview-plus/package-wu.json +112 -0
  257. package/uview-plus/package.json +106 -95
  258. package/uview-plus/readme-wu.md +148 -0
  259. package/uview-ui/index.js +51 -52
  260. package/plugins/uni-upgrade.js +0 -294
@@ -0,0 +1,300 @@
1
+ <template>
2
+ <!-- #ifndef APP-NVUE -->
3
+ <view v-show="isShow" ref="ani" :animation="animationData" :class="customClass" :style="transformStyles" @click="onClick">
4
+ <slot></slot>
5
+ </view>
6
+ <!-- #endif -->
7
+ <!-- #ifdef APP-NVUE -->
8
+ <view v-if="isShow" ref="ani" :animation="animationData" :class="customClass" :style="transformStyles" @click="onClick">
9
+ <slot></slot>
10
+ </view>
11
+ <!-- #endif -->
12
+ </template>
13
+
14
+ <script>
15
+ import { createAnimation } from './createAnimation';
16
+ import { mpMixin } from '../../libs/mixin/mpMixin';
17
+ import { mixin } from '../../libs/mixin/mixin';
18
+ /**
19
+ * transition 过渡动画
20
+ * @description 过渡动画组件
21
+ * @tutorial https://ijry.github.io/uview-plus/components/transition.html
22
+ * @property {Boolean} show = [false|true] 控制组件显示或隐藏
23
+ * @property {Array|String} mode = [fade|slide-top|slide-right|slide-bottom|slide-left|zoom-in|zoom-out] 过渡动画类型
24
+ * @value fade 渐隐渐出过渡
25
+ * @value slide-top 由上至下过渡
26
+ * @value slide-right 由右至左过渡
27
+ * @value slide-bottom 由下至上过渡
28
+ * @value slide-left 由左至右过渡
29
+ * @value zoom-in 由小到大过渡
30
+ * @value zoom-out 由大到小过渡
31
+ * @property {Number} duration 过渡动画持续时间,单位ms(默认300)
32
+ * @property {String} timingFunction 使用的动画过渡函数 (默认 'ease-out' )
33
+ * @property {Object} customStyle 自定义样式
34
+ * @property {String} customClass 自定义类名
35
+ * @event {Function} click 点击组件触发
36
+ * @event {Function} change 过渡动画结束时触发
37
+ */
38
+ export default {
39
+ name: 'u-transition',
40
+ mixins: [mpMixin, mixin],
41
+ emits: ['click', 'change'],
42
+ props: {
43
+ // 是否展示组件
44
+ show: {
45
+ type: Boolean,
46
+ default: false
47
+ },
48
+ // 使用的动画模式
49
+ mode: {
50
+ type: [Array, String, null],
51
+ default() {
52
+ return 'fade';
53
+ }
54
+ },
55
+ // 动画的执行时间,单位ms
56
+ duration: {
57
+ type: [String, Number],
58
+ default: 300
59
+ },
60
+ // 使用的动画过渡函数
61
+ timingFunction: {
62
+ type: String,
63
+ default: 'ease-out'
64
+ },
65
+ customClass: {
66
+ type: String,
67
+ default: ''
68
+ },
69
+ // nvue模式下 是否直接显示,在u-list等cell下面使用就需要设置
70
+ cellChild: {
71
+ type: Boolean,
72
+ default: false
73
+ }
74
+ },
75
+ data() {
76
+ return {
77
+ isShow: false,
78
+ transform: '',
79
+ opacity: 1,
80
+ animationData: {},
81
+ durationTime: 300,
82
+ config: {}
83
+ };
84
+ },
85
+ watch: {
86
+ show: {
87
+ handler(newVal) {
88
+ if (newVal) {
89
+ this.open();
90
+ } else {
91
+ // 避免上来就执行 close,导致动画错乱
92
+ if (this.isShow) {
93
+ this.close();
94
+ }
95
+ }
96
+ },
97
+ immediate: true
98
+ }
99
+ },
100
+ computed: {
101
+ // 生成样式数据
102
+ stylesObject() {
103
+ let styles = {
104
+ ...this.customStyle,
105
+ 'transition-duration': this.duration / 1000 + 's'
106
+ };
107
+ let transform = '';
108
+ for (let i in styles) {
109
+ let line = this.toLine(i);
110
+ transform += line + ':' + styles[i] + ';';
111
+ }
112
+ return transform;
113
+ },
114
+ // 初始化动画条件
115
+ transformStyles() {
116
+ return 'transform:' + this.transform + ';' + 'opacity:' + this.opacity + ';' + this.stylesObject;
117
+ }
118
+ },
119
+ created() {
120
+ // 动画默认配置
121
+ this.config = {
122
+ duration: this.duration,
123
+ timingFunction: 'ease',
124
+ transformOrigin: '50% 50%',
125
+ delay: 0
126
+ };
127
+ this.durationTime = this.duration;
128
+ },
129
+ methods: {
130
+ /**
131
+ * ref 触发 初始化动画
132
+ */
133
+ init(obj = {}) {
134
+ if (obj.duration) {
135
+ this.durationTime = obj.duration;
136
+ }
137
+ this.animation = createAnimation(Object.assign(this.config, obj), this);
138
+ },
139
+ /**
140
+ * 点击组件触发回调
141
+ */
142
+ onClick() {
143
+ this.$emit('click', {
144
+ detail: this.isShow
145
+ });
146
+ },
147
+ /**
148
+ * ref 触发 动画分组
149
+ * @param {Object} obj
150
+ */
151
+ step(obj, config = {}) {
152
+ if (!this.animation) return;
153
+ for (let i in obj) {
154
+ try {
155
+ if (typeof obj[i] === 'object') {
156
+ this.animation[i](...obj[i]);
157
+ } else {
158
+ this.animation[i](obj[i]);
159
+ }
160
+ } catch (e) {
161
+ console.error(`方法 ${i} 不存在`);
162
+ }
163
+ }
164
+ this.animation.step(config);
165
+ return this;
166
+ },
167
+ /**
168
+ * ref 触发 执行动画
169
+ */
170
+ run(fn) {
171
+ if (!this.animation) return;
172
+ this.animation.run(fn);
173
+ },
174
+ // 开始过度动画
175
+ open() {
176
+ clearTimeout(this.timer);
177
+ this.transform = '';
178
+ this.isShow = true;
179
+ let { opacity, transform } = this.styleInit(false);
180
+ if (typeof opacity !== 'undefined') {
181
+ this.opacity = opacity;
182
+ }
183
+ this.transform = transform;
184
+ // 确保动态样式已经生效后,执行动画,如果不加 nextTick ,会导致 wx 动画执行异常
185
+ this.$nextTick(() => {
186
+ // TODO 定时器保证动画完全执行,目前有些问题,后面会取消定时器
187
+ this.timer = setTimeout(() => {
188
+ this.animation = createAnimation(this.config, this);
189
+ this.tranfromInit(false).step();
190
+ this.animation.run();
191
+ this.$emit('change', {
192
+ detail: this.isShow
193
+ });
194
+ }, 20);
195
+ });
196
+ },
197
+ // 关闭过度动画
198
+ close(type) {
199
+ if (!this.animation) return;
200
+ this.tranfromInit(true)
201
+ .step()
202
+ .run(() => {
203
+ this.isShow = false;
204
+ this.animationData = null;
205
+ this.animation = null;
206
+ let { opacity, transform } = this.styleInit(false);
207
+ this.opacity = opacity || 1;
208
+ this.transform = transform;
209
+ this.$emit('change', {
210
+ detail: this.isShow
211
+ });
212
+ });
213
+ },
214
+ // 处理动画开始前的默认样式
215
+ styleInit(type) {
216
+ let styles = {
217
+ transform: ''
218
+ };
219
+ let buildStyle = (type, mode) => {
220
+ if (mode === 'fade') {
221
+ styles.opacity = this.animationType(type)[mode];
222
+ } else {
223
+ styles.transform += this.animationType(type)[mode] + ' ';
224
+ }
225
+ };
226
+ if (typeof this.mode === 'string') {
227
+ buildStyle(type, this.mode);
228
+ } else {
229
+ this.mode.forEach((mode) => {
230
+ buildStyle(type, mode);
231
+ });
232
+ }
233
+ return styles;
234
+ },
235
+ // 处理内置组合动画
236
+ tranfromInit(type) {
237
+ let buildTranfrom = (type, mode) => {
238
+ let aniNum = null;
239
+ if (mode === 'fade') {
240
+ aniNum = type ? 0 : 1;
241
+ } else {
242
+ aniNum = type ? '-100%' : '0';
243
+ if (mode === 'zoom-in') {
244
+ aniNum = type ? 0.8 : 1;
245
+ }
246
+ if (mode === 'zoom-out') {
247
+ aniNum = type ? 1.2 : 1;
248
+ }
249
+ if (mode === 'slide-right') {
250
+ aniNum = type ? '100%' : '0';
251
+ }
252
+ if (mode === 'slide-bottom') {
253
+ aniNum = type ? '100%' : '0';
254
+ }
255
+ }
256
+
257
+ this.animation[this.animationMode()[mode]](aniNum);
258
+ };
259
+ if (typeof this.mode === 'string') {
260
+ buildTranfrom(type, this.mode);
261
+ } else {
262
+ this.mode.forEach((mode) => {
263
+ buildTranfrom(type, mode);
264
+ });
265
+ }
266
+
267
+ return this.animation;
268
+ },
269
+ animationType(type) {
270
+ return {
271
+ fade: type ? 1 : 0,
272
+ 'slide-top': `translateY(${type ? '0' : '-100%'})`,
273
+ 'slide-right': `translateX(${type ? '0' : '100%'})`,
274
+ 'slide-bottom': `translateY(${type ? '0' : '100%'})`,
275
+ 'slide-left': `translateX(${type ? '0' : '-100%'})`,
276
+ 'zoom-in': `scaleX(${type ? 1 : 0.8}) scaleY(${type ? 1 : 0.8})`,
277
+ 'zoom-out': `scaleX(${type ? 1 : 1.2}) scaleY(${type ? 1 : 1.2})`
278
+ };
279
+ },
280
+ // 内置动画类型与实际动画对应字典
281
+ animationMode() {
282
+ return {
283
+ fade: 'opacity',
284
+ 'slide-top': 'translateY',
285
+ 'slide-right': 'translateX',
286
+ 'slide-bottom': 'translateY',
287
+ 'slide-left': 'translateX',
288
+ 'zoom-in': 'scale',
289
+ 'zoom-out': 'scale'
290
+ };
291
+ },
292
+ // 驼峰转中横线
293
+ toLine(name) {
294
+ return name.replace(/([A-Z])/g, '-$1').toLowerCase();
295
+ }
296
+ }
297
+ };
298
+ </script>
299
+
300
+ <style></style>
@@ -0,0 +1,161 @@
1
+ <template>
2
+ <view class="u-code-wrap">
3
+ <!-- 此组件功能由js完成,无需写html逻辑 -->
4
+ </view>
5
+ </template>
6
+
7
+ <script>
8
+ /**
9
+ * verificationCode 验证码输入框
10
+ * @description 考虑到用户实际发送验证码的场景,可能是一个按钮,也可能是一段文字,提示语各有不同,所以本组件 不提供界面显示,只提供提示语,由用户将提示语嵌入到具体的场景
11
+ * @tutorial https://www.uviewui.com/components/verificationCode.html
12
+ * @property {Number String} seconds 倒计时所需的秒数(默认60)
13
+ * @property {String} start-text 开始前的提示语,见官网说明(默认获取验证码)
14
+ * @property {String} change-text 倒计时期间的提示语,必须带有字母"x",见官网说明(默认X秒重新获取)
15
+ * @property {String} end-text 倒计结束的提示语,见官网说明(默认重新获取)
16
+ * @property {Boolean} keep-running 是否在H5刷新或各端返回再进入时继续倒计时(默认false)
17
+ * @event {Function} change 倒计时期间,每秒触发一次
18
+ * @event {Function} start 开始倒计时触发
19
+ * @event {Function} end 结束倒计时触发
20
+ * @example <up-verification-code :seconds="seconds" @end="end" @start="start" ref="uCode"
21
+ */
22
+ export default {
23
+ name: 'up-verification-code',
24
+ props: {
25
+ // 倒计时总秒数
26
+ seconds: {
27
+ type: [String, Number],
28
+ default: 60
29
+ },
30
+ // 尚未开始时提示
31
+ startText: {
32
+ type: String,
33
+ default: '获取验证码'
34
+ },
35
+ // 正在倒计时中的提示
36
+ changeText: {
37
+ type: String,
38
+ default: 'X秒重新获取'
39
+ },
40
+ // 倒计时结束时的提示
41
+ endText: {
42
+ type: String,
43
+ default: '重新获取'
44
+ },
45
+ // 是否在H5刷新或各端返回再进入时继续倒计时
46
+ keepRunning: {
47
+ type: Boolean,
48
+ default: false
49
+ },
50
+ // 为了区分多个页面,或者一个页面多个倒计时组件本地存储的继续倒计时变了
51
+ uniqueKey: {
52
+ type: String,
53
+ default: ''
54
+ }
55
+ },
56
+ data() {
57
+ return {
58
+ secNum: this.seconds,
59
+ timer: null,
60
+ canGetCode: true // 是否可以执行验证码操作
61
+ };
62
+ },
63
+ mounted() {
64
+ this.checkKeepRunning();
65
+ },
66
+ watch: {
67
+ seconds: {
68
+ immediate: true,
69
+ handler(n) {
70
+ this.secNum = n;
71
+ }
72
+ }
73
+ },
74
+ methods: {
75
+ checkKeepRunning() {
76
+ // 获取上一次退出页面(H5还包括刷新)时的时间戳,如果没有上次的保存,此值可能为空
77
+ let lastTimestamp = Number(uni.getStorageSync(this.uniqueKey + '_$uCountDownTimestamp'));
78
+ if (!lastTimestamp) return this.changeEvent(this.startText);
79
+ // 当前秒的时间戳
80
+ let nowTimestamp = Math.floor(+new Date() / 1000);
81
+ // 判断当前的时间戳,是否小于上一次的本该按设定结束,却提前结束的时间戳
82
+ if (this.keepRunning && lastTimestamp && lastTimestamp > nowTimestamp) {
83
+ // 剩余尚未执行完的倒计秒数
84
+ this.secNum = lastTimestamp - nowTimestamp;
85
+ // 清除本地保存的变量
86
+ uni.removeStorageSync(this.uniqueKey + '_$uCountDownTimestamp');
87
+ // 开始倒计时
88
+ this.start();
89
+ } else {
90
+ // 如果不存在需要继续上一次的倒计时,执行正常的逻辑
91
+ this.changeEvent(this.startText);
92
+ }
93
+ },
94
+ // 开始倒计时
95
+ start() {
96
+ // 防止快速点击获取验证码的按钮而导致内部产生多个定时器导致混乱
97
+ if (this.timer) {
98
+ clearInterval(this.timer);
99
+ this.timer = null;
100
+ }
101
+ this.$emit('start');
102
+ this.canGetCode = false;
103
+ // 这里放这句,是为了一开始时就提示,否则要等setInterval的1秒后才会有提示
104
+ this.changeEvent(this.changeText.replace(/x|X/, this.secNum));
105
+ this.setTimeToStorage();
106
+ this.timer = setInterval(() => {
107
+ if (--this.secNum) {
108
+ // 用当前倒计时的秒数替换提示字符串中的"x"字母
109
+ this.changeEvent(this.changeText.replace(/x|X/, this.secNum));
110
+ } else {
111
+ clearInterval(this.timer);
112
+ this.timer = null;
113
+ this.changeEvent(this.endText);
114
+ this.secNum = this.seconds;
115
+ this.$emit('end');
116
+ this.canGetCode = true;
117
+ }
118
+ }, 1000);
119
+ },
120
+ // 重置,可以让用户再次获取验证码
121
+ reset() {
122
+ this.canGetCode = true;
123
+ clearInterval(this.timer);
124
+ this.secNum = this.seconds;
125
+ this.changeEvent(this.endText);
126
+ },
127
+ changeEvent(text) {
128
+ this.$emit('change', text);
129
+ },
130
+ // 保存时间戳,为了防止倒计时尚未结束,H5刷新或者各端的右上角返回上一页再进来
131
+ setTimeToStorage() {
132
+ if (!this.keepRunning || !this.timer) return;
133
+ // 记录当前的时间戳,为了下次进入页面,如果还在倒计时内的话,继续倒计时
134
+ // 倒计时尚未结束,结果大于0;倒计时已经开始,就会小于初始值,如果等于初始值,说明没有开始倒计时,无需处理
135
+ if (this.secNum > 0 && this.secNum <= this.seconds) {
136
+ // 获取当前时间戳(+ new Date()为特殊写法),除以1000变成秒,再去除小数部分
137
+ let nowTimestamp = Math.floor(+new Date() / 1000);
138
+ // 将本该结束时候的时间戳保存起来 => 当前时间戳 + 剩余的秒数
139
+ uni.setStorage({
140
+ key: this.uniqueKey + '_$uCountDownTimestamp',
141
+ data: nowTimestamp + Number(this.secNum)
142
+ });
143
+ }
144
+ }
145
+ },
146
+ // 组件销毁的时候,清除定时器,否则定时器会继续存在,系统不会自动清除
147
+ beforeDestroy() {
148
+ this.setTimeToStorage();
149
+ clearTimeout(this.timer);
150
+ this.timer = null;
151
+ }
152
+ };
153
+ </script>
154
+ <style scoped>
155
+ .u-code-wrap {
156
+ width: 0;
157
+ height: 0;
158
+ position: fixed;
159
+ z-index: -1;
160
+ }
161
+ </style>