stview.js 5.64 KB
Newer Older
Masaru Abe committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20

//名前空間用のオブジェクトを用意する
var STVIEW = {};

STVIEW.latitude = '';
STVIEW.longitude = '';

//Login Process
STVIEW.processLogin = function(cid,sid) {
	var requireChangePassword = 0;
	var skipPwdDate;
	
	var params = {
		cid: cid,
		sid: sid
	};
	
	// Get url to login
	var apiLoginUrl = ClientData.conf_apiLoginUrl();
	
Masaru Abe committed
21
	$('#main-error-message').html("loading...");
Masaru Abe committed
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
	$('#main-error-message').show();
	
	AVWEB.avwCmsApiWithUrl(apiLoginUrl, null, 'webClientStreamingLogin', 'GET', params, function (data) {
		//requirePasswordChange = data.requirePasswordChange;
		LOGIN.userinfo_sid = data.sid;
		LOGIN.userInfo_userName = data.userName;
		LOGIN.optionList = data.serviceOptionList;
		
		LOGIN.getServiceOptionList();
		
		if (data.result == 'success') {
			
			// Save retrieved info
			STVIEW.saveLoginInfo(data);
			
			// set number new push message to 0
			ClientData.pushInfo_newMsgNumber(0);
			
			//ストリーミングモード有効化
			ClientData.isStreamingMode(true);
			//GPS情報
Masaru Abe committed
43 44 45 46 47 48
			if( STVIEW.latitude != '' ){
				ClientData.latitude(STVIEW.latitude);
			}
			if( STVIEW.longitude != '' ){
				ClientData.longitude(STVIEW.longitude);
			}
Masaru Abe committed
49 50 51 52 53
			
			$('#main-error-message').css('display', 'none');
			if (data.requirePasswordChange == 0) {
				ClientData.userInfo_sid(ClientData.userInfo_sid_local());
				
Masaru Abe committed
54 55
				//$('#main-error-message').html("login ok move to:" + COMMON.ScreenIds.ContentViewStreaming);
				//$('#main-error-message').show();
Masaru Abe committed
56 57 58 59
				
				//コンテンツIDセット
				ClientData.contentInfo_contentId(cid);
				//ストリーミングのビューアへ移動
Masaru Abe committed
60
				AVWEB.avwScreenMove("abvw/" + COMMON.ScreenIds.ContentViewStreaming + "?__UPDATEID__");
Masaru Abe committed
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128
				
			} else {
				$('#main-error-message').html(AVWEB.format(I18N.i18nText('msgLoginErrWrong'), 'E001'));
				$('#main-error-message').show();
				return;
			}
		}
		else {
            LOGIN.login_errorMessage = data.errorMessage;
            $('#main-error-message').html(AVWEB.format(I18N.i18nText('msgLoginErrWrong'), data.errorMessage).toString());
            $('#main-error-message').show();
            alert("Open Error1!");
        }
        
    }, function (xhr, statusText, errorThrown) {
    	
        if (xhr.responseText && xhr.status != 0) {
            LOGIN.login_errorMessage = JSON.parse(xhr.responseText).errorMessage;
            
        	alert("Open Error21!:" + LOGIN.login_errorMessage);
            
            $('#main-error-message').html(AVWEB.format(I18N.i18nText('msgLoginErrWrong'), JSON.parse(xhr.responseText).errorMessage).toString());
        } else {
        	
        	alert("Open Error22!:E001");
        	
            $('#main-error-message').html(AVWEB.format(I18N.i18nText('msgLoginErrWrong'), 'E001'));
        }
        $('#main-error-message').show();
    });
	
};

