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

    /**
     * 页面的初始数据
     */
    data: {
        jiaoFeiJiLu:[],
        vrepairapplycode:'',
    },

    /**
     * 生命周期函数--监听页面加载
     */
    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_repairapplyByownerid';
            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_repairapplyByownerid xmlns="http://tempuri.org/">';
            datacopy += `<ownerid>${sum[index]}</ownerid>`;
            datacopy += '</Getfdc_pm_repairapplyByownerid>';
            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_ownerResult = JSON.parse(doc.getElementsByTagName("Getfdc_pm_repairapplyByowneridResult")[0].firstChild.nodeValue);
                    if(Getfdc_pm_ownerResult.ok==true){
                        for (let i = 0; i < Getfdc_pm_ownerResult.Table.length; i++) {
                            tableBX.push(Getfdc_pm_ownerResult.Table[i]);
                        }
                        that.setData({
                            jiaoFeiJiLu:tableBX
                        })
                    }
                }
            })
        }
    },
    bxjlDetail: function (e) {
        wx.navigateTo({
          url: `../bxjlDetail/bxjlDetail?vrepairapplycode=${e.currentTarget.dataset.index}`,
        })
    },

    /**
     * 生命周期函数--监听页面显示
     */
    onShow: function () {

    },

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

    },

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

    },

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

    },

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

    },

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

    }
})