/**
* v_editName.js
* Version: 0.1
* User: wy
* Date: 2017-09-06
* Copyright(c)  2017. U-GEN Tech.Co,Ltd. All Rights Reserved.
* 修改名称页面
*/

import {iot, uPublic, uComponents} from '../../public/public.js';

iot.ready(init);
function init() {
    //通用 input、按钮、dialog、loading组件
    uPublic.componentsInit(['u-text','u-button','u-dialog','u-loading']);
    const app = new Vue({
        data:{
            textName: '门锁-001',
            textErrorTip: null,
            //配置组件
            componentsConfig: initComponentsConfig()     
        },
        mounted(){           
        },
        methods:{
            onNameChange(text){
                nameChange(this,text);           
            },
            //tap <
            onBackTap(){
                backTap();
            },
            //tap 保存
            onSaveButtonTap(){
                saveButtonTap();
            }                     
        }   
    }).$mount('#app');
}

//配置组件参数
function initComponentsConfig() {
    return {
        nameInput: {
            initParam: {
                class: 'custom-editName-text',
                placeholder: Vue.t('editName.nameInputTip')
            }
        },
        //保存 button 参数
        saveButton: {   
            initParam: {
                class: 'custom-button',
                text: Vue.t('btn.save')
            }
        },
        dialog: {
            initParam: {
                class: 'custom-dialog'
            }
        },
        loading: {
            initParam: {
                class: 'custom-loading'
            }
        }                
    }
}

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

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

//tap 保存
function saveButtonTap(){
    iot.navigator.back();
}