|
4 | 4 | <wd-privacy-popup></wd-privacy-popup> |
5 | 5 | <!-- #endif --> |
6 | 6 | <wd-message-box></wd-message-box> |
7 | | - <wd-toast id="wd-toast"></wd-toast> |
| 7 | + <wd-toast></wd-toast> |
8 | 8 | <demo-block title="基本用法"> |
9 | | - <wd-upload :file-list="fileList1" image-mode="aspectFill" :action="action" @change="handleChange1"></wd-upload> |
10 | | - </demo-block> |
11 | | - <demo-block title="多选上传"> |
12 | | - <wd-upload :file-list="fileList2" multiple :action="action" @change="handleChange2"></wd-upload> |
| 9 | + <wd-upload accept="image" :file-list="fileList" image-mode="aspectFill" :action="action" @change="handleChange"></wd-upload> |
13 | 10 | </demo-block> |
14 | 11 | <demo-block title="最大上传数限制"> |
15 | 12 | <wd-upload :file-list="fileList3" :limit="3" :action="action" @change="handleChange3"></wd-upload> |
|
48 | 45 | <!-- <demo-block title="上传至oss"> |
49 | 46 | <wd-upload :file-list="fileList11" action="https://xxx.aliyuncs.com" :build-form-data="buildFormData" @change="handleChange11"></wd-upload> |
50 | 47 | </demo-block> --> |
| 48 | + |
| 49 | + <demo-block title="上传视频"> |
| 50 | + <wd-upload accept="video" multiple :file-list="fileList1" :action="action" @change="handleChange1"></wd-upload> |
| 51 | + </demo-block> |
| 52 | + |
| 53 | + <!-- #ifdef MP-WEIXIN --> |
| 54 | + <demo-block title="上传视频和图片"> |
| 55 | + <wd-upload accept="media" multiple :file-list="fileList11" :action="action" @change="handleChange11"></wd-upload> |
| 56 | + </demo-block> |
| 57 | + <demo-block title="仅上传文件"> |
| 58 | + <wd-upload accept="file" multiple :file-list="fileList12" :action="action" @change="handleChange12"></wd-upload> |
| 59 | + </demo-block> |
| 60 | + <!-- #endif --> |
| 61 | + |
| 62 | + <!-- #ifdef MP-WEIXIN || H5 --> |
| 63 | + <demo-block title="上传视频图片和文件"> |
| 64 | + <wd-upload accept="all" multiple :file-list="fileList13" :action="action" @change="handleChange13"></wd-upload> |
| 65 | + </demo-block> |
| 66 | + <!-- #endif --> |
51 | 67 | </page-wraper> |
52 | 68 | </template> |
53 | 69 | <script lang="ts" setup> |
54 | 70 | import { useToast, useMessage } from '@/uni_modules/wot-design-uni' |
| 71 | +import type { UploadFile } from '@/uni_modules/wot-design-uni/components/wd-upload/types' |
55 | 72 | import { ref } from 'vue' |
56 | 73 |
|
57 | | -const action: string = 'https://ftf.jd.com/api/uploadImg' |
58 | | -const fileList1 = ref<any[]>([ |
| 74 | +const action: string = 'https://mockapi.eolink.com/zhTuw2P8c29bc981a741931bdd86eb04dc1e8fd64865cb5/upload' |
| 75 | +const fileList = ref<UploadFile[]>([ |
59 | 76 | { |
60 | 77 | url: 'https://img.yzcdn.cn/vant/cat.jpeg' |
61 | 78 | } |
62 | 79 | ]) |
63 | | -const fileList2 = ref<any[]>([ |
| 80 | +
|
| 81 | +const fileList1 = ref<UploadFile[]>([]) |
| 82 | +const fileList2 = ref<UploadFile[]>([ |
64 | 83 | { |
65 | 84 | url: 'https://img12.360buyimg.com//n0/jfs/t1/29118/6/4823/55969/5c35c16bE7c262192/c9fdecec4b419355.jpg' |
66 | 85 | } |
67 | 86 | ]) |
68 | | -const fileList3 = ref([]) |
69 | | -const fileList4 = ref([]) |
70 | | -const fileList5 = ref([]) |
71 | | -const fileList6 = ref([]) |
72 | | -const fileList7 = ref([]) |
73 | | -const fileList8 = ref([]) |
74 | | -const fileList9 = ref([]) |
75 | | -const fileList10 = ref([]) |
76 | | -const fileList11 = ref([]) |
| 87 | +const fileList3 = ref<UploadFile[]>([]) |
| 88 | +const fileList4 = ref<UploadFile[]>([]) |
| 89 | +const fileList5 = ref<UploadFile[]>([]) |
| 90 | +const fileList6 = ref<UploadFile[]>([]) |
| 91 | +const fileList7 = ref<UploadFile[]>([]) |
| 92 | +const fileList8 = ref<UploadFile[]>([]) |
| 93 | +const fileList9 = ref<UploadFile[]>([]) |
| 94 | +const fileList10 = ref<UploadFile[]>([]) |
| 95 | +const fileList11 = ref<UploadFile[]>([]) |
| 96 | +const fileList12 = ref<UploadFile[]>([]) |
| 97 | +const fileList13 = ref<UploadFile[]>([]) |
| 98 | +const fileList14 = ref<UploadFile[]>([]) |
| 99 | +const fileList15 = ref<UploadFile[]>([]) |
77 | 100 |
|
78 | 101 | const messageBox = useMessage() |
79 | 102 | const toast = useToast() |
@@ -176,7 +199,17 @@ function handleFail(event: any) { |
176 | 199 | function handleProgess(event: any) { |
177 | 200 | console.log('加载中', event) |
178 | 201 | } |
179 | | -function handleChange1({ fileList }: any) { |
| 202 | +
|
| 203 | +function handleChange({ fileList }: any) { |
| 204 | + fileList.value = fileList |
| 205 | +} |
| 206 | +
|
| 207 | +function handleChange1({ fileList }: { fileList: UploadFile[] }) { |
| 208 | + // fileList.forEach((item) => { |
| 209 | + // if (!item.thumb) { |
| 210 | + // item.thumb = 'https://unpkg.com/wot-design-uni-assets/redpanda.jpg' |
| 211 | + // } |
| 212 | + // }) |
180 | 213 | fileList1.value = fileList |
181 | 214 | } |
182 | 215 | function handleChange2({ fileList }: any) { |
@@ -209,5 +242,14 @@ function handleChange10({ fileList }: any) { |
209 | 242 | function handleChange11({ fileList }: any) { |
210 | 243 | fileList11.value = fileList |
211 | 244 | } |
| 245 | +function handleChange12({ fileList }: any) { |
| 246 | + fileList12.value = fileList |
| 247 | +} |
| 248 | +function handleChange13({ fileList }: any) { |
| 249 | + fileList13.value = fileList |
| 250 | +} |
| 251 | +function handleChange14({ fileList }: any) { |
| 252 | + fileList14.value = fileList |
| 253 | +} |
212 | 254 | </script> |
213 | 255 | <style lang="scss" scoped></style> |
0 commit comments