share-buy.page.js 1.98 KB
'use strict';
require('activity/share-buy.page.css');

let $ = require('yoho-jquery'),
    dialog = require('plugin/dialog'),
    yoho = require('yoho-app');

let $news = $('.news'),
    newsLiL = $news.find('li').length,
    newsHeight = 0;

let shareData = {
    title: '【有货】参与分享购,大家一起拿返利~',
    link: location.href,
    desc: '学生用户专享,返利升级购物可直接抵现金,超级福利等你来嗨~',
    imgUrl: 'http://img11.static.yhbimg.com/yhb-img01/2017/05/10/16/011568a808f9b10e098b6542d3a8cb3d6b.png'
};

require('common');
require('common/share')(shareData);

if (yoho.isApp) {
    if (window.queryString.act_id) {
        shareData.link = 'http://m.yohobuy.com/activity/share-buy?act_id=' + window.queryString.act_id;
    } else {
        shareData.link = 'http://m.yohobuy.com/activity/share-buy';
    }

    yoho.ready(function() {
        yoho.invokeMethod('set.shareInfo', shareData);
    });
}

// 返利资讯的滚动
function Marquee() {
    let diff;

    $news.scrollTop($news.scrollTop() + 1);

    diff = newsHeight - $news.scrollTop();

    if (diff <= 0) {
        $news.scrollTop(Math.abs(diff));
    }
}

if (newsLiL > 1) {

    $news.append('<li>' + $news.find('li:first').html() + '</li>');

    for (let i = 0; i < newsLiL; i++) {
        $news.find('li').eq(i).height($news.find('li:first').height());

        newsHeight = newsHeight + $news.find('li').eq(i).height();
    }

    setInterval(Marquee, 100);
}

$('.join').click(function() {
    if ($('.coupon-list').data('student') === false) {

        dialog.showDialog({
            dialogText: '完成学生认证即可参与活动哦~',
            fast: true,
            hasFooter: {
                rightBtnText: '去认证'
            }
        }, function() {

            yoho.goH5('http://m.yohobuy.com/activity/student/register', '{"action":"go.h5","params":{"islogin":"N","type":"13","url":"http://m.yohobuy.com/activity/student/register"}}');
        }, null, true);
    }
});