/**
* v_addUser.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-button','u-dialog','u-loading']);
    const app = new Vue({
        data:{  
            textName: null,  
            textErrorTip: null,
            //配置组件
            componentsConfig: initComponentsConfig()  
        },
        mounted(){           
        },
        methods:{
            //tap <
            onBackTap(){
                backTap();
            },            
            onNameChange(text){
                nameChange(this,text);            
            },        
            //tap 确定
            onConfirmButtonTap(){
                confirmButtonTap();
            }                      
        }   
    }).$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(){
    iot.navigator.back();
}

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

//tap 确定
function confirmButtonTap(){
    iot.navigator.openWindow({
        url: './doorlockUser.html',
        id: 'doorlockUser'
    });
}