|
|
@ -1,5 +1,7 @@ |
|
|
|
// subpages/eventAdd/add/add.js
|
|
|
|
const app = getApp() |
|
|
|
var config = require('../../../utils/config') |
|
|
|
import {repairSubmit} from "../../../api/index" |
|
|
|
Page({ |
|
|
|
|
|
|
|
/** |
|
|
@ -9,7 +11,6 @@ Page({ |
|
|
|
title: '报修', |
|
|
|
radio: '1', |
|
|
|
bxname: '', |
|
|
|
questionText: '', |
|
|
|
fileList: [ |
|
|
|
// {
|
|
|
|
// url: 'https://img.yzcdn.cn/vant/leaf.jpg',
|
|
|
@ -21,6 +22,10 @@ Page({ |
|
|
|
// isImage: true,
|
|
|
|
// },
|
|
|
|
], |
|
|
|
positionType:null, |
|
|
|
repairItem:'', |
|
|
|
faultDescribe:'', |
|
|
|
position:'' |
|
|
|
}, |
|
|
|
deleteData(event) { |
|
|
|
// 删除
|
|
|
@ -36,26 +41,22 @@ Page({ |
|
|
|
file |
|
|
|
} = event.detail; |
|
|
|
console.log(file, 66) |
|
|
|
const _this = this |
|
|
|
// 当设置 mutiple 为 true 时, file 为数组格式,否则为对象格式
|
|
|
|
wx.uploadFile({ |
|
|
|
url: 'https://example.weixin.qq.com/upload', // 仅为示例,非真实的接口地址
|
|
|
|
url: `${config.BASEURL()}/common/upload`, // 仅为示例,非真实的接口地址
|
|
|
|
filePath: file.url, |
|
|
|
name: 'file', |
|
|
|
formData: { |
|
|
|
user: 'test' |
|
|
|
header: { |
|
|
|
"Content-type": "multipart/form-data", |
|
|
|
'Authorization': wx.getStorageSync('token') |
|
|
|
}, |
|
|
|
success(res) { |
|
|
|
// 上传完成需要更新 fileList
|
|
|
|
const { |
|
|
|
fileList = [] |
|
|
|
} = this.data; |
|
|
|
fileList.push({ |
|
|
|
...file, |
|
|
|
url: res.data |
|
|
|
}); |
|
|
|
this.setData({ |
|
|
|
fileList |
|
|
|
const res1 = JSON.parse(res.data) |
|
|
|
_this.setData({ |
|
|
|
fileList:_this.data.fileList.concat([{url:res1.url,name:new Date().getTime()}]) |
|
|
|
}); |
|
|
|
console.log(_this.data.fileList); |
|
|
|
}, |
|
|
|
}); |
|
|
|
}, |
|
|
@ -68,21 +69,64 @@ Page({ |
|
|
|
}, |
|
|
|
onInput(e) { |
|
|
|
this.setData({ |
|
|
|
questionText: e.detail.value, |
|
|
|
faultDescribe: e.detail.value, |
|
|
|
}); |
|
|
|
// console.log(this.data.questionText, 666)
|
|
|
|
}, |
|
|
|
onButtonTap() { |
|
|
|
wx.showToast({ |
|
|
|
title: '按钮被点击了', |
|
|
|
icon: 'none' |
|
|
|
}); |
|
|
|
repairSubmit() { |
|
|
|
const {position,positionType,repairItem,faultDescribe,fileList} = this.data |
|
|
|
if(!repairItem){ |
|
|
|
wx.showToast({ |
|
|
|
title: '报修物品不能为空', |
|
|
|
icon:'none' |
|
|
|
}) |
|
|
|
return |
|
|
|
} |
|
|
|
if(!faultDescribe){ |
|
|
|
wx.showToast({ |
|
|
|
title: '故障说明不能为空', |
|
|
|
icon:'none' |
|
|
|
}) |
|
|
|
return |
|
|
|
} |
|
|
|
if(positionType === null){ |
|
|
|
wx.showToast({ |
|
|
|
title: '位置不能为空', |
|
|
|
icon:'none' |
|
|
|
}) |
|
|
|
return |
|
|
|
} |
|
|
|
let parms = { |
|
|
|
position, |
|
|
|
images:fileList, |
|
|
|
positionType, |
|
|
|
repairItem, |
|
|
|
faultDescribe |
|
|
|
} |
|
|
|
repairSubmit(parms).then(res=>{ |
|
|
|
if(res.code === 200){ |
|
|
|
wx.showToast({ |
|
|
|
title: '上报成功', |
|
|
|
duration:2000, |
|
|
|
success:()=>{ |
|
|
|
setTimeout(()=>{ |
|
|
|
wx.navigateBack() |
|
|
|
},2000) |
|
|
|
} |
|
|
|
}) |
|
|
|
} |
|
|
|
}) |
|
|
|
}, |
|
|
|
onChange(event) { |
|
|
|
this.setData({ |
|
|
|
radio: event.detail, |
|
|
|
}); |
|
|
|
}, |
|
|
|
onChangeRadio(e){ |
|
|
|
this.setData({ |
|
|
|
positionType:e.detail |
|
|
|
}) |
|
|
|
}, |
|
|
|
/** |
|
|
|
* 生命周期函数--监听页面加载 |
|
|
|
*/ |
|
|
|