baoxiu.js 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236
  1. const Parser = require('../xml/xmldom/dom-parser')
  2. var app = getApp()
  3. Page({
  4. /**
  5. * 页面的初始数据
  6. */
  7. data: {
  8. hname:'',//房产
  9. datatimestart:'',//日期起始
  10. datatimeend:'',//日期结束
  11. dfdapplydate:'',//派单时间
  12. txtdrequiredate:'',//完成时间
  13. txtvcontent:'',// 报事内容
  14. hddhcode:'',//房产编号
  15. ownerid:'',
  16. txtvplace:'',//报事地址
  17. txtvtel:'',
  18. owername:'',
  19. table:[],//上传图片的对象
  20. },
  21. /**
  22. * 生命周期函数--监听页面加载
  23. */
  24. onLoad: function (options) {
  25. var timestamp = Date.parse(new Date());
  26. var date = new Date(timestamp);
  27. var Y =date.getFullYear();
  28. var M = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1)
  29. var D = date.getDate() < 10 ? '0' + date.getDate() : date.getDate(); 
  30. var that = this;
  31. that.setData({
  32. datatimestart:Y + '-'  + M+ '-' + D,
  33. dfdapplydate:Y + '-'  + M+ '-' + D,
  34. txtdrequiredate:Y + '-'  + M+ '-' + D,
  35. datatimeend:Y + 2 + '-' + M + '-' + D,
  36. hname:options.hname,
  37. ownerid:options.ownerid,
  38. txtvtel:options.tel,
  39. owername:options.ownername,
  40. hddhcode:options.hcode,
  41. })
  42. },
  43. bindDateChangeb:function(e){
  44. this.setData({
  45. txtdrequiredate: e.detail.value
  46. })
  47. },
  48. // 选择日期
  49. bindDateChange: function(e) {
  50. this.setData({
  51. dfdapplydate: e.detail.value
  52. })
  53. },
  54. // 删除图片
  55. removeImage(e) {
  56. var index = e.target.dataset.index;
  57. var imgs = this.data.table;
  58. imgs.splice(index,1);
  59. this.setData({
  60. table:imgs,
  61. })
  62. },
  63. // 选择图片
  64. chooseImage:function(e){
  65. var that = this;
  66. wx.chooseImage({
  67. count:3,
  68. sizeType:['original','compressed'],
  69. sourceType:['album','camera'],
  70. success(res){
  71. that.setData({
  72. table: res.tempFilePaths
  73. });
  74. }
  75. })
  76. },
  77. ceShibtnJiaoFei:function(e){
  78. },
  79. // 点击提交报修
  80. btnJiaoFei: function (e) {
  81. var that= this;
  82. if(this.data.txtvtel==''){
  83. wx.showToast({
  84. title: '请填写手机号',
  85. icon: 'none',
  86. duration: 2000
  87. })
  88. return;
  89. }
  90. if(this.data.txtvplace==''){
  91. wx.showToast({
  92. title: '请填写报事地址',
  93. icon: 'none',
  94. duration: 2000
  95. })
  96. return;
  97. }
  98. let fileurl = "";// 图片名称
  99. if(this.data.table.length>0){
  100. // 拼接多(单)个图片名称
  101. for (let index = 0; index < this.data.table.length; index++) {
  102. if(this.data.table[index].substring(0,11)=='http://tmp/'){
  103. fileurl += this.data.table[index].substring(11)+',';
  104. }
  105. if(this.data.table[index].substring(0,9)=='wxfile://'){
  106. fileurl += this.data.table[index].substring(9)+',';
  107. }
  108. }
  109. }
  110. var method='Insertfdc_pm_repair ';
  111. var wsdlurl= app.webUrl;
  112. var targetNamespace='http://tempuri.org/';
  113. var datacopy= '<?xml version="1.0" encoding="utf-8"?>';
  114. datacopy += '<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">';
  115. datacopy += '<soap:Header><MySoapHeader xmlns="http://tempuri.org/">';
  116. datacopy += `<UserName>${app.UserName}</UserName>`;
  117. datacopy += `<PassWord>${app.PassWord}</PassWord>`;
  118. datacopy += '</MySoapHeader></soap:Header>';
  119. datacopy += '<soap:Body>';
  120. datacopy += '<Insertfdc_pm_repair xmlns="http://tempuri.org/">';
  121. datacopy += `<dfdapplydate>${this.data.dfdapplydate}</dfdapplydate>`;
  122. datacopy += `<txtdrequiredate>${this.data.txtdrequiredate}</txtdrequiredate>`;
  123. datacopy += `<hddhcode>${this.data.hddhcode}</hddhcode>`;
  124. datacopy += `<hddownerid>${this.data.ownerid}</hddownerid>`;
  125. datacopy += `<txtvcontent>${this.data.txtvcontent}</txtvcontent>`;
  126. datacopy += `<txtvplace>${this.data.txtvplace}</txtvplace>`;
  127. datacopy += `<txtvtel>${this.data.txtvtel}</txtvtel>`;
  128. datacopy += `<fileurl>${fileurl}</fileurl>`;
  129.     datacopy += '</Insertfdc_pm_repair>';
  130.     datacopy += '</soap:Body>';
  131.     datacopy += '</soap:Envelope>';
  132. wx.request({
  133. url: wsdlurl,
  134. data: datacopy,
  135. method: 'POST',
  136. header: {
  137. 'Content-Type':'text/xml; charset=utf-8',
  138. 'SOAPAction':targetNamespace+method,
  139. },
  140. success:function(res){
  141. var XMLParser = new Parser.DOMParser();
  142. var doc = XMLParser.parseFromString(res.data);
  143. var Insertfdc_pm_repairResult = doc.getElementsByTagName("Insertfdc_pm_repairResult")[0].firstChild.nodeValue;
  144. if(Insertfdc_pm_repairResult=='保存成功!'){
  145. wx.showToast({
  146. title: '提交成功!',
  147. icon: 'success',
  148. duration: 1000
  149. })
  150. // 图片上传
  151. for (let index = 0; index < that.data.table.length; index++) {
  152. wx.uploadFile({
  153. filePath: that.data.table[index],
  154. name: 'name',
  155. url: app.coreUrl+ 'InsertPicture',
  156. header:{
  157. 'content-type':'multipart/form-data'
  158. },
  159. name:'upload',
  160. success:function(res){
  161. if(res.data=='true'){
  162. wx.navigateBack({
  163. delta: 2
  164. })
  165. }
  166. },
  167. })
  168. }
  169. } else {
  170. wx.showToast({
  171. title: Insertfdc_pm_repairResult,
  172. icon: 'none',
  173. duration: 2000
  174. })
  175. }
  176. }
  177. })
  178. },
  179. // 修改报事地址
  180. updateTxtvplace: function (e) {
  181. this.setData({
  182. txtvplace: e.detail.value
  183. })
  184. },
  185. // 编辑报事人电话
  186. updateTxtvtel: function (e) {
  187. this.setData({
  188. txtvtel: e.detail.value
  189. })
  190. },
  191. // 编辑报事人电话
  192. updateTxtvcontent: function (e) {
  193. this.setData({
  194. txtvcontent: e.detail.value
  195. })
  196. },
  197. // 预览图片
  198. handleImagePreview: function (e) {
  199. var idx = e.target.dataset.index;
  200. var imag = this.data.table;
  201. wx.previewImage({
  202. current: imag[idx], //当前预览的图片
  203. urls: imag, //所有要预览的图片
  204. })
  205. },
  206. /**
  207. * 生命周期函数--监听页面卸载
  208. */
  209. onUnload: function () {
  210. },
  211. /**
  212. * 页面相关事件处理函数--监听用户下拉动作
  213. */
  214. onPullDownRefresh: function () {
  215. },
  216. /**
  217. * 页面上拉触底事件的处理函数
  218. */
  219. onReachBottom: function () {
  220. },
  221. /**
  222. * 用户点击右上角分享
  223. */
  224. onShareAppMessage: function () {
  225. }
  226. })