@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
@@ -1,35 +1,31 @@
1
- import {
2
- number as testNumber,
3
- array as testArray,
4
- empty as testEmpty
5
- } from './test'
6
- import { round } from './digit.js'
1
+ import { number as testNumber, array as testArray, empty as testEmpty } from './test';
2
+ import { round } from './digit.js';
7
3
  import config from '../config/config';
8
4
  /**
9
5
  * @description 如果value小于min,取min;如果value大于max,取max
10
- * @param {number} min
11
- * @param {number} max
6
+ * @param {number} min
7
+ * @param {number} max
12
8
  * @param {number} value
13
9
  */
14
10
  export function range(min = 0, max = 0, value = 0) {
15
- return Math.max(min, Math.min(max, Number(value)))
11
+ return Math.max(min, Math.min(max, Number(value)));
16
12
  }
17
13
 
18
14
  /**
19
15
  * @description 用于获取用户传递值的px值 如果用户传递了"xxpx"或者"xxrpx",取出其数值部分,如果是"xxxrpx"还需要用过uni.rpx2px进行转换
20
16
  * @param {number|string} value 用户传递值的px值
21
- * @param {boolean} unit
17
+ * @param {boolean} unit
22
18
  * @returns {number|string}
23
19
  */
24
20
  export function getPx(value, unit = false) {
25
- if (testNumber(value)) {
26
- return unit ? `${value}px` : Number(value)
27
- }
28
- // 如果带有rpx,先取出其数值部分,再转为px值
29
- if (/(rpx|upx)$/.test(value)) {
30
- return unit ? `${uni.upx2px(parseInt(value))}px` : Number(uni.upx2px(parseInt(value)))
31
- }
32
- return unit ? `${parseInt(value)}px` : parseInt(value)
21
+ if (testNumber(value)) {
22
+ return unit ? `${value}px` : Number(value);
23
+ }
24
+ // 如果带有rpx,先取出其数值部分,再转为px值
25
+ if (/(rpx|upx)$/.test(value)) {
26
+ return unit ? `${uni.upx2px(parseInt(value))}px` : Number(uni.upx2px(parseInt(value)));
27
+ }
28
+ return unit ? `${parseInt(value)}px` : parseInt(value);
33
29
  }
34
30
 
35
31
  /**
@@ -38,51 +34,51 @@ export function getPx(value, unit = false) {
38
34
  * @returns {Promise} 返回promise
39
35
  */
40
36
  export function sleep(value = 30) {
41
- return new Promise((resolve) => {
42
- setTimeout(() => {
43
- resolve()
44
- }, value)
45
- })
37
+ return new Promise((resolve) => {
38
+ setTimeout(() => {
39
+ resolve();
40
+ }, value);
41
+ });
46
42
  }
47
43
  /**
48
44
  * @description 运行期判断平台
49
- * @returns {string} 返回所在平台(小写)
45
+ * @returns {string} 返回所在平台(小写)
50
46
  * @link 运行期判断平台 https://uniapp.dcloud.io/frame?id=判断平台
51
47
  */
52
48
  export function os() {
53
- // #ifdef APP || H5 || MP-WEIXIN
54
- return uni.getDeviceInfo().platform.toLowerCase()
55
- // #endif
56
- // #ifndef APP || H5 || MP-WEIXIN
57
- return uni.getSystemInfoSync().platform.toLowerCase()
58
- // #endif
49
+ // #ifdef APP || H5 || MP-WEIXIN
50
+ return uni.getDeviceInfo().platform.toLowerCase();
51
+ // #endif
52
+ // #ifndef APP || H5 || MP-WEIXIN
53
+ return uni.getSystemInfoSync().platform.toLowerCase();
54
+ // #endif
59
55
  }
60
56
  /**
61
57
  * @description 获取系统信息同步接口
62
- * @link 获取系统信息同步接口 https://uniapp.dcloud.io/api/system/info?id=getsysteminfosync
58
+ * @link 获取系统信息同步接口 https://uniapp.dcloud.io/api/system/info?id=getsysteminfosync
63
59
  */
64
60
  export function sys() {
65
- return uni.getSystemInfoSync()
61
+ return uni.getSystemInfoSync();
66
62
  }
67
63
  export function getWindowInfo() {
68
- let ret = {}
69
- // #ifdef APP || H5 || MP-WEIXIN
70
- ret = uni.getWindowInfo()
71
- // #endif
72
- // #ifndef APP || H5 || MP-WEIXIN
73
- ret = sys()
74
- // #endif
75
- return ret
64
+ let ret = {};
65
+ // #ifdef APP || H5 || MP-WEIXIN
66
+ ret = uni.getWindowInfo();
67
+ // #endif
68
+ // #ifndef APP || H5 || MP-WEIXIN
69
+ ret = sys();
70
+ // #endif
71
+ return ret;
76
72
  }
77
73
  export function getDeviceInfo() {
78
- let ret = {}
79
- // #ifdef APP || H5 || MP-WEIXIN
80
- ret = uni.getDeviceInfo()
81
- // #endif
82
- // #ifndef APP || H5 || MP-WEIXIN
83
- ret = sys()
84
- // #endif
85
- return ret
74
+ let ret = {};
75
+ // #ifdef APP || H5 || MP-WEIXIN
76
+ ret = uni.getDeviceInfo();
77
+ // #endif
78
+ // #ifndef APP || H5 || MP-WEIXIN
79
+ ret = sys();
80
+ // #endif
81
+ return ret;
86
82
  }
87
83
 
88
84
  /**
@@ -91,11 +87,11 @@ export function getDeviceInfo() {
91
87
  * @param {Number} max 最大值
92
88
  */
93
89
  export function random(min, max) {
94
- if (min >= 0 && max > 0 && max >= min) {
95
- const gab = max - min + 1
96
- return Math.floor(Math.random() * gab + min)
97
- }
98
- return 0
90
+ if (min >= 0 && max > 0 && max >= min) {
91
+ const gab = max - min + 1;
92
+ return Math.floor(Math.random() * gab + min);
93
+ }
94
+ return 0;
99
95
  }
100
96
 
101
97
  /**
@@ -104,32 +100,32 @@ export function random(min, max) {
104
100
  * @param {Nubmer} radix 生成uuid的基数(意味着返回的字符串都是这个基数),2-二进制,8-八进制,10-十进制,16-十六进制
105
101
  */
