SOURCE

var portconfig = {"terminaluuid":"terminaluuid","WAN1":{
        "name":"pon1",
        "service_type":"pppoe",
        "pppoe_username":"1232222222",
        "pppoe_password":"2584596190",
   },"WAN2":{
       "name":"pon2",
        "service_type":"dhcp",
        "pppoe_username":"1232222222",
        "pppoe_password":"2584596190",
   }
   };
   console.log(portconfig);
if (!portconfig) {
        console.log("yes!!!!");
    } else  {
        var port ={};
        
        console.log(portconfig.WAN1.name);
        if (portconfig.WAN1) {
                port.mod = "IF",
                port.submod = "wanconnect",
                port.action = "mod";
                port.data ={};
                console.log(portconfig.port.service_type);
            if ( portconfig.WAN1.service_type === "static"){
                    port.data.name = "WAN1.1",
                    port.data.priority_id = "0",
                    port.data.enable = "1",
                    port.data.service_type = "2",     //
                    port.data.address_type = "1",
                    port.data.package_mode = "1",
                    port.data.ipaddr = "",
                    port.data.ipmask = "",
                    port.data.gateway = "",
                    port.data.dns_primary ="";
                    port.data.nat_enable ="1"
            }else if ( portconfig.WAN1.service_type === "pppoe" ){
                    port.data.name = "WAN1.1",
                    port.data.priority_id = "0",
                    port.data.enable = "1",
                    port.data.conn_type = "1",
                    port.data.package_mode = "2",
                    port.data.service_type = "2",
                    port.data.address_type = "3",
                    port.data.pppoe_username = portconfig.WAN1.pppoe_username,
                    port.data.pppoe_password = portconfig.WAN1.pppoe_password;
                   port. data.nat_enable ="1"
            }else if ( portconfig.WAN1.service_type === "dhcp" ) {
                    port.data.name = "WAN1.1",
                    port.data.priority_id = "0",
                    port.data.enable = "1",
                    port.data.conn_type = "1",
                    port.data.service_type = "2",
                    port.data.package_mode = "1",
                    port.data.address_type = "2",
                    port.data.nat_enable ="1"
            }else{
                console.log("error!!!!!!!!!")
            }

            console.log(port);


        } else {
            console.log("NO!!!!!!!!!");
        }
    }
console 命令行工具 X clear

                    
>
console