webpackJsonp([14],{

/***/ 221:
/***/ (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__(4);

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

/**
* v_editNickname.js
* Version: 0.1
* User: zjx
* Date: 2017-09-29
* Copyright(c)  2017. U-GEN Tech.Co,Ltd. All Rights Reserved.
* 引导页面
*/

_public.iot.ready(init);
function init() {
    //通用 dialog、loading组件
    _public.uPublic.componentsInit(['u-dialog', 'u-loading', 'u-text']);
    _public.uPublic.closeSlideBack();
    var app = new Vue({
        data: {
            //配置组件
            textNickName: _public.iot.navigator.getExtras().nickname,
            textErrorTip: null,
            componentsConfig: initComponentsConfig()
        },
        mounted: function mounted() {},

        methods: {
            getTextNickName: function getTextNickName() {
                return this.textNickName;
            },
            setTextNickName: function setTextNickName(text) {
                this.textNickName = this;
            },
            onSaveTap: function onSaveTap() {
                saveTap(this);
            },
            onBackTap: function onBackTap() {
                backTap();
            },
            onNicknameChange: function onNicknameChange(text) {
                nicknameChange(this, text);
            }
        }
    }).$mount('#app');
}

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

//保存昵称
function saveTap(self) {
    if (self.textNickName == null || self.textNickName.trim() == '') {
        self.textErrorTip = Vue.t('editNickname.nickNameInputTip');
    } else {
        _public.uComponents.showLoading(self);
        _public.iot.business.user.setInfo({
            data: {
                nickname: self.textNickName,
                head: ''
            },
            success: function success(response) {
                if (response.data = 'success') {
                    _public.iot.navigator.aback();
                }
            },
            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() {
                _public.uComponents.hideLoading(self);
            }
        });
    }
}

_public.iot.navigator.aback = function () {
    _public.iot.navigator.fire(plus.webview.currentWebview().opener(), 'returnPage', {});
    _public.iot.navigator.back();
};

//返回上一页
function backTap() {
    _public.iot.navigator.aback();
}

function nicknameChange(self, text) {
    self.textNickName = text;
    self.textErrorTip = '';
}
/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(2)["default"]))

/***/ }),

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

module.exports = __webpack_require__(221);


/***/ })

},[322]);
//# sourceMappingURL=editNickname.js.map