var req_url = getApp().globalData.base_url;
|
var Public_array = []; //全局公共图片数组
|
Page({
|
/**
|
* 页面的初始数据
|
*/
|
data: {
|
sign:'',
|
img:'',
|
name: "",
|
number: '',
|
radio: '1',
|
reason: '',
|
bumen: '',
|
opinion: '',
|
tempFilePaths: '', //上传图片路径
|
signtempFilePaths: '',
|
safetymeasure:'',
|
},
|
showPopup() {
|
wx.navigateTo({
|
url: '../sign/sign?opinion=' + this.data.opinion + '&bumen=' + this.data.bumen + '&name=' + this.data.number
|
})
|
// this.setData({ show: true });
|
},
|
/**
|
* 生命周期函数--监听页面加载
|
*/
|
onLoad: function (options) {
|
console.log(options);
|
this.setData({
|
name: options.zyptepe,
|
number: options.zypcode,
|
bumen: options.bumen,
|
opinion: options.opinion,
|
safetymeasure:options.safetymeasure
|
})
|
},
|
|
onChange(event) {
|
this.setData({
|
radio: event.detail,
|
});
|
},
|
|
//点击调用照相机和本地相册功能
|
camera: function (event) {
|
var that = this
|
wx.chooseMedia({
|
count: 1,
|
itemList: ['拍照', '从相册中选择'],
|
mediaType: ['image'],
|
sourceType: ['album', 'camera'],
|
camera: 'back',
|
success: function (res) {
|
console.log(res);
|
if (res.tapIndex == 0) {
|
sourceType = 'camera'
|
} else if (res.tapIndex == 1) {
|
sourceType = 'album'
|
}
|
that.setData({
|
tempFilePaths: res.tempFiles[0].tempFilePath,
|
})
|
}
|
})
|
},
|
previewImage: function (e) {
|
wx.previewImage({
|
current: this.data.tempFilePaths, // 当前显示图片的链接,不填则默认为 urls 的第一张
|
urls: [this.data.tempFilePaths] // 需要预览的图片链接列表
|
})
|
},
|
|
previewsign: function (e) {
|
wx.previewImage({
|
current: this.data.signtempFilePaths, // 当前显示图片的链接,不填则默认为 urls 的第一张
|
urls: [this.data.signtempFilePaths] // 需要预览的图片链接列表
|
})
|
},
|
deletesign(e) {
|
let index = e.currentTarget.dataset.index;
|
Public_array.splice(index, 1) //根据下标删除1个图片
|
this.setData({
|
signtempFilePaths: '',
|
})
|
},
|
//删除图片
|
deleteImage(e) {
|
let index = e.currentTarget.dataset.index;
|
Public_array.splice(index, 1) //根据下标删除1个图片
|
this.setData({
|
tempFilePaths: '',
|
})
|
},
|
reasonBindInput(event) {
|
var that = this
|
that.setData({
|
reason: event.detail
|
})
|
},
|
|
processing(e) {
|
if (this.data.name=='动火作业') {
|
wx.navigateTo({
|
url: '../fireSafetymeasure/fireSafetymeasure?safetymeasure=' + this.data.safetymeasure+'&zypcode=' + this.data.number
|
})
|
}else if (this.data.name=='高处安全') {
|
wx.navigateTo({
|
url: '../AltitudeSafetymeasure/AltitudeSafetymeasure?safetymeasure=' + this.data.safetymeasure+'&zypcode=' + this.data.number
|
})
|
}else if (this.data.name=='受限空间') {
|
wx.navigateTo({
|
url: '../SpanceSafetymeasure/SpanceSafetymeasure?safetymeasure=' + this.data.safetymeasure+'&zypcode=' + this.data.number
|
})
|
}else if (this.data.name=='吊装安全') {
|
wx.navigateTo({
|
url: '../LiftingSafetymeasure/LiftingSafetymeasure?safetymeasure=' + this.data.safetymeasure+'&zypcode=' + this.data.number
|
})
|
}else if (this.data.name=='临时用电安全') {
|
wx.navigateTo({
|
url: '../ElectricitySafetymeasure/ElectricitySafetymeasure?safetymeasure=' + this.data.safetymeasure+'&zypcode=' + this.data.number
|
})
|
}else if (this.data.name=='动土安全') {
|
wx.navigateTo({
|
url: '../GroundSafetymeasure/GroundSafetymeasure?safetymeasure=' + this.data.safetymeasure+'&zypcode=' + this.data.number
|
})
|
}else if (this.data.name=='断路安全作业') {
|
wx.navigateTo({
|
url: '../CircuitSafetymeasure/CircuitSafetymeasure?safetymeasure=' + this.data.safetymeasure+'&zypcode=' + this.data.number
|
})
|
}else if (this.data.name=='盲板抽堵安全') {
|
wx.navigateTo({
|
url: '../BilndSafetymeasure/BilndSafetymeasure?safetymeasure=' + this.data.safetymeasure+'&zypcode=' + this.data.number
|
})
|
}
|
},
|
|
|
submitForm: function (e) {
|
wx.showLoading({
|
title: '正在上传',//加载转圈显示
|
});
|
var that = this;
|
if (that.data.radio == 1) {
|
if (that.data.bumen!='完工验收负责人') {
|
if (!that.data.tempFilePaths) {
|
wx.showToast({
|
title: '请上传照片',
|
icon: 'error',
|
duration: 2000
|
});
|
return false
|
}
|
}
|
|
}
|
if (that.data.radio == 2) {
|
if (!that.data.reason) {
|
wx.showToast({
|
title: '请填写处理意见',
|
icon: 'error',
|
duration: 2000
|
});
|
return false
|
}
|
console.log(that.data.reason);
|
wx.request({
|
url: req_url + "/smszyp",
|
method: 'get',
|
data: {
|
// opinion: that.data.opinion,
|
bumen: that.data.bumen,
|
// zyptype: that.data.name,
|
zypcode: that.data.number,
|
handleidea: that.data.reason,
|
// picture: img,
|
// sign: sign,
|
// isgive: that.data.radio,
|
},
|
header: {
|
'Content-Type': 'application/json'
|
},
|
success: (res) => {
|
if (res.errMsg == "request:ok") {
|
wx.showToast({
|
title: '操作成功',
|
icon: 'success',
|
duration: 2000
|
});
|
} else {
|
wx.showToast({
|
title: '操作失败',
|
})
|
}
|
}
|
// })
|
});
|
}
|
// if (that.data.radio == 3) {
|
// // if (!that.data.signtempFilePaths) {
|
// if (!that.data.tempFilePaths) {
|
// wx.showToast({
|
// title: '请上传照片',
|
// icon: 'error',
|
// duration: 2000
|
// });
|
// return false
|
// }
|
// // }
|
|
// }
|
|
var sign = ''
|
console.log(that.data.signtempFilePaths);
|
if (that.data.signtempFilePaths) {
|
var pic_url = that.data.signtempFilePaths; // 选中的图片路径
|
console.log(11111111111);
|
that.uploadPerPic(pic_url,that.data.signtempFilePaths, function back(res) {
|
sign = res
|
console.log(res);
|
// that.setData({
|
// sign: res
|
// })
|
var img = ''
|
console.log(that.data.tempFilePaths);
|
if (that.data.tempFilePaths) {
|
var pic_url = that.data.tempFilePaths; // 选中的图片路径
|
console.log(11111111111);
|
that.uploadPerPic(pic_url, null, function back(resp) {
|
img = resp
|
// that.setData({
|
// img: res
|
// })
|
wx.request({
|
url: req_url + "/addHandle",
|
method: 'post',
|
data: {
|
opinion: that.data.opinion,
|
bumen: that.data.bumen,
|
zyptype: that.data.name,
|
zypcode: that.data.number,
|
handleidea: that.data.reason,
|
picture: resp ,
|
sign: res,
|
isgive: that.data.radio,
|
},
|
header: {
|
'Content-Type': 'application/json'
|
},
|
success: (res) => {
|
if (res.errMsg == "request:ok") {
|
var content= that.data.bumen+":"+wx.getStorageSync('username')+"处理编号为:"+that.data.number+"的动火作业票"
|
wx.request({
|
url: req_url + "/addZypLog",
|
method: 'post',
|
data: {
|
name:wx.getStorageSync('username'),
|
zyptype:"动火作业",
|
bumen: that.data.bumen,
|
zypcode: that.data.number,
|
content: content,
|
},
|
header: {
|
'Content-Type': 'application/json'
|
},
|
success: (res) => {
|
console.log(res);
|
|
}
|
});
|
|
wx.showToast({
|
title: '操作成功',
|
icon: 'success',
|
duration: 2000
|
});
|
wx.navigateTo({
|
url: '../index/index',
|
})
|
} else {
|
wx.showToast({
|
title: '操作失败',
|
})
|
}
|
}
|
// })
|
});
|
console.log(res);
|
})
|
}
|
|
})
|
}
|
console.log(sign);
|
|
console.log(that.data.sign);
|
|
// var pic_url = that.data.tempFilePaths; // 选中的图片路径
|
// var img = ''
|
// that.uploadPerPic(pic_url, function back(res) {
|
// console.log(res);
|
// img = res
|
// wx.request({
|
// url: req_url + "/addHandle",
|
// method: 'post',
|
// data: {
|
// opinion:that.data.opinion,
|
// bumen:that.data.bumen,
|
// zyptype:that.data.name,
|
// zypcode: that.data.number,
|
// handleidea: that.data.reason,
|
// picture: img,
|
// sign:sign,
|
// isgive: that.data.radio,
|
// },
|
// header: {
|
// 'Content-Type': 'application/json'
|
// },
|
// success: (res) => {
|
// if (res.errMsg == "request:ok") {
|
// wx.showToast({
|
// title: '操作成功',
|
// icon: 'success',
|
// duration: 2000
|
// });
|
// wx.navigateTo({
|
// url: '../index/index',
|
// })
|
// } else {
|
// wx.showToast({
|
// title: '操作失败',
|
// })
|
// }
|
// }
|
// // })
|
// });
|
},
|
|
uploadPerPic(url, sign, back) {
|
var name = ''
|
var that=this
|
if (sign) {
|
name = 'sign'+that.data.number
|
} else {
|
name = that.data.number
|
}
|
console.log(name);
|
wx.uploadFile({
|
url: req_url + "addpic",
|
method: "POST",
|
filePath: url,
|
name: 'file',
|
formData: {
|
'opinion': that.data.opinion,
|
'bumen': that.data.bumen,
|
'name': name,
|
},
|
success(res) {
|
if (sign) {
|
that.setData({
|
img: res
|
})
|
|
} else {
|
that.setData({
|
sign: res
|
})
|
}
|
console.log(res);
|
back(res.data);
|
},
|
fail(e) { }
|
})
|
},
|
bindViewTap() {
|
wx.navigateTo({
|
url: '../index/index'
|
})
|
},
|
/**
|
* 生命周期函数--监听页面卸载
|
*/
|
onUnload: function () {
|
Public_array = []; //清空公共数组
|
},
|
})
|