1.0.9 • Published 6 years ago
wm-upload v1.0.9
wm-upload
wm-upload 组件会自动生成inputfile 只需要 在click 时间中调用new 方法 传入三个参数 第一个参数json对象 第二个参数为成功后的回调 第三个参数是失败回调
必填项
- getConfigUrl
- businessType
- uploadTerminal
- type
businessType 参数类型说明
- 00101 资讯图片
- 00102 专题图片
- 00103 营销图片
- 00104 内容聚合页图片
- 00105 自建档案图片
- 00106 一问一答聊天图片
- 00107 一问一答、图文咨询提交描述图片
- 00108 医疗图片
- 00109 今日好孕分享图片
- 00110 医生端认证图片
- 00111 职工头像
- 00112 海淘身份认证图片
- 00113 商品截图分享图片
- 00114 用户扫描证件上传图片
- 00201 医生端音频
- 00301 视频
- 00401 文件
uploadTerminal 参数说明
- uploadTerminal: '1' --APP端
- uploadTerminal: '2' --PC 端,
type 参数说明
- 支持 image, audio, video , application 格式 默认image
maxLength 参数说明
- 最多还能传几张
beforeUpload
- 请求前处理
successfn 回调方法说明
- 返回图片数组 {index:xxxxx,url:xxxxx},{index:xxxxx,url:xxxxx}
- index 为图片索引根据业务场景使用
- url 图片地址
import Upload from 'wm-upload';
new Upload({
getConfigUrl: wx_config.serverUrl + '/contentcenter/api/oss/signature/generate',
businessType: '00107',
uploadTerminal: '1',
type: this.props.type || 'image',
maxLength:6,
beforeUpload: () => {
// 上传前的处理
self.loading = Modal.loading();
}
// ratio:0.95, //图片质量
},(res) => {
// 成功的回调
this.fileList = this.fileList.concat(res.fileList)
this.setImageList(this.fileList)
self.loading && Modal.closeModal(self.loading)
}, (res) => {
// 失败的回调
Modal.toast(res.msg);
console.log(res)
})