uview-pro 0.0.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 (149) hide show
  1. package/changelog.md +6 -0
  2. package/components/u-action-sheet/u-action-sheet.vue +205 -0
  3. package/components/u-alert-tips/u-alert-tips.vue +241 -0
  4. package/components/u-avatar/u-avatar.vue +220 -0
  5. package/components/u-avatar-cropper/u-avatar-cropper.vue +329 -0
  6. package/components/u-avatar-cropper/weCropper.d.ts +54 -0
  7. package/components/u-avatar-cropper/weCropper.js +1267 -0
  8. package/components/u-avatar-cropper/weCropper.ts +1254 -0
  9. package/components/u-back-top/u-back-top.vue +156 -0
  10. package/components/u-badge/u-badge.vue +189 -0
  11. package/components/u-button/u-button.vue +562 -0
  12. package/components/u-calendar/u-calendar.vue +725 -0
  13. package/components/u-car-keyboard/u-car-keyboard.vue +236 -0
  14. package/components/u-card/u-card.vue +240 -0
  15. package/components/u-cell-group/u-cell-group.vue +56 -0
  16. package/components/u-cell-item/u-cell-item.vue +245 -0
  17. package/components/u-checkbox/u-checkbox.vue +310 -0
  18. package/components/u-checkbox-group/u-checkbox-group.vue +134 -0
  19. package/components/u-circle-progress/u-circle-progress.vue +210 -0
  20. package/components/u-col/u-col.vue +135 -0
  21. package/components/u-collapse/u-collapse.vue +82 -0
  22. package/components/u-collapse-item/u-collapse-item.vue +190 -0
  23. package/components/u-column-notice/u-column-notice.vue +264 -0
  24. package/components/u-count-down/u-count-down.vue +333 -0
  25. package/components/u-count-to/u-count-to.vue +297 -0
  26. package/components/u-divider/u-divider.vue +141 -0
  27. package/components/u-dropdown/u-dropdown.vue +311 -0
  28. package/components/u-dropdown-item/u-dropdown-item.vue +135 -0
  29. package/components/u-empty/u-empty.vue +111 -0
  30. package/components/u-field/u-field.vue +469 -0
  31. package/components/u-form/u-form.vue +162 -0
  32. package/components/u-form-item/u-form-item.vue +476 -0
  33. package/components/u-full-screen/u-full-screen.vue +80 -0
  34. package/components/u-gap/u-gap.vue +48 -0
  35. package/components/u-grid/u-grid.vue +101 -0
  36. package/components/u-grid-item/u-grid-item.vue +136 -0
  37. package/components/u-icon/u-icon.vue +389 -0
  38. package/components/u-image/types.ts +48 -0
  39. package/components/u-image/u-image.vue +218 -0
  40. package/components/u-index-anchor/u-index-anchor.vue +101 -0
  41. package/components/u-index-list/u-index-list.vue +376 -0
  42. package/components/u-input/u-input.vue +462 -0
  43. package/components/u-keyboard/u-keyboard.vue +188 -0
  44. package/components/u-lazy-load/u-lazy-load.vue +288 -0
  45. package/components/u-line/u-line.vue +71 -0
  46. package/components/u-line-progress/u-line-progress.vue +128 -0
  47. package/components/u-link/u-link.vue +87 -0
  48. package/components/u-loading/u-loading.vue +111 -0
  49. package/components/u-loadmore/u-loadmore.vue +205 -0
  50. package/components/u-mask/u-mask.vue +137 -0
  51. package/components/u-message-input/u-message-input.vue +315 -0
  52. package/components/u-modal/u-modal.vue +284 -0
  53. package/components/u-navbar/u-navbar.vue +314 -0
  54. package/components/u-no-network/image.ts +2 -0
  55. package/components/u-no-network/u-no-network.vue +311 -0
  56. package/components/u-notice-bar/u-notice-bar.vue +274 -0
  57. package/components/u-number-box/u-number-box.vue +344 -0
  58. package/components/u-number-keyboard/u-number-keyboard.vue +170 -0
  59. package/components/u-parse/libs/CssHandler.js +100 -0
  60. package/components/u-parse/libs/MpHtmlParser.js +580 -0
  61. package/components/u-parse/libs/config.js +80 -0
  62. package/components/u-parse/libs/handler.wxs +22 -0
  63. package/components/u-parse/libs/trees.vue +505 -0
  64. package/components/u-parse/u-parse.vue +645 -0
  65. package/components/u-picker/u-picker.vue +808 -0
  66. package/components/u-popup/u-popup.vue +404 -0
  67. package/components/u-radio/u-radio.vue +272 -0
  68. package/components/u-radio-group/u-radio-group.vue +116 -0
  69. package/components/u-rate/u-rate.vue +349 -0
  70. package/components/u-read-more/u-read-more.vue +199 -0
  71. package/components/u-row/u-row.vue +95 -0
  72. package/components/u-row-notice/u-row-notice.vue +273 -0
  73. package/components/u-search/u-search.vue +298 -0
  74. package/components/u-section/u-section.vue +175 -0
  75. package/components/u-select/u-select.vue +387 -0
  76. package/components/u-skeleton/u-skeleton.vue +230 -0
  77. package/components/u-slider/u-slider.vue +293 -0
  78. package/components/u-steps/u-steps.vue +200 -0
  79. package/components/u-sticky/u-sticky.vue +189 -0
  80. package/components/u-subsection/u-subsection.vue +388 -0
  81. package/components/u-swipe-action/u-swipe-action.vue +289 -0
  82. package/components/u-swiper/u-swiper.vue +305 -0
  83. package/components/u-switch/u-switch.vue +146 -0
  84. package/components/u-tabbar/u-tabbar.vue +347 -0
  85. package/components/u-table/u-table.vue +104 -0
  86. package/components/u-tabs/u-tabs.vue +322 -0
  87. package/components/u-tabs-swiper/u-tabs-swiper.vue +426 -0
  88. package/components/u-tag/u-tag.vue +270 -0
  89. package/components/u-td/u-td.vue +76 -0
  90. package/components/u-th/u-th.vue +70 -0
  91. package/components/u-time-line/u-time-line.vue +39 -0
  92. package/components/u-time-line-item/u-time-line-item.vue +88 -0
  93. package/components/u-toast/types.ts +4 -0
  94. package/components/u-toast/u-toast.vue +238 -0
  95. package/components/u-top-tips/u-top-tips.vue +118 -0
  96. package/components/u-tr/u-tr.vue +24 -0
  97. package/components/u-upload/u-upload.vue +600 -0
  98. package/components/u-verification-code/u-verification-code.vue +194 -0
  99. package/components/u-waterfall/u-waterfall.vue +186 -0
  100. package/iconfont.css +910 -0
  101. package/index.scss +23 -0
  102. package/index.ts +166 -0
  103. package/libs/config/config.ts +26 -0
  104. package/libs/config/zIndex.ts +37 -0
  105. package/libs/css/color.scss +155 -0
  106. package/libs/css/common.scss +176 -0
  107. package/libs/css/style.components.scss +7 -0
  108. package/libs/css/style.h5.scss +8 -0
  109. package/libs/css/style.mp.scss +72 -0
  110. package/libs/css/style.nvue.scss +3 -0
  111. package/libs/css/style.vue.scss +175 -0
  112. package/libs/function/$parent.ts +22 -0
  113. package/libs/function/addUnit.ts +13 -0
  114. package/libs/function/color.ts +37 -0
  115. package/libs/function/colorGradient.ts +123 -0
  116. package/libs/function/debounce.ts +28 -0
  117. package/libs/function/deepClone.ts +39 -0
  118. package/libs/function/deepMerge.ts +34 -0
  119. package/libs/function/getParent.ts +59 -0
  120. package/libs/function/getRect.ts +26 -0
  121. package/libs/function/guid.ts +42 -0
  122. package/libs/function/md5.ts +397 -0
  123. package/libs/function/parent.ts +21 -0
  124. package/libs/function/queryParams.ts +60 -0
  125. package/libs/function/random.ts +16 -0
  126. package/libs/function/randomArray.ts +11 -0
  127. package/libs/function/route.ts +118 -0
  128. package/libs/function/sys.ts +15 -0
  129. package/libs/function/test.ts +229 -0
  130. package/libs/function/throttle.ts +31 -0
  131. package/libs/function/timeFormat.ts +54 -0
  132. package/libs/function/timeFrom.ts +48 -0
  133. package/libs/function/toast.ts +14 -0
  134. package/libs/function/trim.ts +21 -0
  135. package/libs/function/type2icon.ts +36 -0
  136. package/libs/hooks/useEmitter.ts +77 -0
  137. package/libs/hooks/useParent.ts +29 -0
  138. package/libs/request/index.ts +237 -0
  139. package/libs/store/index.ts +88 -0
  140. package/libs/util/area.ts +1 -0
  141. package/libs/util/async-validator.js +1356 -0
  142. package/libs/util/city.ts +1 -0
  143. package/libs/util/emitter.ts +112 -0
  144. package/libs/util/mitt.ts +118 -0
  145. package/libs/util/parent.ts +20 -0
  146. package/libs/util/province.ts +1 -0
  147. package/package.json +98 -0
  148. package/readme.md +165 -0
  149. package/theme.scss +38 -0
