baoxiu.js 8.4 KB

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