webpackJsonp([13],{

/***/ 157:
/***/ (function(module, exports, __webpack_require__) {

"use strict";
/* WEBPACK VAR INJECTION */(function(Vue) {

var _public = __webpack_require__(2);

_public.iot.ready(init); /**
                         * v_index.js
                         * Version: 0.1
                         * User: wy
                         * Date: 2017-09-06
                         * Copyright(c)  2017. U-GEN Tech.Co,Ltd. All Rights Reserved.
                         * 引导页面
                         */

function init() {
				//通用 dialog、loading组件
				_public.uPublic.componentsInit(['u-dialog', 'u-loading', 'u-button']);
				var app = new Vue({
								data: {
												//配置组件
												componentsConfig: initComponentsConfig()
								},
								mounted: function mounted() {
												//          setTimeout(function(){
												//              iot.navigator.openWindow({
												//                  url: './login.html',
												//                  id: 'login'
												//              });
												//          },2000)   
												var self = this;
								},

								methods: {
												onLoginButtonTap: function onLoginButtonTap() {
																loginButtonTap(this);
												}
								}
				}).$mount('#app');
}

//配置组件参数
function initComponentsConfig() {
				return {
								//登录 button 参数
								loginButton: {
												initParam: {
																class: 'custom-guide-button',
																text: Vue.t('btn.guideLogin')
												}
								},
								dialog: {
												initParam: {
																class: 'custom-dialog'
												}
								},
								loading: {
												initParam: {
																class: 'custom-loading'
												}
								}
				};
}

function loginButtonTap(self) {
				_public.uComponents.showLoading(self);
				_public.iot.business.sds.init({
								data: {
												oa: true
								},
								success: function success(response) {
												console.log(response);
												_public.iot.business.user.login({
																data: {
																				sds: true
																},
																success: function success(response) {
																				console.log(response);
																				var data = _public.uPublic.checkResponseData(response.data);
																				if (data) {
																								console.log("云端登陆");
																								cloudsLogin(self, data.UserID);
																								//			    		iot.navigator.openWindow({
																								//					        url: '../device/index.html',
																								//					        id: 'device'
																								//					    });
																				} else {}
																},
																error: function error(_error) {
																				console.log(_error);
																				//请求失败
																				_public.uPublic.openRequestErrorAlert(self);
																},
																complete: function complete() {}
												});
								},
								error: function error(_error2) {
												console.log(_error2);
												//请求失败
												_public.uPublic.openRequestErrorAlert(self);
								}
				});
}

//云端登陆
function cloudsLogin(self, id) {
				_public.iot.business.user.autoLogin({
								success: function success(response) {
												console.log(response);
												var data = _public.uPublic.checkResponseData(response.data);
												if (data) {
																_public.uComponents.hideLoading(self);
																_public.iot.navigator.openWindow({
																				url: '../device/index.html',
																				id: 'device'
																});
												} else {}
								},
								error: function error(_error3) {
												console.log(_error3);
												_public.iot.business.user.login({
																data: {
																				username: id,
																				pwd: id
																},
																success: function success(response) {
																				console.log(response);
																				var data = _public.uPublic.checkResponseData(response.data);
																				if (data) {
																								_public.uComponents.hideLoading(self);
																								_public.iot.navigator.openWindow({
																												url: '../device/index.html',
																												id: 'device'
																								});
																				} else {}
																},
																error: function error(_error4) {
																				console.log(_error4);
																				//不存在此用户
																				//		    	if(code == 10002){
																				//用户注册
																				_public.iot.business.user.reg({
																								data: {
																												username: id,
																												pwd: id,
																												vcode: id
																								},
																								success: function success(response) {
																												console.log(response);
																												//注册成功
																												var data = _public.uPublic.checkResponseData(response.data);
																												if (data) {
																																_public.uComponents.hideLoading(self);
																																_public.iot.navigator.openWindow({
																																				url: '../device/index.html',
																																				id: 'device'
																																});
																												} else {}
																								},
																								error: function error(_error5) {
																												console.log(_error5);
																												//注册失败
																												_public.uComponents.openAlert(self, Vue.t('login.failure'), {
																																text: Vue.t('dialog.confirm'), callback: function callback() {
																																				plus.webview.currentWebview().reload();
																																}
																												});
																								},
																								complete: function complete() {}
																				});
																				//		    	}
																				//请求失败
																				_public.uPublic.openRequestErrorAlert(self);
																},
																complete: function complete() {}
												});
								},
								complete: function complete() {}
				});
				//	
}
/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(1)["default"]))

/***/ }),

/***/ 276:
/***/ (function(module, exports, __webpack_require__) {

module.exports = __webpack_require__(157);


/***/ })

},[276]);
//# sourceMappingURL=index.js.map