const Parser = require('../xml/xmldom/dom-parser')
var app = getApp();
Page({

    /**
     * 页面的初始数据
     */
    data: {
        jiaoFeiJiLu:[]
    },
    onShow:function(options){
      
    },
    /**
     * 生命周期函数--监听页面显示
     */
    onLoad: function (optitons) {
      wx.showToast({
        title: '加载中',
        icon: 'loading',
        duration: 1000
      })
      var that = this;
      var tableBX = [];
      var sum = optitons.sessionPhone.split(',');
      for (let index = 0; index < sum.length-1; index++) {
        var method='Getfdc_pm_revfare ';
        var wsdlurl=app.webUrl;
        var targetNamespace='http://tempuri.org/';
        var datacopy= '<?xml version="1.0" encoding="utf-8"?>';
        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/">';
        datacopy += '<soap:Header><MySoapHeader xmlns="http://tempuri.org/">';
        datacopy += `<UserName>${app.UserName}</UserName>`;
        datacopy += `<PassWord>${app.PassWord}</PassWord>`;
        datacopy += '</MySoapHeader></soap:Header>';
        datacopy += '<soap:Body>';
        datacopy += '<Getfdc_pm_revfare   xmlns="http://tempuri.org/">';
        datacopy += `<weixinid>${optitons.openid}</weixinid>`;
        datacopy += `<ownerid>${sum[index]}</ownerid>`;
        datacopy += '</Getfdc_pm_revfare  >';
        datacopy += '</soap:Body>';
        datacopy += '</soap:Envelope>';
        wx.request({
          url: wsdlurl,
          data: datacopy, 
          method: 'POST', 
          header: { 
            'Content-Type':'text/xml; charset=utf-8',
            'SOAPAction':targetNamespace+method,
          }, 
          success:function(res){
            var XMLParser = new Parser.DOMParser();
            var doc = XMLParser.parseFromString(res.data);
            var Getfdc_pm_revfareResult = JSON.parse(doc.getElementsByTagName("Getfdc_pm_revfareResult")[0].firstChild.nodeValue);
            if(Getfdc_pm_revfareResult.ok!=false){
              for (let i = 0; i < Getfdc_pm_revfareResult.Table.length; i++) {
                tableBX.push(Getfdc_pm_revfareResult.Table[i]);
              }
              that.setData({
                  jiaoFeiJiLu:tableBX
              })
            }
          }
        })
      }
    },

    /**
     * 生命周期函数--监听页面初次渲染完成
     */
    onReady: function () {

    },

    /**
     * 生命周期函数--监听页面隐藏
     */
    onHide: function () {

    },

    /**
     * 生命周期函数--监听页面卸载
     */
    onUnload: function () {

    },

    /**
     * 页面相关事件处理函数--监听用户下拉动作
     */
    onPullDownRefresh: function () {

    },

    /**
     * 页面上拉触底事件的处理函数
     */
    onReachBottom: function () {

    },

    /**
     * 用户点击右上角分享
     */
    onShareAppMessage: function () {

    }
})