106
102
  export function guid(len = 32, firstU = true, radix = null) {
107
- const chars = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'.split('')
108
- const uuid = []
109
- radix = radix || chars.length
110
-
111
- if (len) {
112
- // 如果指定uuid长度,只是取随机的字符,0|x为位运算,能去掉x的小数位,返回整数位
113
- for (let i = 0; i < len; i++) uuid[i] = chars[0 | Math.random() * radix]
114
- } else {
115
- let r
116
- // rfc4122标准要求返回的uuid中,某些位为固定的字符
117
- uuid[8] = uuid[13] = uuid[18] = uuid[23] = '-'
118
- uuid[14] = '4'
119
-
120
- for (let i = 0; i < 36; i++) {
121
- if (!uuid[i]) {
122
- r = 0 | Math.random() * 16
123
- uuid[i] = chars[(i == 19) ? (r & 0x3) | 0x8 : r]
124
- }
125
- }
126
- }
127
- // 移除第一个字符,并用u替代,因为第一个字符为数值时,该guuid不能用作id或者class
128
- if (firstU) {
129
- uuid.shift()
130
- return `u${uuid.join('')}`
131
- }
132
- return uuid.join('')
103
+ const chars = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'.split('');
104
+ const uuid = [];
105
+ radix = radix || chars.length;
106
+
107
+ if (len) {
108
+ // 如果指定uuid长度,只是取随机的字符,0|x为位运算,能去掉x的小数位,返回整数位
109
+ for (let i = 0; i < len; i++) uuid[i] = chars[0 | (Math.random() * radix)];
110
+ } else {
111
+ let r;
112
+ // rfc4122标准要求返回的uuid中,某些位为固定的字符
113
+ uuid[8] = uuid[13] = uuid[18] = uuid[23] = '-';
114
+ uuid[14] = '4';
115
+
116
+ for (let i = 0; i < 36; i++) {
117
+ if (!uuid[i]) {
118
+ r = 0 | (Math.random() * 16);
119
+ uuid[i] = chars[i == 19 ? (r & 0x3) | 0x8 : r];
120
+ }
121
+ }
122
+ }
123
+ // 移除第一个字符,并用u替代,因为第一个字符为数值时,该guuid不能用作id或者class
124
+ if (firstU) {
125
+ uuid.shift();
126
+ return `u${uuid.join('')}`;
127
+ }
128
+ return uuid.join('');
133
129
  }
134
130
 
135
131
  /**
@@ -140,19 +136,19 @@ export function guid(len = 32, firstU = true, radix = null) {
140
136
  * @param {string|undefined} name 父组件的参数名
141
137
  */
142
138
  export function $parent(name = undefined) {
143
- let parent = this.$parent
144
- // 通过while历遍,这里主要是为了H5需要多层解析的问题
145
- while (parent) {
146
- // 父组件
147
- name = name.replace(/up-([a-zA-Z0-9-_]+)/g, 'u-$1')
148
- if (parent.$options && parent.$options.name !== name) {
149
- // 如果组件的name不相等,继续上一级寻找
150
- parent = parent.$parent
151
- } else {
152
- return parent
153
- }
154
- }
155
- return false
139
+ let parent = this.$parent;
140
+ // 通过while历遍,这里主要是为了H5需要多层解析的问题
141
+ while (parent) {
142
+ // 父组件
143
+ name = name.replace(/up-([a-zA-Z0-9-_]+)/g, 'u-$1');
144
+ if (parent.$options && parent.$options.name !== name) {
145
+ // 如果组件的name不相等,继续上一级寻找
146
+ parent = parent.$parent;
147
+ } else {
148
+ return parent;
149
+ }
150
+ }
151
+ return false;
156
152
  }
157
153
 
158
154
  /**
@@ -163,39 +159,42 @@ export function $parent(name = undefined) {
163
159
  * @returns {object|string}
164
160
  */
165
161
  export function addStyle(customStyle, target = 'object') {
166
- // 字符串转字符串,对象转对象情形,直接返回
167
- if (testEmpty(customStyle) || typeof(customStyle) === 'object' && target === 'object' || target === 'string' &&
168
- typeof(customStyle) === 'string') {
169
- return customStyle
170
- }
171
- // 字符串转对象
172
- if (target === 'object') {
173
- // 去除字符串样式中的两端空格(中间的空格不能去掉,比如padding: 20px 0如果去掉了就错了),空格是无用的
174
- customStyle = trim(customStyle)
175
- // 根据";"将字符串转为数组形式
176
- const styleArray = customStyle.split(';')
177
- const style = {}
178
- // 历遍数组,拼接成对象
179
- for (let i = 0; i < styleArray.length; i++) {
180
- // 'font-size:20px;color:red;',如此最后字符串有";"的话,会导致styleArray最后一个元素为空字符串,这里需要过滤
181
- if (styleArray[i]) {
182
- const item = styleArray[i].split(':')
183
- style[trim(item[0])] = trim(item[1])
184
- }
185
- }
186
- return style
187
- }
188
- // 这里为对象转字符串形式
189
- let string = ''
190
- if (typeof customStyle === 'object') {
191
- customStyle.forEach((val, i) => {
192
- // 驼峰转为中划线的形式,否则css内联样式,无法识别驼峰样式属性名
193
- const key = i.replace(/([A-Z])/g, '-$1').toLowerCase()
194
- string += `${key}:${val};`
195
- })
196
- }
197
- // 去除两端空格
198
- return trim(string)
162
+ // 字符串转字符串,对象转对象情形,直接返回
163
+ if (
164
+ testEmpty(customStyle) ||
165
+ (typeof customStyle === 'object' && target === 'object') ||
166
+ (target === 'string' && typeof customStyle === 'string')
167
+ ) {
168
+ return customStyle;
169
+ }
170
+ // 字符串转对象
171
+ if (target === 'object') {
172
+ // 去除字符串样式中的两端空格(中间的空格不能去掉,比如padding: 20px 0如果去掉了就错了),空格是无用的
173
+ customStyle = trim(customStyle);
174
+ // 根据";"将字符串转为数组形式
175
+ const styleArray = customStyle.split(';');
176
+ const style = {};
177
+ // 历遍数组,拼接成对象
178
+ for (let i = 0; i < styleArray.length; i++) {
179
+ // 'font-size:20px;color:red;',如此最后字符串有";"的话,会导致styleArray最后一个元素为空字符串,这里需要过滤
180
+ if (styleArray[i]) {
181
+ const item = styleArray[i].split(':');
182
+ style[trim(item[0])] = trim(item[1]);
183
+ }
184
+ }
185
+ return style;
186
+ }
187
+ // 这里为对象转字符串形式
188
+ let string = '';
189
+ if (typeof customStyle === 'object') {
190
+ customStyle.forEach((val, i) => {
191
+ // 驼峰转为中划线的形式,否则css内联样式,无法识别驼峰样式属性名
192
+ const key = i.replace(/([A-Z])/g, '-$1').toLowerCase();
193
+ string += `${key}:${val};`;
194
+ });
195
+ }
196
+ // 去除两端空格
197
+ return trim(string);
199
198
  }
200
199
 
201
200
  /**
@@ -204,15 +203,15 @@ export function addStyle(customStyle, target = 'object') {
204
203
  * @param {string} unit 添加的单位名 比如px
205
204
  */
206
205
  export function addUnit(value = 'auto', unit = '') {
207
- if (!unit) {
208
- unit = config.unit || 'px'
209
- }
210
- if (unit == 'rpx' && testNumber(String(value))) {
211
- value = value * 2
212
- }
213
- value = String(value)
214
- // 用内置验证规则中的number判断是否为数值
215
- return testNumber(value) ? `${value}${unit}` : value
206
+ if (!unit) {
207
+ unit = config.unit || 'px';
208
+ }
209
+ if (unit == 'rpx' && testNumber(String(value))) {
210
+ value = value * 2;
211
+ }
212
+ value = String(value);
213
+ // 用内置验证规则中的number判断是否为数值
214
+ return testNumber(value) ? `${value}${unit}` : value;
216
215
  }
