uview-ui-wjf 1.0.0

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 (368) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +71 -0
  3. package/changelog.md +388 -0
  4. package/components/u--form/u--form.vue +92 -0
  5. package/components/u--image/u--image.vue +73 -0
  6. package/components/u--input/u--input.vue +115 -0
  7. package/components/u--text/u--text.vue +72 -0
  8. package/components/u--textarea/u--textarea.vue +85 -0
  9. package/components/u-action-sheet/props.js +54 -0
  10. package/components/u-action-sheet/u-action-sheet.vue +278 -0
  11. package/components/u-album/props.js +59 -0
  12. package/components/u-album/u-album.vue +259 -0
  13. package/components/u-alert/props.js +44 -0
  14. package/components/u-alert/u-alert.vue +243 -0
  15. package/components/u-avatar/props.js +78 -0
  16. package/components/u-avatar/u-avatar.vue +173 -0
  17. package/components/u-avatar-group/props.js +52 -0
  18. package/components/u-avatar-group/u-avatar-group.vue +103 -0
  19. package/components/u-back-top/props.js +54 -0
  20. package/components/u-back-top/u-back-top.vue +129 -0
  21. package/components/u-badge/props.js +72 -0
  22. package/components/u-badge/u-badge.vue +171 -0
  23. package/components/u-button/nvue.scss +46 -0
  24. package/components/u-button/props.js +161 -0
  25. package/components/u-button/u-button.vue +495 -0
  26. package/components/u-button/vue.scss +80 -0
  27. package/components/u-calendar/header.vue +99 -0
  28. package/components/u-calendar/month.vue +579 -0
  29. package/components/u-calendar/props.js +144 -0
  30. package/components/u-calendar/u-calendar.vue +384 -0
  31. package/components/u-calendar/util.js +85 -0
  32. package/components/u-car-keyboard/props.js +14 -0
  33. package/components/u-car-keyboard/u-car-keyboard.vue +311 -0
  34. package/components/u-cell/props.js +110 -0
  35. package/components/u-cell/u-cell.vue +229 -0
  36. package/components/u-cell-group/props.js +14 -0
  37. package/components/u-cell-group/u-cell-group.vue +61 -0
  38. package/components/u-checkbox/props.js +69 -0
  39. package/components/u-checkbox/u-checkbox.vue +344 -0
  40. package/components/u-checkbox-group/props.js +82 -0
  41. package/components/u-checkbox-group/u-checkbox-group.vue +103 -0
  42. package/components/u-circle-progress/props.js +8 -0
  43. package/components/u-circle-progress/u-circle-progress.vue +198 -0
  44. package/components/u-code/props.js +34 -0
  45. package/components/u-code/u-code.vue +129 -0
  46. package/components/u-code-input/props.js +79 -0
  47. package/components/u-code-input/u-code-input.vue +252 -0
  48. package/components/u-col/props.js +29 -0
  49. package/components/u-col/u-col.vue +162 -0
  50. package/components/u-collapse/props.js +19 -0
  51. package/components/u-collapse/u-collapse.vue +90 -0
  52. package/components/u-collapse-item/props.js +59 -0
  53. package/components/u-collapse-item/u-collapse-item.vue +225 -0
  54. package/components/u-column-notice/props.js +55 -0
  55. package/components/u-column-notice/u-column-notice.vue +160 -0
  56. package/components/u-count-down/props.js +24 -0
  57. package/components/u-count-down/u-count-down.vue +163 -0
  58. package/components/u-count-down/utils.js +62 -0
  59. package/components/u-count-to/props.js +59 -0
  60. package/components/u-count-to/u-count-to.vue +184 -0
  61. package/components/u-datetime-picker/props.js +120 -0
  62. package/components/u-datetime-picker/u-datetime-picker.vue +361 -0
  63. package/components/u-divider/props.js +44 -0
  64. package/components/u-divider/u-divider.vue +116 -0
  65. package/components/u-dropdown/props.js +65 -0
  66. package/components/u-dropdown/u-dropdown.vue +127 -0
  67. package/components/u-dropdown-item/props.js +36 -0
  68. package/components/u-dropdown-item/u-dropdown-item.vue +127 -0
  69. package/components/u-empty/props.js +59 -0
  70. package/components/u-empty/u-empty.vue +128 -0
  71. package/components/u-form/props.js +45 -0
  72. package/components/u-form/u-form.vue +214 -0
  73. package/components/u-form-item/props.js +48 -0
  74. package/components/u-form-item/u-form-item.vue +235 -0
  75. package/components/u-gap/props.js +24 -0
  76. package/components/u-gap/u-gap.vue +38 -0
  77. package/components/u-grid/props.js +19 -0
  78. package/components/u-grid/u-grid.vue +97 -0
  79. package/components/u-grid-item/props.js +14 -0
  80. package/components/u-grid-item/u-grid-item.vue +209 -0
  81. package/components/u-icon/icons.js +214 -0
  82. package/components/u-icon/props.js +89 -0
  83. package/components/u-icon/u-icon.vue +237 -0
  84. package/components/u-image/props.js +84 -0
  85. package/components/u-image/u-image.vue +232 -0
  86. package/components/u-index-anchor/props.js +29 -0
  87. package/components/u-index-anchor/u-index-anchor.vue +91 -0
  88. package/components/u-index-item/props.js +5 -0
  89. package/components/u-index-item/u-index-item.vue +87 -0
  90. package/components/u-index-list/props.js +29 -0
  91. package/components/u-index-list/u-index-list.vue +440 -0
  92. package/components/u-input/props.js +187 -0
  93. package/components/u-input/u-input.vue +369 -0
  94. package/components/u-keyboard/props.js +84 -0
  95. package/components/u-keyboard/u-keyboard.vue +164 -0
  96. package/components/u-line/props.js +33 -0
  97. package/components/u-line/u-line.vue +62 -0
  98. package/components/u-line-progress/props.js +28 -0
  99. package/components/u-line-progress/u-line-progress.vue +144 -0
  100. package/components/u-link/props.js +39 -0
  101. package/components/u-link/u-link.vue +83 -0
  102. package/components/u-list/props.js +76 -0
  103. package/components/u-list/u-list.vue +157 -0
  104. package/components/u-list-item/props.js +9 -0
  105. package/components/u-list-item/u-list-item.vue +116 -0
  106. package/components/u-loading-icon/props.js +59 -0
  107. package/components/u-loading-icon/u-loading-icon.vue +343 -0
  108. package/components/u-loading-page/props.js +49 -0
  109. package/components/u-loading-page/u-loading-page.vue +115 -0
  110. package/components/u-loadmore/props.js +94 -0
  111. package/components/u-loadmore/u-loadmore.vue +150 -0
  112. package/components/u-modal/props.js +89 -0
  113. package/components/u-modal/u-modal.vue +228 -0
  114. package/components/u-navbar/props.js +84 -0
  115. package/components/u-navbar/u-navbar.vue +186 -0
  116. package/components/u-no-network/props.js +19 -0
  117. package/components/u-no-network/u-no-network.vue +220 -0
  118. package/components/u-notice-bar/props.js +70 -0
  119. package/components/u-notice-bar/u-notice-bar.vue +101 -0
  120. package/components/u-notify/props.js +49 -0
  121. package/components/u-notify/u-notify.vue +211 -0
  122. package/components/u-number-box/props.js +109 -0
  123. package/components/u-number-box/u-number-box.vue +416 -0
  124. package/components/u-number-keyboard/props.js +19 -0
  125. package/components/u-number-keyboard/u-number-keyboard.vue +196 -0
  126. package/components/u-overlay/props.js +24 -0
  127. package/components/u-overlay/u-overlay.vue +68 -0
  128. package/components/u-parse/node/node.vue +499 -0
  129. package/components/u-parse/parser.js +1075 -0
  130. package/components/u-parse/props.js +45 -0
  131. package/components/u-parse/u-parse.vue +366 -0
  132. package/components/u-picker/props.js +79 -0
  133. package/components/u-picker/u-picker.vue +286 -0
  134. package/components/u-picker-column/props.js +5 -0
  135. package/components/u-picker-column/u-picker-column.vue +27 -0
  136. package/components/u-popup/props.js +79 -0
  137. package/components/u-popup/u-popup.vue +304 -0
  138. package/components/u-radio/props.js +64 -0
  139. package/components/u-radio/u-radio.vue +339 -0
  140. package/components/u-radio-group/props.js +85 -0
  141. package/components/u-radio-group/u-radio-group.vue +108 -0
  142. package/components/u-rate/props.js +69 -0
  143. package/components/u-rate/u-rate.vue +306 -0
  144. package/components/u-read-more/props.js +61 -0
  145. package/components/u-read-more/u-read-more.vue +157 -0
  146. package/components/u-row/props.js +19 -0
  147. package/components/u-row/u-row.vue +93 -0
  148. package/components/u-row-notice/props.js +39 -0
  149. package/components/u-row-notice/u-row-notice.vue +330 -0
  150. package/components/u-safe-bottom/props.js +5 -0
  151. package/components/u-safe-bottom/u-safe-bottom.vue +56 -0
  152. package/components/u-scroll-list/nvue.js +28 -0
  153. package/components/u-scroll-list/other.js +0 -0
  154. package/components/u-scroll-list/props.js +34 -0
  155. package/components/u-scroll-list/scrollWxs.wxs +50 -0
  156. package/components/u-scroll-list/u-scroll-list.vue +224 -0
  157. package/components/u-search/props.js +118 -0
  158. package/components/u-search/u-search.vue +303 -0
  159. package/components/u-skeleton/props.js +59 -0
  160. package/components/u-skeleton/u-skeleton.vue +244 -0
  161. package/components/u-slider/mpother.js +113 -0
  162. package/components/u-slider/mpwxs.js +42 -0
  163. package/components/u-slider/mpwxs.wxs +121 -0
  164. package/components/u-slider/nvue - /345/211/257/346/234/254.js" +180 -0
  165. package/components/u-slider/nvue.js +193 -0
  166. package/components/u-slider/props.js +54 -0
  167. package/components/u-slider/u-slider.vue +55 -0
  168. package/components/u-status-bar/props.js +8 -0
  169. package/components/u-status-bar/u-status-bar.vue +46 -0
  170. package/components/u-steps/props.js +39 -0
  171. package/components/u-steps/u-steps.vue +80 -0
  172. package/components/u-steps-item/props.js +24 -0
  173. package/components/u-steps-item/u-steps-item.vue +316 -0
  174. package/components/u-sticky/props.js +40 -0
  175. package/components/u-sticky/u-sticky.vue +212 -0
  176. package/components/u-subsection/props.js +49 -0
  177. package/components/u-subsection/u-subsection.vue +299 -0
  178. package/components/u-swipe-action/props.js +9 -0
  179. package/components/u-swipe-action/u-swipe-action.vue +67 -0
  180. package/components/u-swipe-action-item/index - backup.wxs +256 -0
  181. package/components/u-swipe-action-item/index.wxs +225 -0
  182. package/components/u-swipe-action-item/nvue - backup.js +270 -0
  183. package/components/u-swipe-action-item/nvue.js +174 -0
  184. package/components/u-swipe-action-item/props.js +41 -0
  185. package/components/u-swipe-action-item/u-swipe-action-item.vue +190 -0
  186. package/components/u-swipe-action-item/wxs.js +15 -0
  187. package/components/u-swiper/props.js +125 -0
  188. package/components/u-swiper/u-swiper.vue +255 -0
  189. package/components/u-swiper-indicator/props.js +29 -0
  190. package/components/u-swiper-indicator/u-swiper-indicator.vue +110 -0
  191. package/components/u-switch/props.js +54 -0
  192. package/components/u-switch/u-switch.vue +177 -0
  193. package/components/u-tabbar/props.js +44 -0
  194. package/components/u-tabbar/u-tabbar.vue +141 -0
  195. package/components/u-tabbar-item/props.js +35 -0
  196. package/components/u-tabbar-item/u-tabbar-item.vue +142 -0
  197. package/components/u-table/props.js +5 -0
  198. package/components/u-table/u-table.vue +29 -0
  199. package/components/u-tabs/props.js +64 -0
  200. package/components/u-tabs/u-tabs.vue +363 -0
  201. package/components/u-tabs-item/props.js +5 -0
  202. package/components/u-tabs-item/u-tabs-item.vue +29 -0
  203. package/components/u-tag/props.js +84 -0
  204. package/components/u-tag/u-tag.vue +358 -0
  205. package/components/u-td/props.js +5 -0
  206. package/components/u-td/u-td.vue +31 -0
  207. package/components/u-text/props.js +110 -0
  208. package/components/u-text/u-text.vue +223 -0
  209. package/components/u-text/value.js +85 -0
  210. package/components/u-textarea/props.js +119 -0
  211. package/components/u-textarea/u-textarea.vue +239 -0
  212. package/components/u-toast/u-toast.vue +291 -0
  213. package/components/u-toolbar/props.js +34 -0
  214. package/components/u-toolbar/u-toolbar.vue +102 -0
  215. package/components/u-tooltip/clipboard.min.js +58 -0
  216. package/components/u-tooltip/props.js +59 -0
  217. package/components/u-tooltip/u-tooltip.vue +366 -0
  218. package/components/u-tr/props.js +5 -0
  219. package/components/u-tr/u-tr.vue +31 -0
  220. package/components/u-transition/nvue.ani-map.js +68 -0
  221. package/components/u-transition/props.js +24 -0
  222. package/components/u-transition/transition.js +157 -0
  223. package/components/u-transition/u-transition.vue +92 -0
  224. package/components/u-transition/vue.ani-style.scss +113 -0
  225. package/components/u-upload/mixin.js +21 -0
  226. package/components/u-upload/props.js +124 -0
  227. package/components/u-upload/u-upload.vue +566 -0
  228. package/components/u-upload/utils.js +151 -0
  229. package/components/uview-ui/uview-ui.vue +15 -0
  230. package/index.js +79 -0
  231. package/index.scss +23 -0
  232. package/libs/config/color.js +17 -0
  233. package/libs/config/config.js +34 -0
  234. package/libs/config/props/actionSheet.js +25 -0
  235. package/libs/config/props/album.js +25 -0
  236. package/libs/config/props/alert.js +22 -0
  237. package/libs/config/props/avatar.js +28 -0
  238. package/libs/config/props/avatarGroup.js +23 -0
  239. package/libs/config/props/backtop.js +27 -0
  240. package/libs/config/props/badge.js +27 -0
  241. package/libs/config/props/button.js +42 -0
  242. package/libs/config/props/calendar.js +42 -0
  243. package/libs/config/props/carKeyboard.js +15 -0
  244. package/libs/config/props/cell.js +35 -0
  245. package/libs/config/props/cellGroup.js +17 -0
  246. package/libs/config/props/checkbox.js +27 -0
  247. package/libs/config/props/checkboxGroup.js +29 -0
  248. package/libs/config/props/circleProgress.js +15 -0
  249. package/libs/config/props/code.js +21 -0
  250. package/libs/config/props/codeInput.js +29 -0
  251. package/libs/config/props/col.js +19 -0
  252. package/libs/config/props/collapse.js +17 -0
  253. package/libs/config/props/collapseItem.js +25 -0
  254. package/libs/config/props/columnNotice.js +24 -0
  255. package/libs/config/props/countDown.js +18 -0
  256. package/libs/config/props/countTo.js +25 -0
  257. package/libs/config/props/datetimePicker.js +37 -0
  258. package/libs/config/props/divider.js +23 -0
  259. package/libs/config/props/empty.js +26 -0
  260. package/libs/config/props/form.js +22 -0
  261. package/libs/config/props/formItem.js +23 -0
  262. package/libs/config/props/gap.js +19 -0
  263. package/libs/config/props/grid.js +17 -0
  264. package/libs/config/props/gridItem.js +16 -0
  265. package/libs/config/props/icon.js +36 -0
  266. package/libs/config/props/image.js +30 -0
  267. package/libs/config/props/indexAnchor.js +19 -0
  268. package/libs/config/props/indexList.js +19 -0
  269. package/libs/config/props/input.js +48 -0
  270. package/libs/config/props/keyboard.js +30 -0
  271. package/libs/config/props/line.js +20 -0
  272. package/libs/config/props/lineProgress.js +19 -0
  273. package/libs/config/props/link.js +26 -0
  274. package/libs/config/props/list.js +28 -0
  275. package/libs/config/props/listItem.js +15 -0
  276. package/libs/config/props/loadingIcon.js +30 -0
  277. package/libs/config/props/loadingPage.js +23 -0
  278. package/libs/config/props/loadmore.js +32 -0
  279. package/libs/config/props/modal.js +31 -0
  280. package/libs/config/props/navbar.js +32 -0
  281. package/libs/config/props/noNetwork.js +18 -0
  282. package/libs/config/props/noticeBar.js +27 -0
  283. package/libs/config/props/notify.js +22 -0
  284. package/libs/config/props/numberBox.js +35 -0
  285. package/libs/config/props/numberKeyboard.js +17 -0
  286. package/libs/config/props/overlay.js +18 -0
  287. package/libs/config/props/parse.js +22 -0
  288. package/libs/config/props/picker.js +29 -0
  289. package/libs/config/props/popup.js +29 -0
  290. package/libs/config/props/radio.js +27 -0
  291. package/libs/config/props/radioGroup.js +30 -0
  292. package/libs/config/props/rate.js +26 -0
  293. package/libs/config/props/readMore.js +22 -0
  294. package/libs/config/props/row.js +17 -0
  295. package/libs/config/props/rowNotice.js +21 -0
  296. package/libs/config/props/scrollList.js +20 -0
  297. package/libs/config/props/search.js +37 -0
  298. package/libs/config/props/section.js +24 -0
  299. package/libs/config/props/skeleton.js +25 -0
  300. package/libs/config/props/slider.js +25 -0
  301. package/libs/config/props/statusBar.js +15 -0
  302. package/libs/config/props/steps.js +21 -0
  303. package/libs/config/props/stepsItem.js +18 -0
  304. package/libs/config/props/sticky.js +20 -0
  305. package/libs/config/props/subsection.js +23 -0
  306. package/libs/config/props/swipeAction.js +15 -0
  307. package/libs/config/props/swipeActionItem.js +21 -0
  308. package/libs/config/props/swiper.js +39 -0
  309. package/libs/config/props/swipterIndicator.js +19 -0
  310. package/libs/config/props/switch.js +24 -0
  311. package/libs/config/props/tabbar.js +22 -0
  312. package/libs/config/props/tabbarItem.js +20 -0
  313. package/libs/config/props/tabs.js +32 -0
  314. package/libs/config/props/tag.js +29 -0
  315. package/libs/config/props/text.js +38 -0
  316. package/libs/config/props/textarea.js +36 -0
  317. package/libs/config/props/toast.js +30 -0
  318. package/libs/config/props/toolbar.js +21 -0
  319. package/libs/config/props/tooltip.js +25 -0
  320. package/libs/config/props/transition.js +18 -0
  321. package/libs/config/props/upload.js +36 -0
  322. package/libs/config/props.js +190 -0
  323. package/libs/config/zIndex.js +20 -0
  324. package/libs/css/color.scss +155 -0
  325. package/libs/css/common.scss +97 -0
  326. package/libs/css/components.scss +15 -0
  327. package/libs/css/flex.scss +257 -0
  328. package/libs/css/h5.scss +0 -0
  329. package/libs/css/mixin.scss +8 -0
  330. package/libs/css/mp.scss +0 -0
  331. package/libs/css/nvue.scss +0 -0
  332. package/libs/css/vue.scss +27 -0
  333. package/libs/function/colorGradient.js +134 -0
  334. package/libs/function/debounce.js +29 -0
  335. package/libs/function/digit.js +167 -0
  336. package/libs/function/index.js +731 -0
  337. package/libs/function/platform.js +75 -0
  338. package/libs/function/test.js +288 -0
  339. package/libs/function/throttle.js +30 -0
  340. package/libs/luch-request/adapters/index.js +97 -0
  341. package/libs/luch-request/core/InterceptorManager.js +50 -0
  342. package/libs/luch-request/core/Request.js +198 -0
  343. package/libs/luch-request/core/buildFullPath.js +20 -0
  344. package/libs/luch-request/core/defaults.js +29 -0
  345. package/libs/luch-request/core/dispatchRequest.js +3 -0
  346. package/libs/luch-request/core/mergeConfig.js +103 -0
  347. package/libs/luch-request/core/settle.js +16 -0
  348. package/libs/luch-request/helpers/buildURL.js +69 -0
  349. package/libs/luch-request/helpers/combineURLs.js +14 -0
  350. package/libs/luch-request/helpers/isAbsoluteURL.js +14 -0
  351. package/libs/luch-request/index.d.ts +116 -0
  352. package/libs/luch-request/index.js +3 -0
  353. package/libs/luch-request/utils/clone.js +264 -0
  354. package/libs/luch-request/utils.js +131 -0
  355. package/libs/mixin/button.js +13 -0
  356. package/libs/mixin/mixin.js +160 -0
  357. package/libs/mixin/mpMixin.js +8 -0
  358. package/libs/mixin/mpShare.js +13 -0
  359. package/libs/mixin/openType.js +25 -0
  360. package/libs/mixin/style.js +228 -0
  361. package/libs/mixin/touch.js +59 -0
  362. package/libs/util/async-validator.js +1343 -0
  363. package/libs/util/calendar.js +546 -0
  364. package/libs/util/dayjs.js +308 -0
  365. package/libs/util/emitter.js +51 -0
  366. package/libs/util/route.js +124 -0
  367. package/package.json +83 -0
  368. package/theme.scss +44 -0
