|
|
var $ = require('yoho-jquery'),
|
|
|
Swiper = require('yoho-swiper'),
|
|
|
lazyLoad = require('yoho-jquery-lazyload'),
|
|
|
fastclick = require('yoho-fastclick'),
|
|
|
tip = require('../plugin/tip'),
|
|
|
dialog = require('../plugin/dialog'),
|
|
|
Hammer = require('yoho-hammer');
|
|
|
|
|
|
var _weChatInterface = '//m.yohobuy.com/life/getSignPackage',
|
|
|
wx = window.wx,
|
|
|
C_ID,
|
|
|
getChannel;
|
|
|
|
|
|
|
|
|
|
|
|
require('../common');
|
|
|
|
|
|
// require('../common/footer');
|
|
|
|
|
|
// 根据ua判断页头
|
|
|
(function uaHeader() {
|
|
|
var UALIST = ['MicroMessenger', 'QQ/', 'Weibo'],
|
|
|
UA = navigator.userAgent,
|
|
|
i;
|
|
|
|
|
|
for (i = 0; i < UALIST.length; i++) {
|
|
|
if (UA.indexOf(UALIST[i]) > -1) {
|
|
|
$('#yoho-header').remove();
|
|
|
return;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
}());
|
|
|
|
|
|
getChannel = function() {
|
|
|
var name = window.cookie('_Channel');
|
|
|
|
|
|
return {
|
|
|
boys: 1,
|
|
|
girls: 2,
|
|
|
kids: 3,
|
|
|
lifestyle: 4
|
|
|
}[name] || 1;
|
|
|
};
|
|
|
C_ID = getChannel();
|
|
|
|
|
|
function uuid() {
|
|
|
var s = [];
|
|
|
var hexDigits = '0123456789abcdef';
|
|
|
var id = '';
|
|
|
var i = 0;
|
|
|
|
|
|
for (i = 0; i < 36; i++) {
|
|
|
s[i] = hexDigits.substr(Math.floor(Math.random() * 0x10), 1);
|
|
|
}
|
|
|
s[14] = '4'; // bits 12-15 of the time_hi_and_version field to 0010
|
|
|
s[19] = hexDigits.substr((s[19] & 0x3) | 0x8, 1); // bits 6-7 of the clock_seq_hi_and_reserved to 01
|
|
|
s[8] = s[13] = s[18] = s[23] = '-';
|
|
|
|
|
|
id = s.join('');
|
|
|
|
|
|
return id;
|
|
|
}
|
|
|
|
|
|
|
|
|
fastclick.attach(document.body);
|
|
|
lazyLoad($('img.lazy'));
|
|
|
|
|
|
// 头部banner轮播
|
|
|
if ($('.banner-swiper').find('li').size() > 1) {
|
|
|
new Swiper('.banner-swiper', {
|
|
|
lazyLoading: true,
|
|
|
lazyLoadingInPrevNext: true,
|
|
|
loop: true,
|
|
|
autoplay: 3000,
|
|
|
autoplayDisableOnInteraction: false,
|
|
|
paginationClickable: true,
|
|
|
slideElement: 'li',
|
|
|
pagination: '.banner-top .pagination-inner'
|
|
|
});
|
|
|
}
|
|
|
|
|
|
// 获取url中的参数
|
|
|
function getUrlParam(name) {
|
|
|
|
|
|
// 构造一个含有目标参数的正则表达式对象
|
|
|
var reg = new RegExp('(^|&)' + name + '=([^&]*)(&|$)');
|
|
|
|
|
|
// 匹配目标参数
|
|
|
var r = window.location.search.substr(1).match(reg);
|
|
|
|
|
|
// 返回参数值
|
|
|
if (r !== null) {
|
|
|
return r[2];
|
|
|
}
|
|
|
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
$('.on-lingqu', 'div.main-right-use').on('click', function() {
|
|
|
var $curDom = $(this),
|
|
|
req = '',
|
|
|
href = '',
|
|
|
a = '';
|
|
|
|
|
|
if (getUrlParam('app_version')) {
|
|
|
req += '&app_version=' + getUrlParam('app_version');
|
|
|
}
|
|
|
|
|
|
if (getUrlParam('uid')) {
|
|
|
req += '&uid=' + getUrlParam('uid');
|
|
|
}
|
|
|
|
|
|
|
|
|
if (!$curDom.hasClass('received')) {
|
|
|
$.ajax({
|
|
|
url: '//m.yohobuy.com/coupon/receiveCoupon?code=a83b7d55324fb65f96c1f85a3387ebd8' + req,
|
|
|
data: {
|
|
|
couponID: $curDom.parents('.coupon-floor').attr('coupon-id')
|
|
|
},
|
|
|
dataType: 'json',
|
|
|
success: function(data) {
|
|
|
var msg = data.msg,
|
|
|
status = data.status,
|
|
|
newUrl = '//m.yohobuy.com/signin.html?refer=' + location.href;
|
|
|
|
|
|
|
|
|
if (data.isApp === true) {
|
|
|
newUrl = data.url;
|
|
|
}
|
|
|
if (data.noLogin === true) {
|
|
|
location.href = newUrl;
|
|
|
} else {
|
|
|
if (status) {
|
|
|
href = $curDom.parent('.main-right-use').attr('href');
|
|
|
$curDom.parent('.main-right-use').wrap('<a class=\'main-right-use\' href=' + href + '></a>');
|
|
|
a = $curDom.parent('.main-right-use').parent('a');
|
|
|
a.html('<span class="received"></span>');
|
|
|
|
|
|
tip.show('领券成功');
|
|
|
} else {
|
|
|
tip.show(msg);
|
|
|
}
|
|
|
}
|
|
|
},
|
|
|
error: function() {
|
|
|
tip.show('网络异常!');
|
|
|
}
|
|
|
});
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 微信分享
|
|
|
*/
|
|
|
if (typeof wx !== 'undefined') {
|
|
|
$.getJSON(_weChatInterface + '?pageurl=' +
|
|
|
encodeURIComponent(location.href.split('#')[0]) + '&callback=?',
|
|
|
function(json) {
|
|
|
var _appId,
|
|
|
_timestamp,
|
|
|
_nonceStr,
|
|
|
_signature;
|
|
|
|
|
|
if (json) {
|
|
|
_appId = json.appId.toString();
|
|
|
_timestamp = json.timestamp;
|
|
|
_nonceStr = json.nonceStr.toString();
|
|
|
_signature = json.signature.toString();
|
|
|
|
|
|
wx.config({
|
|
|
debug: false,
|
|
|
appId: _appId,
|
|
|
timestamp: _timestamp,
|
|
|
nonceStr: _nonceStr,
|
|
|
signature: _signature,
|
|
|
jsApiList: [
|
|
|
'checkJsApi',
|
|
|
'onMenuShareTimeline',
|
|
|
'onMenuShareAppMessage',
|
|
|
'onMenuShareQQ',
|
|
|
'onMenuShareWeibo',
|
|
|
'hideMenuItems',
|
|
|
'showMenuItems',
|
|
|
'hideAllNonBaseMenuItem',
|
|
|
'showAllNonBaseMenuItem',
|
|
|
'translateVoice',
|
|
|
'startRecord',
|
|
|
'stopRecord',
|
|
|
'onRecordEnd',
|
|
|
'playVoice',
|
|
|
'pauseVoice',
|
|
|
'stopVoice',
|
|
|
'uploadVoice',
|
|
|
'downloadVoice',
|
|
|
'chooseImage',
|
|
|
'previewImage',
|
|
|
'uploadImage',
|
|
|
'downloadImage',
|
|
|
'getNetworkType',
|
|
|
'openLocation',
|
|
|
'getLocation',
|
|
|
'hideOptionMenu',
|
|
|
'showOptionMenu',
|
|
|
'closeWindow',
|
|
|
'scanQRCode',
|
|
|
'chooseWXPay',
|
|
|
'openProductSpecificView',
|
|
|
'addCard',
|
|
|
'chooseCard',
|
|
|
'openCard'
|
|
|
]
|
|
|
});
|
|
|
}
|
|
|
});
|
|
|
|
|
|
wx.ready(function() {
|
|
|
var shareData = {
|
|
|
title: 'YOHO!BUY有货【学生】专享福利大派送!4大特权享不停!',
|
|
|
desc: '全球1000+潮流品牌每日上新!一起来YOHO!玩潮流!',
|
|
|
imgUrl: 'http://img12.static.yhbimg.com/brandCertificate/2016/08/10/14/0204d441c737c687fc418b2372d0aba8be.png',
|
|
|
link: 'https://m.yohobuy.com/activity/student'
|
|
|
};
|
|
|
|
|
|
// 分享给朋友
|
|
|
wx.onMenuShareAppMessage(shareData);
|
|
|
|
|
|
// 分享到朋友圈
|
|
|
wx.onMenuShareTimeline(shareData);
|
|
|
|
|
|
// 分享到QQ
|
|
|
wx.onMenuShareQQ(shareData);
|
|
|
|
|
|
// 分享到微博
|
|
|
wx.onMenuShareWeibo(shareData);
|
|
|
});
|
|
|
}
|
|
|
|
|
|
setTimeout(function() {
|
|
|
var len = $('.good-info', '.goods-list').length;
|
|
|
var ids = [];
|
|
|
var check = location.pathname.indexOf('quanyi') === -1;
|
|
|
|
|
|
$('.good-info', '.goods-list').each(function() {
|
|
|
var goodids = $(this).find('.good-thumb').attr('href').match(/"product_skn":([^}]+)/, 'g');
|
|
|
var goodid = goodids && goodids.length === 2 ? goodids[1] : '';
|
|
|
|
|
|
ids.push(goodid);
|
|
|
});
|
|
|
|
|
|
if (check && window._yas && window._yas.sendCustomInfo) {
|
|
|
window._yas.sendCustomInfo({
|
|
|
op: 'YB_STUDENT_VIP_GDS_LIST',
|
|
|
param: JSON.stringify({
|
|
|
C_ID: C_ID,
|
|
|
PRD_NUM: len,
|
|
|
PRD_ID: ids.join(','),
|
|
|
ACTION_ID: 0,
|
|
|
SORT_TYPE: 4,
|
|
|
REC_ID: uuid(40) + '0000'
|
|
|
})
|
|
|
}, true);
|
|
|
}
|
|
|
if ($('.s-verify-fail').size()) {
|
|
|
if (window._yas && window._yas.sendCustomInfo) {
|
|
|
window._yas.sendCustomInfo({
|
|
|
op: 'YB_STUDENT_ATTCT_RESULT',
|
|
|
param: JSON.stringify({
|
|
|
C_ID: C_ID,
|
|
|
SRC_ID: 5,
|
|
|
ATTCT_RES: 2,
|
|
|
FAILURE_CAUSE: $('.s-verify-fail').attr('prompt')
|
|
|
})
|
|
|
}, true);
|
|
|
}
|
|
|
} else if ($('.s-verify-success').size()) {
|
|
|
if (window._yas && window._yas.sendCustomInfo) {
|
|
|
window._yas.sendCustomInfo({
|
|
|
op: 'YB_STUDENT_ATTCT_RESULT',
|
|
|
param: JSON.stringify({
|
|
|
C_ID: C_ID,
|
|
|
SRC_ID: 5,
|
|
|
ATTCT_RES: 1,
|
|
|
FAILURE_CAUSE: '',
|
|
|
ATTCT_INFO: JSON.parse(localStorage.STUDENTCOOKIES)
|
|
|
})
|
|
|
}, true);
|
|
|
}
|
|
|
} else {
|
|
|
|
|
|
// 埋点 学生营销宣传首页
|
|
|
// if (window._yas && window._yas.sendCustomInfo) {
|
|
|
// window._yas.sendCustomInfo({
|
|
|
// op: 'YB_STUDENT_HOME',
|
|
|
// param: JSON.stringify({
|
|
|
// C_ID: C_ID
|
|
|
// }),
|
|
|
// }, true);
|
|
|
// }
|
|
|
}
|
|
|
|
|
|
}, 3000);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$('.swiper-slide', '.banner-top').click(function() {
|
|
|
var options;
|
|
|
var url = $(this).find('a').attr('href');
|
|
|
var index = $(this).index();
|
|
|
var tid = $(this).parents('.s-section').data('template-id');
|
|
|
|
|
|
options = {
|
|
|
op: 'YB_STUDENT_VIP_FLR',
|
|
|
param: JSON.stringify({
|
|
|
C_ID: C_ID,
|
|
|
F_ID: tid || 1,
|
|
|
F_NAME: '焦点图',
|
|
|
F_URL: encodeURIComponent(url),
|
|
|
F_INDEX: 1,
|
|
|
I_INDEX: index
|
|
|
})
|
|
|
};
|
|
|
if (window._yas && window._yas.sendCustomInfo) {
|
|
|
window._yas.sendCustomInfo(options, true);
|
|
|
}
|
|
|
|
|
|
// return false;
|
|
|
});
|
|
|
|
|
|
// 学生活动页楼层埋点
|
|
|
$('.s-activity, .main-left, .s-quan, .iconfont', '.s-section').click(function() {
|
|
|
var options;
|
|
|
var url = $(this).attr('href');
|
|
|
var index = $(this).index();
|
|
|
var tid = $(this).parents('.s-section').data('template-id');
|
|
|
var obj = {
|
|
|
's-activity': {
|
|
|
fname: '学生专属活动',
|
|
|
findex: 4,
|
|
|
iindex: index
|
|
|
},
|
|
|
'more iconfont': {
|
|
|
fname: '领券中心',
|
|
|
findex: 3,
|
|
|
iindex: 0
|
|
|
},
|
|
|
'main-left': {
|
|
|
fname: '领券中心',
|
|
|
findex: 3,
|
|
|
iindex: $(this).parent().parent().index()
|
|
|
},
|
|
|
'more s-quan': {
|
|
|
fname: '学生权益',
|
|
|
findex: 2,
|
|
|
iindex: 0
|
|
|
}
|
|
|
}[$(this).attr('class')];
|
|
|
|
|
|
options = {
|
|
|
op: 'YB_STUDENT_VIP_FLR',
|
|
|
param: JSON.stringify({
|
|
|
C_ID: C_ID,
|
|
|
F_ID: tid,
|
|
|
F_NAME: obj.fname,
|
|
|
F_URL: encodeURIComponent(url),
|
|
|
F_INDEX: obj.findex,
|
|
|
I_INDEX: obj.iindex
|
|
|
})
|
|
|
};
|
|
|
if (window._yas && window._yas.sendCustomInfo) {
|
|
|
window._yas.sendCustomInfo(options, true);
|
|
|
}
|
|
|
});
|
|
|
$('.good-info', '.goods-list').click(function() {
|
|
|
var options;
|
|
|
|
|
|
var index = $(this).index();
|
|
|
var goodids = $(this).find('.good-thumb').attr('href').match(/"product_skn":([^}]+)/, 'g');
|
|
|
var goodid = goodids && goodids.length === 2 ? goodids[1] : '';
|
|
|
|
|
|
options = {
|
|
|
op: 'YB_STUDENT_VIP_GDS_LIST',
|
|
|
param: JSON.stringify({
|
|
|
C_ID: C_ID,
|
|
|
PRD_NUM: Number(index) + 1,
|
|
|
PRD_ID: goodid,
|
|
|
ACTION_ID: 1,
|
|
|
REC_ID: uuid(40) + '0000'
|
|
|
})
|
|
|
};
|
|
|
if (window._yas && window._yas.sendCustomInfo) {
|
|
|
window._yas.sendCustomInfo(options, true);
|
|
|
}
|
|
|
});
|
|
|
$('.s-renzhen').click(function() {
|
|
|
var options = {
|
|
|
op: 'YB_STUDENT_ATTCT_INFO',
|
|
|
param: JSON.stringify({
|
|
|
C_ID: C_ID,
|
|
|
SRC_ID: 1
|
|
|
})
|
|
|
};
|
|
|
|
|
|
if (window._yas && window._yas.sendCustomInfo) {
|
|
|
window._yas.sendCustomInfo(options, true);
|
|
|
}
|
|
|
});
|
|
|
|
|
|
$('.dialog-wrapper').addClass('s-dialog-wrapper');
|
|
|
$('.s-dialog').on('click', function() {
|
|
|
var text = [{
|
|
|
dialogText: '<h2>权益1: 新品立享9折</h2><p>学生购买指定原价新品时,可立即享受9折优惠,与VIP折扣不可同时享受</p>'
|
|
|
}, {
|
|
|
dialogText: '<h2>权益2: 每1元返1个有货币</h2><p>1、学生购买指定商品时,以商品的实际成交金额计算,每1元返1个有货币;</p>' +
|
|
|
'<p>2、返有货币时间:确认收货7日后,系统将自动将对应数量的有货币返至购买账户;</p>' +
|
|
|
'<p>3、有货币有效期:获得当日至次年12月31日,逾期自动作废;</p>' +
|
|
|
'<p>4、查看有货币:登录后,点击“个人中心”在“我的有货币”中可以查看有货币余额及明细。</p>'
|
|
|
}, {
|
|
|
dialogText: '<h2>权益3: 免单抽奖</h2><p>1、每月将在累计购物金额最高的学校中,抽取3名幸运学生用户,获得免单资格;</p>' +
|
|
|
'<p>2、免单用户名单将在每月第1个工作日公布在有货微信公众号上,可关注【有货YOHOBUY】;</p>' +
|
|
|
'<p>3、免单用户将在中奖次日获得与实付金额等额的现金券,使用时间:中奖当月。</p>'
|
|
|
}, {
|
|
|
dialogText: '<h2>权益4: 学生专享活动</h2><p>每月不定期的开展学生专享活动,可打开有货APP推送,及时查收学生专享活动通知。</p>'
|
|
|
}];
|
|
|
var dialogBoxHammer, dialogRightBtn;
|
|
|
|
|
|
dialog.showDialog({
|
|
|
student: true,
|
|
|
dialogText: text[$(this).index()].dialogText,
|
|
|
hasFooter: {
|
|
|
rightBtnText: '我知道了'
|
|
|
}
|
|
|
}, function() {
|
|
|
$('body').css({
|
|
|
overflow: '',
|
|
|
position: ''
|
|
|
});
|
|
|
dialog.hideDialog();
|
|
|
}, undefined, true);
|
|
|
|
|
|
$('.dialog-content').css({
|
|
|
padding: '0 1.5rem 1rem 1.5rem'
|
|
|
});
|
|
|
|
|
|
$('.dialog-box').css({
|
|
|
'border-radius': '0.25rem',
|
|
|
background: '#fff'
|
|
|
});
|
|
|
|
|
|
$('.dialog-right-btn').css({
|
|
|
border: 'none',
|
|
|
color: '#d0021b'
|
|
|
});
|
|
|
|
|
|
$('body').css({
|
|
|
overflow: 'hidden',
|
|
|
position: 'fixed'
|
|
|
});
|
|
|
|
|
|
dialogBoxHammer = new Hammer(document.getElementsByClassName('dialog-box')[0]);
|
|
|
dialogRightBtn = new Hammer(document.getElementsByClassName('dialog-right-btn')[0]);
|
|
|
|
|
|
dialogBoxHammer.on('tap', function(event) {
|
|
|
event.srcEvent.stopPropagation();
|
|
|
});
|
|
|
|
|
|
dialogRightBtn.on('tap', function(event) {
|
|
|
$('body').css({
|
|
|
overflow: '',
|
|
|
position: ''
|
|
|
});
|
|
|
dialog.hideDialog();
|
|
|
event.preventDefault();
|
|
|
event.srcEvent.stopPropagation();
|
|
|
});
|
|
|
|
|
|
$('.dialog-content').addClass('s-dialog-content');
|
|
|
});
|
|
|
|
|
|
$('#float-layer-close').on('touchend', function() {
|
|
|
$('#float-layer-app').hide();
|
|
|
return false;
|
|
|
});
|
|
|
|
|
|
if ($('#float-layer-btn') && $('#float-layer-btn')[0]) {
|
|
|
var floatLayerBtnHammer = new Hammer($('#float-layer-btn')[0]);
|
|
|
var unionType = window.queryString.union_type || 367;
|
|
|
floatLayerBtnHammer.on('tap', function(e) {
|
|
|
|
|
|
window.downLoadApp(unionType);
|
|
|
e.srcEvent.stopPropagation();
|
|
|
});
|
|
|
} |
...
|
...
|
|