217
216
 
218
217
  /**
@@ -221,19 +220,19 @@ export function addUnit(value = 'auto', unit = '') {
221
220
  * @returns {*} 克隆后的对象或者原值(不是对象)
222
221
  */
223
222
  export function deepClone(obj) {
224
- // 对常见的“非”值,直接返回原来值
225
- if ([null, undefined, NaN, false].includes(obj)) return obj
226
- if (typeof obj !== 'object' && typeof obj !== 'function') {
227
- // 原始类型直接返回
228
- return obj
229
- }
230
- const o = testArray(obj) ? [] : {}
231
- for (const i in obj) {
232
- if (obj.hasOwnProperty(i)) {
233
- o[i] = typeof obj[i] === 'object' ? deepClone(obj[i]) : obj[i]
234
- }
235
- }
236
- return o
223
+ // 对常见的“非”值,直接返回原来值
224
+ if ([null, undefined, NaN, false].includes(obj)) return obj;
225
+ if (typeof obj !== 'object' && typeof obj !== 'function') {
226
+ // 原始类型直接返回
227
+ return obj;
228
+ }
229
+ const o = testArray(obj) ? [] : {};
230
+ for (const i in obj) {
231
+ if (obj.hasOwnProperty(i)) {
232
+ o[i] = typeof obj[i] === 'object' ? deepClone(obj[i]) : obj[i];
233
+ }
234
+ }
235
+ return o;
237
236
  }
238
237
 
239
238
  /**
@@ -243,27 +242,27 @@ export function deepClone(obj) {
243
242
  * @returns {object|boolean} 深度合并后的对象或者false(入参有不是对象)
244
243
  */
245
244
  export function deepMerge(targetOrigin = {}, source = {}) {
246
- let target = deepClone(targetOrigin)
247
- if (typeof target !== 'object' || typeof source !== 'object') return false
248
- for (const prop in source) {
249
- if (!source.hasOwnProperty(prop)) continue
250
- if (prop in target) {
251
- if (source[prop] == null) {
252
- target[prop] = source[prop]
253
- }else if (typeof target[prop] !== 'object') {
254
- target[prop] = source[prop]
255
- } else if (typeof source[prop] !== 'object') {
256
- target[prop] = source[prop]
257
- } else if (target[prop].concat && source[prop].concat) {
258
- target[prop] = target[prop].concat(source[prop])
259
- } else {
260
- target[prop] = deepMerge(target[prop], source[prop])
261
- }
262
- } else {
263
- target[prop] = source[prop]
264
- }
265
- }
266
- return target
245
+ let target = deepClone(targetOrigin);
246
+ if (typeof target !== 'object' || typeof source !== 'object') return false;
247
+ for (const prop in source) {
248
+ if (!source.hasOwnProperty(prop)) continue;
249
+ if (prop in target) {
250
+ if (source[prop] == null) {
251
+ target[prop] = source[prop];
252
+ } else if (typeof target[prop] !== 'object') {
253
+ target[prop] = source[prop];
254
+ } else if (typeof source[prop] !== 'object') {
255
+ target[prop] = source[prop];
256
+ } else if (target[prop].concat && source[prop].concat) {
257
+ target[prop] = target[prop].concat(source[prop]);
258
+ } else {
259
+ target[prop] = deepMerge(target[prop], source[prop]);
260
+ }
261
+ } else {
262
+ target[prop] = source[prop];
263
+ }
264
+ }
265
+ return target;
267
266
  }
268
267
  /**
269
268
  * @description JS对象深度合并
@@ -272,26 +271,26 @@ export function deepMerge(targetOrigin = {}, source = {}) {
272
271
  * @returns {object|boolean} 深度合并后的对象或者false(入参有不是对象)
273
272
  */
274
273
  export function shallowMerge(target, source = {}) {
275
- if (typeof target !== 'object' || typeof source !== 'object') return false
276
- for (const prop in source) {
277
- if (!source.hasOwnProperty(prop)) continue
278
- if (prop in target) {
279
- if (source[prop] == null) {
280
- target[prop] = source[prop]
281
- }else if (typeof target[prop] !== 'object') {
282
- target[prop] = source[prop]
283
- } else if (typeof source[prop] !== 'object') {
284
- target[prop] = source[prop]
285
- } else if (target[prop].concat && source[prop].concat) {
286
- target[prop] = target[prop].concat(source[prop])
287
- } else {
288
- target[prop] = shallowMerge(target[prop], source[prop])
289
- }
290
- } else {
291
- target[prop] = source[prop]
292
- }
293
- }
294
- return target
274
+ if (typeof target !== 'object' || typeof source !== 'object') return false;
275
+ for (const prop in source) {
276
+ if (!source.hasOwnProperty(prop)) continue;
277
+ if (prop in target) {
278
+ if (source[prop] == null) {
279
+ target[prop] = source[prop];
280
+ } else if (typeof target[prop] !== 'object') {
281
+ target[prop] = source[prop];
282
+ } else if (typeof source[prop] !== 'object') {
283
+ target[prop] = source[prop];
284
+ } else if (target[prop].concat && source[prop].concat) {
285
+ target[prop] = target[prop].concat(source[prop]);
286
+ } else {
287
+ target[prop] = shallowMerge(target[prop], source[prop]);
288
+ }
289
+ } else {
290
+ target[prop] = source[prop];
291
+ }
292
+ }
293
+ return target;
295
294
  }
296
295
 
297
296
  /**
@@ -299,10 +298,10 @@ export function shallowMerge(target, source = {}) {
299
298
  * @param {*} err 错误内容
300
299
  */
301
300
  export function error(err) {
302
- // 开发环境才提示,生产环境不会提示
303
- if (process.env.NODE_ENV === 'development') {
304
- console.error(`uView提示:${err}`)
305
- }
301
+ // 开发环境才提示,生产环境不会提示
302
+ if (process.env.NODE_ENV === 'development') {
303
+ console.error(`uView提示:${err}`);
304
+ }
306
305
  }
307
306
 
308
307
  /**
@@ -311,34 +310,32 @@ export function error(err) {
311
310
  * @returns {array} 打乱后的数组
312
311
  */
313
312
  export function randomArray(array = []) {
314
- // 原理是sort排序,Math.random()产生0<= x < 1之间的数,会导致x-0.05大于或者小于0
315
- return array.sort(() => Math.random() - 0.5)
313
+ // 原理是sort排序,Math.random()产生0<= x < 1之间的数,会导致x-0.05大于或者小于0
314
+ return array.sort(() => Math.random() - 0.5);
316
315
  }
317
316
 
318
317
  // padStart 的 polyfill,因为某些机型或情况,还无法支持es7的padStart,比如电脑版的微信小程序
319
318
  // 所以这里做一个兼容polyfill的兼容处理
