agreement.page.js 2.07 KB
/* /**
 * 服务协议
 * @author: zxr
 * @date: 2016/10/27
 */
let $ = require('yoho-jquery');
let appVersion = $('input[name="app_version"]').val();
let yoho;

require('js/common');
yoho = require('js/yoho-app');

$('.pitch').on('click', function() {
    if ($('.pitch').hasClass('select')) {
        $(this).removeClass('select');
        $(this).html('');
    } else {
        $(this).addClass('select');
        $(this).html('');
    }
});

$('.submit-btn').on('click', function() {
    if ($('.pitch').hasClass('select')) {
        if (appVersion === '1') {
            let params = {
                action: 'go.serviceClause',
                params: { selected: 'Y' },
            };

            yoho.invokeMethod('go.serviceClause', params.params);
        } else {
            location.href =
                '//m.yohobuy.com/passport/reg/password' +
                window.location.search +
                '&selected=Y';
        }
    } else {
        if (appVersion === '1') {
            let params = {
                action: 'go.serviceClause',
                params: { selected: 'N' },
            };

            yoho.invokeMethod('go.serviceClause', params.params);
        } else {
            location.href =
                '//m.yohobuy.com/passport/reg/password' +
                window.location.search +
                '&selected=N';
        }
    }
});

$('.download-protocol-btn').on('click', function() {
    let type = $(this).data('type');
    let url =
        'https://cdn.yoho.cn/yohobuy/pdf/YOHO!BUY有货用户服务协议0725.pdf';

    if (type === 'privacy') {
        url = 'https://cdn.yoho.cn/yohobuy/pdf/有货隐私条款(2019.8.7).pdf';
    }

    if (appVersion === '1') {
        let params = {
            action: 'go.downloadProtocol',
            params: {
                url: url,
                type: type,
            },
        };

        yoho.invokeMethod('go.downloadProtocol', params.params);
    } else {
        if (type === 'privacy') {
            window.open(url);
        } else {
            window.open(url);
        }
    }
});