<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
	  xmlns:th="http://www.thymeleaf.org"
	  xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
	  layout:decorate="~{/mobile/layout/loginLayout}">
<th:block layout:fragment="layout_css">
</th:block>
<th:block layout:fragment="layout_top_script">
</th:block>
<th:block layout:fragment="layout_content">
<body>
	<div>
	</div>
<form id="loginForm" onsubmit="return false;"></form>
</body>
</th:block>
<th:block layout:fragment="layout_script">
<script>
	$(function(){
		getDeviceInfo();

		getLoginInfo();
	});

	/*****************************************
	* 로그인
	******************************************/
	function fn_login(loginId, password) {
	    //로그인 로직 추가
	    let formData = new FormData();
		formData.append("loginId", loginId);
		formData.append("password", password);
		formData.append("deviceUuid", deviceUuid1);
		formData.append("phoneType", phoneType1);
		formData.append("modelName", modelName1);
		formData.append("osVersion", osVersion1);
		formData.append("pushKey", pushKey1);
		formData.append("appVersion", appVersion1);
		formData.append("deviceYn", deviceYn);

		if(""!=loginId && ""!=password){
			$.ajax({
				url: '/mobilelogin/login.do',
				data: formData,
				dataType: 'json',
				processData: false,
				contentType: false,
				type: 'POST',
				async: true,
				success: function(data){
					if(data.msgCode=='0'){
						fn_leftFormAction("/home");
					}else{
						fn_leftFormAction("/mobile");
					}
				},
				error : function(xhr, status, error) {
					modalEvent.danger("로그인 오류", data.msgDesc);
				},
				beforeSend:function(){

				},
				complete:function(){

				}
			});
		}else{
			fn_leftFormAction("/mobile");
		}
	}

	/*****************************************
	* sns 로그인
	******************************************/
	function fn_snsLogin(loginId, loginType){
		let formData = new FormData();
		formData.append("loginId", loginId);
		formData.append("loginType", loginType);
		formData.append("deviceUuid", deviceUuid1);
		formData.append("phoneType", phoneType1);
		formData.append("modelName", modelName1);
		formData.append("osVersion", osVersion1);
		formData.append("pushKey", pushKey1);
		formData.append("appVersion", appVersion1);
		formData.append("deviceYn", deviceYn);

		if(""!=loginId && ""!=loginType){
			$.ajax({
				url: '/mobilelogin/snsLogin.do',
				data: formData,
				dataType: "json",
				processData: false,
				contentType: false,
				type: 'POST',
				success: function(data){
					if(data.msgCode=='0'){
						fn_leftFormAction("/home");
					}else{
						fn_leftFormAction("/mobile");
					}
				},
				error : function(xhr, status, error) {
					modalEvent.danger("로그인 오류", data.msgDesc);
				}
			});
		}else{
			fn_leftFormAction("/mobile");
		}
	}
</script>
</th:block>
</html>