320
319
  if (!String.prototype.padStart) {
321
- // 为了方便表示这里 fillString 用了ES6 的默认参数,不影响理解
322
- String.prototype.padStart = function(maxLength, fillString = ' ') {
323
- if (Object.prototype.toString.call(fillString) !== '[object String]') {
324
- throw new TypeError(
325
- 'fillString must be String'
326
- )
327
- }
328
- const str = this
329
- // 返回 String(str) 这里是为了使返回的值是字符串字面量,在控制台中更符合直觉
330
- if (str.length >= maxLength) return String(str)
331
-
332
- const fillLength = maxLength - str.length
333
- let times = Math.ceil(fillLength / fillString.length)
334
- while (times >>= 1) {
335
- fillString += fillString
336
- if (times === 1) {
337
- fillString += fillString
338
- }
339
- }
340
- return fillString.slice(0, fillLength) + str
341
- }
320
+ // 为了方便表示这里 fillString 用了ES6 的默认参数,不影响理解
321
+ String.prototype.padStart = function (maxLength, fillString = ' ') {
322
+ if (Object.prototype.toString.call(fillString) !== '[object String]') {
323
+ throw new TypeError('fillString must be String');
324
+ }
325
+ const str = this;
326
+ // 返回 String(str) 这里是为了使返回的值是字符串字面量,在控制台中更符合直觉
327
+ if (str.length >= maxLength) return String(str);
328
+
329
+ const fillLength = maxLength - str.length;
330
+ let times = Math.ceil(fillLength / fillString.length);
331
+ while ((times >>= 1)) {
332
+ fillString += fillString;
333
+ if (times === 1) {
334
+ fillString += fillString;
335
+ }
336
+ }
337
+ return fillString.slice(0, fillLength) + str;
338
+ };
342
339
  }
343
340
 
344
341
  /**
@@ -348,94 +345,90 @@ if (!String.prototype.padStart) {
348
345
  * @returns {string} 返回格式化后的字符串
349
346
  */
350
347
  export function timeFormat(dateTime = null, formatStr = 'yyyy-mm-dd') {
351
- let date
352
- // 若传入时间为假值,则取当前时间
348
+ let date;
349
+ // 若传入时间为假值,则取当前时间
353
350
  if (!dateTime) {
354
- date = new Date()
351
+ date = new Date();
355
352
  }
356
353
  // 若为unix秒时间戳,则转为毫秒时间戳(逻辑有点奇怪,但不敢改,以保证历史兼容)
357
354
  else if (/^\d{10}$/.test(dateTime.toString().trim())) {
358
- date = new Date(dateTime * 1000)
355
+ date = new Date(dateTime * 1000);
359
356
  }
360
357
  // 若用户传入字符串格式时间戳,new Date无法解析,需做兼容
361
358
  else if (typeof dateTime === 'string' && /^\d+$/.test(dateTime.trim())) {
362
- date = new Date(Number(dateTime))
359
+ date = new Date(Number(dateTime));
363
360
  }
364
361
  // 其他都认为符合 RFC 2822 规范
365
362
  else {
366
363
  // 处理平台性差异,在Safari/Webkit中,new Date仅支持/作为分割符的字符串时间
367
- date = new Date(
368
- typeof dateTime === 'string'
369
- ? dateTime.replace(/-/g, '/')
370
- : dateTime
371
- )
372
- }
373
-
374
- const timeSource = {
375
- 'y': date.getFullYear().toString(), //
376
- 'm': (date.getMonth() + 1).toString().padStart(2, '0'), //
377
- 'd': date.getDate().toString().padStart(2, '0'), //
378
- 'h': date.getHours().toString().padStart(2, '0'), // 时
379
- 'M': date.getMinutes().toString().padStart(2, '0'), // 分
380
- 's': date.getSeconds().toString().padStart(2, '0') // 秒
381
- // 有其他格式化字符需求可以继续添加,必须转化成字符串
382
- }
364
+ date = new Date(typeof dateTime === 'string' ? dateTime.replace(/-/g, '/') : dateTime);
365
+ }
366
+
367
+ const timeSource = {
368
+ y: date.getFullYear().toString(), // 年
369
+ m: (date.getMonth() + 1).toString().padStart(2, '0'), // 月
370
+ d: date.getDate().toString().padStart(2, '0'), // 日
371
+ h: date.getHours().toString().padStart(2, '0'), // 时
372
+ M: date.getMinutes().toString().padStart(2, '0'), //
373
+ s: date.getSeconds().toString().padStart(2, '0') //
374
+ // 有其他格式化字符需求可以继续添加,必须转化成字符串
375
+ };
383
376
 
384
377
  for (const key in timeSource) {
385
- const [ret] = new RegExp(`${key}+`).exec(formatStr) || []
378
+ const [ret] = new RegExp(`${key}+`).exec(formatStr) || [];
386
379
  if (ret) {
387
380
  // 年可能只需展示两位
388
- const beginIndex = key === 'y' && ret.length === 2 ? 2 : 0
389
- formatStr = formatStr.replace(ret, timeSource[key].slice(beginIndex))
381
+ const beginIndex = key === 'y' && ret.length === 2 ? 2 : 0;
382
+ formatStr = formatStr.replace(ret, timeSource[key].slice(beginIndex));
390
383
  }
391
384
  }
392
385
 
393
- return formatStr
386
+ return formatStr;
394
387
  }
395
388
 
396
389
  /**
397
390
  * @description 时间戳转为多久之前
398
391
  * @param {String|Number} timestamp 时间戳
399
- * @param {String|Boolean} format
392
+ * @param {String|Boolean} format
400
393
  * 格式化规则如果为时间格式字符串,超出一定时间范围,返回固定的时间格式;
401
394
  * 如果为布尔值false,无论什么时间,都返回多久以前的格式
402
395
  * @returns {string} 转化后的内容
403
396
  */
