"use strict";
import { util } from '../../../util/util.js'
import { fullMap } from '../../../fullMap.js';
import { khcAlert } from '../../../component/alert/khcAlert.js'
import {config} from "../../../config.js";
import {httpUtil} from "../../../util/httpUtil.js";
let functionMap=new Map();// 使用 Map 来存储多个函数。每个函数都通过 set 方法添加到 Map 中，键是函数名，值是对应的函数。
export function main(jsonConfig) {
    try {
        functionMap.get(jsonConfig.button_method).apply(jsonConfig);
    } catch (error) {
        khcAlert.showSystemError(error.message);
        console.log(error);
    }
}
function nsInit(){
    let jsonConfig=this;
    let nsTemplate=`<div class="authentication-wrapper authentication-2 px-4">
    <div class="authentication-inner py-5">
        <!-- Form -->
        <form class="card">
            <div class="p-4 p-sm-5">
                <!-- Logo -->
                <div class="d-flex justify-content-center align-items-center pb-2 mb-4">
                    <div class="ui-w-60">
                        <div class="w-100 position-relative" style="padding-bottom: 54%">
                            <svg class="w-100 h-100 position-absolute" viewBox="0 0 148 80" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"><defs><linearGradient id="a" x1="46.49" x2="62.46" y1="53.39" y2="48.2" gradientUnits="userSpaceOnUse"><stop stop-opacity=".25" offset="0"></stop><stop stop-opacity=".1" offset=".3"></stop><stop stop-opacity="0" offset=".9"></stop></linearGradient><linearGradient id="e" x1="76.9" x2="92.64" y1="26.38" y2="31.49" xlink:href="#a"></linearGradient><linearGradient id="d" x1="107.12" x2="122.74" y1="53.41" y2="48.33" xlink:href="#a"></linearGradient></defs><path class="fill-primary" transform="translate(-.1)" d="M121.36,0,104.42,45.08,88.71,3.28A5.09,5.09,0,0,0,83.93,0H64.27A5.09,5.09,0,0,0,59.5,3.28L43.79,45.08,26.85,0H.1L29.43,76.74A5.09,5.09,0,0,0,34.19,80H53.39a5.09,5.09,0,0,0,4.77-3.26L74.1,35l16,41.74A5.09,5.09,0,0,0,94.82,80h18.95a5.09,5.09,0,0,0,4.76-3.24L148.1,0Z"></path><path transform="translate(-.1)" d="M52.19,22.73l-8.4,22.35L56.51,78.94a5,5,0,0,0,1.64-2.19l7.34-19.2Z" fill="url(#a)"></path><path transform="translate(-.1)" d="M95.73,22l-7-18.69a5,5,0,0,0-1.64-2.21L74.1,35l8.33,21.79Z" fill="url(#e)"></path><path transform="translate(-.1)" d="M112.73,23l-8.31,22.12,12.66,33.7a5,5,0,0,0,1.45-2l7.3-18.93Z" fill="url(#d)"></path></svg>
                        </div>
                    </div>
                </div>
                <!-- / Logo -->
                <h5 class="text-center text-muted font-weight-normal mb-4" _msttexthash="13531791" _msthash="1">重置密码</h5>
                <hr class="mt-0 mb-4">
                <p _msttexthash="226181410" _msthash="2">输入您的电子邮件地址，我们将向您发送一个链接以重置您的密码。</p>
                <div class="form-group">
                    <input type="text" class="form-control" placeholder="输入您的电子邮件地址" _mstplaceholder="496301" _msthash="3" value="test@xxx.com">
                </div>
                <button type="button" class="btn btn-primary btn-block" _msttexthash="43707781" _msthash="4" id="submitButton">发送密码重置电子邮件</button>
            </div>
        </form>
        <!-- / Form -->
    </div>
</div>`
    document.getElementById(objParentObjID).innerHTML=nsTemplate
    document.getElementById('submitButton').addEventListener('click',function (){
        //请求接口示例
        let params={}
        params.nosessionCode='ns_system_config'
        params.methodNameShow="isWhiteListIP";//调试字段
        params.methodName=util.textEncrypt('isWhiteListIP',new Date().getTime(),util.getLocalStorageItem('ip'));
        let obj={url:config.getConfigJson().nosessionActionUrl,params:params,config:'no token'}
        httpUtil.post(obj,(response)=>{//模拟调用接口
            let resData=response.data.data
            console.log(resData)
            khcAlert.showSuccessMessage('点击了发送按钮');
        });
    })


}
functionMap.set('nsInit', nsInit);// 将函数添加到 Map 中