webpackJsonp([19],{

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

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

var _public = __webpack_require__(2);

_public.iot.ready(init); /**
                         * v_addUser.js
                         * Version: 0.1
                         * User: wy
                         * Date: 2017-10-09
                         * Copyright(c)  2017. U-GEN Tech.Co,Ltd. All Rights Reserved.
                         * 添加用户页面
                         */

function init() {
    //通用 input、按钮、dialog、loading组件
    _public.uPublic.componentsInit(['u-text', 'u-button', 'u-dialog', 'u-loading']);
    var app = new Vue({
        data: {
            textName: null,
            textErrorTip: null,
            //配置组件
            componentsConfig: initComponentsConfig()
        },
        mounted: function mounted() {},

        methods: {
            getTextName: function getTextName() {
                return this.textName;
            },
            setTextName: function setTextName(text) {
                this.textName = text;
            },
            getTextErrorTip: function getTextErrorTip() {
                return this.textErrorTip;
            },
            setTextErrorTip: function setTextErrorTip(tip) {
                this.textErrorTip = tip;
            },

            //tap <
            onBackTap: function onBackTap() {
                backTap();
            },
            onNameChange: function onNameChange(text) {
                nameChange(this, text);
            },

            //tap 确定
            onConfirmButtonTap: function onConfirmButtonTap() {
                confirmButtonTap(this);
            }
        }
    }).$mount('#app');
}

//配置组件参数
function initComponentsConfig() {
    return {
        nameInput: {
            initParam: {
                class: 'custom-text',
                icon: '&#xe6b0;',
                placeholder: Vue.t('addUser.nameInputTip')
            }
        },
        //确定 button 参数
        confirmButton: {
            initParam: {
                class: 'custom-button',
                text: Vue.t('btn.confirm')
            }
        },
        dialog: {
            initParam: {
                class: 'custom-dialog'
            }
        },
        loading: {
            initParam: {
                class: 'custom-loading'
            }
        }
    };
}

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

function nameChange(self, text) {
    self.textName = text;
    self.setTextErrorTip(null);
    console.log('nameChange: ' + self.textName);
}

//tap 确定
function confirmButtonTap(self) {
    if (self.getTextName() == null || self.getTextName().trim() == '') {
        self.setTextErrorTip(Vue.t('addUser.error.nameCanNotEmpty'));
    } else {
        _public.uComponents.showLoading(self);
        _public.iot.business.api.sendCustom('lock/addUser', {
            data: {
                device_id: self.extras.deviceId
            },
            success: function success(response) {
                console.log(response);
                _public.uComponents.openAlert(self, Vue.t('addUser.addUserSuccess'), {
                    text: Vue.t('btn.confirm'), callback: function callback() {
                        console.log("添加用户成功");
                        _public.iot.storage.getMap('isFirstAdd', function (res) {
                            if (res) {
                                //跳转到门锁用户界面
                                _public.iot.navigator.openWindow({
                                    url: './doorlockUser.html',
                                    id: 'doorlockUser'
                                });
                            } else {}
                        }, function () {});
                    }
                });
            },
            error: function error(_error) {
                console.log(_error);
                _public.uComponents.openAlert(self, Vue.t('addUser.addUserFailure'), {
                    text: Vue.t('btn.confirm'), callback: function callback() {
                        console.log("添加用户失败");
                    }
                });
            },
            complete: function complete() {
                _public.uComponents.hideLoading(self);
            }
        });
    }
}

function showGuide() {}
/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(1)["default"]))

/***/ }),

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

module.exports = __webpack_require__(150);


/***/ })

},[266]);
//# sourceMappingURL=addUser.js.map