webpackJsonp([8],{

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

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

var _config = __webpack_require__(9);

var _config2 = _interopRequireDefault(_config);

var _public = __webpack_require__(6);

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

/**
* v_editName.js
* Version: 0.1
* User: wy
* Date: 2017-10-09
* Copyright(c)  2017. U-GEN Tech.Co,Ltd. All Rights Reserved.
* 修改名称页面
*/
_public.iot.ready(init);
function init() {
    //通用 input、dialog、loading组件
    _public.uPublic.componentsInit(['u-text', 'u-dialog', 'u-loading']);
    _public.uPublic.closeSlideBack();
    var app = new Vue({
        data: {
            textName: _public.iot.navigator.getExtras().nickname,
            textErrorTip: '',
            //配置组件
            componentsConfig: initComponentsConfig(),
            extras: {},
            role: null
        },
        mounted: function mounted() {
            this.extras = _public.iot.navigator.getExtras();
            this.role = this.extras.role;
        },

        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();
            },

            //tap 保存
            onSaveTap: function onSaveTap() {
                saveTap(this);
            },
            onNameChange: function onNameChange(text) {
                nameChange(this, text);
            }
        }
    }).$mount('#app');
}

//配置组件参数
function initComponentsConfig() {
    return {
        nameInput: {
            initParam: {
                class: 'custom-editName-text',
                placeholder: Vue.t('editName.nickNameInputTip'),
                maxlength: _config2.default.input.maxlength
            }
        },
        dialog: {
            initParam: {
                class: 'custom-dialog'
            }
        },
        loading: {
            initParam: {
                class: 'custom-loading'
            }
        }
    };
}

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

//tap 保存
function saveTap(self) {
    if (self.getTextName() == null || self.getTextName().trim() == '') {
        self.setTextErrorTip(Vue.t('editName.error.nicknameCanNotBeBlank'));
    } else if (_public.uPublic.checkString(self.getTextName())) {
        self.setTextErrorTip(Vue.t('textTip.textType'));
    } else if (self.getTextErrorTip() == '') {
        _public.uComponents.showLoading(self);
        _public.iot.business.api.sendCustom('lock/setLockUserName', {
            data: {
                rel_id: self.extras.id,
                nickname: self.getTextName(),
                device_id: self.extras.deviceId
            },
            success: function success(response) {
                console.log(response);
                if (response.data.success) {
                    _public.iot.navigator.fire(plus.webview.currentWebview().opener(), 'returnPage', {});
                    _public.uComponents.openAlert(self, Vue.t('editName.editNameSuccess'), {
                        text: Vue.t('btn.confirm'), callback: function callback() {
                            var opener = plus.webview.currentWebview().opener();
                            var view = plus.webview.getWebviewById(opener.id);
                            console.log(view);
                            _public.iot.navigator.aback();
                        }
                    });
                }
                //		    	let data = uPublic.checkResponseData(response.data);
                //	    		if(data){
                //			    	uComponents.openAlert(self, Vue.t('editName.nicknameCanNotBeBlank'), {
                //			        text: Vue.t('btn.confirm'), callback: function () {
                //							let opener = plus.webview.currentWebview().opener();
                //							let view = plus.webview.getWebviewById(opener.id);
                //							console.log(view);
                //							iot.navigator.fire(plus.webview.currentWebview().opener(),'returnPage',{});
                //							console.log('returnPage');
                //		    				iot.navigator.back();
                //				        }
                //			    	});
                //	    		}
            },
            error: function error(_error) {
                console.log(_error);
                //		    	if(window.iotDebug){
                //	                iotDebug.push('end: 修改用户名称失败'+JSON.stringify(error));
                //	           	}
                //		    	if (window.iotDebug) {
                //	                iotDebug.upload(iot,'修改用户名称失败');
                //	            }
                _public.uComponents.openAlert(self, Vue.t('editName.editNameFailue'), {
                    text: Vue.t('btn.confirm'), callback: function callback() {
                        var opener = plus.webview.currentWebview().opener();
                        _public.iot.navigator.back();
                    }
                });
            },
            complete: function complete() {
                _public.uComponents.hideLoading(self);
            }
        });
    }
}

function nameChange(self, text) {
    self.textName = text;
    self.setTextErrorTip('');
    console.log('nameChange: ' + self.textName);
}
/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(4)["default"]))

/***/ }),

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

module.exports = __webpack_require__(191);


/***/ })

},[301]);
//# sourceMappingURL=editName.js.map