mirror of
https://gitee.com/vant-contrib/vant-weapp.git
synced 2025-04-06 03:58:05 +08:00
feat(uploader): add showmenu prop support (#5229)
Co-authored-by: liuhaihonggia <liuhaihong@youzan.com>
This commit is contained in:
parent
3d0615e042
commit
bcae47b8d0
@ -244,7 +244,8 @@ uploadFilePromise(fileName, chooseResult) {
|
|||||||
| compressed | 当 accept 为 `video` 时生效,是否压缩视频,默认为`true` | _boolean_ | - |
|
| compressed | 当 accept 为 `video` 时生效,是否压缩视频,默认为`true` | _boolean_ | - |
|
||||||
| max-duration | 当 accept 为 `video` \| `media` 时生效,拍摄视频最长拍摄时间,单位秒 | _number_ | `60` |
|
| max-duration | 当 accept 为 `video` \| `media` 时生效,拍摄视频最长拍摄时间,单位秒 | _number_ | `60` |
|
||||||
| media-type `v1.10.8` | 当 accept 为 `media` 时生效,选择的文件的文件类型,可选值为 `image` `video` | _string[]_ | `['image', 'video']` |
|
| media-type `v1.10.8` | 当 accept 为 `media` 时生效,选择的文件的文件类型,可选值为 `image` `video` | _string[]_ | `['image', 'video']` |
|
||||||
| extension `v1.10.11` | 当 accept 为 `file` 时生效,根据文件拓展名过滤可选择文件。每一项都不能是空字符串。默认不过滤 | _string[] | undefined_ | - |
|
| extension `v1.10.11` | 当 accept 为 `file` 时生效,根据文件拓展名过滤可选择文件。每一项都不能是空字符串。默认不过滤 | _string[] \| undefined_ | - |
|
||||||
|
| showmenu `v1.10.13` | 预览图片时,是否显示长按菜单 | _boolean_ | `true` |
|
||||||
| upload-icon | 上传区域图标,可选值见 [Icon 组件](#/icon) | _string_ | `plus` |
|
| upload-icon | 上传区域图标,可选值见 [Icon 组件](#/icon) | _string_ | `plus` |
|
||||||
|
|
||||||
#### accept 的合法值
|
#### accept 的合法值
|
||||||
@ -261,14 +262,14 @@ uploadFilePromise(fileName, chooseResult) {
|
|||||||
|
|
||||||
`file-list` 为一个对象数组,数组中的每一个对象包含以下 `key`。
|
`file-list` 为一个对象数组,数组中的每一个对象包含以下 `key`。
|
||||||
|
|
||||||
| 参数 | 说明 |
|
| 参数 | 说明 |
|
||||||
| --------- | ------------------------------------------------------ |
|
| --- | --- |
|
||||||
| `url` | 图片和视频的网络资源地址 |
|
| `url` | 图片和视频的网络资源地址 |
|
||||||
| `name` | 文件名称,视频将在全屏预览时作为标题显示 |
|
| `name` | 文件名称,视频将在全屏预览时作为标题显示 |
|
||||||
| `thumb` | 图片缩略图或视频封面的网络资源地址,仅对图片和视频有效,`accept` 为 `video`时,真机不会返回该属性,建议使用 `media` 和 `media-type` 配合完成视频上传 |
|
| `thumb` | 图片缩略图或视频封面的网络资源地址,仅对图片和视频有效,`accept` 为 `video`时,真机不会返回该属性,建议使用 `media` 和 `media-type` 配合完成视频上传 |
|
||||||
| `type` | 文件类型,可选值`image` `video` `file` |
|
| `type` | 文件类型,可选值`image` `video` `file` |
|
||||||
| `isImage` | 手动标记图片资源 |
|
| `isImage` | 手动标记图片资源 |
|
||||||
| `isVideo` | 手动标记视频资源 |
|
| `isVideo` | 手动标记视频资源 |
|
||||||
|
|
||||||
### Slot
|
### Slot
|
||||||
|
|
||||||
|
@ -1,11 +1,6 @@
|
|||||||
import { VantComponent } from '../common/component';
|
import { VantComponent } from '../common/component';
|
||||||
import { isImageFile, chooseFile, isVideoFile, File } from './utils';
|
import { isImageFile, chooseFile, isVideoFile, File } from './utils';
|
||||||
import {
|
import { imageProps, videoProps, mediaProps, messageFileProps } from './shared';
|
||||||
chooseImageProps,
|
|
||||||
chooseVideoProps,
|
|
||||||
chooseMediaProps,
|
|
||||||
chooseMessageFileProps,
|
|
||||||
} from './shared';
|
|
||||||
import { isBoolean, isPromise } from '../common/validator';
|
import { isBoolean, isPromise } from '../common/validator';
|
||||||
|
|
||||||
VantComponent({
|
VantComponent({
|
||||||
@ -65,10 +60,10 @@ VantComponent({
|
|||||||
type: String,
|
type: String,
|
||||||
value: 'photograph',
|
value: 'photograph',
|
||||||
},
|
},
|
||||||
...chooseImageProps,
|
...imageProps,
|
||||||
...chooseVideoProps,
|
...videoProps,
|
||||||
...chooseMediaProps,
|
...mediaProps,
|
||||||
...chooseMessageFileProps,
|
...messageFileProps,
|
||||||
},
|
},
|
||||||
|
|
||||||
data: {
|
data: {
|
||||||
@ -175,12 +170,13 @@ VantComponent({
|
|||||||
if (!this.data.previewFullImage) return;
|
if (!this.data.previewFullImage) return;
|
||||||
|
|
||||||
const { index } = event.currentTarget.dataset;
|
const { index } = event.currentTarget.dataset;
|
||||||
const { lists } = this.data;
|
const { lists, showmenu } = this.data;
|
||||||
const item = lists[index];
|
const item = lists[index];
|
||||||
|
|
||||||
wx.previewImage({
|
wx.previewImage({
|
||||||
urls: lists.filter((item) => isImageFile(item)).map((item) => item.url),
|
urls: lists.filter((item) => isImageFile(item)).map((item) => item.url),
|
||||||
current: item.url,
|
current: item.url,
|
||||||
|
showmenu,
|
||||||
fail() {
|
fail() {
|
||||||
wx.showToast({ title: '预览图片失败', icon: 'none' });
|
wx.showToast({ title: '预览图片失败', icon: 'none' });
|
||||||
},
|
},
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
// props for choose image
|
// props for image
|
||||||
export const chooseImageProps = {
|
export const imageProps = {
|
||||||
sizeType: {
|
sizeType: {
|
||||||
type: Array,
|
type: Array,
|
||||||
value: ['original', 'compressed'],
|
value: ['original', 'compressed'],
|
||||||
@ -8,10 +8,14 @@ export const chooseImageProps = {
|
|||||||
type: Array,
|
type: Array,
|
||||||
value: ['album', 'camera'],
|
value: ['album', 'camera'],
|
||||||
},
|
},
|
||||||
|
showmenu: {
|
||||||
|
type: Boolean,
|
||||||
|
value: true,
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
// props for choose video
|
// props for video
|
||||||
export const chooseVideoProps = {
|
export const videoProps = {
|
||||||
capture: {
|
capture: {
|
||||||
type: Array,
|
type: Array,
|
||||||
value: ['album', 'camera'],
|
value: ['album', 'camera'],
|
||||||
@ -30,8 +34,8 @@ export const chooseVideoProps = {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
// props for choose media
|
// props for media
|
||||||
export const chooseMediaProps = {
|
export const mediaProps = {
|
||||||
capture: {
|
capture: {
|
||||||
type: Array,
|
type: Array,
|
||||||
value: ['album', 'camera'],
|
value: ['album', 'camera'],
|
||||||
@ -50,7 +54,7 @@ export const chooseMediaProps = {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
// props for choose file
|
// props for file
|
||||||
export const chooseMessageFileProps = {
|
export const messageFileProps = {
|
||||||
extension: null,
|
extension: null,
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user