Commit 6fa2eb07 by honghong

上传图片

parent 45d4f3a9
......@@ -56,7 +56,8 @@
<view class="form-tips">以下内容三选一必填</view>
</view>
<view class="">
<comUpload v-model="formInfo.pictureList" @getVal="getPhotoList" ref="photoRef" ></comUpload>
<comUpload v-model="formInfo.pictureList" @getVal="getPhotoList" @delVal="delPhotoItem"
ref="photoRef"></comUpload>
</view>
</view>
<view>
......@@ -64,8 +65,8 @@
<view class="form-item-name">上传视频</view>
</view>
<view class="">
<comUpload @getVal="getVideoList" ref="videoRef" :acceptType="acceptType"
:multiple="multiple"></comUpload>
<comUpload v-model="formInfo.videoList" @getVal="getVideoList" ref="videoRef" :acceptType="acceptType"
:multiple="isMultiple"></comUpload>
</view>
</view>
<view>
......@@ -126,7 +127,7 @@
return {
showTime: false, //时间选择器是否显示
acceptType: 'video',
multiple: false, //视频上传数量(多张、单张)
isMultiple: false, //视频上传数量(多张、单张)
path: 'https://vkceyugu.cdn.bspapp.com/VKCEYUGU-hello-uniapp/2cc220e0-c27a-11ea-9dfb-6da8e309e0d8.mp3',
voicePath: '',
showPopup: false,
......@@ -187,7 +188,7 @@
// 时间格式化默认值
if (!that.formInfo.repairTime) {
that.formInfo.repairTime = uni.$u.timeFormat(Number(new Date()), 'yyyy-mm-dd');
}else{
} else {
that.formInfo.repairTime = uni.$u.timeFormat(that.formInfo.repairTime, 'yyyy-mm-dd')
}
},
......@@ -195,24 +196,35 @@
methods: {
// 获取上传图片的值
getPhotoList(data) {
this.formInfo.pictureList.push({
url: data.data.url,
let that = this
let photoList = []
that.formInfo.pictureList.push({
url: data.url,
fileType: 'picture'
})
},
//删除照片
delPhotoItem(index) {
this.formInfo.pictureList.splice(index, 1)
},
// 获取上传视频的值
getVideoList(data) {
this.formInfo.videoList.push({
url: data.data.url,
let that = this
console.log(data,'有的哈桑')
let videoList = []
videoList.push({
url: data.url,
fileType: 'video'
})
that.formInfo.videoList = videoList
},
// 上传音频事件
getVoiceList(data) {
this.formInfo.videoList.push({
url: data.data.url,
fileType: 'voice'
})
// this.formInfo.videoList.push({
// url: data.data.url,
// fileType: 'voice'
// })
},
//确认修改和重新发布按钮
handleUpdateForm() {
......@@ -234,7 +246,7 @@
let cleatTime = setTimeout(() => {
clearTimeout(cleatTime)
that.$uniGo.reLaunch({
url:'/pages/demand/index'
url: '/pages/demand/index'
})
}, 1000)
......@@ -247,7 +259,11 @@
let that = this
this.$refs.form.validate().then(res => {
if (res) {
if(that.formInfo.pictureList.length || that.formInfo.videoList.length || that.formInfo.voiceList.length){
that.handleAdd()
}else{
uni.$u.toast('图片、视频、音频选其一必填')
}
}
}).catch(errors => {
uni.$u.toast('校验失败')
......@@ -308,12 +324,11 @@
remark: '', //备注说明
pictureList: [], //图片
videoList: [], //视频
voiceList: [
{
url:'https://vkceyugu.cdn.bspapp.com/VKCEYUGU-hello-uniapp/2cc220e0-c27a-11ea-9dfb-6da8e309e0d8.mp3',
fileType: 'voice'
}
], //音频
voiceList: [], //音频
// {
// url: 'https://vkceyugu.cdn.bspapp.com/VKCEYUGU-hello-uniapp/2cc220e0-c27a-11ea-9dfb-6da8e309e0d8.mp3',
// fileType: 'voice'
// }
// fileVos:[
// {
// url:'https://img1.baidu.com/it/u=567782244,1695500002&fm=253&fmt=auto&app=138&f=JPEG?w=753&h=500',//地址
......
......@@ -46,30 +46,34 @@
fileList1: [],
};
},
watch:{
value:{
handler(newVal,oldVal){
console.log(newVal,newVal,'监听')
if(newVal.length){
this.fileList1 = newVal
console.log(this.fileList1,'大家撒')
watch: {
value: {
handler(val) {
console.log(val, '单')
if(val && val.length){
this.fileList1 = val
}else{
this.fileList1 = []
}
},
immediate:true,
deep:true
}
immediate: true,
deep: true
},
},
onLoad() {},
methods: {
deletePic(event) {
this[`fileList${event.name}`].splice(event.index, 1)
this.$emit('delVal', event.index);
},
// 新增图片
async afterRead(event) {
// 当设置 multiple 为 true 时, file 为数组格式,否则为对象格式
let lists = [].concat(event.file)
console.log(lists,'点九三')
let fileListLen = this[`fileList${event.name}`].length
lists.map((item) => {
this[`fileList${event.name}`].push({
......@@ -95,13 +99,20 @@
url: this.uploadUrl, // 仅为示例,非真实的接口地址
filePath: url,
name: 'file',
header:{
header: {
'Authorization': `Bearer ${uni.getStorageSync('token')}`
},
success: (res) => {
this.$emit('getVal',JSON.parse(res.data))
console.log(res.data, '单价')
const {
data
} = JSON.parse(res.data);
console.log(data, '大街上可能')
this.$emit('getVal', data);
setTimeout(() => {
resolve(res.data.data)
resolve(data.url)
// resolve(res.data.data)
}, 1000)
}
});
......
......@@ -40,7 +40,7 @@ const apiBaseConfig = {
domain: hostUrl + api,
// upload: hostUrl + api + '/system/oss/upload',
upload: hostUrl + '/xinrenli/file/upload',
upload: hostUrl + api+'/xinrenli/file/upload',
imgBgUrl: hostUrl + imgApi,
// bWeChatAppid: 'wxb323afcbe152514f',
bWeChatAppid: 'wx862d98c98e4fe97d',
......
......@@ -184,7 +184,7 @@
//申请退款接口
async applyRefundFun(id){
let that = this
const data_back = await applyRefund({id:id,status:'4'})
const data_back = await applyRefund({id:id,status:'5'})
const {code} = data_back
if(code === 200){
uni.showToast({
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment