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

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('hbs/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) {
                    if (result.data && result.data.nickname) {
                        result.data.nickname = cleanHtml.htmlEncode(result.data.nickname);
                    }

                    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);
                    });
                }
            }
        });
    }
}());