hy-app 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.
- package/README.md +42 -0
- package/api/http.ts +138 -0
- package/api/index.ts +1 -0
- package/common/index.ts +1 -0
- package/common/versionControl.ts +102 -0
- package/components/dialog/TheDialog.vue +128 -0
- package/components/dialog/index.ts +38 -0
- package/components/hy-address-picker/hy-address-picker.vue +262 -0
- package/components/hy-address-picker/props.ts +27 -0
- package/components/hy-address-picker/typing.d.ts +98 -0
- package/components/hy-avatar/hy-avatar.vue +217 -0
- package/components/hy-avatar/props.ts +20 -0
- package/components/hy-avatar/typing.d.ts +64 -0
- package/components/hy-back-top/hy-back-top.vue +71 -0
- package/components/hy-back-top/props.ts +23 -0
- package/components/hy-back-top/typing.d.ts +49 -0
- package/components/hy-badge/hy-badge.vue +155 -0
- package/components/hy-badge/props.ts +19 -0
- package/components/hy-badge/typing.d.ts +60 -0
- package/components/hy-button/hy-button.vue +394 -0
- package/components/hy-button/props.ts +36 -0
- package/components/hy-button/typing.d.ts +125 -0
- package/components/hy-card/hy-card.vue +198 -0
- package/components/hy-card/props.ts +29 -0
- package/components/hy-card/typing.d.ts +112 -0
- package/components/hy-cell/hy-cell.vue +268 -0
- package/components/hy-cell/props.ts +20 -0
- package/components/hy-cell/typing.d.ts +98 -0
- package/components/hy-check-button/hy-check-button.vue +71 -0
- package/components/hy-check-button/props.ts +20 -0
- package/components/hy-check-button/typing.d.ts +79 -0
- package/components/hy-checkbox/hy-checkbox.vue +299 -0
- package/components/hy-checkbox/props.ts +28 -0
- package/components/hy-checkbox/typing.d.ts +77 -0
- package/components/hy-datetime-picker/hy-datetime-picker.vue +584 -0
- package/components/hy-datetime-picker/props.ts +36 -0
- package/components/hy-datetime-picker/typing.d.ts +135 -0
- package/components/hy-divider/hy-divider.vue +164 -0
- package/components/hy-divider/props.ts +21 -0
- package/components/hy-divider/typing.d.ts +64 -0
- package/components/hy-empty/hy-empty.vue +122 -0
- package/components/hy-empty/props.ts +21 -0
- package/components/hy-empty/typing.d.ts +68 -0
- package/components/hy-folding-panel/hy-folding-panel.vue +94 -0
- package/components/hy-folding-panel/props.ts +17 -0
- package/components/hy-folding-panel/typing.d.ts +59 -0
- package/components/hy-form/hy-form.vue +372 -0
- package/components/hy-form/props.ts +15 -0
- package/components/hy-form/typing.d.ts +51 -0
- package/components/hy-grid/hy-grid.vue +126 -0
- package/components/hy-grid/props.ts +16 -0
- package/components/hy-grid/typing.d.ts +62 -0
- package/components/hy-icon/hy-icon.vue +207 -0
- package/components/hy-icon/props.ts +24 -0
- package/components/hy-icon/typing.d.ts +80 -0
- package/components/hy-input/hy-input.vue +402 -0
- package/components/hy-input/props.ts +41 -0
- package/components/hy-input/typing.d.ts +148 -0
- package/components/hy-line/hy-line.vue +44 -0
- package/components/hy-line/props.ts +12 -0
- package/components/hy-line/typing.d.ts +32 -0
- package/components/hy-line-progress/hy-line-progress.vue +118 -0
- package/components/hy-line-progress/props.ts +12 -0
- package/components/hy-line-progress/typing.d.ts +28 -0
- package/components/hy-list/hy-list.vue +250 -0
- package/components/hy-list/props.ts +18 -0
- package/components/hy-list/typing.d.ts +50 -0
- package/components/hy-login/ThePhoneLogin.vue +106 -0
- package/components/hy-login/TheUserLogin.vue +391 -0
- package/components/hy-login/hy-login.vue +283 -0
- package/components/hy-login/props.ts +32 -0
- package/components/hy-login/typing.d.ts +60 -0
- package/components/hy-modal/hy-modal.vue +240 -0
- package/components/hy-modal/props.ts +24 -0
- package/components/hy-modal/typing.d.ts +70 -0
- package/components/hy-navbar/hy-navbar.vue +194 -0
- package/components/hy-navbar/props.ts +24 -0
- package/components/hy-navbar/typing.d.ts +81 -0
- package/components/hy-notice-bar/hy-column-notice.vue +130 -0
- package/components/hy-notice-bar/hy-notice-bar.vue +82 -0
- package/components/hy-notice-bar/hy-row-notice.vue +182 -0
- package/components/hy-notice-bar/props.ts +19 -0
- package/components/hy-notice-bar/typing.d.ts +56 -0
- package/components/hy-number-step/hy-number-step.vue +428 -0
- package/components/hy-number-step/props.ts +29 -0
- package/components/hy-number-step/typing.d.ts +104 -0
- package/components/hy-overlay/hy-overlay.vue +54 -0
- package/components/hy-overlay/props.ts +10 -0
- package/components/hy-overlay/typing.d.ts +24 -0
- package/components/hy-picker/hy-picker.vue +499 -0
- package/components/hy-picker/props.ts +30 -0
- package/components/hy-picker/typing.d.ts +115 -0
- package/components/hy-popup/hy-popup.vue +269 -0
- package/components/hy-popup/props.ts +21 -0
- package/components/hy-popup/typing.d.ts +68 -0
- package/components/hy-price/hy-price.vue +86 -0
- package/components/hy-price/props.ts +13 -0
- package/components/hy-price/typing.d.ts +36 -0
- package/components/hy-qrcode/hy-qrcode.vue +153 -0
- package/components/hy-qrcode/props.ts +20 -0
- package/components/hy-qrcode/qrcode.js +1364 -0
- package/components/hy-qrcode/typing.d.ts +64 -0
- package/components/hy-radio/hy-radio.vue +319 -0
- package/components/hy-radio/props.ts +28 -0
- package/components/hy-radio/typing.d.ts +85 -0
- package/components/hy-rate/hy-rate.vue +261 -0
- package/components/hy-rate/props.ts +18 -0
- package/components/hy-rate/typing.d.ts +60 -0
- package/components/hy-read-more/hy-read-more.vue +134 -0
- package/components/hy-read-more/props.ts +20 -0
- package/components/hy-read-more/typing.d.ts +44 -0
- package/components/hy-safe-bottom/hy-safe-bottom.vue +64 -0
- package/components/hy-scroll-list/hy-scroll-list.vue +146 -0
- package/components/hy-scroll-list/props.ts +12 -0
- package/components/hy-scroll-list/typing.d.ts +28 -0
- package/components/hy-search/hy-search.vue +294 -0
- package/components/hy-search/props.ts +29 -0
- package/components/hy-search/typing.d.ts +109 -0
- package/components/hy-slider/hy-slider.vue +511 -0
- package/components/hy-slider/props.ts +21 -0
- package/components/hy-slider/typing.d.ts +68 -0
- package/components/hy-steps/hy-steps.vue +352 -0
- package/components/hy-steps/props.ts +15 -0
- package/components/hy-steps/typing.d.ts +58 -0
- package/components/hy-subsection/hy-subsection.vue +272 -0
- package/components/hy-subsection/props.ts +16 -0
- package/components/hy-subsection/typing.d.ts +44 -0
- package/components/hy-swiper/hy-swiper-indicator.vue +105 -0
- package/components/hy-swiper/hy-swiper.vue +242 -0
- package/components/hy-swiper/props.ts +30 -0
- package/components/hy-swiper/typing.d.ts +107 -0
- package/components/hy-switch/hy-switch.vue +168 -0
- package/components/hy-switch/props.ts +16 -0
- package/components/hy-switch/typing.d.ts +48 -0
- package/components/hy-tabs/hy-tabs.vue +416 -0
- package/components/hy-tabs/props.ts +26 -0
- package/components/hy-tabs/typing.d.ts +86 -0
- package/components/hy-tag/hy-tag.vue +374 -0
- package/components/hy-tag/props.ts +22 -0
- package/components/hy-tag/typing.d.ts +76 -0
- package/components/hy-textarea/hy-textarea.vue +229 -0
- package/components/hy-textarea/props.ts +26 -0
- package/components/hy-textarea/typing.d.ts +27 -0
- package/components/hy-tooltip/hy-tooltip.vue +332 -0
- package/components/hy-tooltip/props.ts +17 -0
- package/components/hy-tooltip/typing.d.ts +52 -0
- package/components/hy-transition/hy-transition.vue +150 -0
- package/components/hy-transition/index.scss +113 -0
- package/components/hy-transition/props.ts +10 -0
- package/components/hy-transition/typing.d.ts +36 -0
- package/components/hy-upload/hy-upload.vue +557 -0
- package/components/hy-upload/props.ts +29 -0
- package/components/hy-upload/typing.d.ts +147 -0
- package/components/hy-warn/hy-warn.vue +228 -0
- package/components/hy-warn/props.ts +14 -0
- package/components/hy-warn/typing.d.ts +40 -0
- package/components/hy-waterfall/hy-waterfall.vue +51 -0
- package/components/hy-waterfall/props.ts +10 -0
- package/components/hy-waterfall/typing.d.ts +20 -0
- package/components/index.ts +162 -0
- package/components/message/TheMessage.vue +169 -0
- package/components/message/index.ts +54 -0
- package/components/u-form/form.js +22 -0
- package/components/u-form/hy-form.vue +324 -0
- package/components/u-form/props.js +49 -0
- package/components/u-form/schema.js +1451 -0
- package/components/u-form/u-form.vue +267 -0
- package/components/u-form/utils.js +65 -0
- package/components/u-form-item/formItem.js +24 -0
- package/components/u-form-item/hy-form-item.vue +360 -0
- package/components/u-form-item/props.js +57 -0
- package/components/u-form-item/u-form-item.vue +294 -0
- package/components/yk-dialog/yk-dialog.vue +129 -0
- package/components/yk-tabbar/props.ts +49 -0
- package/components/yk-tabbar/yk-tabbar.vue +224 -0
- package/config/color.ts +6 -0
- package/config/icon.ts +366 -0
- package/config/index.ts +2 -0
- package/global/index.ts +6 -0
- package/global/register-properties.ts +37 -0
- package/index.ts +8 -0
- package/libs/css/common.scss +0 -0
- package/libs/css/iconfont.css +379 -0
- package/libs/css/iconfont.ttf +0 -0
- package/libs/css/mixin.scss +15 -0
- package/package.json +42 -0
- package/public/icons/error.png +0 -0
- package/public/icons/success.png +0 -0
- package/public/icons/warning.png +0 -0
- package/store/index.ts +1 -0
- package/store/userInfo.ts +25 -0
- package/theme.scss +94 -0
- package/typing/index.ts +7 -0
- package/typing/modules/common.d.ts +50 -0
- package/typing/modules/dialog.ts +17 -0
- package/typing/modules/enum.ts +67 -0
- package/typing/modules/form.ts +161 -0
- package/typing/modules/http.ts +68 -0
- package/typing/modules/icon.d.ts +366 -0
- package/typing/modules/img.ts +15 -0
- package/typing/modules/rect.ts +10 -0
- package/utils/address.json +5890 -0
- package/utils/base64.ts +119 -0
- package/utils/index.ts +3 -0
- package/utils/inside.ts +310 -0
- package/utils/utils.ts +446 -0
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { CSSProperties } from "vue";
|
|
2
|
+
|
|
3
|
+
export default interface IProps {
|
|
4
|
+
/**
|
|
5
|
+
* @description 是否展示组件
|
|
6
|
+
* */
|
|
7
|
+
show: boolean;
|
|
8
|
+
/**
|
|
9
|
+
* @description 使用的动画模式(默认:fade)
|
|
10
|
+
* */
|
|
11
|
+
mode?:
|
|
12
|
+
| "fade"
|
|
13
|
+
| "fade-up"
|
|
14
|
+
| "fade-down"
|
|
15
|
+
| "fade-left"
|
|
16
|
+
| "fade-right"
|
|
17
|
+
| "fade-zoom"
|
|
18
|
+
| "slide-up"
|
|
19
|
+
| "slide-down"
|
|
20
|
+
| "slide-left"
|
|
21
|
+
| "slide-right"
|
|
22
|
+
| "zoom-in"
|
|
23
|
+
| "zoom-out";
|
|
24
|
+
/**
|
|
25
|
+
* @description 动画的执行时间,单位ms
|
|
26
|
+
* */
|
|
27
|
+
duration?: number;
|
|
28
|
+
/**
|
|
29
|
+
* @description 使用的动画过渡函数(默认:ease-out)
|
|
30
|
+
* */
|
|
31
|
+
timingFunction?: string;
|
|
32
|
+
/**
|
|
33
|
+
* @description 定义需要用到的外部样式
|
|
34
|
+
* */
|
|
35
|
+
customStyle?: CSSProperties;
|
|
36
|
+
}
|
|
@@ -0,0 +1,557 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<view class="hy-upload" :style="[customStyle]">
|
|
3
|
+
<view class="hy-upload__wrap">
|
|
4
|
+
<template v-if="previewImage">
|
|
5
|
+
<view
|
|
6
|
+
class="hy-upload__wrap__preview"
|
|
7
|
+
v-for="(item, index) in lists"
|
|
8
|
+
:key="index"
|
|
9
|
+
>
|
|
10
|
+
<image
|
|
11
|
+
v-if="item.isImage || (item.type && item.type === 'image')"
|
|
12
|
+
:src="item.thumb || item.url"
|
|
13
|
+
:mode="imageMode"
|
|
14
|
+
class="hy-upload__wrap__preview__image"
|
|
15
|
+
@tap="onPreviewImage(item, index)"
|
|
16
|
+
:style="[
|
|
17
|
+
{
|
|
18
|
+
width: addUnit(width),
|
|
19
|
+
height: addUnit(height)
|
|
20
|
+
}
|
|
21
|
+
]"
|
|
22
|
+
/>
|
|
23
|
+
<view
|
|
24
|
+
v-else
|
|
25
|
+
class="hy-upload__wrap__preview__other"
|
|
26
|
+
@tap="onClickPreview(item, index)"
|
|
27
|
+
>
|
|
28
|
+
<u-icon
|
|
29
|
+
color="#80CBF9"
|
|
30
|
+
size="26"
|
|
31
|
+
:name="
|
|
32
|
+
item.isVideo || (item.type && item.type === 'video')
|
|
33
|
+
? 'movie'
|
|
34
|
+
: 'folder'
|
|
35
|
+
"
|
|
36
|
+
></u-icon>
|
|
37
|
+
<text class="hy-upload__wrap__preview__other__text">
|
|
38
|
+
{{
|
|
39
|
+
item.isVideo || (item.type && item.type === "video")
|
|
40
|
+
? "视频"
|
|
41
|
+
: "文件"
|
|
42
|
+
}}
|
|
43
|
+
</text>
|
|
44
|
+
</view>
|
|
45
|
+
|
|
46
|
+
<!-- 上传进度条 -->
|
|
47
|
+
<view class="material-sent" v-if="item.status === 'loading'">
|
|
48
|
+
<progress
|
|
49
|
+
class="select-tips"
|
|
50
|
+
:percent="item.schedule"
|
|
51
|
+
stroke-width="4"
|
|
52
|
+
activeColor="#B99C65"
|
|
53
|
+
/>
|
|
54
|
+
<view class="tips-text"> 上传进度{{ item.schedule }}% </view>
|
|
55
|
+
</view>
|
|
56
|
+
<!-- 上传进度条 -->
|
|
57
|
+
|
|
58
|
+
<!-- 删除图片图标 -->
|
|
59
|
+
<view
|
|
60
|
+
class="hy-upload__deletable"
|
|
61
|
+
v-if="item.status !== 'loading' && (deletable || item.deletable)"
|
|
62
|
+
@tap.stop="deleteItem(index)"
|
|
63
|
+
>
|
|
64
|
+
<view class="hy-upload__deletable__icon">
|
|
65
|
+
<HyIcon
|
|
66
|
+
:name="IconConfig.CLOSE"
|
|
67
|
+
color="#ffffff"
|
|
68
|
+
size="14"
|
|
69
|
+
></HyIcon>
|
|
70
|
+
</view>
|
|
71
|
+
</view>
|
|
72
|
+
<!-- 删除图片图标 -->
|
|
73
|
+
|
|
74
|
+
<!-- 上传成功图标 -->
|
|
75
|
+
<view class="hy-upload__success" v-if="item.status === 'success'">
|
|
76
|
+
<!-- #ifndef APP-NVUE -->
|
|
77
|
+
<view class="hy-upload__success__icon">
|
|
78
|
+
<HyIcon
|
|
79
|
+
:name="IconConfig.CHECK_MASK"
|
|
80
|
+
color="#ffffff"
|
|
81
|
+
size="12"
|
|
82
|
+
></HyIcon>
|
|
83
|
+
</view>
|
|
84
|
+
<!-- #endif -->
|
|
85
|
+
</view>
|
|
86
|
+
<!-- 上传成功图标 -->
|
|
87
|
+
</view>
|
|
88
|
+
</template>
|
|
89
|
+
|
|
90
|
+
<template v-if="isInCount">
|
|
91
|
+
<view v-if="$slots.trigger" @tap="chooseFileFn">
|
|
92
|
+
<slot name="trigger" />
|
|
93
|
+
</view>
|
|
94
|
+
<view
|
|
95
|
+
v-else-if="!$slots.trigger && ($slots.default || $slots.$default)"
|
|
96
|
+
@tap="chooseFileFn"
|
|
97
|
+
>
|
|
98
|
+
<slot />
|
|
99
|
+
</view>
|
|
100
|
+
<view
|
|
101
|
+
v-else
|
|
102
|
+
class="hy-upload__button"
|
|
103
|
+
:hover-class="!disabled ? 'hy-upload__button--hover' : ''"
|
|
104
|
+
hover-stay-time="150"
|
|
105
|
+
@tap="chooseFileFn"
|
|
106
|
+
:class="[disabled && 'hy-upload__button--disabled']"
|
|
107
|
+
:style="[
|
|
108
|
+
{
|
|
109
|
+
width: addUnit(width),
|
|
110
|
+
height: addUnit(height)
|
|
111
|
+
}
|
|
112
|
+
]"
|
|
113
|
+
>
|
|
114
|
+
<HyIcon
|
|
115
|
+
:name="uploadIcon"
|
|
116
|
+
size="26"
|
|
117
|
+
:color="uploadIconColor"
|
|
118
|
+
></HyIcon>
|
|
119
|
+
<text v-if="uploadText" class="hy-upload__button__text">{{
|
|
120
|
+
uploadText
|
|
121
|
+
}}</text>
|
|
122
|
+
</view>
|
|
123
|
+
</template>
|
|
124
|
+
</view>
|
|
125
|
+
</view>
|
|
126
|
+
</template>
|
|
127
|
+
|
|
128
|
+
<script setup lang="ts">
|
|
129
|
+
import { ref, toRefs, watch } from "vue";
|
|
130
|
+
import defaultProps from "./props";
|
|
131
|
+
import IProps, { FileVo } from "./typing";
|
|
132
|
+
import { addUnit, chooseFile } from "../../utils";
|
|
133
|
+
import { IconConfig } from "../../config";
|
|
134
|
+
// 组件
|
|
135
|
+
import HyIcon from "../hy-icon/hy-icon.vue";
|
|
136
|
+
|
|
137
|
+
const props = withDefaults(defineProps<IProps>(), defaultProps);
|
|
138
|
+
const {
|
|
139
|
+
accept,
|
|
140
|
+
fileList,
|
|
141
|
+
maxCount,
|
|
142
|
+
disabled,
|
|
143
|
+
extension,
|
|
144
|
+
multiple,
|
|
145
|
+
compressed,
|
|
146
|
+
maxDuration,
|
|
147
|
+
sizeType,
|
|
148
|
+
camera,
|
|
149
|
+
name,
|
|
150
|
+
maxSize,
|
|
151
|
+
previewFullImage,
|
|
152
|
+
deletable,
|
|
153
|
+
useBeforeRead,
|
|
154
|
+
afterRead
|
|
155
|
+
} = toRefs(props);
|
|
156
|
+
const emit = defineEmits([
|
|
157
|
+
"clickPreview",
|
|
158
|
+
"beforeRead",
|
|
159
|
+
"error",
|
|
160
|
+
"delete",
|
|
161
|
+
"afterRead",
|
|
162
|
+
"oversize"
|
|
163
|
+
]);
|
|
164
|
+
|
|
165
|
+
const lists = ref<FileVo[]>([]);
|
|
166
|
+
const isInCount = ref<boolean>(true);
|
|
167
|
+
const previewImage = ref<boolean>(true);
|
|
168
|
+
|
|
169
|
+
const formatFileList = () => {
|
|
170
|
+
lists.value = fileList.value.map((item: FileVo) =>
|
|
171
|
+
Object.assign(Object.assign({}, item), {
|
|
172
|
+
// 如果item.url为本地选择的blob文件的话,无法判断其为video还是image,此处优先通过accept做判断处理
|
|
173
|
+
isImage: accept.value === "image",
|
|
174
|
+
isVideo: accept.value === "video",
|
|
175
|
+
deletable: item.deletable || deletable.value
|
|
176
|
+
})
|
|
177
|
+
);
|
|
178
|
+
isInCount.value = lists.value.length < maxCount.value;
|
|
179
|
+
};
|
|
180
|
+
|
|
181
|
+
watch(
|
|
182
|
+
() => fileList.value,
|
|
183
|
+
() => {
|
|
184
|
+
formatFileList();
|
|
185
|
+
},
|
|
186
|
+
{ immediate: true, deep: true }
|
|
187
|
+
);
|
|
188
|
+
|
|
189
|
+
watch(
|
|
190
|
+
() => deletable.value,
|
|
191
|
+
() => {
|
|
192
|
+
formatFileList();
|
|
193
|
+
}
|
|
194
|
+
);
|
|
195
|
+
|
|
196
|
+
watch(
|
|
197
|
+
() => maxCount.value,
|
|
198
|
+
() => {
|
|
199
|
+
formatFileList();
|
|
200
|
+
}
|
|
201
|
+
);
|
|
202
|
+
|
|
203
|
+
watch(
|
|
204
|
+
() => accept.value,
|
|
205
|
+
() => {
|
|
206
|
+
formatFileList();
|
|
207
|
+
}
|
|
208
|
+
);
|
|
209
|
+
|
|
210
|
+
const chooseFileFn = () => {
|
|
211
|
+
if (disabled.value) return;
|
|
212
|
+
// 如果用户传入的是字符串,需要格式化成数组
|
|
213
|
+
let capture;
|
|
214
|
+
try {
|
|
215
|
+
capture = Array.isArray(capture) ? capture : capture!.split(",");
|
|
216
|
+
} catch (e) {
|
|
217
|
+
capture = [];
|
|
218
|
+
}
|
|
219
|
+
chooseFile(
|
|
220
|
+
Object.assign(
|
|
221
|
+
{
|
|
222
|
+
accept: accept.value,
|
|
223
|
+
extension: extension.value,
|
|
224
|
+
multiple: multiple.value,
|
|
225
|
+
capture: capture,
|
|
226
|
+
compressed: compressed.value,
|
|
227
|
+
maxDuration: maxDuration.value,
|
|
228
|
+
sizeType: sizeType.value,
|
|
229
|
+
camera: camera.value
|
|
230
|
+
},
|
|
231
|
+
{
|
|
232
|
+
maxCount: maxCount.value - lists.value.length
|
|
233
|
+
}
|
|
234
|
+
)
|
|
235
|
+
)
|
|
236
|
+
.then((res: any) => {
|
|
237
|
+
onBeforeRead(multiple.value ? res : res[0]);
|
|
238
|
+
})
|
|
239
|
+
.catch((error) => {
|
|
240
|
+
emit("error", error);
|
|
241
|
+
});
|
|
242
|
+
};
|
|
243
|
+
// 文件读取之前
|
|
244
|
+
const onBeforeRead = (file: FileVo) => {
|
|
245
|
+
let res: any = true;
|
|
246
|
+
// beforeRead是否为一个方法
|
|
247
|
+
if (typeof props.beforeRead === "function") {
|
|
248
|
+
// 如果用户定义了此方法,则去执行此方法,并传入读取的文件回调
|
|
249
|
+
res = props.beforeRead(file, getDetail());
|
|
250
|
+
}
|
|
251
|
+
if (useBeforeRead.value) {
|
|
252
|
+
res = new Promise((resolve, reject) => {
|
|
253
|
+
emit(
|
|
254
|
+
"beforeRead",
|
|
255
|
+
Object.assign(
|
|
256
|
+
Object.assign(
|
|
257
|
+
{
|
|
258
|
+
file
|
|
259
|
+
},
|
|
260
|
+
getDetail()
|
|
261
|
+
),
|
|
262
|
+
{
|
|
263
|
+
callback: (ok: any) => {
|
|
264
|
+
ok ? resolve(ok) : reject();
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
)
|
|
268
|
+
);
|
|
269
|
+
});
|
|
270
|
+
}
|
|
271
|
+
if (!res) return;
|
|
272
|
+
if (typeof res === "function") {
|
|
273
|
+
res.then((data: any) => onAfterRead(data || file));
|
|
274
|
+
} else {
|
|
275
|
+
onAfterRead(file);
|
|
276
|
+
}
|
|
277
|
+
};
|
|
278
|
+
const getDetail = (index?: number) => {
|
|
279
|
+
return {
|
|
280
|
+
name: name.value,
|
|
281
|
+
index: index == null ? fileList.value.length : index
|
|
282
|
+
};
|
|
283
|
+
};
|
|
284
|
+
const onAfterRead = (file: FileVo) => {
|
|
285
|
+
const oversize = Array.isArray(file)
|
|
286
|
+
? file.some((item) => item.size > maxSize.value)
|
|
287
|
+
: file.size > maxSize.value;
|
|
288
|
+
if (oversize) {
|
|
289
|
+
emit(
|
|
290
|
+
"oversize",
|
|
291
|
+
Object.assign(
|
|
292
|
+
{
|
|
293
|
+
file
|
|
294
|
+
},
|
|
295
|
+
getDetail()
|
|
296
|
+
)
|
|
297
|
+
);
|
|
298
|
+
return;
|
|
299
|
+
}
|
|
300
|
+
if (typeof props.afterRead === "function") {
|
|
301
|
+
props.afterRead(file, getDetail());
|
|
302
|
+
}
|
|
303
|
+
emit(
|
|
304
|
+
"afterRead",
|
|
305
|
+
Object.assign(
|
|
306
|
+
{
|
|
307
|
+
file
|
|
308
|
+
},
|
|
309
|
+
getDetail()
|
|
310
|
+
)
|
|
311
|
+
);
|
|
312
|
+
};
|
|
313
|
+
|
|
314
|
+
/**
|
|
315
|
+
* @description 删除文件
|
|
316
|
+
* */
|
|
317
|
+
const deleteItem = (index: number) => {
|
|
318
|
+
fileList.value.splice(index, 1);
|
|
319
|
+
isInCount.value = lists.value.length < maxCount.value;
|
|
320
|
+
emit(
|
|
321
|
+
"delete",
|
|
322
|
+
Object.assign(Object.assign({}, getDetail(index)), {
|
|
323
|
+
file: fileList.value[index]
|
|
324
|
+
})
|
|
325
|
+
);
|
|
326
|
+
};
|
|
327
|
+
|
|
328
|
+
/**
|
|
329
|
+
* @description 预览图片
|
|
330
|
+
* */
|
|
331
|
+
const onPreviewImage = (previewItem: FileVo, index: number) => {
|
|
332
|
+
if (!previewItem.isImage || !previewFullImage.value) return;
|
|
333
|
+
let current = 0;
|
|
334
|
+
const urls = [];
|
|
335
|
+
let imageIndex = 0;
|
|
336
|
+
for (var i = 0; i < lists.value.length; i++) {
|
|
337
|
+
const item: FileVo = lists.value[i];
|
|
338
|
+
if (item.isImage || (item.type && item.type === "image")) {
|
|
339
|
+
urls.push(item.url || item.thumb);
|
|
340
|
+
if (i === index) {
|
|
341
|
+
current = imageIndex;
|
|
342
|
+
}
|
|
343
|
+
imageIndex += 1;
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
if (urls.length < 1) {
|
|
347
|
+
return;
|
|
348
|
+
}
|
|
349
|
+
uni.previewImage({
|
|
350
|
+
urls: urls,
|
|
351
|
+
current: current,
|
|
352
|
+
fail() {
|
|
353
|
+
uni.showToast({ title: "预览图片失败" });
|
|
354
|
+
}
|
|
355
|
+
});
|
|
356
|
+
};
|
|
357
|
+
|
|
358
|
+
/**
|
|
359
|
+
* @description 预览视频
|
|
360
|
+
* */
|
|
361
|
+
const onPreviewVideo = (index: number) => {
|
|
362
|
+
if (!previewFullImage.value) return;
|
|
363
|
+
let current = 0;
|
|
364
|
+
const sources: any[] = [];
|
|
365
|
+
let videoIndex = 0;
|
|
366
|
+
for (let i = 0; i < lists.value.length; i++) {
|
|
367
|
+
const item: FileVo = lists.value[i];
|
|
368
|
+
if (item.isVideo || (item.type && item.type === "video")) {
|
|
369
|
+
sources.push(
|
|
370
|
+
Object.assign(Object.assign({}, item), {
|
|
371
|
+
type: "video"
|
|
372
|
+
})
|
|
373
|
+
);
|
|
374
|
+
if (i === index) {
|
|
375
|
+
current = videoIndex;
|
|
376
|
+
}
|
|
377
|
+
videoIndex += 1;
|
|
378
|
+
}
|
|
379
|
+
}
|
|
380
|
+
if (sources.length < 1) {
|
|
381
|
+
return;
|
|
382
|
+
}
|
|
383
|
+
// #ifdef MP-WEIXIN
|
|
384
|
+
wx.previewMedia({
|
|
385
|
+
sources: sources,
|
|
386
|
+
current: current,
|
|
387
|
+
fail() {
|
|
388
|
+
uni.showToast({ title: "预览视频失败" });
|
|
389
|
+
}
|
|
390
|
+
});
|
|
391
|
+
// #endif
|
|
392
|
+
};
|
|
393
|
+
|
|
394
|
+
const onClickPreview = (item: FileVo, index: number) => {
|
|
395
|
+
if (!previewFullImage.value) return;
|
|
396
|
+
switch (item.type) {
|
|
397
|
+
case "video":
|
|
398
|
+
onPreviewVideo(index);
|
|
399
|
+
break;
|
|
400
|
+
default:
|
|
401
|
+
break;
|
|
402
|
+
}
|
|
403
|
+
emit(
|
|
404
|
+
"clickPreview",
|
|
405
|
+
Object.assign(Object.assign({}, item), getDetail(index))
|
|
406
|
+
);
|
|
407
|
+
};
|
|
408
|
+
</script>
|
|
409
|
+
|
|
410
|
+
<style lang="scss" scoped>
|
|
411
|
+
@import "../../libs/css/mixin.scss";
|
|
412
|
+
@import "../../theme.scss";
|
|
413
|
+
$hy-upload-image-width: 80px !default;
|
|
414
|
+
$hy-upload-text-font-size: 11px !default;
|
|
415
|
+
|
|
416
|
+
.hy-upload {
|
|
417
|
+
@include flex(column);
|
|
418
|
+
flex: 1;
|
|
419
|
+
|
|
420
|
+
&__wrap {
|
|
421
|
+
@include flex;
|
|
422
|
+
flex-wrap: wrap;
|
|
423
|
+
flex: 1;
|
|
424
|
+
|
|
425
|
+
&__preview {
|
|
426
|
+
border-radius: 2px;
|
|
427
|
+
margin: 0 8px 8px 0;
|
|
428
|
+
position: relative;
|
|
429
|
+
overflow: hidden;
|
|
430
|
+
@include flex;
|
|
431
|
+
|
|
432
|
+
&__image {
|
|
433
|
+
width: $hy-upload-image-width;
|
|
434
|
+
height: $hy-upload-image-width;
|
|
435
|
+
}
|
|
436
|
+
|
|
437
|
+
&__other {
|
|
438
|
+
width: $hy-upload-image-width;
|
|
439
|
+
height: $hy-upload-image-width;
|
|
440
|
+
background-color: rgb(242, 242, 242);
|
|
441
|
+
flex: 1;
|
|
442
|
+
@include flex(column);
|
|
443
|
+
justify-content: center;
|
|
444
|
+
align-items: center;
|
|
445
|
+
|
|
446
|
+
&__text {
|
|
447
|
+
font-size: $hy-upload-text-font-size;
|
|
448
|
+
color: $hy-tips-color;
|
|
449
|
+
margin-top: 2px;
|
|
450
|
+
}
|
|
451
|
+
}
|
|
452
|
+
}
|
|
453
|
+
}
|
|
454
|
+
|
|
455
|
+
&__deletable {
|
|
456
|
+
position: absolute;
|
|
457
|
+
top: 0;
|
|
458
|
+
right: 0;
|
|
459
|
+
background-color: rgb(55, 55, 55);
|
|
460
|
+
height: 14px;
|
|
461
|
+
width: 14px;
|
|
462
|
+
@include flex;
|
|
463
|
+
border-bottom-left-radius: 100px;
|
|
464
|
+
align-items: center;
|
|
465
|
+
justify-content: center;
|
|
466
|
+
z-index: 9;
|
|
467
|
+
|
|
468
|
+
&__icon {
|
|
469
|
+
position: absolute;
|
|
470
|
+
transform: scale(0.7);
|
|
471
|
+
top: 0;
|
|
472
|
+
right: 0;
|
|
473
|
+
}
|
|
474
|
+
}
|
|
475
|
+
|
|
476
|
+
&__success {
|
|
477
|
+
position: absolute;
|
|
478
|
+
bottom: 0;
|
|
479
|
+
right: 0;
|
|
480
|
+
@include flex;
|
|
481
|
+
// 由于weex(nvue)为阿里巴巴的KPI(部门业绩考核)的laji产物,不支持css绘制三角形
|
|
482
|
+
// 所以在nvue下使用图片,非nvue下使用css实现
|
|
483
|
+
/* #ifndef APP-NVUE */
|
|
484
|
+
border-style: solid;
|
|
485
|
+
border-color: transparent $hy-success $hy-success transparent;
|
|
486
|
+
border-width: 9px;
|
|
487
|
+
align-items: center;
|
|
488
|
+
justify-content: center;
|
|
489
|
+
/* #endif */
|
|
490
|
+
|
|
491
|
+
&__icon {
|
|
492
|
+
/* #ifndef APP-NVUE */
|
|
493
|
+
position: absolute;
|
|
494
|
+
transform: scale(0.7);
|
|
495
|
+
bottom: -10px;
|
|
496
|
+
right: -10px;
|
|
497
|
+
/* #endif */
|
|
498
|
+
/* #ifdef APP-NVUE */
|
|
499
|
+
width: 16px;
|
|
500
|
+
height: 16px;
|
|
501
|
+
/* #endif */
|
|
502
|
+
}
|
|
503
|
+
}
|
|
504
|
+
|
|
505
|
+
&__button {
|
|
506
|
+
@include flex(column);
|
|
507
|
+
align-items: center;
|
|
508
|
+
justify-content: center;
|
|
509
|
+
width: $hy-upload-image-width;
|
|
510
|
+
height: $hy-upload-image-width;
|
|
511
|
+
background-color: rgb(244, 245, 247);
|
|
512
|
+
border-radius: 2px;
|
|
513
|
+
margin: 0 8px 8px 0;
|
|
514
|
+
/* #ifndef APP-NVUE */
|
|
515
|
+
box-sizing: border-box;
|
|
516
|
+
/* #endif */
|
|
517
|
+
|
|
518
|
+
&__text {
|
|
519
|
+
font-size: $hy-upload-text-font-size;
|
|
520
|
+
color: $hy-tips-color;
|
|
521
|
+
margin-top: 2px;
|
|
522
|
+
}
|
|
523
|
+
|
|
524
|
+
&--hover {
|
|
525
|
+
background-color: rgb(230, 231, 233);
|
|
526
|
+
}
|
|
527
|
+
|
|
528
|
+
&--disabled {
|
|
529
|
+
opacity: 0.5;
|
|
530
|
+
}
|
|
531
|
+
}
|
|
532
|
+
}
|
|
533
|
+
|
|
534
|
+
.material-sent {
|
|
535
|
+
width: 100%;
|
|
536
|
+
height: 100%;
|
|
537
|
+
background: rgba(245, 245, 245, 0.3);
|
|
538
|
+
backdrop-filter: blur(4px);
|
|
539
|
+
position: absolute;
|
|
540
|
+
display: flex;
|
|
541
|
+
justify-content: center;
|
|
542
|
+
align-items: center;
|
|
543
|
+
flex-direction: column;
|
|
544
|
+
z-index: 10;
|
|
545
|
+
|
|
546
|
+
.select-tips {
|
|
547
|
+
width: 70%;
|
|
548
|
+
height: 10rpx;
|
|
549
|
+
margin-bottom: 12rpx;
|
|
550
|
+
}
|
|
551
|
+
|
|
552
|
+
.tips-text {
|
|
553
|
+
font-size: 12px;
|
|
554
|
+
color: #b99c65;
|
|
555
|
+
}
|
|
556
|
+
}
|
|
557
|
+
</style>
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import IProps from "./typing";
|
|
2
|
+
import { IconConfig } from "../../config";
|
|
3
|
+
|
|
4
|
+
const defaultProps: IProps = {
|
|
5
|
+
accept: "image",
|
|
6
|
+
extension: [],
|
|
7
|
+
capture: ["album", "camera"],
|
|
8
|
+
compressed: true,
|
|
9
|
+
camera: "back",
|
|
10
|
+
maxDuration: 60,
|
|
11
|
+
uploadIcon: IconConfig.UPLOAD,
|
|
12
|
+
uploadIconColor: "#D3D4D6",
|
|
13
|
+
useBeforeRead: false,
|
|
14
|
+
previewFullImage: true,
|
|
15
|
+
maxCount: 52,
|
|
16
|
+
disabled: false,
|
|
17
|
+
imageMode: "aspectFill",
|
|
18
|
+
name: "",
|
|
19
|
+
sizeType: ["original", "compressed"],
|
|
20
|
+
multiple: false,
|
|
21
|
+
deletable: true,
|
|
22
|
+
maxSize: Number.MAX_VALUE,
|
|
23
|
+
fileList: [],
|
|
24
|
+
uploadText: "",
|
|
25
|
+
width: 80,
|
|
26
|
+
height: 80
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
export default defaultProps;
|