invite-share.js 1.48 KB
/**
 * 邀请码分享头部
 */
require('common/_invite-share.css');
require('common');
let $ = require('yoho-jquery');
let inviteCode = window.queryString.inviteCode;

function inviteSharePoint(type) {
    if (window._yas && window._yas.sendCustomInfo) {
        window._yas.sendCustomInfo({
            op: 'YB_INVITE_SHARE_C',
            param: JSON.stringify({
                TYPE: type
            })
        }, true);
    }
}

(function() {
    let inviteShare = require('common/invite-share.hbs');

    if (inviteCode) {
        $.ajax({
            type: 'GET',
            url: '/activity/invite-uesr-info',
            data: {
                inviteCode: inviteCode
            },
            success: function(result) {

                if (result.code === 200 && parseInt(result.data.isDisplay, 10) === 1) {
                    let shareData = inviteShare({
                        inviteShare: result.data
                    });

                    $('.top-downloadbar').hide();
                    $('body').prepend(shareData); // 放置最前

                    $('.close-invite').on('click', function() {
                        $('.invite-share').hide();
                    });

                    $('.invite-go').click(function() {
                        inviteSharePoint(1);
                    });

                    $('.share-packet').click(function() {
                        inviteSharePoint(2);
                    });
                }
            }
        });
    }
}());