webpackJsonp([12],{

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

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

var _public = __webpack_require__(4);

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

function init() {
    //通用 dialog、loading组件
    _public.uPublic.componentsInit(['u-button', 'u-dialog', 'u-loading']);
    _public.uPublic.closeSlideBack();
    var app = new Vue({
        data: {
            //配置组件
            nickname: null,
            componentsConfig: initComponentsConfig()
        },
        mounted: function mounted() {
            var self = this;
            getInfo(this);
            window.addEventListener('returnPage', function (event) {
                console.log("in");
                getInfo(self);
            });
            var wv = _public.iot.navigator.getCurrentWebView();
            console.log(wv);
        },

        methods: {
            //tap 修改昵称
            onEditNicknameTap: function onEditNicknameTap() {
                editNicknameTap(this);
            },

            //tap 修改密码
            onEditPasswordTap: function onEditPasswordTap() {
                editPasswordTap();
            },
            onBackTap: function onBackTap() {
                backTap();
            },

            //tap 退出系统
            onLogoutButtonTap: function onLogoutButtonTap() {
                logoutButtonTap(this);
            }
        }
    }).$mount('#app');
}

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

//tap 修改昵称
function editNicknameTap(self) {
    _public.iot.navigator.openWindow({
        url: '../myInfo/editNickname.html',
        id: 'editNickname',
        extras: {
            nickname: self.nickname
        }
    });
}

//tap 修改密码
function editPasswordTap() {
    _public.iot.navigator.openWindow({
        url: '../myInfo/editPassword.html',
        id: 'editPassword'
    });
}

function backTap() {
    _public.iot.navigator.back();
}

function getInfo(self) {
    _public.iot.business.user.getInfo({
        success: function success(response) {
            var data = _public.uPublic.checkResponseData(response.data);
            if (data) {
                console.log(data);
                self.nickname = data.nickname;
            } else {}
        },
        error: function error(_error) {
            console.log(_error);
            //  		if(window.iotDebug){
            //              iotDebug.push('end: 获取用户信息'+JSON.stringify(error));
            //         	}
            //	    	if (window.iotDebug) {
            //              iotDebug.upload(iot,'获取用户信息');
            //          }
            _public.uPublic.openRequestErrorAlert(self);
        },
        complete: function complete() {}
    });
}

//tap 退出系统
function logoutButtonTap(self) {
    _public.uComponents.openConfirm(self, Vue.t('myInfo.logoutDialogTip'), { text: Vue.t('dialog.cancel'), callback: function callback() {} }, { text: Vue.t('dialog.confirm'), callback: function callback() {
            _public.iot.business.user.logout({
                data: {
                    sds: true
                },
                success: function success(response) {
                    _public.iot.business.websql.delMaps(['utoken', 'userinfo'], function (response) {
                        console.log(response);
                    }, function (error) {
                        console.log(error);
                        //		                if(window.iotDebug){
                        //			                iotDebug.push('end: 清除tocken失败'+JSON.stringify(error));
                        //			           	}
                        //				    	if (window.iotDebug) {
                        //			                iotDebug.upload(iot,'清除tocken失败');
                        //			            }
                        _public.uPublic.openRequestErrorAlert(self);
                    });
                    _public.iot.storage.delMaps(['notifyTime', 'alarmTime', 'openTime'], function (response) {
                        console.log(response);
                    }, function () {});
                    _public.iot.navigator.openWindow({
                        url: '../login/index.html',
                        id: 'login'
                    });
                    var wvs = plus.webview.all();
                    for (var i = 0; i < wvs.length - 1; i++) {
                        plus.webview.close(wvs[i]);
                    }
                },
                error: function error(_error2) {
                    console.log(_error2);
                    if (window.iotDebug) {
                        iotDebug.push('end: 退出登陆失败' + JSON.stringify(_error2));
                    }
                    if (window.iotDebug) {
                        iotDebug.upload(_public.iot, '退出登陆失败');
                    }
                    _public.uPublic.openRequestErrorAlert(self);
                },
                complete: function complete() {
                    console.log("complete");
                }
            });
        } });
}
/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(2)["default"]))

/***/ }),

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

module.exports = __webpack_require__(223);


/***/ })

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