404
397
  export function timeFrom(timestamp = null, format = 'yyyy-mm-dd') {
405
- if (timestamp == null) timestamp = Number(new Date())
406
- timestamp = parseInt(timestamp)
407
- // 判断用户输入的时间戳是秒还是毫秒,一般前端js获取的时间戳是毫秒(13位),后端传过来的为秒(10位)
408
- if (timestamp.toString().length == 10) timestamp *= 1000
409
- let timer = (new Date()).getTime() - timestamp
410
- timer = parseInt(timer / 1000)
411
- // 如果小于5分钟,则返回"刚刚",其他以此类推
412
- let tips = ''
413
- switch (true) {
414
- case timer < 300:
415
- tips = '刚刚'
416
- break
417
- case timer >= 300 && timer < 3600:
418
- tips = `${parseInt(timer / 60)}分钟前`
419
- break
420
- case timer >= 3600 && timer < 86400:
421
- tips = `${parseInt(timer / 3600)}小时前`
422
- break
423
- case timer >= 86400 && timer < 2592000:
424
- tips = `${parseInt(timer / 86400)}天前`
425
- break
426
- default:
427
- // 如果format为false,则无论什么时间戳,都显示xx之前
428
- if (format === false) {
429
- if (timer >= 2592000 && timer < 365 * 86400) {
430
- tips = `${parseInt(timer / (86400 * 30))}个月前`
431
- } else {
432
- tips = `${parseInt(timer / (86400 * 365))}年前`
433
- }
434
- } else {
435
- tips = timeFormat(timestamp, format)
436
- }
437
- }
438
- return tips
398
+ if (timestamp == null) timestamp = Number(new Date());
399
+ timestamp = parseInt(timestamp);
400
+ // 判断用户输入的时间戳是秒还是毫秒,一般前端js获取的时间戳是毫秒(13位),后端传过来的为秒(10位)
401
+ if (timestamp.toString().length == 10) timestamp *= 1000;
402
+ let timer = new Date().getTime() - timestamp;
403
+ timer = parseInt(timer / 1000);
404
+ // 如果小于5分钟,则返回"刚刚",其他以此类推
405
+ let tips = '';
406
+ switch (true) {
407
+ case timer < 300:
408
+ tips = '刚刚';
409
+ break;
410
+ case timer >= 300 && timer < 3600:
411
+ tips = `${parseInt(timer / 60)}分钟前`;
412
+ break;
413
+ case timer >= 3600 && timer < 86400:
414
+ tips = `${parseInt(timer / 3600)}小时前`;
415
+ break;
416
+ case timer >= 86400 && timer < 2592000:
417
+ tips = `${parseInt(timer / 86400)}天前`;
418
+ break;
419
+ default:
420
+ // 如果format为false,则无论什么时间戳,都显示xx之前
421
+ if (format === false) {
422
+ if (timer >= 2592000 && timer < 365 * 86400) {
423
+ tips = `${parseInt(timer / (86400 * 30))}个月前`;
424
+ } else {
425
+ tips = `${parseInt(timer / (86400 * 365))}年前`;
426
+ }
427
+ } else {
428
+ tips = timeFormat(timestamp, format);
429
+ }
430
+ }
431
+ return tips;
439
432
  }
440
433
 
441
434
  /**
@@ -444,20 +437,20 @@ export function timeFrom(timestamp = null, format = 'yyyy-mm-dd') {
444
437
  * @param String pos both(左右)|left|right|all 默认both
445
438
  */
446
439
  export function trim(str, pos = 'both') {
447
- str = String(str)
448
- if (pos == 'both') {
449
- return str.replace(/^\s+|\s+$/g, '')
450
- }
451
- if (pos == 'left') {
452
- return str.replace(/^\s*/, '')
453
- }
454
- if (pos == 'right') {
455
- return str.replace(/(\s*$)/g, '')
456
- }
457
- if (pos == 'all') {
458
- return str.replace(/\s+/g, '')
459
- }
460
- return str
440
+ str = String(str);
441
+ if (pos == 'both') {
442
+ return str.replace(/^\s+|\s+$/g, '');
443
+ }
444
+ if (pos == 'left') {
445
+ return str.replace(/^\s*/, '');
446
+ }
447
+ if (pos == 'right') {
448
+ return str.replace(/(\s*$)/g, '');
449
+ }
450
+ if (pos == 'all') {
451
+ return str.replace(/\s+/g, '');
452
+ }
453
+ return str;
461
454
  }
462
455
 
463
456
  /**
@@ -467,55 +460,55 @@ export function trim(str, pos = 'both') {
467
460
  * @param {string} arrayFormat 规则 indices|brackets|repeat|comma
468
461
  */
469
462
  export function queryParams(data = {}, isPrefix = true, arrayFormat = 'brackets') {
470
- const prefix = isPrefix ? '?' : ''
471
- const _result = []
472
- if (['indices', 'brackets', 'repeat', 'comma'].indexOf(arrayFormat) == -1) arrayFormat = 'brackets'
473
- for (const key in data) {
474
- const value = data[key]
475
- // 去掉为空的参数
476
- if (['', undefined, null].indexOf(value) >= 0) {
477
- continue
478
- }
479
- // 如果值为数组,另行处理
480
- if (value.constructor === Array) {
481
- // e.g. {ids: [1, 2, 3]}
482
- switch (arrayFormat) {
483
- case 'indices':
484
- // 结果: ids[0]=1&ids[1]=2&ids[2]=3
485
- for (let i = 0; i < value.length; i++) {
486
- _result.push(`${key}[${i}]=${value[i]}`)
487
- }
488
- break
489
- case 'brackets':
490
- // 结果: ids[]=1&ids[]=2&ids[]=3
491
- value.forEach((_value) => {
492
- _result.push(`${key}[]=${_value}`)
493
- })
494
- break
495
- case 'repeat':
496
- // 结果: ids=1&ids=2&ids=3
497
- value.forEach((_value) => {
498
- _result.push(`${key}=${_value}`)
499
- })
500
- break
501
- case 'comma':
502
- // 结果: ids=1,2,3
503
- let commaStr = ''
504
- value.forEach((_value) => {
505
- commaStr += (commaStr ? ',' : '') + _value
506
- })
507
- _result.push(`${key}=${commaStr}`)
508
- break
509
- default:
510
- value.forEach((_value) => {
511
- _result.push(`${key}[]=${_value}`)
512
- })
513
- }
514
- } else {
515
- _result.push(`${key}=${value}`)
516
- }
517
- }
518
- return _result.length ? prefix + _result.join('&') : ''
463
+ const prefix = isPrefix ? '?' : '';
464
+ const _result = [];
465
+ if (['indices', 'brackets', 'repeat', 'comma'].indexOf(arrayFormat) == -1) arrayFormat = 'brackets';
466
+ for (const key in data) {
467
+ const value = data[key];
468
+ // 去掉为空的参数
469
+ if (['', undefined, null].indexOf(value) >= 0) {
470
+ continue;
471
+ }
472
+ // 如果值为数组,另行处理
473
+ if (value.constructor === Array) {
474
+ // e.g. {ids: [1, 2, 3]}
475
+ switch (arrayFormat) {
476
+ case 'indices':
477
+ // 结果: ids[0]=1&ids[1]=2&ids[2]=3
478
+ for (let i = 0; i < value.length; i++) {
479
+ _result.push(`${key}[${i}]=${value[i]}`);
480
+ }
481
+ break;
482
+ case 'brackets':
483
+ // 结果: ids[]=1&ids[]=2&ids[]=3
484
+ value.forEach((_value) => {
485
+ _result.push(`${key}[]=${_value}`);
486
+ });
487
+ break;
488
+ case 'repeat':
489
+ // 结果: ids=1&ids=2&ids=3
490
+ value.forEach((_value) => {
491
+ _result.push(`${key}=${_value}`);
492
+ });
493
+ break;
494
+ case 'comma':
495
+ // 结果: ids=1,2,3
496
+ let commaStr = '';
497
+ value.forEach((_value) => {
498
+ commaStr += (commaStr ? ',' : '') + _value;
499
+ });
500
+ _result.push(`${key}=${commaStr}`);
501
+ break;
502
+ default:
503
+ value.forEach((_value) => {
504
+ _result.push(`${key}[]=${_value}`);
505
+ });
506
+ }
507
+ } else {
508
+ _result.push(`${key}=${value}`);
509
+ }
510
+ }
511
+ return _result.length ? prefix + _result.join('&') : '';
519
512
  }
520
513
 
521
514
  /**
@@ -524,11 +517,11 @@ export function queryParams(data = {}, isPrefix = true, arrayFormat = 'brackets'
524
517
  * @param {Number} duration 提示的延迟时间,单位毫秒,默认:2000
525
518
  */