//check Save Login Info
STVIEW.saveLoginInfo = function(data) {

	var lang = I18N.getCurrentLanguage();
	// load language
	I18N.changeLanguage(lang);

	var accountPath = data.urlPath;
	var loginId = data.loginId;
	var date = new Date();
    ClientData.userInfo_accountPath(accountPath);
    ClientData.userInfo_loginId(loginId);
    ClientData.userInfo_accountPath_session(accountPath);
    ClientData.userInfo_loginId_session(loginId);
    ClientData.userInfo_userName(LOGIN.userInfo_userName);

    ClientData.userInfo_lastLoginTime(date.jpDateTimeString());
	ClientData.userInfo_sid_local(LOGIN.userinfo_sid);
	LOGIN.saveServiceUserOption();
	
	//alert("url:" + ClientData.userInfo_accountPath() + " loginId:" + ClientData.userInfo_loginId());
	
	// 不要なフラグ落とす
	ClientData.common_contentDataChkFlg(false);
	ClientData.userInfo_rememberLogin(false);
	
	//ページジャンプ設定をクリア
	ClientData.JumpQueue([]);
	ClientData.IsJumpBack(false);
	
};

//$(document).ready(function () {
STVIEW.ready = function(){
	
Masaru Abe committed
129 130
	//$('#main-error-message').html( window.location.href );
	//$('#main-error-message').show();
Masaru Abe committed
131
	//return;
Masaru Abe committed
132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147
	
	//引数の確認
	var sid = COMMON.getUrlParam('sid', '');
	var cid = COMMON.getUrlParam('cid', '');
	var page = COMMON.getUrlParam('page', '');
	var latitude = COMMON.getUrlParam('latitude', '');
	var longitude = COMMON.getUrlParam('longitude', '');
	var reload = COMMON.getUrlParam('reload', '');
	
	var isView = false;
	if( !sid || !cid ){
		//表示出来ない
		$('#main-error-message').html(AVWEB.format(I18N.i18nText('msgLoginErrWrong'), 'E001'));
		$('#main-error-message').show();
		return;
	}
Masaru Abe committed
148
	
Masaru Abe committed
149 150 151 152 153 154
	var isReload = false;
	if( reload != "" ){
		if( reload == "true" ){
			isReload = true;
		}
	}
Masaru Abe committed
155 156
	
	//---初期化
Masaru Abe committed
157 158 159 160 161 162 163
	if( isReload == false ){
		//セッションストレージクリア
		SessionStorageUtils.clear();
		AVWEB.avwUserSessionObj = null;
		// create new session
		AVWEB.avwCreateUserSession();
	}
Masaru Abe committed
164 165 166 167 168 169 170 171 172 173 174 175 176
	I18N.initi18n();

	var sysSettings = AVWEB.avwSysSetting(); // get info in conf.json
	
	//モード初期化
	ClientData.isGetitsMode(false);
	ClientData.isStreamingMode(false);
	
	//confのパラメータセット
	ClientData.conf_apiUrl( sysSettings.apiUrl );
	ClientData.conf_apiLoginUrl( sysSettings.apiLoginUrl );
	ClientData.conf_apiResourceDlUrl( sysSettings. apiResourceDlUrl );
	
Masaru Abe committed
177 178 179
	if( isReload == false ){
		//念のため前回までの閲覧ログは削除
		ClientData.ContentLogData([]);
Masaru Abe committed
180 181 182
	}
	
	//ページ番号指定有り
Masaru Abe committed
183
	if( page == "" || page == "0" || page == "1"){
Masaru Abe committed
184 185 186 187 188 189 190 191
		ClientData.common_prePageNo(null)
	} else {
		ClientData.common_prePageNo(page);
	}
	//GPS
	if( latitude != "" ){
		STVIEW.latitude = latitude;
	}
Masaru Abe committed
192
	if( longitude != "" ){
Masaru Abe committed
193 194 195
		STVIEW.longitude = longitude;
	}
	
Masaru Abe committed
196 197 198 199 200 201 202
	if( STVIEW.latitude != "" && STVIEW.longitude != "" ){
		STVIEW.processLogin(cid,sid);
	} else {
		setTimeout(function (){
			STVIEW.processLogin(cid,sid);
		}, 1000);
	}
Masaru Abe committed
203 204 205 206
};
//});