/**
* v_addUnlockInfo.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() {
    //通用 select、开关、按钮、dialog、loading组件
    uPublic.componentsInit(['u-select','u-switch','u-button','u-dialog','u-loading']);
    const app = new Vue({
        data:{     
            recordSelectIndex: 0,
            recordSelectList: [], 
            valueSetHijack: 1,
            guideShowFlag: false,   
            guideStep1ShowFlag: false, 
            guideStep2ShowFlag: false,  
            guideStep3ShowFlag: false,   
            guideStep4ShowFlag: false,  
            guideStep5ShowFlag: false,   
            guideStep6ShowFlag: false,                         
            //配置组件
            componentsConfig: initComponentsConfig()   
        },
        mounted(){           
        },
        methods:{
            getGuideShowFlag(){
                return this.guideShowFlag;
            },
            setGuideShowFlag(boolean){
                this.guideShowFlag = boolean;
            },
            getGuideStep1ShowFlag(){
                return this.guideStep1ShowFlag;
            },
            setGuideStep1ShowFlag(boolean){
                this.guideStep1ShowFlag = boolean;
            },
            getGuideStep2ShowFlag(){
                return this.guideStep2ShowFlag;
            },
            setGuideStep2ShowFlag(boolean){
                this.guideStep2ShowFlag = boolean;
            },
            getGuideStep3ShowFlag(){
                return this.guideStep3ShowFlag;
            },
            setGuideStep3ShowFlag(boolean){
                this.guideStep3ShowFlag = boolean;
            },
            getGuideStep4ShowFlag(){
                return this.guideStep4ShowFlag;
            },
            setGuideStep4ShowFlag(boolean){
                this.guideStep4ShowFlag = boolean;
            },
            getGuideStep5ShowFlag(){
                return this.guideStep5ShowFlag;
            },
            setGuideStep5ShowFlag(boolean){
                this.guideStep5ShowFlag = boolean;
            },
            getGuideStep6ShowFlag(){
                return this.guideStep6ShowFlag;
            },
            setGuideStep6ShowFlag(boolean){
                this.guideStep6ShowFlag = boolean;
            },
            //tap <
            onBackTap(){
                backTap();
            },
            onRecordSelectChange(value) {
                recordSelectChange(this, value);
            },
            //tap 添加
            onAddButtonTap(){
                addButtonTap();
            },
            //tap 下一步
            onNextButtonTap(){
                nextButtonTap(this);
            },
            onNextStepButtonTap(){
                nextStepButtonTap(this);
            },
            //tap 我知道了
            onISeeButtonTap(){
                iSeeButtonTap(this);
            }                                      
        }   
    }).$mount('#app');
}

//配置组件参数
function initComponentsConfig() {
    return {
        recordSelect: {
            initParam: {
                class: 'custom-select',
                list: [
                    {value: 1, title: '16:35',subtitle: 'ID:001'},
                    {value: 2, title: '15:33',subtitle: 'ID:002'},
                    {value: 3, title: '15:06',subtitle: 'ID:007'}
                ],
                pagesize: Number.MAX_VALUE,
                tip: Vue.t('addUnlockInfo.noRecordTip')
            }
        },
        //设为劫持指纹
        setHijackSwitch: {
            initParam: {
                class: 'custom-setHijack-switch',
                text: Vue.t('addUnlockInfo.setHijackSwitch')
            }
        },
        //添加 button 参数
        addButton: {   
            initParam: {
                class: 'custom-button',
                text: Vue.t('btn.add')
            }
        }, 
        //下一步 button 参数
        nextButton: {   
            initParam: {
                class: 'custom-dialog-button',
                text: Vue.t('btn.next')
            }
        },
        //我知道了 button 参数
        iSeeButton: {   
            initParam: {
                class: 'custom-dialog-button',
                text: Vue.t('btn.iSee')
            }
        },
        dialog: {
            initParam: {
                class: 'custom-dialog'
            }
        },
        loading: {
            initParam: {
                class: 'custom-loading'
            }
        }               
    }
}

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

function recordSelectChange(self, value) {
    self.recordSelectIndex = value;
    console.log('recordSelectChange:' + self.recordSelectIndex);
}

//tap 添加 
function addButtonTap(){
    iot.navigator.back();
}

//tap 下一步
function nextButtonTap(self){
    self.setGuideStep1ShowFlag(false);
    self.setGuideStep2ShowFlag(false);
    self.setGuideStep3ShowFlag(true);
    self.setGuideStep4ShowFlag(true);
}

function nextStepButtonTap(self){
    self.setGuideStep3ShowFlag(false);
    self.setGuideStep4ShowFlag(false);
    self.setGuideStep5ShowFlag(true);
    self.setGuideStep6ShowFlag(true);
}

//tap 我知道了
function iSeeButtonTap(self){
    self.setGuideShowFlag(false);
}