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

    /**
     * 页面的初始数据
     */
    data: {
        jiaoFeiJiLu:{},
        imgs:[],
        userFileUrl:app.userFileUrl,//读取报事上传图片地址
    },

    /**
     * 生命周期函数--监听页面加载
     */
    onLoad: function (options) {
        var that = this;
        var method='Getfdc_pm_repairapplySumByID';
        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_repairapplySumByID xmlns="http://tempuri.org/">';
        datacopy += `<vrepairapplycode>${options.vrepairapplycode}</vrepairapplycode>`;
        datacopy += '</Getfdc_pm_repairapplySumByID>';
        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_repairapplySumByIDResult")[0].firstChild.nodeValue);
                if(Getfdc_pm_ownerResult.ok==true){
                    that.setData({
                        jiaoFeiJiLu:Getfdc_pm_ownerResult.Table[0]
                    })
                }
            }
        })
        var methods='Getfdc_pm_file';
        var wsdlurls=app.webUrl;
        var targetNamespaces='http://tempuri.org/';
        var datacopys= '<?xml version="1.0" encoding="utf-8"?>';
        datacopys += '<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/">';
        datacopys += '<soap:Header><MySoapHeader xmlns="http://tempuri.org/">';
        datacopys += '<UserName>admin</UserName>';
        datacopys += '<PassWord>admin123</PassWord>';
        datacopys += '</MySoapHeader></soap:Header>';
        datacopys += '<soap:Body>';
        datacopys += '<Getfdc_pm_file xmlns="http://tempuri.org/">';
        datacopys += `<code>${options.vrepairapplycode}</code>`;
        datacopys += '</Getfdc_pm_file>';
        datacopys += '</soap:Body>';
        datacopys += '</soap:Envelope>';
        wx.request({
            url: wsdlurls,
            data: datacopys, 
            method: 'POST', 
            header: { 
            'Content-Type':'text/xml; charset=utf-8',
            'SOAPAction':targetNamespaces+methods,
            }, 
            success:function(res){
                var XMLParsers = new Parser.DOMParser();
                var docs = XMLParsers.parseFromString(res.data);
                var Getfdc_pm_fileResult = JSON.parse(docs.getElementsByTagName("Getfdc_pm_fileResult")[0].firstChild.nodeValue);
                if(Getfdc_pm_fileResult.ok==true){
                    that.setData({
                        imgs:Getfdc_pm_fileResult.Table
                    })
                }
            }
        })
    },

    // 查看图片
    handleImagePreview: function (e) {
    },

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

    },

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

    },

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

    },

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

    },

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

    },

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

    }
})