526
519
  export function toast(title, duration = 2000) {
527
- uni.showToast({
528
- title: String(title),
529
- icon: 'none',
530
- duration
531
- })
520
+ uni.showToast({
521
+ title: String(title),
522
+ icon: 'none',
523
+ duration
524
+ });
532
525
  }
533
526
 
534
527
  /**
@@ -537,32 +530,32 @@ export function toast(title, duration = 2000) {
537
530
  * @param {boolean} fill 是否使用fill填充实体的图标
538
531
  */
539
532
  export function type2icon(type = 'success', fill = false) {
540
- // 如果非预置值,默认为success
541
- if (['primary', 'info', 'error', 'warning', 'success'].indexOf(type) == -1) type = 'success'
542
- let iconName = ''
543
- // 目前(2019-12-12),info和primary使用同一个图标
544
- switch (type) {
545
- case 'primary':
546
- iconName = 'info-circle'
547
- break
548
- case 'info':
549
- iconName = 'info-circle'
550
- break
551
- case 'error':
552
- iconName = 'close-circle'
553
- break
554
- case 'warning':
555
- iconName = 'error-circle'
556
- break
557
- case 'success':
558
- iconName = 'checkmark-circle'
559
- break
560
- default:
561
- iconName = 'checkmark-circle'
562
- }
563
- // 是否是实体类型,加上-fill,在icon组件库中,实体的类名是后面加-fill的
564
- if (fill) iconName += '-fill'
565
- return iconName
533
+ // 如果非预置值,默认为success
534
+ if (['primary', 'info', 'error', 'warning', 'success'].indexOf(type) == -1) type = 'success';
535
+ let iconName = '';
536
+ // 目前(2019-12-12),info和primary使用同一个图标
537
+ switch (type) {
538
+ case 'primary':
539
+ iconName = 'info-circle';
540
+ break;
541
+ case 'info':
542
+ iconName = 'info-circle';
543
+ break;
544
+ case 'error':
545
+ iconName = 'close-circle';
546
+ break;
547
+ case 'warning':
548
+ iconName = 'error-circle';
549
+ break;
550
+ case 'success':
551
+ iconName = 'checkmark-circle';
552
+ break;
553
+ default:
554
+ iconName = 'checkmark-circle';
555
+ }
556
+ // 是否是实体类型,加上-fill,在icon组件库中,实体的类名是后面加-fill的
557
+ if (fill) iconName += '-fill';
558
+ return iconName;
566
559
  }
567
560
 
568
561
  /**
@@ -574,24 +567,24 @@ export function type2icon(type = 'success', fill = false) {
574
567
  * @returns {string} 格式化后的数字
575
568
  */
576
569
  export function priceFormat(number, decimals = 0, decimalPoint = '.', thousandsSeparator = ',') {
577
- number = (`${number}`).replace(/[^0-9+-Ee.]/g, '')
578
- const n = !isFinite(+number) ? 0 : +number
579
- const prec = !isFinite(+decimals) ? 0 : Math.abs(decimals)
580
- const sep = (typeof thousandsSeparator === 'undefined') ? ',' : thousandsSeparator
581
- const dec = (typeof decimalPoint === 'undefined') ? '.' : decimalPoint
582
- let s = ''
583
-
584
- s = (prec ? round(n, prec) + '' : `${Math.round(n)}`).split('.')
585
- const re = /(-?\d+)(\d{3})/
586
- while (re.test(s[0])) {
587
- s[0] = s[0].replace(re, `$1${sep}$2`)
588
- }
589
-
590
- if ((s[1] || '').length < prec) {
591
- s[1] = s[1] || ''
592
- s[1] += new Array(prec - s[1].length + 1).join('0')
593
- }
594
- return s.join(dec)
570
+ number = `${number}`.replace(/[^0-9+-Ee.]/g, '');
571
+ const n = !isFinite(+number) ? 0 : +number;
572
+ const prec = !isFinite(+decimals) ? 0 : Math.abs(decimals);
573
+ const sep = typeof thousandsSeparator === 'undefined' ? ',' : thousandsSeparator;
574
+ const dec = typeof decimalPoint === 'undefined' ? '.' : decimalPoint;
575
+ let s = '';
576
+
577
+ s = (prec ? round(n, prec) + '' : `${Math.round(n)}`).split('.');
578
+ const re = /(-?\d+)(\d{3})/;
579
+ while (re.test(s[0])) {
580
+ s[0] = s[0].replace(re, `$1${sep}$2`);
581
+ }
582
+
583
+ if ((s[1] || '').length < prec) {
584
+ s[1] = s[1] || '';
585
+ s[1] += new Array(prec - s[1].length + 1).join('0');
586
+ }
587
+ return s.join(dec);
595
588
  }
596
589
 
597
590
  /**
@@ -600,17 +593,17 @@ export function priceFormat(number, decimals = 0, decimalPoint = '.', thousandsS
600
593
  * 比如以30位阈值,那么300大于30,可以理解为用户想要的是300ms,而不是想花300s去执行一个动画
601
594
  * @param {String|number} value 比如: "1s"|"100ms"|1|100
602
595
  * @param {boolean} unit 提示: 如果是false 默认返回number
603
- * @return {string|number}
596
+ * @return {string|number}
604
597
  */
605
598
  export function getDuration(value, unit = true) {
606
- const valueNum = parseInt(value)
607
- if (unit) {
608
- if (/s$/.test(value)) return value
609
- return value > 30 ? `${value}ms` : `${value}s`
610
- }
611
- if (/ms$/.test(value)) return valueNum
612
- if (/s$/.test(value)) return valueNum > 30 ? valueNum : valueNum * 1000
613
- return valueNum
599
+ const valueNum = parseInt(value);
600
+ if (unit) {
601
+ if (/s$/.test(value)) return value;
602
+ return value > 30 ? `${value}ms` : `${value}s`;
603
+ }
604
+ if (/ms$/.test(value)) return valueNum;
605
+ if (/s$/.test(value)) return valueNum > 30 ? valueNum : valueNum * 1000;
606
+ return valueNum;
614
607
  }
615
608
 
616
609
  /**
@@ -618,7 +611,7 @@ export function getDuration(value, unit = true) {
618
611
  * @param {String} value 需要补零的值
619
612
  */
620
613
  export function padZero(value) {
621
- return `00${value}`.slice(-2)
614
+ return `00${value}`.slice(-2);
622
615
  }
623
616
 
624
617
  /**
@@ -627,13 +620,13 @@ export function padZero(value) {
627
620
  * @param {*} event
628
621
  */
629
622
  export function formValidate(instance, event) {
630
- const formItem = $parent.call(instance, 'u-form-item')
631
- const form = $parent.call(instance, 'u-form')
632
- // 如果发生变化的input或者textarea等,其父组件中有u-form-item或者u-form等,就执行form的validate方法
633
- // 同时将form-item的pros传递给form,让其进行精确对象验证
634
- if (formItem && form) {
635
- form.validateField(formItem.prop, () => {}, event)
636
- }
623
+ const formItem = $parent.call(instance, 'u-form-item');
624
+ const form = $parent.call(instance, 'u-form');
625
+ // 如果发生变化的input或者textarea等,其父组件中有u-form-item或者u-form等,就执行form的validate方法
626
+ // 同时将form-item的pros传递给form,让其进行精确对象验证
627
+ if (formItem && form) {
628
+ form.validateField(formItem.prop, () => {}, event);
629
+ }
637
630
  }
