202 lines
4.5 KiB
JavaScript
202 lines
4.5 KiB
JavaScript
let util = require('../../../../utils/util')
|
|
let apiArr = require('../../../../api/partner')
|
|
Page({
|
|
|
|
/**
|
|
* 页面的初始数据
|
|
*/
|
|
data: {
|
|
fileList: [],
|
|
fileList2: [],
|
|
device_code: "",
|
|
customer_name: "",
|
|
customer_phone: "",
|
|
region: "",
|
|
address: "",
|
|
deviceList: [],
|
|
fault_desc: "",
|
|
page_num: 1,
|
|
page_size: 50,
|
|
show: false,
|
|
currentDeviceInfo: ""
|
|
},
|
|
|
|
changeShow1() {
|
|
let that = this
|
|
that.setData({
|
|
show: true
|
|
})
|
|
},
|
|
getDeviceList() {
|
|
console.log(apiArr);
|
|
let that = this
|
|
util.postUrl4(apiArr.deviceList, {
|
|
page_num: that.data.page_num,
|
|
page_size: that.data.page_size,
|
|
}, res => {
|
|
that.setData({
|
|
deviceList: res.list
|
|
})
|
|
})
|
|
},
|
|
|
|
updateFault_desc(e) {
|
|
let that = this
|
|
that.setData({
|
|
fault_desc: e.detail.value
|
|
})
|
|
},
|
|
|
|
confirmPackage(e) {
|
|
let that = this
|
|
that.setData({
|
|
show: false,
|
|
currentDeviceInfo: e.detail.value,
|
|
device_code: e.detail.value.device_code
|
|
})
|
|
},
|
|
onClose() {
|
|
let that = this
|
|
that.setData({
|
|
show: false
|
|
})
|
|
},
|
|
|
|
beforeRead(e) {
|
|
let that = this
|
|
wx.showLoading({
|
|
title: '上传中',
|
|
mask: true,
|
|
})
|
|
util.uploadFileUrl(e.detail.file.url, (res) => {
|
|
wx.hideLoading()
|
|
let datas = JSON.parse(res)
|
|
console.log(datas.data);
|
|
let url = util.img_url + datas.data.path
|
|
let fileList = that.data.fileList
|
|
let fileList2 = that.data.fileList2
|
|
let obj = {
|
|
url: url,
|
|
name: 'avatar'
|
|
}
|
|
let obj2 = {
|
|
url: datas.data.path,
|
|
name: 'avatar'
|
|
}
|
|
fileList.push(obj)
|
|
fileList2.push(obj2)
|
|
that.setData({
|
|
fileList,
|
|
fileList2
|
|
})
|
|
})
|
|
},
|
|
deleteImg(e) {
|
|
console.log(e);
|
|
let that = this
|
|
let fileList = that.data.fileList
|
|
let fileList2 = that.data.fileList2
|
|
fileList.splice(e.detail.index, 1)
|
|
fileList2.splice(e.detail.index, 1)
|
|
that.setData({
|
|
fileList,
|
|
fileList2
|
|
})
|
|
},
|
|
|
|
submit() {
|
|
let that = this
|
|
|
|
if (!that.data.currentDeviceInfo.device_id) {
|
|
return wx.showToast({
|
|
title: '请选择维修设备',
|
|
icon: "none"
|
|
})
|
|
}
|
|
if (!that.data.fault_desc) {
|
|
return wx.showToast({
|
|
title: '请填写故障描述',
|
|
icon: "none"
|
|
})
|
|
}
|
|
|
|
if (!that.data.fileList.length) {
|
|
return wx.showToast({
|
|
title: '请上传故障图片',
|
|
icon: "none"
|
|
})
|
|
}
|
|
util.postUrl4(apiArr.createRepairOrder, {
|
|
device_code: that.data.currentDeviceInfo.device_code,
|
|
appointment_time: '',
|
|
fault_desc: that.data.fault_desc,
|
|
fault_imgs: that.data.fileList2[0].url
|
|
}, res => {
|
|
wx.showToast({
|
|
title: '创建成功!',
|
|
icon: "none"
|
|
})
|
|
setTimeout(()=>{
|
|
wx.navigateBack({
|
|
delta:1
|
|
})
|
|
},1500)
|
|
})
|
|
},
|
|
/**
|
|
* 生命周期函数--监听页面加载
|
|
*/
|
|
onLoad(options) {
|
|
let that = this
|
|
that.getDeviceList()
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面初次渲染完成
|
|
*/
|
|
onReady() {
|
|
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面显示
|
|
*/
|
|
onShow() {
|
|
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面隐藏
|
|
*/
|
|
onHide() {
|
|
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面卸载
|
|
*/
|
|
onUnload() {
|
|
|
|
},
|
|
|
|
/**
|
|
* 页面相关事件处理函数--监听用户下拉动作
|
|
*/
|
|
onPullDownRefresh() {
|
|
|
|
},
|
|
|
|
/**
|
|
* 页面上拉触底事件的处理函数
|
|
*/
|
|
onReachBottom() {
|
|
|
|
},
|
|
|
|
/**
|
|
* 用户点击右上角分享
|
|
*/
|
|
onShareAppMessage() {
|
|
|
|
}
|
|
}) |