视频上传
This commit is contained in:
parent
b22db99e63
commit
8c05ceb8fb
|
@ -15,15 +15,24 @@
|
|||
<text style="font-size:24rpx ; color:#E18C34 ;">上传时应注重真实性、清晰度</text>
|
||||
</u-form-item>
|
||||
<view class="" style="display: flex;flex-wrap: wrap;">
|
||||
<u-upload :fileList="formData.imageList" @afterRead="afterRead" @delete="deletePic" name="6"
|
||||
multiple :maxCount="5">
|
||||
<view class='uploadimg' @click="show=true">
|
||||
<u-icon name="plus" color="#777777"></u-icon>
|
||||
<view class="" style="color: #777777;font-size: 20rpx;">
|
||||
上传图片/视频
|
||||
</view>
|
||||
</view>
|
||||
<!-- <view class="" style="width: 100rpx;height: 100rpx;background-color: red;" @click="test">
|
||||
|
||||
</view> -->
|
||||
<!-- <u-upload :fileList="formData.imageList" @afterRead="afterRead" @delete="deletePic" name="6"
|
||||
multiple :maxCount="5" accept="video">
|
||||
<view class='uploadimg'>
|
||||
<u-icon name="plus" color="#777777"></u-icon>
|
||||
<view class="" style="color: #777777;font-size: 24rpx;">
|
||||
上传图片
|
||||
</view>
|
||||
</view>
|
||||
</u-upload>
|
||||
</u-upload> -->
|
||||
</view>
|
||||
</view>
|
||||
<view class="card">
|
||||
|
@ -98,7 +107,8 @@
|
|||
</view>
|
||||
</view>
|
||||
</u-popup>
|
||||
|
||||
<u-picker :show="show" :columns="columns" confirmColor='#33BB3C' @close='show=false' @confirm='choseMedia'
|
||||
@cancel='show=false'></u-picker>
|
||||
|
||||
</view>
|
||||
|
||||
|
@ -131,6 +141,9 @@
|
|||
},
|
||||
data() {
|
||||
return {
|
||||
columns: [
|
||||
['图片', '视频', ]
|
||||
],
|
||||
isWholeSale: false, //批发商
|
||||
show: false, //选择图片还是视屏
|
||||
showCustom: false, //计量单位自定义
|
||||
|
@ -152,24 +165,6 @@
|
|||
],
|
||||
selfAttr: "",
|
||||
formData: {
|
||||
// // store_name: "",
|
||||
// imageList: [],
|
||||
// cate_name: "",
|
||||
// cate_id: "",
|
||||
// attrValue: [{
|
||||
// "price": "",
|
||||
// "unit_name": "",
|
||||
// "wholesale_unit_name": "",
|
||||
// "wholesale_price": '',
|
||||
// "stock": "",
|
||||
// open: true,
|
||||
// spec_type: '单规格'
|
||||
// }],
|
||||
// image: '',
|
||||
// slider_image: [],
|
||||
// delivery_way: [],
|
||||
// attr: [],
|
||||
// // product_attribute: [],
|
||||
"store_name": "",
|
||||
"imageList": [
|
||||
|
||||
|
@ -240,24 +235,100 @@
|
|||
message: '请选择',
|
||||
trigger: ['blur', 'change']
|
||||
}
|
||||
// 'userInfo.name': {
|
||||
// type: 'string',
|
||||
// required: true,
|
||||
// message: '请填写姓名',
|
||||
// trigger: ['blur', 'change']
|
||||
// },
|
||||
// 'userInfo.sex': {
|
||||
// type: 'string',
|
||||
// max: 1,
|
||||
// required: true,
|
||||
// message: '请选择男或女',
|
||||
// trigger: ['blur', 'change']
|
||||
// },
|
||||
|
||||
},
|
||||
};
|
||||
},
|
||||
|
||||
methods: {
|
||||
choseMedia(e) {
|
||||
console.log(e.value)
|
||||
this.show = false
|
||||
if (e.value[0] == '图片') {
|
||||
this.handleChooseImage()
|
||||
// uni.chooseImage({
|
||||
// count: 6, //默认9
|
||||
// sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图,默认二者都有
|
||||
// sourceType: ['album', 'camera'], //从相册选择
|
||||
// success: function(res) {
|
||||
// console.log(JSON.stringify(res.tempFilePaths));
|
||||
// }
|
||||
// });
|
||||
} else {
|
||||
this.uploadVideo()
|
||||
// uni.chooseVideo({
|
||||
// sourceType: ['camera', 'album'],
|
||||
// success: function(res) {
|
||||
// self.src = res.tempFilePath;
|
||||
// }
|
||||
// });
|
||||
}
|
||||
|
||||
},
|
||||
// 选择图片
|
||||
handleChooseImage() {
|
||||
let that = this;
|
||||
that.$util.uploadImageOne('upload/image', function(res) {
|
||||
// that.setFormData.imageList.push(res.data.path);
|
||||
});
|
||||
},
|
||||
// 上传视频
|
||||
uploadVideo() {
|
||||
uni.chooseVideo({
|
||||
sourceType: ['camera', 'album'],
|
||||
success: res => {
|
||||
console.log(res)
|
||||
|
||||
if (Math.ceil(res.size / 1024) < this.upload_max * 1024) {
|
||||
uni.uploadFile({
|
||||
url: this.uploadUrl, //仅为示例,非真实的接口地址
|
||||
filePath: res.tempFilePath,
|
||||
name: 'file',
|
||||
//请求参数
|
||||
// formData: {
|
||||
// user: 'test'
|
||||
// },
|
||||
header: {
|
||||
// #ifdef MP
|
||||
'Content-Type': 'multipart/form-data',
|
||||
// #endif
|
||||
[TOKENNAME]: 'Bearer ' + store.state.app.token
|
||||
},
|
||||
success: uploadFileRes => {
|
||||
// let data = JSON.parse(uploadFileRes.data);
|
||||
// this.addGoodsSecoundData.video_link = (data.data.src);
|
||||
},
|
||||
complete: a => {
|
||||
// console.log(a);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
uni.showModal({
|
||||
title: '提示',
|
||||
content: `视频超出限制${this.upload_max}MB,已过滤`
|
||||
});
|
||||
}
|
||||
},
|
||||
fail: err => {
|
||||
// 取消上传也会出现弹框
|
||||
// uni.showModal({
|
||||
// content: JSON.stringify(err)
|
||||
// });
|
||||
console.log(err)
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
test() {
|
||||
uni.chooseFile({
|
||||
count: 6, //默认100
|
||||
extension: ['.zip', '.doc'],
|
||||
success: function(res) {
|
||||
console.log(JSON.stringify(res.tempFilePaths));
|
||||
}
|
||||
});
|
||||
|
||||
},
|
||||
// 删除图片
|
||||
deletePic(event) {
|
||||
this.formData[`imageList`].splice(event.index, 1)
|
||||
|
|
|
@ -56,8 +56,7 @@
|
|||
<view style="display: flex;align-items: center;font-size: 28rpx;color:#777777 ;" slot="right"
|
||||
@click="navgo(`/pages/product/addGoodDetail/goodsAttr?formData=${JSON.stringify(formData)}&&mer_id=${mer_id}`)">
|
||||
<view style="margin-right: 10rpx;line-height: 25rpx;">
|
||||
{{Object.values(formData.product_attribute).address ?"已设置":"未设置"}}
|
||||
<!-- {{Object.values(formData.product_attribute) }} -->
|
||||
{{isSet(formData.product_attribute)?'已设置':'未设置' }}
|
||||
</view>
|
||||
<u-icon name="arrow-right"></u-icon>
|
||||
</view>
|
||||
|
@ -285,7 +284,15 @@
|
|||
};
|
||||
},
|
||||
methods: {
|
||||
isSet(obj) {
|
||||
for (let key in obj) {
|
||||
if (typeof obj[key] == 'object') this.isSet(obj[key])
|
||||
else {
|
||||
if (Boolean(obj[key])) return true;
|
||||
}
|
||||
}
|
||||
|
||||
},
|
||||
// 删除图片
|
||||
deletePic1(event) {
|
||||
this.formData[`imageList`].splice(event.index, 1)
|
||||
|
@ -326,8 +333,6 @@
|
|||
});
|
||||
})
|
||||
},
|
||||
|
||||
|
||||
// 删除图片
|
||||
deletePic(event) {
|
||||
this.formData.content.image.splice(event.index, 1)
|
||||
|
|
Loading…
Reference in New Issue