/**
* 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-button','u-dialog','u-loading']);
    const app = new Vue({
        data:{     
            recordSelectIndex: 0,
            recordSelectList: [],                                 
            //配置组件
            componentsConfig: initComponentsConfig()   
        },
        mounted(){           
        },
        methods:{
            //tap <
            onBackTap(){
                backTap();
            },
            onRecordSelectChange(value) {
                recordSelectChange(this, value);
            },
            //tap 添加
            onAddButtonTap(){
                addButtonTap();
            }                                     
        }   
    }).$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
            }
        },
        //添加 button 参数
        addButton: {   
            initParam: {
                class: 'custom-button',
                text: Vue.t('btn.add')
            }
        },
        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();
}