318 lines
9.6 KiB
JavaScript
318 lines
9.6 KiB
JavaScript
let util = require('../../../utils/util')
|
|
let apiArr = require('../../../api/water_filter')
|
|
|
|
Page({
|
|
data: {
|
|
type: "",
|
|
id: "",
|
|
newOrderDesc: {},
|
|
msg: "",
|
|
imgList: [],
|
|
imgList2: [],
|
|
repairOrderDesc: {},
|
|
partOrderDesc: {},
|
|
dis1: false,
|
|
dis2: false,
|
|
dis3: false,
|
|
deviceInfo:{},
|
|
deviceCode:"",
|
|
},
|
|
// 新装///////////////////////////////
|
|
//输入框
|
|
updateInstructions(e) {
|
|
let that = this
|
|
that.setData({
|
|
msg: e.detail.value
|
|
})
|
|
},
|
|
// 上传图片
|
|
uploadImage() {
|
|
let that = this
|
|
wx.showLoading({
|
|
title: '上传中...',
|
|
})
|
|
wx.chooseMedia({
|
|
count: 9,
|
|
mediaType: ['image'],
|
|
success: (res) => {
|
|
let tempFiles = res.tempFiles.map(file => file.tempFilePath);
|
|
let imgList = []
|
|
let imgList2 = []
|
|
let uploadCount = 0;
|
|
|
|
tempFiles.forEach((item, index) => {
|
|
util.uploadFileUrl(item, res => {
|
|
res = JSON.parse(res)
|
|
imgList[index] = util.img_url + res.data.path;
|
|
imgList2[index] = res.data.path
|
|
uploadCount++;
|
|
|
|
// 所有文件上传完成后更新数据
|
|
if (uploadCount === tempFiles.length) {
|
|
that.setData({
|
|
imgList: imgList,
|
|
imgList2
|
|
}, () => {
|
|
wx.hideLoading();
|
|
});
|
|
}
|
|
});
|
|
});
|
|
},
|
|
fail: err => {
|
|
wx.hideLoading()
|
|
console.log(err, 999);
|
|
}
|
|
});
|
|
},
|
|
// 删除图片
|
|
deleteImage(e) {
|
|
console.log(e);
|
|
let that = this
|
|
const index = e.currentTarget.dataset.index;
|
|
let imgList = that.data.imgList
|
|
let imgList2 = that.data.imgList2
|
|
|
|
imgList = imgList.slice(index, 1)
|
|
imgList2 = imgList2.slice(index, 1)
|
|
this.setData({
|
|
imgList,
|
|
imgList2
|
|
});
|
|
},
|
|
getNewOrderDesc() {
|
|
let that = this
|
|
util.postUrl(apiArr.newOrderDesc, { install_id: Number(that.data.id) }, res => {
|
|
console.log(res);
|
|
res.product_icon = util.img_url + res.product_icon
|
|
|
|
that.setData({
|
|
newOrderDesc: res,
|
|
})
|
|
|
|
if (res.status == 3) {
|
|
let imgList2 = res.install_imgs.split(',')
|
|
let imgList = []
|
|
imgList2.forEach((item, index) => {
|
|
imgList.push(util.img_url + item)
|
|
})
|
|
that.setData({
|
|
msg: res.install_desc,
|
|
imgList2,
|
|
imgList,
|
|
dis1: true
|
|
})
|
|
}
|
|
|
|
})
|
|
},
|
|
completeNewOrder(e) {
|
|
let status = Number(e.currentTarget.dataset.type)
|
|
let that = this
|
|
let content = '确认完成该工单吗?'
|
|
if (status == 3) {
|
|
content = '确认完成该工单吗?'
|
|
} else {
|
|
content = '确认撤销该工单吗?'
|
|
}
|
|
wx.showModal({
|
|
title: '提示',
|
|
content: content,
|
|
success: (res) => {
|
|
if (res.confirm) {
|
|
util.postUrl(apiArr.completeNewOrder, {
|
|
install_id: Number(that.data.id),
|
|
status,
|
|
install_desc: that.data.msg,
|
|
install_imgs: that.data.imgList2.join(','),
|
|
install_time: util.getCurrentTime(),
|
|
device_id:that.data.deviceInfo.device_id,
|
|
product_id:that.data.deviceInfo.product_id
|
|
}, res => {
|
|
wx.showToast({
|
|
title: res.msg,
|
|
})
|
|
if (res.msg == '操作成功') {
|
|
setTimeout(() => {
|
|
wx.navigateBack({
|
|
delta: 1
|
|
})
|
|
}, 1500);
|
|
}
|
|
})
|
|
}
|
|
}
|
|
});
|
|
},
|
|
scanQrcode() {
|
|
let that = this
|
|
wx.scanCode({
|
|
success: (res) => {
|
|
console.log('扫码结果:', res.result);
|
|
// 处理扫码结果
|
|
this.setData({
|
|
deviceCode: res.result
|
|
});
|
|
|
|
util.postUrl(apiArr.getDeviceByCode,{
|
|
device_code:res.result
|
|
},res=>{
|
|
that.setData({
|
|
deviceInfo:res
|
|
})
|
|
})
|
|
|
|
},
|
|
fail: (err) => {
|
|
wx.showToast({
|
|
title: '扫码失败',
|
|
icon: 'none'
|
|
});
|
|
}
|
|
});
|
|
},
|
|
// 新装///////////////////////////////
|
|
|
|
// 维修 ///////////////////////////////
|
|
getRepairOrderDesc() {
|
|
let that = this
|
|
util.postUrl(apiArr.RepairOrderDesc, {
|
|
repair_id: that.data.id
|
|
}, res => {
|
|
res.fault_imgs = util.img_url + res.fault_imgs
|
|
that.setData({
|
|
repairOrderDesc: res
|
|
})
|
|
|
|
if (res.status == 3 || res.status == 4) {
|
|
let imgList2 = res.repair_imgs.split(',')
|
|
let imgList = []
|
|
imgList2.forEach((item, index) => {
|
|
imgList.push(util.img_url + item)
|
|
})
|
|
console.log(imgList);
|
|
that.setData({
|
|
msg: res.repair_desc,
|
|
imgList,
|
|
imgList2,
|
|
dis2: true
|
|
})
|
|
}
|
|
})
|
|
},
|
|
completeRepairOrder(e) {
|
|
let status = Number(e.currentTarget.dataset.type)
|
|
let that = this
|
|
let content = '确认完成该工单吗?'
|
|
if (status == 3) {
|
|
content = '确认完成该工单吗?'
|
|
} else {
|
|
content = '确认撤销该工单吗?'
|
|
}
|
|
wx.showModal({
|
|
title: '提示',
|
|
content: content,
|
|
success: (res) => {
|
|
if (res.confirm) {
|
|
util.postUrl(apiArr.completeRepairOrder, {
|
|
repair_id: Number(that.data.id),
|
|
status,
|
|
repair_desc: that.data.msg,
|
|
repair_imgs: that.data.imgList2.join(','),
|
|
repair_time: util.getCurrentTime()
|
|
}, res => {
|
|
wx.showToast({
|
|
title: res.msg,
|
|
})
|
|
if (res.msg == '操作成功') {
|
|
setTimeout(() => {
|
|
wx.navigateBack({
|
|
delta: 1
|
|
})
|
|
}, 1500);
|
|
}
|
|
})
|
|
}
|
|
}
|
|
});
|
|
},
|
|
// 维修 ///////////////////////////////
|
|
|
|
// 滤芯更换 ///////////////////////////////
|
|
getPartOrderDesc() {
|
|
let that = this
|
|
util.postUrl(apiArr.PartOrderDesc, {
|
|
replace_id: that.data.id
|
|
}, res => {
|
|
that.setData({
|
|
partOrderDesc: res
|
|
})
|
|
|
|
if (res.status == 3 || res.status == 4) {
|
|
that.setData({
|
|
msg: res.install_desc,
|
|
dis3: true
|
|
})
|
|
}
|
|
|
|
})
|
|
},
|
|
completePartOrder(e) {
|
|
let status = Number(e.currentTarget.dataset.type)
|
|
let that = this
|
|
let content = '确认完成该工单吗?'
|
|
if (status == 3) {
|
|
content = '确认完成该工单吗?'
|
|
} else {
|
|
content = '确认撤销该工单吗?'
|
|
}
|
|
wx.showModal({
|
|
title: '提示',
|
|
content: content,
|
|
success: (res) => {
|
|
if (res.confirm) {
|
|
util.postUrl(apiArr.completePartOrder, {
|
|
replace_id: Number(that.data.id),
|
|
status,
|
|
install_desc: that.data.msg,
|
|
install_time: util.getCurrentTime()
|
|
}, res => {
|
|
wx.showToast({
|
|
title: res.msg,
|
|
})
|
|
if (res.msg == '操作成功') {
|
|
setTimeout(() => {
|
|
wx.navigateBack({
|
|
delta: 1
|
|
})
|
|
}, 1500);
|
|
}
|
|
})
|
|
}
|
|
}
|
|
});
|
|
},
|
|
// 滤芯更换 ///////////////////////////////
|
|
|
|
|
|
|
|
onLoad(options) {
|
|
let that = this
|
|
// 这里可以根据options.id来设置不同的假数据
|
|
const id = options.id;
|
|
this.setData({
|
|
id,
|
|
type: options.type
|
|
});
|
|
|
|
if (options.type == 0) {
|
|
that.getNewOrderDesc()
|
|
} else if (options.type == 1) {
|
|
that.getRepairOrderDesc()
|
|
} else {
|
|
that.getPartOrderDesc()
|
|
}
|
|
},
|
|
|
|
|
|
}); |