Commit 6fa2eb07 by honghong

上传图片

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