@zfqh/uniapp 0.1.1

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 (310) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/LICENSE +21 -0
  3. package/README.md +39 -0
  4. package/docs/api/apis/core.md +189 -0
  5. package/docs/api/apis/index.md +82 -0
  6. package/docs/api/apis/request.md +369 -0
  7. package/docs/api/configs/api.md +32 -0
  8. package/docs/api/configs/app.md +43 -0
  9. package/docs/api/configs/brand.md +43 -0
  10. package/docs/api/configs/cdn.md +35 -0
  11. package/docs/api/configs/color.md +144 -0
  12. package/docs/api/configs/env.md +120 -0
  13. package/docs/api/configs/index.md +394 -0
  14. package/docs/api/configs/link.md +33 -0
  15. package/docs/api/configs/log.md +27 -0
  16. package/docs/api/configs/mp.md +34 -0
  17. package/docs/api/configs/navigate.md +27 -0
  18. package/docs/api/configs/page.md +32 -0
  19. package/docs/api/configs/path.md +27 -0
  20. package/docs/api/configs/storage.md +24 -0
  21. package/docs/api/configs/tabbar.md +29 -0
  22. package/docs/api/configs/toast.md +35 -0
  23. package/docs/api/configs/update.md +25 -0
  24. package/docs/api/configs/upload.md +45 -0
  25. package/docs/api/configs/ver.md +32 -0
  26. package/docs/api/configs/web.md +28 -0
  27. package/docs/api/hooks/index.md +182 -0
  28. package/docs/api/hooks/useI18n.md +27 -0
  29. package/docs/api/hooks/useOverlay.md +37 -0
  30. package/docs/api/hooks/usePopup.md +35 -0
  31. package/docs/api/hooks/useVersion.md +23 -0
  32. package/docs/api/index.md +269 -0
  33. package/docs/api/mixins/app.md +29 -0
  34. package/docs/api/mixins/badge.md +23 -0
  35. package/docs/api/mixins/debounce.md +32 -0
  36. package/docs/api/mixins/deep.md +29 -0
  37. package/docs/api/mixins/index.md +23 -0
  38. package/docs/api/mixins/login.md +22 -0
  39. package/docs/api/mixins/model.md +26 -0
  40. package/docs/api/mixins/redirect.md +26 -0
  41. package/docs/api/mixins/share.md +29 -0
  42. package/docs/api/mixins/show.md +27 -0
  43. package/docs/api/mixins/webview.md +27 -0
  44. package/docs/api/modules/app.md +30 -0
  45. package/docs/api/modules/dict.md +28 -0
  46. package/docs/api/modules/im.md +22 -0
  47. package/docs/api/modules/index.md +44 -0
  48. package/docs/api/modules/launch.md +26 -0
  49. package/docs/api/modules/location.md +25 -0
  50. package/docs/api/modules/login.md +35 -0
  51. package/docs/api/modules/network.md +26 -0
  52. package/docs/api/modules/system.md +29 -0
  53. package/docs/api/utils/audio.md +84 -0
  54. package/docs/api/utils/consts.md +201 -0
  55. package/docs/api/utils/cos.md +269 -0
  56. package/docs/api/utils/debounce.md +89 -0
  57. package/docs/api/utils/file.md +78 -0
  58. package/docs/api/utils/index.md +547 -0
  59. package/docs/api/utils/locale.md +32 -0
  60. package/docs/api/utils/message.md +81 -0
  61. package/docs/api/utils/navigate.md +267 -0
  62. package/docs/api/utils/pages.md +205 -0
  63. package/docs/api/utils/permission.md +28 -0
  64. package/docs/api/utils/permit.md +62 -0
  65. package/docs/api/utils/query.md +89 -0
  66. package/docs/api/utils/request.md +34 -0
  67. package/docs/api/utils/storage.md +145 -0
  68. package/docs/api/utils/subscribe.md +77 -0
  69. package/docs/api/utils/throttle.md +101 -0
  70. package/docs/api/utils/toast.md +164 -0
  71. package/docs/api/utils/uni.md +28 -0
  72. package/docs/api/utils/update.md +165 -0
  73. package/docs/components/g-back-button.md +76 -0
  74. package/docs/components/g-checkbox-list.md +101 -0
  75. package/docs/components/g-container.md +93 -0
  76. package/docs/components/g-data-list.md +106 -0
  77. package/docs/components/g-dot-text.md +79 -0
  78. package/docs/components/g-env.md +75 -0
  79. package/docs/components/g-float.md +83 -0
  80. package/docs/components/g-grid-image.md +91 -0
  81. package/docs/components/g-grid-swiper.md +99 -0
  82. package/docs/components/g-icon.md +106 -0
  83. package/docs/components/g-mask.md +82 -0
  84. package/docs/components/g-money.md +90 -0
  85. package/docs/components/g-more.md +78 -0
  86. package/docs/components/g-page-container.md +170 -0
  87. package/docs/components/g-permission-popup.md +117 -0
  88. package/docs/components/g-polyline-chat.md +102 -0
  89. package/docs/components/g-polyline-view.md +67 -0
  90. package/docs/components/g-popup.md +144 -0
  91. package/docs/components/g-refresh-view.md +118 -0
  92. package/docs/components/g-render-image.md +83 -0
  93. package/docs/components/g-search.md +120 -0
  94. package/docs/components/g-share-photo.md +77 -0
  95. package/docs/components/g-share-view.md +83 -0
  96. package/docs/components/g-share-weixin.md +81 -0
  97. package/docs/components/g-skeleton-view.md +71 -0
  98. package/docs/components/g-skeleton.md +64 -0
  99. package/docs/components/g-tag-editor.md +134 -0
  100. package/docs/components/g-timer.md +72 -0
  101. package/docs/components/g-trtc-room.md +116 -0
  102. package/docs/components/g-trtc-tui.md +84 -0
  103. package/docs/components/g-trtc.md +124 -0
  104. package/docs/components/g-upload.md +117 -0
  105. package/docs/components/g-waterfall.md +84 -0
  106. package/docs/components/index.md +109 -0
  107. package/docs/components/styles/base-styles.md +367 -0
  108. package/docs/components/styles/global-vars.md +150 -0
  109. package/docs/components/usage.md +112 -0
  110. package/docs/faq/index.md +78 -0
  111. package/docs/guide/getting-started.md +195 -0
  112. package/docs/guide/project-frame.md +297 -0
  113. package/docs/index.md +80 -0
  114. package/lib/apis/core.d.ts +12 -0
  115. package/lib/apis/core.js +13 -0
  116. package/lib/apis/index.d.ts +2 -0
  117. package/lib/apis/index.js +2 -0
  118. package/lib/apis/request.d.ts +4 -0
  119. package/lib/apis/request.js +27 -0
  120. package/lib/components/g-back-button/g-back-button.vue +141 -0
  121. package/lib/components/g-checkbox-list/g-checkbox-list.vue +156 -0
  122. package/lib/components/g-container/g-container.vue +159 -0
  123. package/lib/components/g-data-list/g-data-list.vue +192 -0
  124. package/lib/components/g-dot-text/g-dot-text.vue +114 -0
  125. package/lib/components/g-env/g-env.vue +123 -0
  126. package/lib/components/g-float/g-float.vue +131 -0
  127. package/lib/components/g-grid-image/g-grid-image.vue +84 -0
  128. package/lib/components/g-grid-swiper/g-grid-swiper.vue +224 -0
  129. package/lib/components/g-icon/g-icon.vue +72 -0
  130. package/lib/components/g-mask/g-mask.vue +126 -0
  131. package/lib/components/g-money/g-money.vue +174 -0
  132. package/lib/components/g-more/g-more.vue +68 -0
  133. package/lib/components/g-page-container/g-page-container.vue +470 -0
  134. package/lib/components/g-permission-popup/g-permission-popup.vue +80 -0
  135. package/lib/components/g-polyline-chat/g-polyline-chat.vue +255 -0
  136. package/lib/components/g-polyline-view/g-polyline-view.vue +104 -0
  137. package/lib/components/g-popup/g-popup.vue +449 -0
  138. package/lib/components/g-refresh-view/g-refresh-view.vue +213 -0
  139. package/lib/components/g-render-image/g-render-image.vue +222 -0
  140. package/lib/components/g-search/g-search.vue +274 -0
  141. package/lib/components/g-share-photo/g-share-photo.vue +75 -0
  142. package/lib/components/g-share-view/g-share-view.vue +157 -0
  143. package/lib/components/g-share-weixin/g-share-weixin.vue +106 -0
  144. package/lib/components/g-skeleton/g-skeleton.vue +55 -0
  145. package/lib/components/g-skeleton-view/g-skeleton-view.vue +78 -0
  146. package/lib/components/g-tag-editor/g-tag-editor.vue +482 -0
  147. package/lib/components/g-timer/g-timer.vue +61 -0
  148. package/lib/components/g-trtc/g-trtc.vue +347 -0
  149. package/lib/components/g-trtc-room/g-trtc-room.vue +524 -0
  150. package/lib/components/g-trtc-room/iconfont.scss +59 -0
  151. package/lib/components/g-trtc-tui/g-trtc-tui.vue +245 -0
  152. package/lib/components/g-upload/g-upload.vue +294 -0
  153. package/lib/components/g-waterfall/g-waterfall.vue +101 -0
  154. package/lib/configs/api.d.ts +7 -0
  155. package/lib/configs/api.js +6 -0
  156. package/lib/configs/app.d.ts +26 -0
  157. package/lib/configs/app.js +50 -0
  158. package/lib/configs/brand.d.ts +22 -0
  159. package/lib/configs/brand.js +26 -0
  160. package/lib/configs/cdn.d.ts +13 -0
  161. package/lib/configs/cdn.js +12 -0
  162. package/lib/configs/color.d.ts +62 -0
  163. package/lib/configs/color.js +66 -0
  164. package/lib/configs/env.d.ts +37 -0
  165. package/lib/configs/env.js +71 -0
  166. package/lib/configs/index.d.ts +170 -0
  167. package/lib/configs/index.js +82 -0
  168. package/lib/configs/link.d.ts +11 -0
  169. package/lib/configs/link.js +3 -0
  170. package/lib/configs/log.d.ts +9 -0
  171. package/lib/configs/log.js +8 -0
  172. package/lib/configs/mp.d.ts +15 -0
  173. package/lib/configs/mp.js +9 -0
  174. package/lib/configs/navigate.d.ts +17 -0
  175. package/lib/configs/navigate.js +5 -0
  176. package/lib/configs/page.d.ts +18 -0
  177. package/lib/configs/page.js +14 -0
  178. package/lib/configs/path.d.ts +11 -0
  179. package/lib/configs/path.js +10 -0
  180. package/lib/configs/storage.d.ts +7 -0
  181. package/lib/configs/storage.js +6 -0
  182. package/lib/configs/tabbar.d.ts +7 -0
  183. package/lib/configs/tabbar.js +6 -0
  184. package/lib/configs/toast.d.ts +18 -0
  185. package/lib/configs/toast.js +29 -0
  186. package/lib/configs/update.d.ts +45 -0
  187. package/lib/configs/update.js +6 -0
  188. package/lib/configs/upload.d.ts +30 -0
  189. package/lib/configs/upload.js +7 -0
  190. package/lib/configs/ver.d.ts +8 -0
  191. package/lib/configs/ver.js +28 -0
  192. package/lib/configs/web.d.ts +5 -0
  193. package/lib/configs/web.js +2 -0
  194. package/lib/hooks/index.d.ts +4 -0
  195. package/lib/hooks/index.js +4 -0
  196. package/lib/hooks/useI18n.d.ts +2 -0
  197. package/lib/hooks/useI18n.js +19 -0
  198. package/lib/hooks/useOverlay.d.ts +1 -0
  199. package/lib/hooks/useOverlay.js +17 -0
  200. package/lib/hooks/usePopup.d.ts +1 -0
  201. package/lib/hooks/usePopup.js +14 -0
  202. package/lib/hooks/useVersion.d.ts +6 -0
  203. package/lib/hooks/useVersion.js +21 -0
  204. package/lib/index.d.ts +26 -0
  205. package/lib/index.js +33 -0
  206. package/lib/mixins/app.d.ts +14 -0
  207. package/lib/mixins/app.js +105 -0
  208. package/lib/mixins/badge.d.ts +24 -0
  209. package/lib/mixins/badge.js +44 -0
  210. package/lib/mixins/debounce.d.ts +6 -0
  211. package/lib/mixins/debounce.js +11 -0
  212. package/lib/mixins/deep.d.ts +6 -0
  213. package/lib/mixins/deep.js +8 -0
  214. package/lib/mixins/index.d.ts +8 -0
  215. package/lib/mixins/index.js +8 -0
  216. package/lib/mixins/login.d.ts +4 -0
  217. package/lib/mixins/login.js +25 -0
  218. package/lib/mixins/model.d.ts +22 -0
  219. package/lib/mixins/model.js +29 -0
  220. package/lib/mixins/redirect.d.ts +8 -0
  221. package/lib/mixins/redirect.js +94 -0
  222. package/lib/mixins/share.d.ts +15 -0
  223. package/lib/mixins/share.js +55 -0
  224. package/lib/mixins/show.d.ts +9 -0
  225. package/lib/mixins/show.js +16 -0
  226. package/lib/mixins/webview.d.ts +26 -0
  227. package/lib/mixins/webview.js +225 -0
  228. package/lib/modules/app.d.ts +5 -0
  229. package/lib/modules/app.js +19 -0
  230. package/lib/modules/dict.d.ts +8 -0
  231. package/lib/modules/dict.js +43 -0
  232. package/lib/modules/im.d.ts +6 -0
  233. package/lib/modules/im.js +105 -0
  234. package/lib/modules/index.d.ts +8 -0
  235. package/lib/modules/index.js +8 -0
  236. package/lib/modules/launch.d.ts +5 -0
  237. package/lib/modules/launch.js +32 -0
  238. package/lib/modules/location.d.ts +5 -0
  239. package/lib/modules/location.js +57 -0
  240. package/lib/modules/login.d.ts +5 -0
  241. package/lib/modules/login.js +72 -0
  242. package/lib/modules/network.d.ts +5 -0
  243. package/lib/modules/network.js +39 -0
  244. package/lib/modules/system.d.ts +5 -0
  245. package/lib/modules/system.js +65 -0
  246. package/lib/styles/animate-vue.scss +3 -0
  247. package/lib/styles/animate.scss +27 -0
  248. package/lib/styles/bg-vue.scss +21 -0
  249. package/lib/styles/bg.scss +93 -0
  250. package/lib/styles/border.scss +218 -0
  251. package/lib/styles/flex-nvue.scss +64 -0
  252. package/lib/styles/flex-vue.scss +75 -0
  253. package/lib/styles/font.scss +59 -0
  254. package/lib/styles/index.scss +25 -0
  255. package/lib/styles/layout-nvue.scss +24 -0
  256. package/lib/styles/layout-vue.scss +30 -0
  257. package/lib/styles/layout.scss +76 -0
  258. package/lib/styles/opacity.scss +10 -0
  259. package/lib/styles/reset-vue.scss +46 -0
  260. package/lib/styles/shadow.scss +12 -0
  261. package/lib/styles/sizing-vue.scss +21 -0
  262. package/lib/styles/sizing.scss +21 -0
  263. package/lib/styles/spacing.scss +234 -0
  264. package/lib/styles/text-nvue.scss +21 -0
  265. package/lib/styles/text-vue.scss +70 -0
  266. package/lib/styles/text.scss +122 -0
  267. package/lib/styles/var.module.scss +29 -0
  268. package/lib/utils/audio.d.ts +14 -0
  269. package/lib/utils/audio.js +43 -0
  270. package/lib/utils/consts.d.ts +30 -0
  271. package/lib/utils/consts.js +52 -0
  272. package/lib/utils/cos.d.ts +15 -0
  273. package/lib/utils/cos.js +140 -0
  274. package/lib/utils/debounce.d.ts +2 -0
  275. package/lib/utils/debounce.js +30 -0
  276. package/lib/utils/file.d.ts +28 -0
  277. package/lib/utils/file.js +292 -0
  278. package/lib/utils/index.d.ts +166 -0
  279. package/lib/utils/index.js +485 -0
  280. package/lib/utils/locale.d.ts +6 -0
  281. package/lib/utils/locale.js +19 -0
  282. package/lib/utils/message.d.ts +9 -0
  283. package/lib/utils/message.js +63 -0
  284. package/lib/utils/navigate.d.ts +27 -0
  285. package/lib/utils/navigate.js +183 -0
  286. package/lib/utils/pages.d.ts +21 -0
  287. package/lib/utils/pages.js +79 -0
  288. package/lib/utils/permission.d.ts +16 -0
  289. package/lib/utils/permission.js +291 -0
  290. package/lib/utils/permit.d.ts +30 -0
  291. package/lib/utils/permit.js +181 -0
  292. package/lib/utils/query.d.ts +13 -0
  293. package/lib/utils/query.js +14 -0
  294. package/lib/utils/request.d.ts +8 -0
  295. package/lib/utils/request.js +126 -0
  296. package/lib/utils/storage.d.ts +53 -0
  297. package/lib/utils/storage.js +145 -0
  298. package/lib/utils/subscribe.d.ts +7 -0
  299. package/lib/utils/subscribe.js +94 -0
  300. package/lib/utils/throttle.d.ts +2 -0
  301. package/lib/utils/throttle.js +32 -0
  302. package/lib/utils/toast.d.ts +17 -0
  303. package/lib/utils/toast.js +66 -0
  304. package/lib/utils/uni.d.ts +1 -0
  305. package/lib/utils/uni.js +147 -0
  306. package/lib/utils/update.d.ts +9 -0
  307. package/lib/utils/update.js +376 -0
  308. package/package.json +49 -0
  309. package/types/index.d.ts +25 -0
  310. package/types/virtual.d.ts +1 -0
