/**
* v_forgetPassword.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:{ 
            numberTel: null,
            textCode: null,
            codeDisabledFlag: false,
            textPassword: null,    
            textErrorTip: null,
            //配置组件
            componentsConfig: initComponentsConfig()     
        },
        mounted(){           
        },
        methods:{
            getCodeDisabledFlag(){
                return this.codeDisabledFlag;
            },
            setCodeDisabledFlag(boolean){
                this.codeDisabledFlag = boolean;
            },       
            onTelChange(number){
                telChange(this,number);            
            },
            onCodeChange(text){
                codeChange(this,text);            
            },      
            onPasswordChange(text){
                passwordChange(this,text);            
            },              
            //tap <
            onBackTap(){
                backTap();
            },
            //tap 获取验证码
            onCodeButtonTap(){
                codeButtonTap(this);
            },
            //tap 确定
            onConfirmButtonTap(){
                confirmButtonTap();
            }                     
        }   
    }).$mount('#app');
}

//配置组件参数
function initComponentsConfig() {
    return {
        telInput: {
            initParam: {
                class: 'custom-text',
                icon: '&#xe6e8;',
                placeholder: Vue.t('forgetPassword.telInputTip'),
                maxlength: 11,
                minlength: 11
            }
        },
        codeInput: {
            initParam: {
                class: 'custom-code-text',
                icon: '&#xe805;',
                placeholder: Vue.t('forgetPassword.codeInputTip')
            }
        },
        //获取验证码 button 参数
        codeButton: {   
            initParam: {
                class: 'custom-code-button',
                text: Vue.t('btn.getCode')
            }
        },
        passwordInput: {
            initParam: {
                class: 'custom-password-text',
                icon: '&#xe64d;',
                placeholder: Vue.t('forgetPassword.passwordInputTip'),
                type: 'password',
                maxlength: 6,
                minlength: 6
            }
        },
        //确定 button 参数
        confirmButton: {   
            initParam: {
                class: 'custom-button',
                text: Vue.t('btn.confirm')
            }
        },
        dialog: {
            initParam: {
                class: 'custom-dialog'
            }
        },
        loading: {
            initParam: {
                class: 'custom-loading'
            }
        }                
    }
}

function telChange(self,number){
    self.numberTel = number;
    console.log('telChange: ' + self.numberTel);
}

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

//tap 获取验证码
function codeButtonTap(self){
    self.setCodeDisabledFlag(true);
}

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

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

//tap 确定
function confirmButtonTap(){
    iot.navigator.back();
}