@@ -0,0 +1,731 @@
1
+ import test from './test.js'
2
+ import { round } from './digit.js'
3
+ /**
4
+ * @description 如果value小于min,取min;如果value大于max,取max
5
+ * @param {number} min
6
+ * @param {number} max
7
+ * @param {number} value
8
+ */
9
+ function range(min = 0, max = 0, value = 0) {
10
+ return Math.max(min, Math.min(max, Number(value)))
11
+ }
12
+
13
+ /**
14
+ * @description 用于获取用户传递值的px值 如果用户传递了"xxpx"或者"xxrpx",取出其数值部分,如果是"xxxrpx"还需要用过uni.upx2px进行转换
15
+ * @param {number|string} value 用户传递值的px值
16
+ * @param {boolean} unit
17
+ * @returns {number|string}
18
+ */
19
+ function getPx(value, unit = false) {
20
+ if (test.number(value)) {
21
+ return unit ? `${value}px` : Number(value)
22
+ }
23
+ // 如果带有rpx,先取出其数值部分,再转为px值
24
+ if (/(rpx|upx)$/.test(value)) {
25
+ return unit ? `${uni.upx2px(parseInt(value))}px` : Number(uni.upx2px(parseInt(value)))
26
+ }
27
+ return unit ? `${parseInt(value)}px` : parseInt(value)
28
+ }
29
+
30
+ /**
31
+ * @description 进行延时,以达到可以简写代码的目的 比如: await uni.$u.sleep(20)将会阻塞20ms
32
+ * @param {number} value 堵塞时间 单位ms 毫秒
33
+ * @returns {Promise} 返回promise
34
+ */
35
+ function sleep(value = 30) {
36
+ return new Promise((resolve) => {
37
+ setTimeout(() => {
38
+ resolve()
39
+ }, value)
40
+ })
41
+ }
42
+ /**
43
+ * @description 运行期判断平台
44
+ * @returns {string} 返回所在平台(小写)
45
+ * @link 运行期判断平台 https://uniapp.dcloud.io/frame?id=判断平台
46
+ */
47
+ function os() {
48
+ return uni.getSystemInfoSync().platform.toLowerCase()
49
+ }
50
+ /**
51
+ * @description 获取系统信息同步接口
52
+ * @link 获取系统信息同步接口 https://uniapp.dcloud.io/api/system/info?id=getsysteminfosync
53
+ */
54
+ function sys() {
55
+ return uni.getSystemInfoSync()
56
+ }
57
+
58
+ /**
59
+ * @description 取一个区间数
60
+ * @param {Number} min 最小值
61
+ * @param {Number} max 最大值
62
+ */
63
+ function random(min, max) {
64
+ if (min >= 0 && max > 0 && max >= min) {
65
+ const gab = max - min + 1
66
+ return Math.floor(Math.random() * gab + min)
67
+ }
68
+ return 0
69
+ }
70
+
71
+ /**
72
+ * @param {Number} len uuid的长度
73
+ * @param {Boolean} firstU 将返回的首字母置为"u"
74
+ * @param {Nubmer} radix 生成uuid的基数(意味着返回的字符串都是这个基数),2-二进制,8-八进制,10-十进制,16-十六进制
75
+ */
76
+ function guid(len = 32, firstU = true, radix = null) {
77
+ const chars = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'.split('')
78
+ const uuid = []
79
+ radix = radix || chars.length
80
+
81
+ if (len) {
82
+ // 如果指定uuid长度,只是取随机的字符,0|x为位运算,能去掉x的小数位,返回整数位
83
+ for (let i = 0; i < len; i++) uuid[i] = chars[0 | Math.random() * radix]
84
+ } else {
85
+ let r
86
+ // rfc4122标准要求返回的uuid中,某些位为固定的字符
87
+ uuid[8] = uuid[13] = uuid[18] = uuid[23] = '-'
88
+ uuid[14] = '4'
89
+
90
+ for (let i = 0; i < 36; i++) {
91
+ if (!uuid[i]) {
92
+ r = 0 | Math.random() * 16
93
+ uuid[i] = chars[(i == 19) ? (r & 0x3) | 0x8 : r]
94
+ }
95
+ }
96
+ }
97
+ // 移除第一个字符,并用u替代,因为第一个字符为数值时,该guuid不能用作id或者class
98
+ if (firstU) {
99
+ uuid.shift()
100
+ return `u${uuid.join('')}`
101
+ }
102
+ return uuid.join('')
103
+ }
104
+
105
+ /**
106
+ * @description 获取父组件的参数,因为支付宝小程序不支持provide/inject的写法
107
+ this.$parent在非H5中,可以准确获取到父组件,但是在H5中,需要多次this.$parent.$parent.xxx
108
+ 这里默认值等于undefined有它的含义,因为最顶层元素(组件)的$parent就是undefined,意味着不传name
109
+ 值(默认为undefined),就是查找最顶层的$parent
110
+ * @param {string|undefined} name 父组件的参数名
111
+ */
112
+ function $parent(name = undefined) {
113
+ let parent = this.$parent
114
+ // 通过while历遍,这里主要是为了H5需要多层解析的问题
115
+ while (parent) {
116
+ // 父组件
117
+ if (parent.$options && parent.$options.name !== name) {
118
+ // 如果组件的name不相等,继续上一级寻找
119
+ parent = parent.$parent
120
+ } else {
121
+ return parent
122
+ }
123
+ }
124
+ return false
125
+ }
126
+
127
+ /**
128
+ * @description 样式转换
129
+ * 对象转字符串,或者字符串转对象
130
+ * @param {object | string} customStyle 需要转换的目标
131
+ * @param {String} target 转换的目的,object-转为对象,string-转为字符串
132
+ * @returns {object|string}
133
+ */
134
+ function addStyle(customStyle, target = 'object') {
135
+ // 字符串转字符串,对象转对象情形,直接返回
136
+ if (test.empty(customStyle) || typeof(customStyle) === 'object' && target === 'object' || target === 'string' &&
137
+ typeof(customStyle) === 'string') {
138
+ return customStyle
139
+ }
140
+ // 字符串转对象
141
+ if (target === 'object') {
142
+ // 去除字符串样式中的两端空格(中间的空格不能去掉,比如padding: 20px 0如果去掉了就错了),空格是无用的
143
+ customStyle = trim(customStyle)
144
+ // 根据";"将字符串转为数组形式
145
+ const styleArray = customStyle.split(';')
146
+ const style = {}
147
+ // 历遍数组,拼接成对象
148
+ for (let i = 0; i < styleArray.length; i++) {
149
+ // 'font-size:20px;color:red;',如此最后字符串有";"的话,会导致styleArray最后一个元素为空字符串,这里需要过滤
150
+ if (styleArray[i]) {
151
+ const item = styleArray[i].split(':')
152
+ style[trim(item[0])] = trim(item[1])
153
+ }
154
+ }
155
+ return style
156
+ }
157
+ // 这里为对象转字符串形式
158
+ let string = ''
159
+ for (const i in customStyle) {
160
+ // 驼峰转为中划线的形式,否则css内联样式,无法识别驼峰样式属性名
161
+ const key = i.replace(/([A-Z])/g, '-$1').toLowerCase()
162
+ string += `${key}:${customStyle[i]};`
163
+ }
164
+ // 去除两端空格
165
+ return trim(string)
166
+ }
167
+
168
+ /**
169
+ * @description 添加单位,如果有rpx,upx,%,px等单位结尾或者值为auto,直接返回,否则加上px单位结尾
170
+ * @param {string|number} value 需要添加单位的值
171
+ * @param {string} unit 添加的单位名 比如px
172
+ */
173
+ function addUnit(value = 'auto', unit = uni?.$u?.config?.unit ?? 'px') {
174
+ value = String(value)
175
+ // 用uView内置验证规则中的number判断是否为数值
176
+ return test.number(value) ? `${value}${unit}` : value
177
+ }
178
+
179
+ /**
180
+ * @description 深度克隆
181
+ * @param {object} obj 需要深度克隆的对象
182
+ * @param cache 缓存
183
+ * @returns {*} 克隆后的对象或者原值(不是对象)
184
+ */
185
+ function deepClone(obj, cache = new WeakMap()) {
186
+ if (obj === null || typeof obj !== 'object') return obj;
187
+ if (cache.has(obj)) return cache.get(obj);
188
+ let clone;
189
+ if (obj instanceof Date) {
190
+ clone = new Date(obj.getTime());
191
+ } else if (obj instanceof RegExp) {
192
+ clone = new RegExp(obj);
193
+ } else if (obj instanceof Map) {
194
+ clone = new Map(Array.from(obj, ([key, value]) => [key, deepClone(value, cache)]));
195
+ } else if (obj instanceof Set) {
196
+ clone = new Set(Array.from(obj, value => deepClone(value, cache)));
197
+ } else if (Array.isArray(obj)) {
198
+ clone = obj.map(value => deepClone(value, cache));
199
+ } else if (Object.prototype.toString.call(obj) === '[object Object]') {
200
+ clone = Object.create(Object.getPrototypeOf(obj));
201
+ cache.set(obj, clone);
202
+ for (const [key, value] of Object.entries(obj)) {
203
+ clone[key] = deepClone(value, cache);
204
+ }
205
+ } else {
206
+ clone = Object.assign({}, obj);
207
+ }
208
+ cache.set(obj, clone);
209
+ return clone;
210
+ }
211
+
212
+ /**
213
+ * @description JS对象深度合并
214
+ * @param {object} target 需要拷贝的对象
215
+ * @param {object} source 拷贝的来源对象
216
+ * @returns {object|boolean} 深度合并后的对象或者false(入参有不是对象)
217
+ */
218
+ function deepMerge(target = {}, source = {}) {
219
+ target = deepClone(target)
220
+ if (typeof target !== 'object' || target === null || typeof source !== 'object' || source === null) return target;
221
+ const merged = Array.isArray(target) ? target.slice() : Object.assign({}, target);
222
+ for (const prop in source) {
223
+ if (!source.hasOwnProperty(prop)) continue;
224
+ const sourceValue = source[prop];
225
+ const targetValue = merged[prop];
226
+ if (sourceValue instanceof Date) {
227
+ merged[prop] = new Date(sourceValue);
228
+ } else if (sourceValue instanceof RegExp) {
229
+ merged[prop] = new RegExp(sourceValue);
230
+ } else if (sourceValue instanceof Map) {
231
+ merged[prop] = new Map(sourceValue);
232
+ } else if (sourceValue instanceof Set) {
233
+ merged[prop] = new Set(sourceValue);
234
+ } else if (typeof sourceValue === 'object' && sourceValue !== null) {
235
+ merged[prop] = deepMerge(targetValue, sourceValue);
236
+ } else {
237
+ merged[prop] = sourceValue;
238
+ }
239
+ }
240
+ return merged;
241
+ }
242
+
243
+ /**
244
+ * @description error提示
245
+ * @param {*} err 错误内容
246
+ */
247
+ function error(err) {
248
+ // 开发环境才提示,生产环境不会提示
249
+ if (process.env.NODE_ENV === 'development') {
250
+ console.error(`uView提示:${err}`)
251
+ }
252
+ }
253
+
254
+ /**
255
+ * @description 打乱数组
256
+ * @param {array} array 需要打乱的数组
257
+ * @returns {array} 打乱后的数组
258
+ */
259
+ function randomArray(array = []) {
260
+ // 原理是sort排序,Math.random()产生0<= x < 1之间的数,会导致x-0.05大于或者小于0
261
+ return array.sort(() => Math.random() - 0.5)
262
+ }
263
+
264
+ // padStart 的 polyfill,因为某些机型或情况,还无法支持es7的padStart,比如电脑版的微信小程序
265
+ // 所以这里做一个兼容polyfill的兼容处理
266
+ if (!String.prototype.padStart) {
267
+ // 为了方便表示这里 fillString 用了ES6 的默认参数,不影响理解
268
+ String.prototype.padStart = function(maxLength, fillString = ' ') {
269
+ if (Object.prototype.toString.call(fillString) !== '[object String]') {
270
+ throw new TypeError(
271
+ 'fillString must be String'
272
+ )
273
+ }
274
+ const str = this
275
+ // 返回 String(str) 这里是为了使返回的值是字符串字面量,在控制台中更符合直觉
276
+ if (str.length >= maxLength) return String(str)
277
+
278
+ const fillLength = maxLength - str.length
279
+ let times = Math.ceil(fillLength / fillString.length)
280
+ while (times >>= 1) {
281
+ fillString += fillString
282
+ if (times === 1) {
283
+ fillString += fillString
284
+ }
285
+ }
286
+ return fillString.slice(0, fillLength) + str
287
+ }
288
+ }
289
+
290
+ /**
291
+ * @description 格式化时间
292
+ * @param {String|Number} dateTime 需要格式化的时间戳
293
+ * @param {String} fmt 格式化规则 yyyy:mm:dd|yyyy:mm|yyyy年mm月dd日|yyyy年mm月dd日 hh时MM分等,可自定义组合 默认yyyy-mm-dd
294
+ * @returns {string} 返回格式化后的字符串
295
+ */
296
+ function timeFormat(dateTime = null, formatStr = 'yyyy-mm-dd') {
297
+ let date
298
+ // 若传入时间为假值,则取当前时间
299
+ if (!dateTime) {
300
+ date = new Date()
301
+ }
302
+ // 若为unix秒时间戳,则转为毫秒时间戳(逻辑有点奇怪,但不敢改,以保证历史兼容)
303
+ else if (/^\d{10}$/.test(dateTime?.toString().trim())) {
304
+ date = new Date(dateTime * 1000)
305
+ }
306
+ // 若用户传入字符串格式时间戳,new Date无法解析,需做兼容
307
+ else if (typeof dateTime === 'string' && /^\d+$/.test(dateTime.trim())) {
308
+ date = new Date(Number(dateTime))
309
+ }
310
+ // 处理平台性差异,在Safari/Webkit中,new Date仅支持/作为分割符的字符串时间
311
+ // 处理 '2022-07-10 01:02:03',跳过 '2022-07-10T01:02:03'
312
+ else if (typeof dateTime === 'string' && dateTime.includes('-') && !dateTime.includes('T')) {
313
+ date = new Date(dateTime.replace(/-/g, '/'))
314
+ }
315
+ // 其他都认为符合 RFC 2822 规范
316
+ else {
317
+ date = new Date(dateTime)
318
+ }
319
+
320
+ const timeSource = {
321
+ 'y': date.getFullYear().toString(), // 年
322
+ 'm': (date.getMonth() + 1).toString().padStart(2, '0'), // 月
323
+ 'd': date.getDate().toString().padStart(2, '0'), // 日
324
+ 'h': date.getHours().toString().padStart(2, '0'), // 时
325
+ 'M': date.getMinutes().toString().padStart(2, '0'), // 分
326
+ 's': date.getSeconds().toString().padStart(2, '0') // 秒
327
+ // 有其他格式化字符需求可以继续添加,必须转化成字符串
328
+ }
329
+
330
+ for (const key in timeSource) {
331
+ const [ret] = new RegExp(`${key}+`).exec(formatStr) || []
332
+ if (ret) {
333
+ // 年可能只需展示两位
334
+ const beginIndex = key === 'y' && ret.length === 2 ? 2 : 0
335
+ formatStr = formatStr.replace(ret, timeSource[key].slice(beginIndex))
336
+ }
337
+ }
338
+
339
+ return formatStr
340
+ }
341
+
342
+ /**
343
+ * @description 时间戳转为多久之前
344
+ * @param {String|Number} timestamp 时间戳
345
+ * @param {String|Boolean} format
346
+ * 格式化规则如果为时间格式字符串,超出一定时间范围,返回固定的时间格式;
347
+ * 如果为布尔值false,无论什么时间,都返回多久以前的格式
348
+ * @returns {string} 转化后的内容
349
+ */
350
+ function timeFrom(timestamp = null, format = 'yyyy-mm-dd') {
351
+ if (timestamp == null) timestamp = Number(new Date())
352
+ timestamp = parseInt(timestamp)
353
+ // 判断用户输入的时间戳是秒还是毫秒,一般前端js获取的时间戳是毫秒(13位),后端传过来的为秒(10位)
354
+ if (timestamp.toString().length == 10) timestamp *= 1000
355
+ let timer = (new Date()).getTime() - timestamp
356
+ timer = parseInt(timer / 1000)
357
+ // 如果小于5分钟,则返回"刚刚",其他以此类推
358
+ let tips = ''
359
+ switch (true) {
360
+ case timer < 300:
361
+ tips = '刚刚'
362
+ break
363
+ case timer >= 300 && timer < 3600:
364
+ tips = `${parseInt(timer / 60)}分钟前`
365
+ break
366
+ case timer >= 3600 && timer < 86400:
367
+ tips = `${parseInt(timer / 3600)}小时前`
368
+ break
369
+ case timer >= 86400 && timer < 2592000:
370
+ tips = `${parseInt(timer / 86400)}天前`
371
+ break
372
+ default:
373
+ // 如果format为false,则无论什么时间戳,都显示xx之前
374
+ if (format === false) {
375
+ if (timer >= 2592000 && timer < 365 * 86400) {
376
+ tips = `${parseInt(timer / (86400 * 30))}个月前`
377
+ } else {
378
+ tips = `${parseInt(timer / (86400 * 365))}年前`
379
+ }
380
+ } else {
381
+ tips = timeFormat(timestamp, format)
382
+ }
383
+ }
384
+ return tips
385
+ }
386
+
387
+ /**
388
+ * @description 去除空格
389
+ * @param String str 需要去除空格的字符串
390
+ * @param String pos both(左右)|left|right|all 默认both
391
+ */
392
+ function trim(str, pos = 'both') {
393
+ str = String(str)
394
+ if (pos == 'both') {
395
+ return str.replace(/^\s+|\s+$/g, '')
396
+ }
397
+ if (pos == 'left') {
398
+ return str.replace(/^\s*/, '')
399
+ }
400
+ if (pos == 'right') {
401
+ return str.replace(/(\s*$)/g, '')
402
+ }
403
+ if (pos == 'all') {
404
+ return str.replace(/\s+/g, '')
405
+ }
406
+ return str
407
+ }
408
+
409
+ /**
410
+ * @description 对象转url参数
411
+ * @param {object} data,对象
412
+ * @param {Boolean} isPrefix,是否自动加上"?"
413
+ * @param {string} arrayFormat 规则 indices|brackets|repeat|comma
414
+ */
415
+ function queryParams(data = {}, isPrefix = true, arrayFormat = 'brackets') {
416
+ const prefix = isPrefix ? '?' : ''
417
+ const _result = []
418
+ if (['indices', 'brackets', 'repeat', 'comma'].indexOf(arrayFormat) == -1) arrayFormat = 'brackets'
419
+ for (const key in data) {
420
+ const value = data[key]
421
+ // 去掉为空的参数
422
+ if (['', undefined, null].indexOf(value) >= 0) {
423
+ continue
424
+ }
425
+ // 如果值为数组,另行处理
426
+ if (value.constructor === Array) {
427
+ // e.g. {ids: [1, 2, 3]}
428
+ switch (arrayFormat) {
429
+ case 'indices':
430
+ // 结果: ids[0]=1&ids[1]=2&ids[2]=3
431
+ for (let i = 0; i < value.length; i++) {
432
+ _result.push(`${key}[${i}]=${value[i]}`)
433
+ }
434
+ break
435
+ case 'brackets':
436
+ // 结果: ids[]=1&ids[]=2&ids[]=3
437
+ value.forEach((_value) => {
438
+ _result.push(`${key}[]=${_value}`)
439
+ })
440
+ break
441
+ case 'repeat':
442
+ // 结果: ids=1&ids=2&ids=3
443
+ value.forEach((_value) => {
444
+ _result.push(`${key}=${_value}`)
445
+ })
446
+ break
447
+ case 'comma':
448
+ // 结果: ids=1,2,3
449
+ let commaStr = ''
450
+ value.forEach((_value) => {
451
+ commaStr += (commaStr ? ',' : '') + _value
452
+ })
453
+ _result.push(`${key}=${commaStr}`)
454
+ break
455
+ default:
456
+ value.forEach((_value) => {
457
+ _result.push(`${key}[]=${_value}`)
458
+ })
459
+ }
460
+ } else {
461
+ _result.push(`${key}=${value}`)
462
+ }
463
+ }
464
+ return _result.length ? prefix + _result.join('&') : ''
465
+ }
466
+
467
+ /**
468
+ * 显示消息提示框
469
+ * @param {String} title 提示的内容,长度与 icon 取值有关。
470
+ * @param {Number} duration 提示的延迟时间,单位毫秒,默认:2000
471
+ */
472
+ function toast(title, duration = 2000) {
473
+ uni.showToast({
474
+ title: String(title),
475
+ icon: 'none',
476
+ duration
477
+ })
478
+ }
479
+
480
+ /**
481
+ * @description 根据主题type值,获取对应的图标
482
+ * @param {String} type 主题名称,primary|info|error|warning|success
483
+ * @param {boolean} fill 是否使用fill填充实体的图标
484
+ */
485
+ function type2icon(type = 'success', fill = false) {
486
+ // 如果非预置值,默认为success
487
+ if (['primary', 'info', 'error', 'warning', 'success'].indexOf(type) == -1) type = 'success'
488
+ let iconName = ''
489
+ // 目前(2019-12-12),info和primary使用同一个图标
490
+ switch (type) {
491
+ case 'primary':
492
+ iconName = 'info-circle'
493
+ break
494
+ case 'info':
495
+ iconName = 'info-circle'
496
+ break
497
+ case 'error':
498
+ iconName = 'close-circle'
499
+ break
500
+ case 'warning':
501
+ iconName = 'error-circle'
502
+ break
503
+ case 'success':
504
+ iconName = 'checkmark-circle'
505
+ break
506
+ default:
507
+ iconName = 'checkmark-circle'
508
+ }
509
+ // 是否是实体类型,加上-fill,在icon组件库中,实体的类名是后面加-fill的
510
+ if (fill) iconName += '-fill'
511
+ return iconName
512
+ }
513
+
514
+ /**
515
+ * @description 数字格式化
516
+ * @param {number|string} number 要格式化的数字
517
+ * @param {number} decimals 保留几位小数
518
+ * @param {string} decimalPoint 小数点符号
519
+ * @param {string} thousandsSeparator 千分位符号
520
+ * @returns {string} 格式化后的数字
521
+ */
522
+ function priceFormat(number, decimals = 0, decimalPoint = '.', thousandsSeparator = ',') {
523
+ number = (`${number}`).replace(/[^0-9+-Ee.]/g, '')
524
+ const n = !isFinite(+number) ? 0 : +number
525
+ const prec = !isFinite(+decimals) ? 0 : Math.abs(decimals)
526
+ const sep = (typeof thousandsSeparator === 'undefined') ? ',' : thousandsSeparator
527
+ const dec = (typeof decimalPoint === 'undefined') ? '.' : decimalPoint
528
+ let s = ''
529
+
530
+ s = (prec ? round(n, prec) + '' : `${Math.round(n)}`).split('.')
531
+ const re = /(-?\d+)(\d{3})/
532
+ while (re.test(s[0])) {
533
+ s[0] = s[0].replace(re, `$1${sep}$2`)
534
+ }
535
+
536
+ if ((s[1] || '').length < prec) {
537
+ s[1] = s[1] || ''
538
+ s[1] += new Array(prec - s[1].length + 1).join('0')
539
+ }
540
+ return s.join(dec)
541
+ }
542
+
543
+ /**
544
+ * @description 获取duration值
545
+ * 如果带有ms或者s直接返回,如果大于一定值,认为是ms单位,小于一定值,认为是s单位
546
+ * 比如以30位阈值,那么300大于30,可以理解为用户想要的是300ms,而不是想花300s去执行一个动画
547
+ * @param {String|number} value 比如: "1s"|"100ms"|1|100
548
+ * @param {boolean} unit 提示: 如果是false 默认返回number
549
+ * @return {string|number}
550
+ */
551
+ function getDuration(value, unit = true) {
552
+ const valueNum = parseInt(value)
553
+ if (unit) {
554
+ if (/s$/.test(value)) return value
555
+ return value > 30 ? `${value}ms` : `${value}s`
556
+ }
557
+ if (/ms$/.test(value)) return valueNum
558
+ if (/s$/.test(value)) return valueNum > 30 ? valueNum : valueNum * 1000
559
+ return valueNum
560
+ }
561
+
562
+ /**
563
+ * @description 日期的月或日补零操作
564
+ * @param {String} value 需要补零的值
565
+ */
566
+ function padZero(value) {
567
+ return `00${value}`.slice(-2)
568
+ }
569
+
570
+ /**
571
+ * @description 在u-form的子组件内容发生变化,或者失去焦点时,尝试通知u-form执行校验方法
572
+ * @param {*} instance
573
+ * @param {*} event
574
+ */
575
+ function formValidate(instance, event) {
576
+ const formItem = uni.$u.$parent.call(instance, 'u-form-item')
577
+ const form = uni.$u.$parent.call(instance, 'u-form')
578
+ // 如果发生变化的input或者textarea等,其父组件中有u-form-item或者u-form等,就执行form的validate方法
579
+ // 同时将form-item的pros传递给form,让其进行精确对象验证
580
+ if (formItem && form) {
581
+ form.validateField(formItem.prop, () => {}, event)
582
+ }
583
+ }
584
+
585
+ /**
586
+ * @description 获取某个对象下的属性,用于通过类似'a.b.c'的形式去获取一个对象的的属性的形式
587
+ * @param {object} obj 对象
588
+ * @param {string} key 需要获取的属性字段
589
+ * @returns {*}
590
+ */
591
+ function getProperty(obj, key) {
592
+ if (!obj) {
593
+ return
594
+ }
595
+ if (typeof key !== 'string' || key === '') {
596
+ return ''
597
+ }
598
+ if (key.indexOf('.') !== -1) {
599
+ const keys = key.split('.')
600
+ let firstObj = obj[keys[0]] || {}
601
+
602
+ for (let i = 1; i < keys.length; i++) {
603
+ if (firstObj) {
604
+ firstObj = firstObj[keys[i]]
605
+ }
606
+ }
607
+ return firstObj
608
+ }
609
+ return obj[key]
610
+ }
611
+
612
+ /**
613
+ * @description 设置对象的属性值,如果'a.b.c'的形式进行设置
614
+ * @param {object} obj 对象
615
+ * @param {string} key 需要设置的属性
616
+ * @param {string} value 设置的值
617
+ */
618
+ function setProperty(obj, key, value) {
619
+ if (!obj) {
620
+ return
621
+ }
622
+ // 递归赋值
623
+ const inFn = function(_obj, keys, v) {
624
+ // 最后一个属性key
625
+ if (keys.length === 1) {
626
+ _obj[keys[0]] = v
627
+ return
628
+ }
629
+ // 0~length-1个key
630
+ while (keys.length > 1) {
631
+ const k = keys[0]
632
+ if (!_obj[k] || (typeof _obj[k] !== 'object')) {
633
+ _obj[k] = {}
634
+ }
635
+ const key = keys.shift()
636
+ // 自调用判断是否存在属性,不存在则自动创建对象
637
+ inFn(_obj[k], keys, v)
638
+ }
639
+ }
640
+
641
+ if (typeof key !== 'string' || key === '') {
642
+
643
+ } else if (key.indexOf('.') !== -1) { // 支持多层级赋值操作
644
+ const keys = key.split('.')
645
+ inFn(obj, keys, value)
646
+ } else {
647
+ obj[key] = value
648
+ }
649
+ }
650
+
651
+ /**
652
+ * @description 获取当前页面路径
653
+ */
654
+ function page() {
655
+ const pages = getCurrentPages()
656
+ // 某些特殊情况下(比如页面进行redirectTo时的一些时机),pages可能为空数组
657
+ return `/${pages[pages.length - 1]?.route ?? ''}`
658
+ }
659
+
660
+ /**
661
+ * @description 获取当前路由栈实例数组
662
+ */
663
+ function pages() {
664
+ const pages = getCurrentPages()
665
+ return pages
666
+ }
667
+
668
+ /**
669
+ * 获取页面历史栈指定层实例
670
+ * @param back {number} [0] - 0或者负数,表示获取历史栈的哪一层,0表示获取当前页面实例,-1 表示获取上一个页面实例。默认0。
671
+ */
672
+ function getHistoryPage(back = 0) {
673
+ const pages = getCurrentPages()
674
+ const len = pages.length
675
+ return pages[len - 1 + back]
676
+ }
677
+
678
+ /**
679
+ * @description 修改uView内置属性值
680
+ * @param {object} props 修改内置props属性
681
+ * @param {object} config 修改内置config属性
682
+ * @param {object} color 修改内置color属性
683
+ * @param {object} zIndex 修改内置zIndex属性
684
+ */
685
+ function setConfig({
686
+ props = {},
687
+ config = {},
688
+ color = {},
689
+ zIndex = {}
690
+ }) {
691
+ const {
692
+ deepMerge,
693
+ } = uni.$u
694
+ uni.$u.config = deepMerge(uni.$u.config, config)
695
+ uni.$u.props = deepMerge(uni.$u.props, props)
696
+ uni.$u.color = deepMerge(uni.$u.color, color)
697
+ uni.$u.zIndex = deepMerge(uni.$u.zIndex, zIndex)
698
+ }
699
+
700
+ export default {
701
+ range,
702
+ getPx,
703
+ sleep,
704
+ os,
705
+ sys,
706
+ random,
707
+ guid,
708
+ $parent,
709
+ addStyle,
710
+ addUnit,
711
+ deepClone,
712
+ deepMerge,
713
+ error,
714
+ randomArray,
715
+ timeFormat,
716
+ timeFrom,
717
+ trim,
718
+ queryParams,
719
+ toast,
720
+ type2icon,
721
+ priceFormat,
722
+ getDuration,
723
+ padZero,
724
+ formValidate,
725
+ getProperty,
726
+ setProperty,
727
+ page,
728
+ pages,
729
+ getHistoryPage,
730
+ setConfig
731
+ }