638
631
 
639
632
  /**
@@ -643,24 +636,24 @@ export function formValidate(instance, event) {
643
636
  * @returns {*}
644
637
  */
645
638
  export function getProperty(obj, key) {
646
- if (typeof obj !== 'object' || null == obj) {
647
- return ''
639
+ if (typeof obj !== 'object' || null == obj) {
640
+ return '';
641
+ }
642
+ if (typeof key !== 'string' || key === '') {
643
+ return '';
644
+ }
645
+ if (key.indexOf('.') !== -1) {
646
+ const keys = key.split('.');
647
+ let firstObj = obj[keys[0]] || {};
648
+
649
+ for (let i = 1; i < keys.length; i++) {
650
+ if (firstObj) {
651
+ firstObj = firstObj[keys[i]];
652
+ }
648
653
  }
649
- if (typeof key !== 'string' || key === '') {
650
- return ''
651
- }
652
- if (key.indexOf('.') !== -1) {
653
- const keys = key.split('.')
654
- let firstObj = obj[keys[0]] || {}
655
-
656
- for (let i = 1; i < keys.length; i++) {
657
- if (firstObj) {
658
- firstObj = firstObj[keys[i]]
659
- }
660
- }
661
- return firstObj
662
- }
663
- return obj[key]
654
+ return firstObj;
655
+ }
656
+ return obj[key];
664
657
  }
665
658
 
666
659
  /**
@@ -670,64 +663,68 @@ export function getProperty(obj, key) {
670
663
  * @param {string} value 设置的值
671
664
  */
672
665
  export function setProperty(obj, key, value) {
673
- if (typeof obj !== 'object' || null == obj) {
674
- return
675
- }
676
- // 递归赋值
677
- const inFn = function(_obj, keys, v) {
678
- // 最后一个属性key
679
- if (keys.length === 1) {
680
- _obj[keys[0]] = v
681
- return
682
- }
683
- // 0~length-1个key
684
- while (keys.length > 1) {
685
- const k = keys[0]
686
- if (!_obj[k] || (typeof _obj[k] !== 'object')) {
687
- _obj[k] = {}
688
- }
689
- const key = keys.shift()
690
- // 自调用判断是否存在属性,不存在则自动创建对象
691
- inFn(_obj[k], keys, v)
692
- }
693
- }
694
-
695
- if (typeof key !== 'string' || key === '') {
696
-
697
- } else if (key.indexOf('.') !== -1) { // 支持多层级赋值操作
698
- const keys = key.split('.')
699
- inFn(obj, keys, value)
700
- } else {
701
- obj[key] = value
702
- }
666
+ if (typeof obj !== 'object' || null == obj) {
667
+ return;
668
+ }
669
+ // 递归赋值
670
+ const inFn = function (_obj, keys, v) {
671
+ // 最后一个属性key
672
+ if (keys.length === 1) {
673
+ _obj[keys[0]] = v;
674
+ return;
675
+ }
676
+ // 0~length-1个key
677
+ while (keys.length > 1) {
678
+ const k = keys[0];
679
+ if (!_obj[k] || typeof _obj[k] !== 'object') {
680
+ _obj[k] = {};
681
+ }
682
+ const key = keys.shift();
683
+ // 自调用判断是否存在属性,不存在则自动创建对象
684
+ inFn(_obj[k], keys, v);
685
+ }
686
+ };
687
+
688
+ if (typeof key !== 'string' || key === '') {
689
+ } else if (key.indexOf('.') !== -1) {
690
+ // 支持多层级赋值操作
691
+ const keys = key.split('.');
692
+ inFn(obj, keys, value);
693
+ } else {
694
+ obj[key] = value;
695
+ }
703
696
  }
704
697
 
705
698
  /**
706
699
  * @description 获取当前页面路径
707
700
  */
708
701
  export function page() {
709
- const pages = getCurrentPages()
710
- // 某些特殊情况下(比如页面进行redirectTo时的一些时机),pages可能为空数组
711
- return `/${pages[pages.length - 1].route || ''}`
702
+ const pages = getCurrentPages();
703
+ // 某些特殊情况下(比如页面进行redirectTo时的一些时机),pages可能为空数组
704
+ return `/${pages[pages.length - 1].route || ''}`;
705
+
706
+ //const route = pages[pages.length - 1]?.route;
707
+ // 某些特殊情况下(比如页面进行redirectTo时的一些时机),pages可能为空数组
708
+ //return `/${route ? route : ''}`;
712
709
  }
713
710
 
714
711
  /**
715
712
  * @description 获取当前路由栈实例数组
716
713
  */
717
714
  export function pages() {
718
- const pages = getCurrentPages()
719
- return pages
715
+ const pages = getCurrentPages();
716
+ return pages;
720
717
  }
721
718
 
722
719
  export function getValueByPath(obj, path) {
723
- // 将路径字符串按 '.' 分割成数组
724
- const pathArr = path.split('.');
725
- // 使用 reduce 方法从 obj 开始,逐级访问嵌套属性
726
- return pathArr.reduce((acc, curr) => {
727
- // 如果当前累加器(acc)是对象且包含当前键(curr),则返回该键对应的值
728
- // 否则返回 undefined(表示路径不存在)
729
- return acc && acc[curr] !== undefined ? acc[curr] : undefined;
730
- }, obj);
720
+ // 将路径字符串按 '.' 分割成数组
721
+ const pathArr = path.split('.');
722
+ // 使用 reduce 方法从 obj 开始,逐级访问嵌套属性
723
+ return pathArr.reduce((acc, curr) => {
724
+ // 如果当前累加器(acc)是对象且包含当前键(curr),则返回该键对应的值
725
+ // 否则返回 undefined(表示路径不存在)
726
+ return acc && acc[curr] !== undefined ? acc[curr] : undefined;
727
+ }, obj);
731
728
  }
732
729
 
733
730
  /**
@@ -737,117 +734,133 @@ export function getValueByPath(obj, path) {
737
734
  * @returns {string} 十六进制颜色值
738
735
  */
739
736
  export function genLightColor(textColor, lightness = 95) {
740
- // 手动解析颜色值(避免使用document)
741
- const rgb = parseColorWithoutDOM(textColor);
742
-
743
- // RGB转HSL色域
744
- const hsl = rgbToHsl(rgb.r, rgb.g, rgb.b);
745
-
746
- // 生成浅色背景
747
- const bgHsl = {
748
- h: hsl.h,
749
- s: hsl.s,
750
- l: Math.min(lightness, 95)
751
- };
752
-
753
- return hslToHex(bgHsl.h, bgHsl.s, bgHsl.l);
737
+ // 手动解析颜色值(避免使用document)
738
+ const rgb = parseColorWithoutDOM(textColor);
739
+
740
+ // RGB转HSL色域
741
+ const hsl = rgbToHsl(rgb.r, rgb.g, rgb.b);
742
+
743
+ // 生成浅色背景
744
+ const bgHsl = {
745
+ h: hsl.h,
746
+ s: hsl.s,
747
+ l: Math.min(lightness, 95)
748
+ };
749
+
750
+ return hslToHex(bgHsl.h, bgHsl.s, bgHsl.l);
751
+ }
752
+
753
+ /* 手动解析颜色字符串(兼容uni-app环境) */
754
+ function parseColorWithoutDOM(colorStr) {
755
+ // 统一转小写处理
756
+ const str = colorStr.toLowerCase().trim();
757
+
758
+ // 处理十六进制格式
759
+ if (str.startsWith('#')) {
760
+ const hex = str.replace('#', '');
761
+ const fullHex =
762
+ hex.length === 3
763
+ ? hex
764
+ .split('')
765
+ .map((c) => c + c)
766
+ .join('')
767
+ : hex;
768
+
769
+ return {
770
+ r: parseInt(fullHex.substring(0, 2), 16),
771
+ g: parseInt(fullHex.substring(2, 4), 16),
772
+ b: parseInt(fullHex.substring(4, 6), 16)
773
+ };
754
774
  }
755
-
756
- /* 手动解析颜色字符串(兼容uni-app环境) */
757
- function parseColorWithoutDOM(colorStr) {
758
- // 统一转小写处理
759
- const str = colorStr.toLowerCase().trim();
760
-
761
- // 处理十六进制格式
762
- if (str.startsWith('#')) {
763
- const hex = str.replace('#', '');
764
- const fullHex = hex.length === 3 ?
765
- hex.split('').map(c => c + c).join('') : hex;
766
-
767
- return {
768
- r: parseInt(fullHex.substring(0,2), 16),
769
- g: parseInt(fullHex.substring(2,4), 16),
770
- b: parseInt(fullHex.substring(4,6), 16)
771
- };
772
- }
773
-
774
- // 处理rgb/rgba格式
775
- const rgbMatch = str.match(/rgba?\((\d+),\s*(\d+),\s*(\d+)/);
776
- if (rgbMatch) {
777
- return {
778
- r: +rgbMatch[1],
779
- g: +rgbMatch[2],
780
- b: +rgbMatch[3]
781
- };
782
- }
783
-
784
- throw new Error('Invalid color format');
775
+
776
+ // 处理rgb/rgba格式
777
+ const rgbMatch = str.match(/rgba?\((\d+),\s*(\d+),\s*(\d+)/);
778
+ if (rgbMatch) {
779
+ return {
780
+ r: +rgbMatch[1],
781
+ g: +rgbMatch[2],
782
+ b: +rgbMatch[3]
783
+ };
785
784
  }
786
785
 
786
+ throw new Error('Invalid color format');
787
+ }
788
+
787
789
  // 辅助函数:RGB 转 HSL(色相、饱和度、亮度)
788
790
  function rgbToHsl(r, g, b) {
789
- r /= 255, g /= 255, b /= 255;
790
- const max = Math.max(r, g, b), min = Math.min(r, g, b);
791
- let h, s, l = (max + min) / 2;
792
-
793
- if (max === min) {
794
- h = s = 0; // achromatic
795
- } else {
796
- const d = max - min;
797
- s = l > 0.5 ? d / (2 - max - min) : d / (max + min);
798
- switch (max) {
799
- case r: h = (g - b) / d + (g < b ? 6 : 0); break;
800
- case g: h = (b - r) / d + 2; break;
801
- case b: h = (r - g) / d + 4; break;
802
- }
803
- h = (h * 60).toFixed(1);
804
- }
805
- return { h: +h, s: +(s * 100).toFixed(1), l: +(l * 100).toFixed(1) };
791
+ (r /= 255), (g /= 255), (b /= 255);
792
+ const max = Math.max(r, g, b),
793
+ min = Math.min(r, g, b);
794
+ let h,
795
+ s,
796
+ l = (max + min) / 2;
797
+
798
+ if (max === min) {
799
+ h = s = 0; // achromatic
800
+ } else {
801
+ const d = max - min;
802
+ s = l > 0.5 ? d / (2 - max - min) : d / (max + min);
803
+ switch (max) {
804
+ case r:
805
+ h = (g - b) / d + (g < b ? 6 : 0);
806
+ break;
807
+ case g:
808
+ h = (b - r) / d + 2;
809
+ break;
810
+ case b:
811
+ h = (r - g) / d + 4;
812
+ break;
813
+ }
814
+ h = (h * 60).toFixed(1);
815
+ }
816
+ return { h: +h, s: +(s * 100).toFixed(1), l: +(l * 100).toFixed(1) };
806
817
  }
807
818
 
808
819
  // 辅助函数:HSL 转十六进制
809
820
  function hslToHex(h, s, l) {
810
- l /= 100;
811
- const a = s * Math.min(l, 1 - l) / 100;
812
- const f = n => {
813
- const k = (n + h / 30) % 12;
814
- const color = l - a * Math.max(Math.min(k - 3, 9 - k, 1), -1);
815
- return Math.round(255 * color).toString(16).padStart(2, '0');
816
- };
817
- return `#${f(0)}${f(8)}${f(4)}`;
821
+ l /= 100;
822
+ const a = (s * Math.min(l, 1 - l)) / 100;
823
+ const f = (n) => {
824
+ const k = (n + h / 30) % 12;
825
+ const color = l - a * Math.max(Math.min(k - 3, 9 - k, 1), -1);
826
+ return Math.round(255 * color)
827
+ .toString(16)
828
+ .padStart(2, '0');
829
+ };
830
+ return `#${f(0)}${f(8)}${f(4)}`;
818
831
  }
819
832
 
820
833
  export default {
821
- range,
822
- getPx,
823
- sleep,
824
- os,
825
- sys,
826
- getWindowInfo,
827
- random,
828
- guid,
829
- $parent,
830
- addStyle,
831
- addUnit,
832
- deepClone,
833
- deepMerge,
834
- shallowMerge,
835
- error,
836
- randomArray,
837
- timeFormat,
838
- timeFrom,
839
- trim,
840
- queryParams,
841
- toast,
842
- type2icon,
843
- priceFormat,
844
- getDuration,
845
- padZero,
846
- formValidate,
847
- getProperty,
848
- setProperty,
849
- page,
850
- pages,
851
- getValueByPath,
852
- genLightColor
853
- }
834
+ range,
835
+ getPx,
836
+ sleep,
837
+ os,
838
+ sys,
839
+ getWindowInfo,
840
+ random,
841
+ guid,
842
+ $parent,
843
+ addStyle,
844
+ addUnit,
845
+ deepClone,
846
+ deepMerge,
847
+ shallowMerge,
848
+ error,
849
+ randomArray,
850
+ timeFormat,
851
+ timeFrom,
852
+ trim,
853
+ queryParams,
854
+ toast,
855
+ type2icon,
856
+ priceFormat,
857
+ getDuration,
858
+ padZero,
859
+ formValidate,
860
+ getProperty,
861
+ setProperty,
862
+ page,
863
+ pages,
864
+ getValueByPath,
865
+ genLightColor
866
+ };