@@ -0,0 +1,482 @@
1
+ <template>
2
+ <view class="tag-editor">
3
+ <view v-if="mode === 'tag'" class="flex items-start flex-wrap" :style="[tagsWrapStyle]" @tap="focus = true">
4
+ <uv-tags
5
+ v-for="(tag, i) in value"
6
+ :key="tag"
7
+ :text="tag"
8
+ :type="defineType(tag)"
9
+ plain
10
+ :closable="!disabled"
11
+ :customStyle="_tagStyle"
12
+ @close="removeTag(i)"
13
+ />
14
+ <view v-if="!disabled" class="flex-1 flex" style="min-width: 160rpx">
15
+ <input
16
+ v-model.trim="content"
17
+ class="box-border flex-1"
18
+ :adjustPosition="adjustPosition"
19
+ :cursorSpacing="cursorSpacing"
20
+ :placeholder="placeholder"
21
+ :focus="focus"
22
+ :disabled="disabled"
23
+ :maxlength="maxlength"
24
+ :placeholderStyle="_placeholderStyle"
25
+ :style="__inputStyle"
26
+ confirm-hold
27
+ @input="input"
28
+ @blur="blur"
29
+ @confirm="confirmTag"
30
+ />
31
+ <text v-if="content" class="ml-10rpx tag-editor-confirm" @tap.stop="confirmTag" @touchend.prevent="confirmTag">
32
+ 确定
33
+ </text>
34
+ </view>
35
+ </view>
36
+ <textarea
37
+ v-else
38
+ v-model.trim="content"
39
+ class="w-full box-border"
40
+ :adjustPosition="adjustPosition"
41
+ :cursorSpacing="cursorSpacing"
42
+ :placeholder="placeholder"
43
+ :disabled="disabled"
44
+ :autoHeight="autoHeight"
45
+ :maxlength="maxlength"
46
+ :placeholderStyle="_placeholderStyle"
47
+ :style="_inputStyle"
48
+ @input="input"
49
+ @blur="blur"
50
+ />
51
+ <view v-for="(item, index) in list" :key="index" class="tag-editor-labels">
52
+ <view v-if="item.title" :style="[titleStyle]"> {{ item.title }} </view>
53
+ <view v-if="item.list" class="flex items-start">
54
+ <view class="flex-1 flex flex-wrap">
55
+ <uv-tags
56
+ v-for="ele in item.list"
57
+ :key="ele.label"
58
+ :text="ele.label"
59
+ size="medium"
60
+ shape="circle"
61
+ type="primary"
62
+ :color="ele.checked ? '#fff' : activeColor"
63
+ :borderColor="ele.checked ? activeColor : inactiveColor"
64
+ :bgColor="ele.checked ? activeColor : inactiveColor"
65
+ :customStyle="_labelStyle"
66
+ @click="select(ele)"
67
+ />
68
+ </view>
69
+ <slot name="extra"></slot>
70
+ </view>
71
+ </view>
72
+ </view>
73
+ </template>
74
+
75
+ <script>
76
+ import color from '../../configs/color';
77
+ import model from '../../mixins/model';
78
+ import debounce from '../../mixins/debounce';
79
+ import deep from '../../mixins/deep';
80
+
81
+ export default {
82
+ data() {
83
+ return {
84
+ list: [],
85
+ content: '',
86
+ cursor: -1,
87
+ focus: false,
88
+ inputList: [],
89
+ };
90
+ },
91
+ mixins: [
92
+ deep,
93
+ debounce,
94
+ model({
95
+ type: [String, Array],
96
+ default: '',
97
+ }),
98
+ ],
99
+ props: {
100
+ mode: {
101
+ type: String,
102
+ default: 'text',
103
+ },
104
+ placeholder: {
105
+ type: String,
106
+ default: '',
107
+ },
108
+ data: {
109
+ type: Array,
110
+ default: () => [],
111
+ },
112
+ values: {
113
+ type: Array,
114
+ default: null,
115
+ },
116
+ autoHeight: {
117
+ type: Boolean,
118
+ default: true,
119
+ },
120
+ adjustPosition: {
121
+ type: Boolean,
122
+ default: true,
123
+ },
124
+ disabled: {
125
+ type: Boolean,
126
+ default: false,
127
+ },
128
+ cursorSpacing: {
129
+ type: [Number, String],
130
+ default: 0,
131
+ },
132
+ separate: {
133
+ type: [String, Boolean],
134
+ default: ',',
135
+ },
136
+ maxlength: {
137
+ type: [String, Number],
138
+ default: 1000,
139
+ },
140
+ height: {
141
+ type: [String, Number],
142
+ default: 40,
143
+ },
144
+ inputSize: {
145
+ type: [String, Number],
146
+ default: 14,
147
+ },
148
+ placeholderSize: {
149
+ type: [String, Number],
150
+ default: 13,
151
+ },
152
+ inputBgColor: {
153
+ type: String,
154
+ default: () => color.bgColor,
155
+ },
156
+ disabledBgColor: {
157
+ type: String,
158
+ default: () => color.bgColor,
159
+ },
160
+ inputColor: {
161
+ type: String,
162
+ default: () => color.mainColor,
163
+ },
164
+ activeColor: {
165
+ type: String,
166
+ default: () => color.primary,
167
+ },
168
+ inactiveColor: {
169
+ type: String,
170
+ default: () => color.primaryLight,
171
+ },
172
+ placeholderColor: {
173
+ type: String,
174
+ default: () => color.tipsColor,
175
+ },
176
+ titleStyle: {
177
+ type: Object,
178
+ default: () => ({}),
179
+ },
180
+ inputStyle: {
181
+ type: Object,
182
+ default: () => ({}),
183
+ },
184
+ customStyle: {
185
+ type: Object,
186
+ default: () => ({}),
187
+ },
188
+ tagStyle: {
189
+ type: Object,
190
+ default: () => ({}),
191
+ },
192
+ labelStyle: {
193
+ type: Object,
194
+ default: () => ({}),
195
+ },
196
+ placeholderStyle: {
197
+ type: Object,
198
+ default: () => ({}),
199
+ },
200
+ customList: {
201
+ type: Array,
202
+ default: null,
203
+ },
204
+ selectClean: {
205
+ type: Boolean,
206
+ default: true,
207
+ },
208
+ },
209
+ computed: {
210
+ tagsWrapStyle({ inputBgColor, disabledBgColor, disabled, customStyle }) {
211
+ return Object.assign(
212
+ {
213
+ padding: '0 20rpx',
214
+ backgroundColor: disabled ? disabledBgColor : inputBgColor,
215
+ borderRadius: '8rpx',
216
+ alignContent: 'baseline',
217
+ },
218
+ customStyle,
219
+ );
220
+ },
221
+ __inputStyle({ inputStyle, inputSize, height, inputColor }) {
222
+ const style = Object.assign(
223
+ {
224
+ fontSize: uni.$uv.addUnit(inputSize),
225
+ color: inputColor,
226
+ height: uni.$uv.addUnit(height),
227
+ },
228
+ inputStyle,
229
+ );
230
+ return style;
231
+ },
232
+ _inputStyle({ inputBgColor, inputColor, disabledBgColor, inputStyle, inputSize, disabled }) {
233
+ const style = Object.assign(
234
+ {
235
+ padding: '26rpx 20rpx 16rpx',
236
+ minHeight: '40rpx',
237
+ backgroundColor: disabled ? disabledBgColor : inputBgColor,
238
+ fontSize: uni.$uv.addUnit(inputSize),
239
+ color: inputColor,
240
+ borderRadius: '8rpx',
241
+ },
242
+ inputStyle,
243
+ );
244
+ return style;
245
+ },
246
+ _labelStyle({ labelStyle }) {
247
+ return Object.assign(
248
+ {
249
+ margin: '20rpx 20rpx 0 0',
250
+ boxSizing: 'border-box',
251
+ lineHeight: '30rpx',
252
+ height: 'auto',
253
+ wordBreak: 'break-all',
254
+ padding: '8rpx 20rpx 6rpx',
255
+ },
256
+ labelStyle,
257
+ );
258
+ },
259
+ _tagStyle({ tagStyle }) {
260
+ return Object.assign(
261
+ {
262
+ margin: '20rpx 20rpx 0 0',
263
+ boxSizing: 'border-box',
264
+ lineHeight: '30rpx',
265
+ height: 'auto',
266
+ wordBreak: 'break-all',
267
+ padding: '6rpx 18rpx 4rpx',
268
+ },
269
+ tagStyle,
270
+ );
271
+ },
272
+ _placeholderStyle({ placeholderStyle, placeholderSize, placeholderColor }) {
273
+ const style = Object.assign(
274
+ { fontSize: uni.$uv.addUnit(placeholderSize), color: placeholderColor },
275
+ placeholderStyle,
276
+ );
277
+ const styles = [];
278
+ Object.keys(style).forEach((k) => {
279
+ styles.push(`${k}:${style[k]}`);
280
+ });
281
+ return styles.join(';');
282
+ },
283
+ contents({ content }) {
284
+ const val = content.trim();
285
+ if (!val) {
286
+ return [];
287
+ }
288
+ return val.split(/[,,]/).filter((e) => !!e.trim());
289
+ },
290
+ },
291
+ watch: {
292
+ data() {
293
+ this.initList();
294
+ },
295
+ value(e, o) {
296
+ if (this.mode !== 'tag') {
297
+ const update = this.content !== e;
298
+ this.content = e;
299
+ if (update) {
300
+ uni.$uv.formValidate(this, 'change');
301
+ this.updateList();
302
+ }
303
+ } else {
304
+ if (e?.length !== o?.length) {
305
+ uni.$uv.formValidate(this, 'change');
306
+ }
307
+ this.updateList();
308
+ }
309
+ },
310
+ content(e) {
311
+ if (this.mode !== 'tag') {
312
+ this.updateModel(e);
313
+ }
314
+ },
315
+ },
316
+ methods: {
317
+ mergeChecked(source) {
318
+ if (typeof source !== 'object') {
319
+ source = {
320
+ label: source,
321
+ };
322
+ }
323
+ const data = { ...source };
324
+ if (this.mode === 'tag' && this.value?.some((val) => val === data.label)) {
325
+ data.checked = true;
326
+ } else if (this.mode !== 'tag' && this.contents.includes(data.label)) {
327
+ data.checked = true;
328
+ } else if (data.checked) {
329
+ delete data.checked;
330
+ }
331
+ return data;
332
+ },
333
+ initList() {
334
+ if (this.disabled) {
335
+ this.list = [];
336
+ } else {
337
+ const value = [];
338
+ this.data.forEach((ele) => {
339
+ if (Array.isArray(ele.list)) {
340
+ const { list: arr, ...rest } = ele;
341
+ value.push({
342
+ ...rest,
343
+ list: arr.map((e) => this.mergeChecked(e)),
344
+ });
345
+ } else if (!value[0]?.list) {
346
+ value[0] = {
347
+ list: [this.mergeChecked(ele)],
348
+ };
349
+ } else {
350
+ value[0].list.push(this.mergeChecked(ele));
351
+ }
352
+ });
353
+ this.list = value;
354
+ }
355
+ },
356
+ updateList() {
357
+ this.list.forEach((ele) => {
358
+ ele.list = ele.list.map((ele) => {
359
+ return this.mergeChecked(ele);
360
+ });
361
+ });
362
+ },
363
+ updateTags(value) {
364
+ this.updateModel([...new Set(value)]);
365
+ },
366
+ input(e) {
367
+ this.$emit('input', e);
368
+ const { cursor, value } = e.detail;
369
+ if (this.mode === 'tag' && value.length === Number(this.maxlength)) {
370
+ this.confirmTag();
371
+ return;
372
+ }
373
+ this.debounce(() => {
374
+ const keyword = value.slice(0, cursor).split(/[,,]/).pop();
375
+ this.$emit('search', keyword);
376
+ this.updateList();
377
+ });
378
+ },
379
+ blur(e) {
380
+ const { cursor } = e.detail;
381
+ this.cursor = cursor;
382
+ this.focus = false;
383
+ uni.$uv.formValidate(this, 'blur');
384
+ },
385
+ select(item) {
386
+ if (this.mode === 'tag') {
387
+ if (!item.checked) {
388
+ if (this.selectClean) {
389
+ this.content = '';
390
+ }
391
+ this.updateTags(this.value.concat(item.label));
392
+ } else {
393
+ this.updateTags(this.value.filter((val) => val !== item.label));
394
+ }
395
+ } else {
396
+ if (!item.checked) {
397
+ const index = this.content.lastIndexOf(this.separate);
398
+ const text = this.content.slice(index + 1);
399
+ if (text && item.label?.includes(text)) {
400
+ this.content = this.contents.slice(0, -1).concat(item.label, '').join(this.separate);
401
+ } else {
402
+ this.content = this.contents.concat(item.label, '').join(this.separate);
403
+ }
404
+ } else {
405
+ const index = this.contents.indexOf(item.label);
406
+ this.content = this.contents
407
+ .slice(0, index)
408
+ .concat(this.contents.slice(index + 1), '')
409
+ .join(this.separate);
410
+ }
411
+ }
412
+ this.updateList();
413
+ },
414
+ removeTag(i) {
415
+ this.findTag(i);
416
+ this.updateTags(this.value.slice(0, i).concat(this.value.slice(i + 1)));
417
+ },
418
+ findTag(i) {
419
+ if (Array.isArray(this.customList) && this.customList.includes(this.value[i])) {
420
+ let index = this.customList.findIndex((item) => item === this.value[i]);
421
+ this.customList.splice(index, 1);
422
+ }
423
+ },
424
+ defineType(tag) {
425
+ if (this.customList && this.customList.includes(tag)) {
426
+ return 'warning';
427
+ } else {
428
+ return 'primary';
429
+ }
430
+ },
431
+ confirmTag() {
432
+ uni.$uv.throttle(() => {
433
+ if (this.separate !== false) {
434
+ this.updateTags(this.value.concat(this.contents));
435
+ } else if (this.content) {
436
+ this.updateTags(this.value.concat(this.content));
437
+ if (Array.isArray(this.customList) && !this.customList.includes(this.content)) {
438
+ this.customList.push(this.content);
439
+ }
440
+ }
441
+ this.$emit('search', '');
442
+ this.content = '';
443
+ // #ifdef MP-WEIXIN
444
+ setTimeout(() => {
445
+ this.content = '';
446
+ }, 100);
447
+ // #endif
448
+ });
449
+ },
450
+ },
451
+ mounted() {
452
+ if (this.mode !== 'tag') {
453
+ this.content = this.value;
454
+ }
455
+ this.initList();
456
+ },
457
+ };
458
+ </script>
459
+
460
+ <style lang="scss" scoped>
461
+ .tag-editor {
462
+ &-confirm {
463
+ height: 50rpx;
464
+ background-color: $uv-primary;
465
+ color: #fff;
466
+ width: 80rpx;
467
+ border-radius: 6rpx;
468
+ display: flex;
469
+ justify-content: center;
470
+ align-items: center;
471
+ font-size: 28rpx;
472
+ }
473
+ ::v-deep .uv-tags {
474
+ &__text {
475
+ line-height: inherit !important;
476
+ }
477
+ &--circle {
478
+ border-radius: 30rpx !important;
479
+ }
480
+ }
481
+ }
482
+ </style>
@@ -0,0 +1,61 @@
1
+ <template>
2
+ <text> {{ time }} </text>
3
+ </template>
4
+
5
+ <script>
6
+ import { dateStringToTime } from '../../utils';
7
+
8
+ export default {
9
+ props: {
10
+ start: {
11
+ type: [String, Number],
12
+ default: 0,
13
+ },
14
+ },
15
+ data() {
16
+ return {
17
+ time: '',
18
+ };
19
+ },
20
+ methods: {
21
+ timeFormat(duration) {
22
+ const h = parseInt(duration / (60 * 60));
23
+ const m = parseInt((duration - h * 60 * 60) / 60);
24
+ const s = parseInt(duration % 60);
25
+ return `${h ? `${String(h).padStart(2, '0')}:` : ''}${String(m).padStart(2, '0')}:${String(s).padStart(2, '0')}`;
26
+ },
27
+ execTimer(timestamp) {
28
+ const timer = () => {
29
+ const duration = parseInt((Date.now() - timestamp) / 1000);
30
+ this.$emit('change', duration);
31
+ this.time = this.timeFormat(duration);
32
+ };
33
+ timer();
34
+ this.timer = setInterval(timer, 1000);
35
+ },
36
+ init() {
37
+ let timestamp = 0;
38
+ if (typeof this.start === 'number') {
39
+ timestamp = this.start;
40
+ } else {
41
+ timestamp = dateStringToTime(this.start);
42
+ }
43
+ if (!timestamp) {
44
+ timestamp = Date.now();
45
+ }
46
+ if (String(timestamp).length === 10) {
47
+ timestamp = timestamp * 1000;
48
+ }
49
+ this.execTimer(timestamp);
50
+ },
51
+ },
52
+ beforeMount() {
53
+ this.init();
54
+ },
55
+ beforeUnmount() {
56
+ clearInterval(this.timer);
57
+ },
58
+ };
59
+ </script>
60
+
61
+ <style></style>