@@ -0,0 +1,315 @@
1
+ <template>
2
+ <view class="u-char-box">
3
+ <view class="u-char-flex">
4
+ <input :disabled="props.disabledKeyboard" :value="valueModel" type="number" :focus="props.focus" :maxlength="props.maxlength" class="u-input" @input="getVal" />
5
+ <view v-for="(item, index) in loopCharArr" :key="index">
6
+ <view
7
+ :class="[
8
+ props.breathe && charArrLength === index ? 'u-breathe' : '',
9
+ 'u-char-item',
10
+ charArrLength === index && props.mode == 'box' ? 'u-box-active' : '',
11
+ props.mode === 'box' ? 'u-box' : ''
12
+ ]"
13
+ :style="{
14
+ fontWeight: props.bold ? 'bold' : 'normal',
15
+ fontSize: props.fontSize + 'rpx',
16
+ width: props.width + 'rpx',
17
+ height: props.width + 'rpx',
18
+ color: props.inactiveColor,
19
+ borderColor: charArrLength === index && props.mode == 'box' ? props.activeColor : props.inactiveColor
20
+ }"
21
+ >
22
+ <view
23
+ class="u-placeholder-line"
24
+ :style="{
25
+ display: charArrLength === index ? 'block' : 'none',
26
+ height: Number(props.width) * 0.5 + 'rpx'
27
+ }"
28
+ v-if="props.mode !== 'middleLine'"
29
+ ></view>
30
+ <view
31
+ v-if="props.mode === 'middleLine' && charArrLength <= index"
32
+ :class="[props.breathe && charArrLength === index ? 'u-breathe' : '', charArrLength === index ? 'u-middle-line-active' : '']"
33
+ class="u-middle-line"
34
+ :style="{
35
+ height: props.bold ? '4px' : '2px',
36
+ background: charArrLength === index ? props.activeColor : props.inactiveColor
37
+ }"
38
+ ></view>
39
+ <view
40
+ v-if="props.mode === 'bottomLine'"
41
+ :class="[props.breathe && charArrLength === index ? 'u-breathe' : '', charArrLength === index ? 'u-bottom-line-active' : '']"
42
+ class="u-bottom-line"
43
+ :style="{
44
+ height: props.bold ? '4px' : '2px',
45
+ background: charArrLength === index ? props.activeColor : props.inactiveColor
46
+ }"
47
+ ></view>
48
+ <block v-if="!props.dotFill"> {{ charArr[index] ? charArr[index] : '' }}</block>
49
+ <block v-else>
50
+ <text class="u-dot">{{ charArr[index] ? '●' : '' }}</text>
51
+ </block>
52
+ </view>
53
+ </view>
54
+ </view>
55
+ </view>
56
+ </template>
57
+
58
+ <script setup lang="ts">
59
+ import { ref, computed, watch } from 'vue';
60
+
61
+ defineOptions({ name: 'u-message-input' });
62
+
63
+ /**
64
+ * messageInput 验证码输入框
65
+ * @description 该组件一般用于验证用户短信验证码的场景,也可以结合uView的键盘组件使用
66
+ * @tutorial https://www.uviewui.com/components/messageInput.html
67
+ * @property {String|Number} maxlength 输入字符个数(默认4)
68
+ * @property {Boolean} dot-fill 是否用圆点填充(默认false)
69
+ * @property {String} mode 模式选择,见上方"基本使用"说明(默认box)
70
+ * @property {String|Number} value 预置值
71
+ * @property {Boolean} breathe 是否开启呼吸效果,见上方说明(默认true)
72
+ * @property {Boolean} focus 是否自动获取焦点(默认false)
73
+ * @property {Boolean} bold 字体和输入横线是否加粗(默认true)
74
+ * @property {String|Number} font-size 字体大小,单位rpx(默认60)
75
+ * @property {String} active-color 当前激活输入框的样式(默认#2979ff)
76
+ * @property {String} inactive-color 非激活输入框的样式,文字颜色同此值(默认#606266)
77
+ * @property {String|Number} width 输入框宽度,单位rpx,高等于宽(默认80)
78
+ * @property {Boolean} disabled-keyboard 禁止点击输入框唤起系统键盘(默认false)
79
+ * @event {Function} change 输入内容发生改变时触发,具体见官网说明
80
+ * @event {Function} finish 输入字符个数达maxlength值时触发,见官网说明
81
+ * @example <u-message-input mode="bottomLine"></u-message-input>
82
+ */
83
+ const props = defineProps({
84
+ // 最大输入长度
85
+ maxlength: {
86
+ type: [Number, String],
87
+ default: 4
88
+ },
89
+ // 是否用圆点填充
90
+ dotFill: {
91
+ type: Boolean,
92
+ default: false
93
+ },
94
+ // 显示模式,box-盒子模式,bottomLine-横线在底部模式,middleLine-横线在中部模式
95
+ mode: {
96
+ type: String,
97
+ default: 'box'
98
+ },
99
+ // 预置值
100
+ value: {
101
+ type: [String, Number],
102
+ default: ''
103
+ },
104
+ // 当前激活输入item,是否带有呼吸效果
105
+ breathe: {
106
+ type: Boolean,
107
+ default: true
108
+ },
109
+ // 是否自动获取焦点
110
+ focus: {
111
+ type: Boolean,
112
+ default: false
113
+ },
114
+ // 字体是否加粗
115
+ bold: {
116
+ type: Boolean,
117
+ default: false
118
+ },
119
+ // 字体大小
120
+ fontSize: {
121
+ type: [String, Number],
122
+ default: 60
123
+ },
124
+ // 激活样式
125
+ activeColor: {
126
+ type: String,
127
+ default: '#2979ff'
128
+ },
129
+ // 未激活的样式
130
+ inactiveColor: {
131
+ type: String,
132
+ default: '#606266'
133
+ },
134
+ // 输入框的大小,单位rpx,宽等于高
135
+ width: {
136
+ type: [Number, String],
137
+ default: '80'
138
+ },
139
+ // 是否隐藏原生键盘,如果想用自定义键盘的话,需设置此参数为true
140
+ disabledKeyboard: {
141
+ type: Boolean,
142
+ default: false
143
+ }
144
+ });
145
+
146
+ const emit = defineEmits(['change', 'finish']);
147
+
148
+ // 输入框实际值
149
+ const valueModel = ref('');
150
+
151
+ // 监听 value 变化,自动同步 valueModel,超出部分截掉
152
+ watch(
153
+ () => props.value,
154
+ val => {
155
+ // 转为字符串
156
+ const strVal = String(val);
157
+ // 超出部分截掉
158
+ valueModel.value = strVal.substring(0, Number(props.maxlength));
159
+ },
160
+ { immediate: true }
161
+ );
162
+
163
+ // 用于显示字符
164
+ const charArr = computed(() => valueModel.value.split(''));
165
+ const charArrLength = computed(() => charArr.value.length);
166
+ // 根据长度,循环输入框的个数,因为头条小程序数值不能用于v-for
167
+ const loopCharArr = computed(() => new Array(Number(props.maxlength)));
168
+
169
+ /**
170
+ * 输入事件处理
171
+ * @param e input事件对象
172
+ */
173
+ function getVal(e: { detail: { value: string } }) {
174
+ const { value } = e.detail;
175
+ valueModel.value = value;
176
+ // 判断长度是否超出了maxlength值,理论上不会发生,因为input组件设置了maxlength属性值
177
+ if (String(value).length > Number(props.maxlength)) return;
178
+ // 未达到maxlength之前,发送change事件,达到后发送finish事件
179
+ emit('change', value);
180
+ if (String(value).length === Number(props.maxlength)) {
181
+ emit('finish', value);
182
+ }
183
+ }
184
+ </script>
185
+
186
+ <style scoped lang="scss">
187
+ @import '../../libs/css/style.components.scss';
188
+
189
+ @keyframes breathe {
190
+ 0% {
191
+ opacity: 0.3;
192
+ }
193
+
194
+ 50% {
195
+ opacity: 1;
196
+ }
197
+
198
+ 100% {
199
+ opacity: 0.3;
200
+ }
201
+ }
202
+
203
+ .u-char-box {
204
+ text-align: center;
205
+ }
206
+
207
+ .u-char-flex {
208
+ @include vue-flex;
209
+ justify-content: center;
210
+ flex-wrap: wrap;
211
+ position: relative;
212
+ }
213
+
214
+ .u-input {
215
+ position: absolute;
216
+ top: 0;
217
+ left: -100%;
218
+ width: 200%;
219
+ height: 100%;
220
+ text-align: left;
221
+ z-index: 9;
222
+ opacity: 0;
223
+ background: none;
224
+ }
225
+
226
+ .u-char-item {
227
+ position: relative;
228
+ width: 90rpx;
229
+ height: 90rpx;
230
+ margin: 10rpx 10rpx;
231
+ font-size: 60rpx;
232
+ font-weight: bold;
233
+ color: $u-main-color;
234
+ line-height: 90rpx;
235
+ @include vue-flex;
236
+ justify-content: center;
237
+ align-items: center;
238
+ }
239
+
240
+ .u-middle-line {
241
+ border: none;
242
+ }
243
+
244
+ .u-box {
245
+ box-sizing: border-box;
246
+ border: 2rpx solid #cccccc;
247
+ border-radius: 6rpx;
248
+ }
249
+
250
+ .u-box-active {
251
+ overflow: hidden;
252
+ animation-timing-function: ease-in-out;
253
+ animation-duration: 1500ms;
254
+ animation-iteration-count: infinite;
255
+ animation-direction: alternate;
256
+ border: 2rpx solid $u-type-primary;
257
+ }
258
+
259
+ .u-middle-line-active {
260
+ background: $u-type-primary;
261
+ }
262
+
263
+ .u-breathe {
264
+ animation: breathe 2s infinite ease;
265
+ }
266
+
267
+ .u-placeholder-line {
268
+ /* #ifndef APP-NVUE */
269
+ display: none;
270
+ /* #endif */
271
+ position: absolute;
272
+ left: 50%;
273
+ top: 50%;
274
+ transform: translate(-50%, -50%);
275
+ width: 2rpx;
276
+ height: 40rpx;
277
+ background: #333333;
278
+ animation: twinkling 1.5s infinite ease;
279
+ }
280
+
281
+ .u-animation-breathe {
282
+ animation-name: breathe;
283
+ }
284
+
285
+ .u-dot {
286
+ font-size: 34rpx;
287
+ line-height: 34rpx;
288
+ }
289
+
290
+ .u-middle-line {
291
+ height: 4px;
292
+ background: #000000;
293
+ width: 80%;
294
+ position: absolute;
295
+ border-radius: 2px;
296
+ top: 50%;
297
+ left: 50%;
298
+ transform: translate(-50%, -50%);
299
+ }
300
+
301
+ .u-bottom-line-active {
302
+ background: $u-type-primary;
303
+ }
304
+
305
+ .u-bottom-line {
306
+ height: 4px;
307
+ background: #000000;
308
+ width: 80%;
309
+ position: absolute;
310
+ border-radius: 2px;
311
+ bottom: 0;
312
+ left: 50%;
313
+ transform: translate(-50%);
314
+ }
315
+ </style>
@@ -0,0 +1,284 @@
1
+ <template>
2
+ <view>
3
+ <u-popup
4
+ :zoom="zoom"
5
+ mode="center"
6
+ :popup="false"
7
+ :z-index="uZIndex"
8
+ v-model="popupValue"
9
+ :length="width"
10
+ :mask-close-able="maskCloseAble"
11
+ :border-radius="borderRadius"
12
+ @close="popupClose"
13
+ :negative-top="negativeTop"
14
+ >
15
+ <view class="u-model">
16
+ <view v-if="showTitle" class="u-model__title u-line-1" :style="[titleStyle]">{{ title }}</view>
17
+ <view class="u-model__content">
18
+ <view :style="[contentStyle]" v-if="slots.default">
19
+ <slot />
20
+ </view>
21
+ <view v-else class="u-model__content__message" :style="[contentStyle]">{{ content }}</view>
22
+ </view>
23
+ <view class="u-model__footer u-border-top" v-if="showCancelButton || showConfirmButton">
24
+ <view v-if="showCancelButton" :hover-stay-time="100" hover-class="u-model__btn--hover" class="u-model__footer__button" :style="[cancelBtnStyle]" @tap="cancel">
25
+ {{ cancelText }}
26
+ </view>
27
+ <view
28
+ v-if="showConfirmButton || slots['confirm-button']"
29
+ :hover-stay-time="100"
30
+ :hover-class="asyncClose ? 'none' : 'u-model__btn--hover'"
31
+ class="u-model__footer__button hairline-left"
32
+ :style="[confirmBtnStyle]"
33
+ @tap="confirm"
34
+ >
35
+ <slot v-if="slots['confirm-button']" name="confirm-button"></slot>
36
+ <template v-else>
37
+ <u-loading mode="circle" :color="confirmColor" v-if="loading"></u-loading>
38
+ <template v-else>
39
+ {{ confirmText }}
40
+ </template>
41
+ </template>
42
+ </view>
43
+ </view>
44
+ </view>
45
+ </u-popup>
46
+ </view>
47
+ </template>
48
+
49
+ <script setup lang="ts">
50
+ import { ref, computed, watch, useSlots } from 'vue';
51
+
52
+ defineOptions({
53
+ name: 'u-modal'
54
+ });
55
+
56
+ /**
57
+ * modal 模态框
58
+ * @description 弹出模态框,常用于消息提示、消息确认、在当前页面内完成特定的交互操作
59
+ * @tutorial https://www.uviewui.com/components/modal.html
60
+ * @property {Boolean} value 是否显示模态框
61
+ * @property {String | Number} z-index 层级
62
+ * @property {String} title 模态框标题(默认"提示")
63
+ * @property {String | Number} width 模态框宽度(默认600)
64
+ * @property {String} content 模态框内容(默认"内容")
65
+ * @property {Boolean} show-title 是否显示标题(默认true)
66
+ * @property {Boolean} async-close 是否异步关闭,只对确定按钮有效(默认false)
67
+ * @property {Boolean} show-confirm-button 是否显示确认按钮(默认true)
68
+ * @property {String | Number} negative-top modal往上偏移的值
69
+ * @property {Boolean} show-cancel-button 是否显示取消按钮(默认false)
70
+ * @property {Boolean} mask-close-able 是否允许点击遮罩关闭modal(默认false)
71
+ * @property {String} confirm-text 确认按钮的文字内容(默认"确认")
72
+ * @property {String} cancel-text 取消按钮的文字内容(默认"取消")
73
+ * @property {String} cancel-color 取消按钮的颜色(默认"#606266")
74
+ * @property {String} confirm-color 确认按钮的文字内容(默认"#2979ff")
75
+ * @property {String | Number} border-radius 模态框圆角值,单位rpx(默认16)
76
+ * @property {Object} title-style 自定义标题样式,对象形式
77
+ * @property {Object} content-style 自定义内容样式,对象形式
78
+ * @property {Object} cancel-style 自定义取消按钮样式,对象形式
79
+ * @property {Object} confirm-style 自定义确认按钮样式,对象形式
80
+ * @property {Boolean} zoom 是否开启缩放模式(默认true)
81
+ * @event {Function} confirm 确认按钮被点击
82
+ * @event {Function} cancel 取消按钮被点击
83
+ * @example <u-modal :src="title" :content="content"></u-modal>
84
+ */
85
+
86
+ const props = defineProps({
87
+ /**
88
+ * 是否显示模态框
89
+ */
90
+ modelValue: { type: Boolean, default: false },
91
+ /**
92
+ * 层级z-index
93
+ */
94
+ zIndex: { type: [Number, String], default: '' },
95
+ /**
96
+ * 标题
97
+ */
98
+ title: { type: String, default: '提示' },
99
+ /**
100
+ * 弹窗宽度,可以是数值(rpx),百分比,auto等
101
+ */
102
+ width: { type: [Number, String], default: 600 },
103
+ /**
104
+ * 弹窗内容
105
+ */
106
+ content: { type: String, default: '内容' },
107
+ /**
108
+ * 是否显示标题
109
+ */
110
+ showTitle: { type: Boolean, default: true },
111
+ /**
112
+ * 是否显示确认按钮
113
+ */
114
+ showConfirmButton: { type: Boolean, default: true },
115
+ /**
116
+ * 是否显示取消按钮
117
+ */
118
+ showCancelButton: { type: Boolean, default: false },
119
+ /**
120
+ * 确认文案
121
+ */
122
+ confirmText: { type: String, default: '确认' },
123
+ /**
124
+ * 取消文案
125
+ */
126
+ cancelText: { type: String, default: '取消' },
127
+ /**
128
+ * 确认按钮颜色
129
+ */
130
+ confirmColor: { type: String, default: '#2979ff' },
131
+ /**
132
+ * 取消文字颜色
133
+ */
134
+ cancelColor: { type: String, default: '#606266' },
135
+ /**
136
+ * 圆角值
137
+ */
138
+ borderRadius: { type: [Number, String], default: 16 },
139
+ /**
140
+ * 标题的样式
141
+ */
142
+ titleStyle: { type: Object, default: () => ({}) },
143
+ /**
144
+ * 内容的样式
145
+ */
146
+ contentStyle: { type: Object, default: () => ({}) },
147
+ /**
148
+ * 取消按钮的样式
149
+ */
150
+ cancelStyle: { type: Object, default: () => ({}) },
151
+ /**
152
+ * 确定按钮的样式
153
+ */
154
+ confirmStyle: { type: Object, default: () => ({}) },
155
+ /**
156
+ * 是否开启缩放效果
157
+ */
158
+ zoom: { type: Boolean, default: true },
159
+ /**
160
+ * 是否异步关闭,只对确定按钮有效
161
+ */
162
+ asyncClose: { type: Boolean, default: false },
163
+ /**
164
+ * 是否允许点击遮罩关闭modal
165
+ */
166
+ maskCloseAble: { type: Boolean, default: false },
167
+ /**
168
+ * 给一个负的margin-top,往上偏移,避免和键盘重合的情况
169
+ */
170
+ negativeTop: { type: [String, Number], default: 0 }
171
+ });
172
+ const emit = defineEmits(['update:modelValue', 'confirm', 'cancel']);
173
+ const slots = useSlots();
174
+
175
+ // 确认按钮是否正在加载中
176
+ const loading = ref(false);
177
+
178
+ const cancelBtnStyle = computed(() => {
179
+ return Object.assign({ color: props.cancelColor }, props.cancelStyle);
180
+ });
181
+ const confirmBtnStyle = computed(() => {
182
+ return Object.assign({ color: props.confirmColor }, props.confirmStyle);
183
+ });
184
+ const uZIndex = computed(() => (props.zIndex ? props.zIndex : 10075));
185
+
186
+ const popupValue = computed({
187
+ get: () => props.modelValue,
188
+ set: (val: boolean) => emit('update:modelValue', val)
189
+ });
190
+
191
+ // 如果是异步关闭时,外部修改v-model的值为false时,重置内部的loading状态,避免下次打开的时候,状态混乱
192
+ watch(
193
+ () => props.modelValue,
194
+ n => {
195
+ if (n === true) loading.value = false;
196
+ }
197
+ );
198
+
199
+ /**
200
+ * 确认按钮点击事件
201
+ */
202
+ function confirm() {
203
+ // 异步关闭
204
+ if (props.asyncClose) {
205
+ loading.value = true;
206
+ } else {
207
+ emit('update:modelValue', false);
208
+ }
209
+ emit('confirm');
210
+ }
211
+
212
+ /**
213
+ * 取消按钮点击事件
214
+ */
215
+ function cancel() {
216
+ emit('cancel');
217
+ emit('update:modelValue', false);
218
+ // 目前popup弹窗关闭有一个延时操作,此处做一个延时
219
+ // 避免确认按钮文字变成了"确定"字样,modal还没消失,造成视觉不好的效果
220
+ setTimeout(() => {
221
+ loading.value = false;
222
+ }, 300);
223
+ }
224
+
225
+ /**
226
+ * 点击遮罩关闭modal,设置v-model的值为false,否则无法第二次弹起modal
227
+ */
228
+ function popupClose() {
229
+ emit('update:modelValue', false);
230
+ }
231
+
232
+ /**
233
+ * 清除加载中的状态
234
+ */
235
+ function clearLoading() {
236
+ loading.value = false;
237
+ }
238
+ </script>
239
+
240
+ <style lang="scss" scoped>
241
+ @import '../../libs/css/style.components.scss';
242
+
243
+ .u-model {
244
+ height: auto;
245
+ overflow: hidden;
246
+ font-size: 32rpx;
247
+ background-color: #fff;
248
+
249
+ &__btn--hover {
250
+ background-color: rgb(230, 230, 230);
251
+ }
252
+
253
+ &__title {
254
+ padding-top: 48rpx;
255
+ font-weight: 500;
256
+ text-align: center;
257
+ color: $u-main-color;
258
+ }
259
+
260
+ &__content {
261
+ &__message {
262
+ padding: 48rpx;
263
+ font-size: 30rpx;
264
+ text-align: center;
265
+ color: $u-content-color;
266
+ }
267
+ }
268
+
269
+ &__footer {
270
+ @include vue-flex;
271
+
272
+ &__button {
273
+ flex: 1;
274
+ height: 100rpx;
275
+ line-height: 100rpx;
276
+ font-size: 32rpx;
277
+ box-sizing: border-box;
278
+ cursor: pointer;
279
+ text-align: center;
280
+ border-radius: 4rpx;
281
+ }
282
+ }
283
+ }
284
+ </style>