/**
 * Created by xiaoqiang on 2018/7/27.
 */
Vue.component('login', {
    template: '#login',
    data: function () {
        return {
            name: 'login component',
            email: '',
            password: '',
            showLogin: true,
        };
    },
    methods: {
        onSubmit: function () {
            var _this = this;
            var email = this.email.trim();
            var password = this.password.trim();
            if (email == '' || password == '') {
                return;
            }
            var url = 'https://www.cutterman.cn/client/login_mirror';
            var param = {
                mail: email,
                password: password,
                app: APP_NAME
            };
            $.post(url, param, function (result) {
                if (result.errno == 0) {
                    bridge.showToast(rb.UI_LOGIN_TEXT_11);
                    var data = JSON.stringify(result);
                    bridge.writeFile('user.json', data);
                    _this.$emit('onlogin', data);
                }
                else {
                    bridge.showToast(result.info);
                }
            });
        },
        startTrail: function () {
        },
        trial: function (val) {
            this.showLogin = !val;
        },
        register: function () {
            bridge.openURL(rb.UI_LOGIN_TEXT_12);
        }
    },
    created: function () {
    },
    mounted: function () {
        window.initResourceBundle();
    }
});
