const Parser = require('../xml/xmldom/dom-parser') var app = getApp() Page({ /** * 页面的初始数据 */ data: { imgUrl:app.imgUrl, hname:'',//房产 datatimestart:'',//日期起始 datatimeend:'',//日期结束 dfdapplydate:'',//派单时间 txtdrequiredate:'',//完成时间 txtvcontent:'',// 报事内容 hddhcode:'',//房产编号 ownerid:'', //房主ID txtvplace:'',//报事地址 txtvtel:'', //报事电话 owername:'', //房主姓名 table:[],//上传图片的对象 }, /** * 生命周期函数--监听页面加载 */ onLoad: function (options) { console.warn('onload',options); var timestamp = Date.parse(new Date()); var date = new Date(timestamp); var Y =date.getFullYear(); var M = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1) var D = date.getDate() < 10 ? '0' + date.getDate() : date.getDate();  var that = this; that.setData({ datatimestart:Y + '-'  + M+ '-' + D, dfdapplydate:Y + '-'  + M+ '-' + D, txtdrequiredate:Y + '-'  + M+ '-' + D, datatimeend:Y + 2 + '-' + M + '-' + D, hname:options.hname, ownerid:options.ownerid, txtvtel:options.phone, owername:options.ownername, hddhcode:options.hcode, }) }, bindDateChangeb:function(e){ this.setData({ txtdrequiredate: e.detail.value }) }, // 选择日期 bindDateChange: function(e) { this.setData({ dfdapplydate: e.detail.value }) }, // 删除图片 removeImage(e) { var index = e.target.dataset.index; var imgs = this.data.table; imgs.splice(index,1); this.setData({ table:imgs, }) }, // 选择图片 chooseImage:function(e){ var that = this; wx.chooseImage({ count:3, sizeType:['original','compressed'], sourceType:['album','camera'], success(res){ that.setData({ table: res.tempFilePaths }); } }) }, ceShibtnJiaoFei:function(e){ }, // 点击提交报修 btnJiaoFei: function (e) { var that= this; if(this.data.txtvtel==''){ wx.showToast({ title: '请填写手机号', icon: 'none', duration: 2000 }) return; } if(this.data.txtvplace==''){ wx.showToast({ title: '请填写报事地址', icon: 'none', duration: 2000 }) return; } let fileurl = "";// 图片名称 if(this.data.table.length>0){ // 拼接多(单)个图片名称 for (let index = 0; index < this.data.table.length; index++) { if(this.data.table[index].substring(0,11)=='http://tmp/'){ fileurl += this.data.table[index].substring(11)+','; } if(this.data.table[index].substring(0,9)=='wxfile://'){ fileurl += this.data.table[index].substring(9)+','; } } } var method='Insertfdc_pm_repair '; var wsdlurl= app.webUrl; var targetNamespace='http://tempuri.org/'; var datacopy= ''; datacopy += ''; datacopy += ''; datacopy += `${app.UserName}`; datacopy += `${app.PassWord}`; datacopy += ''; datacopy += ''; datacopy += ''; datacopy += `${this.data.dfdapplydate}`; datacopy += `${this.data.txtdrequiredate}`; datacopy += `${this.data.hddhcode}`; datacopy += `${this.data.ownerid}`; datacopy += `${this.data.txtvcontent}`; datacopy += `${this.data.txtvplace}`; datacopy += `${this.data.txtvtel}`; datacopy += `${fileurl}`;     datacopy += '';     datacopy += '';     datacopy += ''; wx.request({ url: wsdlurl, data: datacopy, method: 'POST', header: { 'Content-Type':'text/xml; charset=utf-8', 'SOAPAction':targetNamespace+method, }, success:function(res){ console.info('【Insertfdc_pm_repair】',res); var XMLParser = new Parser.DOMParser(); console.info('【Insertfdc_pm_repair】s1'); var doc = XMLParser.parseFromString(res.data); console.info('【Insertfdc_pm_repair】s2'); var Insertfdc_pm_repairResult = doc.getElementsByTagName("Insertfdc_pm_repairResult")[0].firstChild.nodeValue; console.info('Insertfdc_pm_repairResult',Insertfdc_pm_repairResult); if(Insertfdc_pm_repairResult=='保存成功!'){ wx.showToast({ title: '提交成功!', icon: 'success', duration: 1000 }) // 图片上传 for (let index = 0; index < that.data.table.length; index++) { wx.uploadFile({ filePath: that.data.table[index], name: 'name', url: app.coreUrl+ 'InsertPicture', header:{ 'content-type':'multipart/form-data' }, name:'upload', success:function(res){ console.warn('上传图片',res.data); if(res.data=='"上传成功"'){ wx.navigateBack({ delta: 2 }) } else{ wx.showToast({ //上传失败,弹出错误提示 title: res.data, icon: 'none', duration: 3000 }); } }, }) } } else { wx.showToast({ title: Insertfdc_pm_repairResult, icon: 'none', duration: 2000 }) } } }) }, // 修改报事地址 updateTxtvplace: function (e) { this.setData({ txtvplace: e.detail.value }) }, // 编辑报事人电话 updateTxtvtel: function (e) { this.setData({ txtvtel: e.detail.value }) }, // 编辑报事人电话 updateTxtvcontent: function (e) { this.setData({ txtvcontent: e.detail.value }) }, // 预览图片 handleImagePreview: function (e) { var idx = e.target.dataset.index; var imag = this.data.table; wx.previewImage({ current: imag[idx], //当前预览的图片 urls: imag, //所有要预览的图片 }) }, /** * 生命周期函数--监听页面卸载 */ onUnload: function () { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh: function () { }, /** * 页面上拉触底事件的处理函数 */ onReachBottom: function () { }, /** * 用户点击右上角分享 */ onShareAppMessage: function () { } })