/**
* v_editName.js
* Version: 0.1
* User: wy
* Date: 2017-10-09
* 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-dialog','u-loading']);
    const app = new Vue({
        data:{  
            textName: '我是个用户二号',  
            textErrorTip: null,
            //配置组件
            componentsConfig: initComponentsConfig()  
        },
        mounted(){           
        },
        methods:{
            //tap <
            onBackTap(){
                backTap();
            }, 
            //tap 保存
            onSaveTap(){
                saveTap();
            },           
            onNameChange(text){
                nameChange(this,text);            
            }                     
        }   
    }).$mount('#app');
}

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

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

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

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