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,223 @@
1
+ <template>
2
+ <view
3
+ class="u-text"
4
+ :class="[]"
5
+ v-if="show"
6
+ :style="{
7
+ margin: margin,
8
+ justifyContent: align === 'left' ? 'flex-start' : align === 'center' ? 'center' : 'flex-end'
9
+ }"
10
+ @tap="clickHandler"
11
+ >
12
+ <text
13
+ :class="['u-text__price', type && `u-text__value--${type}`]"
14
+ v-if="mode === 'price'"
15
+ :style="[valueStyle]"
16
+ >¥</text
17
+ >
18
+ <view class="u-text__prefix-icon" v-if="prefixIcon">
19
+ <u-icon
20
+ :name="prefixIcon"
21
+ :customStyle="$u.addStyle(iconStyle)"
22
+ ></u-icon>
23
+ </view>
24
+ <u-link
25
+ v-if="mode === 'link'"
26
+ :text="value"
27
+ :href="href"
28
+ underLine
29
+ ></u-link>
30
+ <template v-else-if="openType && isMp">
31
+ <button
32
+ class="u-reset-button u-text__value"
33
+ :style="[valueStyle]"
34
+ :data-index="index"
35
+ :openType="openType"
36
+ @getuserinfo="onGetUserInfo"
37
+ @contact="onContact"
38
+ @getphonenumber="onGetPhoneNumber"
39
+ @error="onError"
40
+ @launchapp="onLaunchApp"
41
+ @opensetting="onOpenSetting"
42
+ :lang="lang"
43
+ :session-from="sessionFrom"
44
+ :send-message-title="sendMessageTitle"
45
+ :send-message-path="sendMessagePath"
46
+ :send-message-img="sendMessageImg"
47
+ :show-message-card="showMessageCard"
48
+ :app-parameter="appParameter"
49
+ >
50
+ {{ value }}
51
+ </button>
52
+ </template>
53
+ <text
54
+ v-else
55
+ class="u-text__value"
56
+ :style="[valueStyle]"
57
+ :class="[
58
+ type && `u-text__value--${type}`,
59
+ lines && `u-line-${lines}`
60
+ ]"
61
+ >{{ value }}</text
62
+ >
63
+ <view class="u-text__suffix-icon" v-if="suffixIcon">
64
+ <u-icon
65
+ :name="suffixIcon"
66
+ :customStyle="$u.addStyle(iconStyle)"
67
+ ></u-icon>
68
+ </view>
69
+ </view>
70
+ </template>
71
+
72
+ <script>
73
+ import value from './value.js'
74
+ import button from '../../libs/mixin/button.js'
75
+ import openType from '../../libs/mixin/openType.js'
76
+ import props from './props.js'
77
+ /**
78
+ * Text 文本
79
+ * @description 此组件集成了文本类在项目中的常用功能,包括状态,拨打电话,格式化日期,*替换,超链接...等功能。 您大可不必在使用特殊文本时自己定义,text组件几乎涵盖您能使用的大部分场景。
80
+ * @tutorial https://www.uviewui.com/components/loading.html
81
+ * @property {String} type 主题颜色
82
+ * @property {Boolean} show 是否显示(默认 true )
83
+ * @property {String | Number} text 显示的值
84
+ * @property {String} prefixIcon 前置图标
85
+ * @property {String} suffixIcon 后置图标
86
+ * @property {String} mode 文本处理的匹配模式 text-普通文本,price-价格,phone-手机号,name-姓名,date-日期,link-超链接
87
+ * @property {String} href mode=link下,配置的链接
88
+ * @property {String | Function} format 格式化规则
89
+ * @property {Boolean} call mode=phone时,点击文本是否拨打电话(默认 false )
90
+ * @property {String} openType 小程序的打开方式
91
+ * @property {Boolean} bold 是否粗体,默认normal(默认 false )
92
+ * @property {Boolean} block 是否块状(默认 false )
93
+ * @property {String | Number} lines 文本显示的行数,如果设置,超出此行数,将会显示省略号
94
+ * @property {String} color 文本颜色(默认 '#303133' )
95
+ * @property {String | Number} size 字体大小(默认 15 )
96
+ * @property {Object | String} iconStyle 图标的样式 (默认 {fontSize: '15px'} )
97
+ * @property {String} decoration 文字装饰,下划线,中划线等,可选值 none|underline|line-through(默认 'none' )
98
+ * @property {Object | String | Number} margin 外边距,对象、字符串,数值形式均可(默认 0 )
99
+ * @property {String | Number} lineHeight 文本行高
100
+ * @property {String} align 文本对齐方式,可选值left|center|right(默认 'left' )
101
+ * @property {String} wordWrap 文字换行,可选值break-word|normal|anywhere(默认 'normal' )
102
+ * @event {Function} click 点击触发事件
103
+ * @example <u--text text="我用十年青春,赴你最后之约"></u--text>
104
+ */
105
+ export default {
106
+ name: 'u--text',
107
+ // #ifdef MP
108
+ mixins: [uni.$u.mpMixin, uni.$u.mixin, value, button, openType, props],
109
+ // #endif
110
+ // #ifndef MP
111
+ mixins: [uni.$u.mpMixin, uni.$u.mixin, value, props],
112
+ // #endif
113
+ computed: {
114
+ valueStyle() {
115
+ const style = {
116
+ textDecoration: this.decoration,
117
+ fontWeight: this.bold ? 'bold' : 'normal',
118
+ wordWrap: this.wordWrap,
119
+ fontSize: uni.$u.addUnit(this.size)
120
+ }
121
+ !this.type && (style.color = this.color)
122
+ this.isNvue && this.lines && (style.lines = this.lines)
123
+ this.lineHeight &&
124
+ (style.lineHeight = uni.$u.addUnit(this.lineHeight))
125
+ !this.isNvue && this.block && (style.display = 'block')
126
+ return uni.$u.deepMerge(style, uni.$u.addStyle(this.customStyle))
127
+ },
128
+ isNvue() {
129
+ let nvue = false
130
+ // #ifdef APP-NVUE
131
+ nvue = true
132
+ // #endif
133
+ return nvue
134
+ },
135
+ isMp() {
136
+ let mp = false
137
+ // #ifdef MP
138
+ mp = true
139
+ // #endif
140
+ return mp
141
+ }
142
+ },
143
+ data() {
144
+ return {}
145
+ },
146
+ methods: {
147
+ clickHandler() {
148
+ // 如果为手机号模式,拨打电话
149
+ if (this.call && this.mode === 'phone') {
150
+ uni.makePhoneCall({
151
+ phoneNumber: this.text
152
+ })
153
+ }
154
+ this.$emit('click')
155
+ }
156
+ }
157
+ }
158
+ </script>
159
+
160
+ <style lang="scss" scoped>
161
+ @import '../../libs/css/components.scss';
162
+
163
+ .u-text {
164
+ @include flex(row);
165
+ align-items: center;
166
+ flex-wrap: nowrap;
167
+ flex: 1;
168
+ /* #ifndef APP-NVUE */
169
+ width: 100%;
170
+ /* #endif */
171
+
172
+ &__price {
173
+ font-size: 14px;
174
+ color: $u-content-color;
175
+ }
176
+
177
+ &__value {
178
+ font-size: 14px;
179
+ @include flex;
180
+ color: $u-content-color;
181
+ flex-wrap: wrap;
182
+ // flex: 1;
183
+ text-overflow: ellipsis;
184
+ align-items: center;
185
+
186
+ &--primary {
187
+ color: $u-primary;
188
+ }
189
+
190
+ &--warning {
191
+ color: $u-warning;
192
+ }
193
+
194
+ &--success {
195
+ color: $u-success;
196
+ }
197
+
198
+ &--info {
199
+ color: $u-info;
200
+ }
201
+
202
+ &--error {
203
+ color: $u-error;
204
+ }
205
+
206
+ &--main {
207
+ color: $u-main-color;
208
+ }
209
+
210
+ &--content {
211
+ color: $u-content-color;
212
+ }
213
+
214
+ &--tips {
215
+ color: $u-tips-color;
216
+ }
217
+
218
+ &--light {
219
+ color: $u-light-color;
220
+ }
221
+ }
222
+ }
223
+ </style>
@@ -0,0 +1,85 @@
1
+ export default {
2
+ computed: {
3
+ // 经处理后需要显示的值
4
+ value() {
5
+ const {
6
+ text,
7
+ mode,
8
+ format,
9
+ href
10
+ } = this
11
+ // 价格类型
12
+ if (mode === 'price') {
13
+ // 如果text不为金额进行提示
14
+ if (!/^\d+(\.\d+)?$/.test(text)) {
15
+ uni.$u.error('金额模式下,text参数需要为金额格式');
16
+ }
17
+ // 进行格式化,判断用户传入的format参数为正则,或者函数,如果没有传入format,则使用默认的金额格式化处理
18
+ if (uni.$u.test.func(format)) {
19
+ // 如果用户传入的是函数,使用函数格式化
20
+ return format(text)
21
+ }
22
+ // 如果format非正则,非函数,则使用默认的金额格式化方法进行操作
23
+ return uni.$u.priceFormat(text, 2)
24
+ } if (mode === 'date') {
25
+ // 判断是否合法的日期或者时间戳
26
+ !uni.$u.test.date(text) && uni.$u.error('日期模式下,text参数需要为日期或时间戳格式')
27
+ // 进行格式化,判断用户传入的format参数为正则,或者函数,如果没有传入format,则使用默认的格式化处理
28
+ if (uni.$u.test.func(format)) {
29
+ // 如果用户传入的是函数,使用函数格式化
30
+ return format(text)
31
+ } if (format) {
32
+ // 如果format非正则,非函数,则使用默认的时间格式化方法进行操作
33
+ return uni.$u.timeFormat(text, format)
34
+ }
35
+ // 如果没有设置format,则设置为默认的时间格式化形式
36
+ return uni.$u.timeFormat(text, 'yyyy-mm-dd')
37
+ } if (mode === 'phone') {
38
+ // 判断是否合法的手机号
39
+ // !uni.$u.test.mobile(text) && uni.$u.error('手机号模式下,text参数需要为手机号码格式')
40
+ if (uni.$u.test.func(format)) {
41
+ // 如果用户传入的是函数,使用函数格式化
42
+ return format(text)
43
+ } if (format === 'encrypt') {
44
+ // 如果format为encrypt,则将手机号进行星号加密处理
45
+ return `${text.substr(0, 3)}****${text.substr(7)}`
46
+ }
47
+ return text
48
+ } if (mode === 'name') {
49
+ // 判断是否合法的字符粗
50
+ !(typeof (text) === 'string') && uni.$u.error('姓名模式下,text参数需要为字符串格式')
51
+ if (uni.$u.test.func(format)) {
52
+ // 如果用户传入的是函数,使用函数格式化
53
+ return format(text)
54
+ } if (format === 'encrypt') {
55
+ // 如果format为encrypt,则将姓名进行星号加密处理
56
+ return this.formatName(text)
57
+ }
58
+ return text
59
+ } if (mode === 'link') {
60
+ // 判断是否合法的字符粗
61
+ !uni.$u.test.url(href) && uni.$u.error('超链接模式下,href参数需要为URL格式')
62
+ return text
63
+ }
64
+ return text
65
+ }
66
+ },
67
+ methods: {
68
+ // 默认的姓名脱敏规则
69
+ formatName(name) {
70
+ let value = ''
71
+ if (name.length === 2) {
72
+ value = name.substr(0, 1) + '*'
73
+ } else if (name.length > 2) {
74
+ let char = ''
75
+ for (let i = 0, len = name.length - 2; i < len; i++) {
76
+ char += '*'
77
+ }
78
+ value = name.substr(0, 1) + char + name.substr(-1, 1)
79
+ } else {
80
+ value = name
81
+ }
82
+ return value
83
+ }
84
+ }
85
+ }
@@ -0,0 +1,119 @@
1
+ export default {
2
+ props: {
3
+ // 输入框的内容
4
+ value: {
5
+ type: [String, Number],
6
+ default: uni.$u.props.textarea.value
7
+ },
8
+ // 输入框为空时占位符
9
+ placeholder: {
10
+ type: [String, Number],
11
+ default: uni.$u.props.textarea.placeholder
12
+ },
13
+ // 指定placeholder的样式类,注意页面或组件的style中写了scoped时,需要在类名前写/deep/
14
+ placeholderClass: {
15
+ type: String,
16
+ default: uni.$u.props.input.placeholderClass
17
+ },
18
+ // 指定placeholder的样式
19
+ placeholderStyle: {
20
+ type: [String, Object],
21
+ default: uni.$u.props.input.placeholderStyle
22
+ },
23
+ // 输入框高度
24
+ height: {
25
+ type: [String, Number],
26
+ default: uni.$u.props.textarea.height
27
+ },
28
+ // 设置键盘右下角按钮的文字,仅微信小程序,App-vue和H5有效
29
+ confirmType: {
30
+ type: String,
31
+ default: uni.$u.props.textarea.confirmType
32
+ },
33
+ // 是否禁用
34
+ disabled: {
35
+ type: Boolean,
36
+ default: uni.$u.props.textarea.disabled
37
+ },
38
+ // 是否显示统计字数
39
+ count: {
40
+ type: Boolean,
41
+ default: uni.$u.props.textarea.count
42
+ },
43
+ // 是否自动获取焦点,nvue不支持,H5取决于浏览器的实现
44
+ focus: {
45
+ type: Boolean,
46
+ default: uni.$u.props.textarea.focus
47
+ },
48
+ // 是否自动增加高度
49
+ autoHeight: {
50
+ type: Boolean,
51
+ default: uni.$u.props.textarea.autoHeight
52
+ },
53
+ // 如果textarea是在一个position:fixed的区域,需要显示指定属性fixed为true
54
+ fixed: {
55
+ type: Boolean,
56
+ default: uni.$u.props.textarea.fixed
57
+ },
58
+ // 指定光标与键盘的距离
59
+ cursorSpacing: {
60
+ type: Number,
61
+ default: uni.$u.props.textarea.cursorSpacing
62
+ },
63
+ // 指定focus时的光标位置
64
+ cursor: {
65
+ type: [String, Number],
66
+ default: uni.$u.props.textarea.cursor
67
+ },
68
+ // 是否显示键盘上方带有”完成“按钮那一栏,
69
+ showConfirmBar: {
70
+ type: Boolean,
71
+ default: uni.$u.props.textarea.showConfirmBar
72
+ },
73
+ // 光标起始位置,自动聚焦时有效,需与selection-end搭配使用
74
+ selectionStart: {
75
+ type: Number,
76
+ default: uni.$u.props.textarea.selectionStart
77
+ },
78
+ // 光标结束位置,自动聚焦时有效,需与selection-start搭配使用
79
+ selectionEnd: {
80
+ type: Number,
81
+ default: uni.$u.props.textarea.selectionEnd
82
+ },
83
+ // 键盘弹起时,是否自动上推页面
84
+ adjustPosition: {
85
+ type: Boolean,
86
+ default: uni.$u.props.textarea.adjustPosition
87
+ },
88
+ // 是否去掉 iOS 下的默认内边距,只微信小程序有效
89
+ disableDefaultPadding: {
90
+ type: Boolean,
91
+ default: uni.$u.props.textarea.disableDefaultPadding
92
+ },
93
+ // focus时,点击页面的时候不收起键盘,只微信小程序有效
94
+ holdKeyboard: {
95
+ type: Boolean,
96
+ default: uni.$u.props.textarea.holdKeyboard
97
+ },
98
+ // 最大输入长度,设置为 -1 的时候不限制最大长度
99
+ maxlength: {
100
+ type: [String, Number],
101
+ default: uni.$u.props.textarea.maxlength
102
+ },
103
+ // 边框类型,surround-四周边框,bottom-底部边框
104
+ border: {
105
+ type: String,
106
+ default: uni.$u.props.textarea.border
107
+ },
108
+ // 用于处理或者过滤输入框内容的方法
109
+ formatter: {
110
+ type: [Function, null],
111
+ default: uni.$u.props.textarea.formatter
112
+ },
113
+ // 是否忽略组件内对文本合成系统事件的处理
114
+ ignoreCompositionEvent: {
115
+ type: Boolean,
116
+ default: true
117
+ }
118
+ }
119
+ }
@@ -0,0 +1,239 @@
1
+ <template>
2
+ <view class="u-textarea" :class="textareaClass" :style="[textareaStyle]">
3
+ <textarea
4
+ class="u-textarea__field"
5
+ :value="innerValue"
6
+ :style="{ height: $u.addUnit(height) }"
7
+ :placeholder="placeholder"
8
+ :placeholder-style="$u.addStyle(placeholderStyle, 'string')"
9
+ :placeholder-class="placeholderClass"
10
+ :disabled="disabled"
11
+ :focus="focus"
12
+ :autoHeight="autoHeight"
13
+ :fixed="fixed"
14
+ :cursorSpacing="cursorSpacing"
15
+ :cursor="cursor"
16
+ :showConfirmBar="showConfirmBar"
17
+ :selectionStart="selectionStart"
18
+ :selectionEnd="selectionEnd"
19
+ :adjustPosition="adjustPosition"
20
+ :disableDefaultPadding="disableDefaultPadding"
21
+ :holdKeyboard="holdKeyboard"
22
+ :maxlength="maxlength"
23
+ :confirmType="confirmType"
24
+ :ignoreCompositionEvent="ignoreCompositionEvent"
25
+ @focus="onFocus"
26
+ @blur="onBlur"
27
+ @linechange="onLinechange"
28
+ @input="onInput"
29
+ @confirm="onConfirm"
30
+ @keyboardheightchange="onKeyboardheightchange"
31
+ ></textarea>
32
+ <text
33
+ class="u-textarea__count"
34
+ :style="{
35
+ 'background-color': disabled ? 'transparent' : '#fff',
36
+ }"
37
+ v-if="count"
38
+ >{{ innerValue.length }}/{{ maxlength }}</text
39
+ >
40
+ </view>
41
+ </template>
42
+
43
+ <script>
44
+ import props from "./props.js";
45
+ /**
46
+ * Textarea 文本域
47
+ * @description 文本域此组件满足了可能出现的表单信息补充,编辑等实际逻辑的功能,内置了字数校验等
48
+ * @tutorial https://www.uviewui.com/components/textarea.html
49
+ *
50
+ * @property {String | Number} value 输入框的内容
51
+ * @property {String | Number} placeholder 输入框为空时占位符
52
+ * @property {String} placeholderClass 指定placeholder的样式类,注意页面或组件的style中写了scoped时,需要在类名前写/deep/ ( 默认 'input-placeholder' )
53
+ * @property {String | Object} placeholderStyle 指定placeholder的样式,字符串/对象形式,如"color: red;"
54
+ * @property {String | Number} height 输入框高度(默认 70 )
55
+ * @property {String} confirmType 设置键盘右下角按钮的文字,仅微信小程序,App-vue和H5有效(默认 'done' )
56
+ * @property {Boolean} disabled 是否禁用(默认 false )
57
+ * @property {Boolean} count 是否显示统计字数(默认 false )
58
+ * @property {Boolean} focus 是否自动获取焦点,nvue不支持,H5取决于浏览器的实现(默认 false )
59
+ * @property {Boolean | Function} autoHeight 是否自动增加高度(默认 false )
60
+ * @property {Boolean} fixed 如果textarea是在一个position:fixed的区域,需要显示指定属性fixed为true(默认 false )
61
+ * @property {Number} cursorSpacing 指定光标与键盘的距离(默认 0 )
62
+ * @property {String | Number} cursor 指定focus时的光标位置
63
+ * @property {Function} formatter 内容式化函数
64
+ * @property {Boolean} showConfirmBar 是否显示键盘上方带有”完成“按钮那一栏,(默认 true )
65
+ * @property {Number} selectionStart 光标起始位置,自动聚焦时有效,需与selection-end搭配使用,(默认 -1 )
66
+ * @property {Number | Number} selectionEnd 光标结束位置,自动聚焦时有效,需与selection-start搭配使用(默认 -1 )
67
+ * @property {Boolean} adjustPosition 键盘弹起时,是否自动上推页面(默认 true )
68
+ * @property {Boolean | Number} disableDefaultPadding 是否去掉 iOS 下的默认内边距,只微信小程序有效(默认 false )
69
+ * @property {Boolean} holdKeyboard focus时,点击页面的时候不收起键盘,只微信小程序有效(默认 false )
70
+ * @property {String | Number} maxlength 最大输入长度,设置为 -1 的时候不限制最大长度(默认 140 )
71
+ * @property {String} border 边框类型,surround-四周边框,none-无边框,bottom-底部边框(默认 'surround' )
72
+ * @property {Boolean} ignoreCompositionEvent 是否忽略组件内对文本合成系统事件的处理
73
+ *
74
+ * @event {Function(e)} focus 输入框聚焦时触发,event.detail = { value, height },height 为键盘高度
75
+ * @event {Function(e)} blur 输入框失去焦点时触发,event.detail = {value, cursor}
76
+ * @event {Function(e)} linechange 输入框行数变化时调用,event.detail = {height: 0, heightRpx: 0, lineCount: 0}
77
+ * @event {Function(e)} input 当键盘输入时,触发 input 事件
78
+ * @event {Function(e)} confirm 点击完成时, 触发 confirm 事件
79
+ * @event {Function(e)} keyboardheightchange 键盘高度发生变化的时候触发此事件
80
+ * @example <u--textarea v-model="value1" placeholder="请输入内容" ></u--textarea>
81
+ */
82
+ export default {
83
+ name: "u-textarea",
84
+ mixins: [uni.$u.mpMixin, uni.$u.mixin, props],
85
+ data() {
86
+ return {
87
+ // 输入框的值
88
+ innerValue: "",
89
+ // 是否处于获得焦点状态
90
+ focused: false,
91
+ // value是否第一次变化,在watch中,由于加入immediate属性,会在第一次触发,此时不应该认为value发生了变化
92
+ firstChange: true,
93
+ // value绑定值的变化是由内部还是外部引起的
94
+ changeFromInner: false,
95
+ // 过滤处理方法
96
+ innerFormatter: value => value
97
+ }
98
+ },
99
+ watch: {
100
+ value: {
101
+ immediate: true,
102
+ handler(newVal, oldVal) {
103
+ this.innerValue = newVal;
104
+ /* #ifdef H5 */
105
+ // 在H5中,外部value变化后,修改input中的值,不会触发@input事件,此时手动调用值变化方法
106
+ if (
107
+ this.firstChange === false &&
108
+ this.changeFromInner === false
109
+ ) {
110
+ this.valueChange();
111
+ }
112
+ /* #endif */
113
+ this.firstChange = false;
114
+ // 重置changeFromInner的值为false,标识下一次引起默认为外部引起的
115
+ this.changeFromInner = false;
116
+ },
117
+ },
118
+ },
119
+ computed: {
120
+ // 组件的类名
121
+ textareaClass() {
122
+ let classes = [],
123
+ { border, disabled, shape } = this;
124
+ border === "surround" &&
125
+ (classes = classes.concat(["u-border", "u-textarea--radius"]));
126
+ border === "bottom" &&
127
+ (classes = classes.concat([
128
+ "u-border-bottom",
129
+ "u-textarea--no-radius",
130
+ ]));
131
+ disabled && classes.push("u-textarea--disabled");
132
+ return classes.join(" ");
133
+ },
134
+ // 组件的样式
135
+ textareaStyle() {
136
+ const style = {};
137
+ // #ifdef APP-NVUE
138
+ // 由于textarea在安卓nvue上的差异性,需要额外再调整其内边距
139
+ if (uni.$u.os() === "android") {
140
+ style.paddingTop = "6px";
141
+ style.paddingLeft = "9px";
142
+ style.paddingBottom = "3px";
143
+ style.paddingRight = "6px";
144
+ }
145
+ // #endif
146
+ return uni.$u.deepMerge(style, uni.$u.addStyle(this.customStyle));
147
+ },
148
+ },
149
+ methods: {
150
+ // 在微信小程序中,不支持将函数当做props参数,故只能通过ref形式调用
151
+ setFormatter(e) {
152
+ this.innerFormatter = e
153
+ },
154
+ onFocus(e) {
155
+ this.$emit("focus", e);
156
+ },
157
+ onBlur(e) {
158
+ this.$emit("blur", e);
159
+ // 尝试调用u-form的验证方法
160
+ uni.$u.formValidate(this, "blur");
161
+ },
162
+ onLinechange(e) {
163
+ this.$emit("linechange", e);
164
+ },
165
+ onInput(e) {
166
+ let { value = "" } = e.detail || {};
167
+ // 格式化过滤方法
168
+ const formatter = this.formatter || this.innerFormatter
169
+ const formatValue = formatter(value)
170
+ // 为了避免props的单向数据流特性,需要先将innerValue值设置为当前值,再在$nextTick中重新赋予设置后的值才有效
171
+ this.innerValue = value
172
+ this.$nextTick(() => {
173
+ this.innerValue = formatValue;
174
+ this.valueChange();
175
+ })
176
+ },
177
+ // 内容发生变化,进行处理
178
+ valueChange() {
179
+ const value = this.innerValue;
180
+ this.$nextTick(() => {
181
+ this.$emit("input", value);
182
+ // 标识value值的变化是由内部引起的
183
+ this.changeFromInner = true;
184
+ this.$emit("change", value);
185
+ // 尝试调用u-form的验证方法
186
+ uni.$u.formValidate(this, "change");
187
+ });
188
+ },
189
+ onConfirm(e) {
190
+ this.$emit("confirm", e);
191
+ },
192
+ onKeyboardheightchange(e) {
193
+ this.$emit("keyboardheightchange", e);
194
+ },
195
+ },
196
+ };
197
+ </script>
198
+
199
+ <style lang="scss" scoped>
200
+ @import "../../libs/css/components.scss";
201
+
202
+ .u-textarea {
203
+ border-radius: 4px;
204
+ background-color: #fff;
205
+ position: relative;
206
+ @include flex;
207
+ flex: 1;
208
+ padding: 9px;
209
+
210
+ &--radius {
211
+ border-radius: 4px;
212
+ }
213
+
214
+ &--no-radius {
215
+ border-radius: 0;
216
+ }
217
+
218
+ &--disabled {
219
+ background-color: #f5f7fa;
220
+ }
221
+
222
+ &__field {
223
+ flex: 1;
224
+ font-size: 15px;
225
+ color: $u-content-color;
226
+ width: 100%;
227
+ }
228
+
229
+ &__count {
230
+ position: absolute;
231
+ right: 5px;
232
+ bottom: 2px;
233
+ font-size: 12px;
234
+ color: $u-tips-color;
235
+ background-color: #ffffff;
236
+ padding: 1px 4px;
237
+ }
238
+ }
239
+ </style>