Authored by weiqingting

4.9.1 -> feature_student

... ... @@ -6,11 +6,13 @@ const crypto = global.yoho.crypto;
const queryString = require('querystring');
const Promise = require('bluebird');
const co = Promise.coroutine;
const headerModel = require('../../../doraemon/models/header'); // 头部model
const getResource = code => {
return serviceApi.get('operations/api/v5/resource/get', {
content_code: code
content_code: code,
platform: 'iphone'
});
};
const vip = (limit) => {
... ... @@ -27,6 +29,8 @@ const verifiedStudentTotal = () => {
const getProvince = () => {
return api.get('', {
method: 'app.studentMarket.getAddressList'
}, {
cache: true
});
};
const getSchool = code => {
... ... @@ -91,26 +95,45 @@ const getPlatForm = (req) => {
yoho.isiOS = /\(i[^;]+;( U;)? CPU.+Mac OS X/i.test(userAgent);
yoho.isAndroid = /Android/i.test(userAgent);
yoho.isApp = /YohoBuy/i.test(req.get('User-Agent'));
yoho.isApp = /YohoBuy/i.test(req.get('User-Agent')) || (req.query.app_version && req.query.client_type);
yoho.isSupportStudent = !yoho.isApp || (/^4.9/i.test(req.query.app_version) && !/^4.9.0/i.test(req.query.app_version));
yoho.http = 'http:';
if (isProduction) {
yoho.http = 'https:';
}
yoho.uid = uids && uids.length === 2 ? uids[1] : ''; // 8041246
yoho.uid = req.user.uid || yoho.uid;
yoho.uid = req.user.uid || yoho.uid || req.query.uid || '';
yoho.isLogin = yoho.uid ? true : false;
return co(function*() {
let data = yield getUser(yoho.uid);
yoho.isStudent = data.data && data.data.vip_info && data.data.vip_info.is_student ? true : false;
console.log(yoho);
// console.log(yoho);
return yoho;
})();
};
// const getRequest = (url)=>{
//
// let regurl = /^[^\?]+\?([\w\W]+)$/;
// let regpara = /([^&=]+)=([\w\W]*?)(&|$|#)/g;
// let ret = {};
// let strpara,
// result;
//
// let arrurl = regurl.exec(url);
//
// if (arrurl && arrurl[1]) {
// strpara = arrurl[1];
// while ((result = regpara.exec(strpara)) !== null) {
// ret[result[1]] = result[2];
// }
// }
// return ret;
// };
exports.index = (req, res, next) => {
... ... @@ -118,12 +141,16 @@ exports.index = (req, res, next) => {
let uid = req.__USER__.uid;
let options;
Promise.all([getResource(code), vip()]).then(datas => {
let coupons,
activities,
banner,
icons,
link,
// url,
// param,
couponids = [];
(datas[0].data || []).forEach((item) => {
... ... @@ -148,11 +175,22 @@ exports.index = (req, res, next) => {
break;
}
});
if (coupons && coupons.data) {
coupons.link = link && link.data ? link.data[0].url + '&app_version=1' : '';
coupons.link = link && link.data ? link.data[0].url + (req.__USER__.isApp ? '&app_version=1' : '') : '';
coupons.data = (coupons.data || []).map((item) => {
couponids.push(item.couponID);
// if (item.image.url.indexOf('?') === -1) {
// item.image.url += '?';
// }
//
//
// url = item.image.url.substring(0, item.image.url.indexOf('?'));
//
// param = JSON.stringify(getRequest(item.image.url));
// item.image.url = item.image.url + '&app_version=1&openby:yohobuy={"action":"go.h5","params":{"islogin":"N","url":"' + url + '","param":' + param + '}}';
// console.log(item);
return item;
});
}
... ... @@ -161,6 +199,7 @@ exports.index = (req, res, next) => {
coupons.data = (coupons.data || []).map((item)=>{
item.status = 1;
(cous.data || []).forEach((it) => {
if (+it.couponId === +item.couponID) {
item.hasNum = it.hasNum;
item.status = it.status;
... ... @@ -171,7 +210,7 @@ exports.index = (req, res, next) => {
});
datas[1].data = datas[1].data || {};
datas[1].data.product_list = (datas[1].data.product_list || []).map(function(value) {
value.goodsId = value.goods_list[0].goods_id;
value.url = helpers.urlFormat(`/product/pro_${value.product_id}_${value.goodsId}/${value.cn_alphabet}.html`) + `?openby:yohobuy={"action":"go.productDetail","params":{"product_skn":${value.product_skn}}}`;
... ... @@ -186,10 +225,18 @@ exports.index = (req, res, next) => {
coupons: coupons,
activities: activities,
isStudent: req.__USER__.isStudent,
isSupportStudent: req.__USER__.isSupportStudent,
isLogin: req.__USER__.isLogin,
title: '有货学生专享优惠',
http: req.__USER__.http
http: req.__USER__.http,
uid: req.__USER__.uid
};
if (!req.__USER__.isApp) {
options.pageHeader = headerModel.setNav({
navTitle: options.title,
navBtn: true
});
}
options.loginUrl = '//m.yohobuy.com/activity/student/register';
if (options.isApp) {
... ... @@ -200,7 +247,7 @@ exports.index = (req, res, next) => {
options.loginUrl = options.loginUrl + '?openby:yohobuy={"action":"go.h5","params":{"islogin":"N","url":"' + req.__USER__.http + '//m.yohobuy.com/activity/student/register"}}';
}
} else {
options.loginUrl = options.loginUrl + '?openby:yohobuy={"action":"go.weblogin","params":{"jumpurl":{"url":"' + req.__USER__.http + '//m.yohobuy.com/activity/student/register"}}}';
options.loginUrl = options.loginUrl + '?openby:yohobuy={"action":"go.weblogin","params":{"jumpurl":{"url":"' + req.__USER__.http + '//m.yohobuy.com/activity/student"}}}';
}
} else {
if (options.isLogin) {
... ... @@ -227,14 +274,23 @@ exports.province = (req, res, next) => {
};
exports.register = (req, res, next) => {
let years = [];
let years = [],
refer;
for (let i = 0; i < 8; i++) {
years.push((new Date()).getFullYear() - i);
}
Promise.all([verifiedStudentTotal(), getEducationLevelList()]).then((arr) => {
if (req.__USER__.isStudent) {
res.redirect(helpers.urlFormat('/activity/student'));
refer = req.get('referer') || '/home?openby:yohobuy={"action":"go.mine"}';// TODO
// if (refer) {
// refer = decodeURI(req.cookies.refer);
// } else {
// refer = '/activity/student';
// }
// refer = refer;
res.redirect(helpers.urlFormat(refer));
} else {
res.render('register', {
title: '认证信息填写',
... ... @@ -308,7 +364,9 @@ exports.verifystudent = (req, res, next) => {
isverify: isverify,
prompt: prompt,
isLogin: user.data && user.data.vip_info && user.data.vip_info.is_student ? true : false,
title: '学生身份认证'
title: '学生身份认证',
http: req.__USER__.http,
uid: req.__USER__.uid
});
}).catch(next);
... ... @@ -335,7 +393,7 @@ exports.detail = (req, res) => {
};
exports.isLogin = (req, res, next) => {
let refer = req.cookies.refer;
// let refer = req.cookies.refer;
getPlatForm(req).then((yoho)=>{
... ... @@ -345,21 +403,22 @@ exports.isLogin = (req, res, next) => {
return;
}
if (refer) {
refer = decodeURI(req.cookies.refer);
} else {
refer = '/activity/student/register';
}
// refer = decodeURI(req.cookies.refer)||req.get("refer");
//
// if (refer) {
// refer = decodeURI(req.cookies.refer)||req.get("refer");
// } else {
// refer = '/activity/student/register';
// }
res.redirect(helpers.urlFormat('/signin.html', {
refer: refer
refer: req.get('referer') || '/activity/student/register'
}));
});
};
exports.getUser = (req, res, next)=>{
getPlatForm(req).then((yoho)=>{
req.__USER__ = yoho;
... ...
... ... @@ -13,10 +13,10 @@
</section>
<div class="s-form">
<section class="s-feild">
<label>真实姓名</label><input type="text" name="tb_name" id="tb_name" placeholder="请输入您的真实姓名">
<label>真实姓名</label><input type="text" name="tb_name" id="tb_name" placeholder="请输入您的真实姓名" >
</section>
<section class="s-feild">
<label>身份证号</label><input type="text" id="tb_cert_no" name="tb_cert_no" placeholder="请输入您身份证号码">
<label>身份证号</label><input type="text" id="tb_cert_no" name="tb_cert_no" placeholder="请输入您身份证号码" maxlength="18">
</section>
<section class="s-feild" data-aslider-in="province|fade">
<label>学校省份</label><input type="text" id="s-province-tb" name="s-province-tb" readonly="readonly" placeholder="请选择省份"><span class="s-select iconfont" >&#xe604;</span>
... ... @@ -34,7 +34,9 @@
</div>
<div class="s-footer">
<section class="s-shenming">
<span class="checkbox icon-s-checked iconfont"></span>
<input type="checkbox" id="checkbox" class="regular-checkbox" style="visibility: hidden;">
<label class="checkbox icon-s-checked iconfont" for="checkbox">
</label>
同意<a class="s-blue" href='//m.yohobuy.com/activity/student/detail/renzhen?openby:yohobuy={"action":"go.h5","params":{"islogin":"N","url":"{{http}}//m.yohobuy.com/activity/student/detail/renzhen"}}'>Yoho!Buy有货学生认证协议</a>
</section>
<a class="s-submit" href="javascript:void(0);">去支付宝完成认证</a>
... ... @@ -78,8 +80,10 @@
<div class="mobile-container">
<div class="mobile-wrap yoho-page student">
<section class='s-search'>
<span class="iconfont s-empty">&#xe60f;</span>
<div class='s-seach-tip'><span class="iconfont search-icon empty">&#xe60f;</span>搜索学校</div>
<input id='s-search-school' class='s-input-search'>
<input id='s-search-school' class='s-input-search'>
<span class="iconfont s-clear">&#xe623;</span>
</section>
<div class='s-items' id='s-school'>
</div>
... ...
{{#unless isApp}}
<header class="yoho-header">
<a href="javascript:history.go(-1);" class="iconfont nav-back"></a>
<p class="nav-title">有货学生专享优惠</p>
</header>
{{/unless}}
<div class="mobile-container">
<div class="mobile-wrap yoho-page student">
{{! 头部banner}}
... ... @@ -32,15 +27,20 @@
<a class='more' href="{{link}}">...</a>
</h1>
<div class='s-coupon-contain'>
<style type="text/css">
.no-bg{
color: #fff!important;
background-image: none!important;
}
</style>
{{#each data}}
<div class="coupon-floor" coupon-id="{{couponID}}">
<div class="floor-main" style="background-image: url({{image image.src 0 0}});">
<a href="{{image.url}}" class="main-left"></a>
<a href="{{image.url}}" class="main-right-use" >
<a href='{{image.url}}' class="main-left"></a>
<a href='{{image.url}}' class="main-right-use" >
{{#isEqual status 1}}
<span class="on-receive on-lingqu" style="color: #fff;background-image: none;">
<p>可以</p>
<span class="on-receive on-lingqu no-bg">
<p>点击</p>
<p>领取</p>
</span>
{{/isEqual}}
... ... @@ -51,7 +51,7 @@
<span class="received"></span>
{{/isEqual}}
{{#isEqual status 4}}
<span class="on-receive" style="color: #fff;background-image: none;">
<span class="on-receive no-bg" >
<p>已经</p>
<p>过期</p>
</span>
... ... @@ -76,7 +76,7 @@
{{/activities}}
<section class='s-section clearfix'>
<h1>学生专享商品<a class="more" href="//search.m.yohobuy.com/?students=1&title=学生专享商品&app_version=1">...</a></h1>
<h1>学生专享商品<a class="more" href="//search.m.yohobuy.com/?students=1&title=学生专享商品&uid={{uid}}{{#isApp}}&app_version=1{{/isApp}}">...</a></h1>
<div class='goods-list clearfix'>
{{#each goods}}
<div class="good-info">
... ... @@ -118,13 +118,20 @@
</div>
{{/each}}
</div>
<a class='s-more' href='//search.m.yohobuy.com/?students=1&title=学生专享商品&app_version=1'>查看更多</a>
<a class='s-more' href='//search.m.yohobuy.com/?students=1&title=学生专享商品&uid={{uid}}{{#isApp}}&app_version=1{{/isApp}}'>查看更多</a>
</section>
{{#loginUrl}}
<div class='s-layout'>
快来认证吧,认证通过即可享受专属优惠!
{{#if @root.isSupportStudent}}
快来认证吧,认证通过即可享受专属优惠!
{{else}}
请升级最新APP版本,完成认证
{{/if}}
{{#if @root.isSupportStudent}}
<a class='s-renzhen' href='{{.}}'>立即认证</a>
{{/if}}
</div>
<div class="s-replace"></div>
{{/loginUrl}}
... ...
{{#unless isApp}}
<header class="yoho-header">
<a href="//m.yohobuy.com/activity/student?openby:yohobuy={'action':'go.h5','params':{'islogin':'N','url':'{{http}}//m.yohobuy.com/activity/student'}}" class="iconfont nav-back"></a>
<p class="nav-title">学生身份认证</p>
</header>
{{/unless}}
<div class="mobile-container">
<div class="mobile-wrap yoho-page student">
{{#if isverify}}
... ... @@ -18,7 +20,7 @@
</section>
{{/if}}
<section class='s-section clearfix'>
<h1>学生专享商品<a class="more" href="//search.m.yohobuy.com/?students=1&title=学生专享商品&app_version=1">...</a></h1>
<h1>学生专享商品<a class="more" href="//search.m.yohobuy.com/?students=1&title=学生专享商品&uid={{uid}}{{#isApp}}&app_version=1{{/isApp}}">...</a></h1>
<div class='goods-list clearfix'>
{{#each goods}}
<div class="good-info">
... ... @@ -60,7 +62,7 @@
</div>
{{/each}}
</div>
<a class='s-more' href="//search.m.yohobuy.com/?students=1&title=学生专享商品&app_version=1">查看更多</a>
<a class='s-more' href="//search.m.yohobuy.com/?students=1&title=学生专享商品{{#isApp}}&app_version=1{{/isApp}}">查看更多</a>
</section>
</div>
</div>
... ...
... ... @@ -64,20 +64,21 @@
</div>
{{/if}}
</div>
{{#studentPrice}}
<div class="price-date">
<div class="student-price">
<i class="student-name">学生价</i><span class="student-value">¥{{.}}</span>
{{#if studentPrice}}
<div class="price-date">
<div class="student-price">
<i class="student-name">学生价</i><span class="student-value">¥{{round studentPrice}}</span>
</div>
</div>
</div>
{{/studentPrice}}
{{/if}}
{{#if studentCoinNum}}
<div class="price-date">
<div class="student-price">
<i class="student-name"></i> 学生返币{{studentCoinNum}}
<div class="price-date">
<div class="student-price">
<i class="student-name"></i> 学生返币{{ studentCoinNum}}
</div>
</div>
</div>
{{else}}
{{#commodityReturn}}
<div class="price-date">
... ... @@ -90,15 +91,15 @@
{{#unless studentPrice}}
{{# vipLevel}}
<ul class="vip-level clearfix">
{{# list}}
<li class="icons-item {{#if currentLevel}}current-level{{/if}}">
<ul class="vip-level clearfix">
{{# list}}
<li class="icons-item {{#if currentLevel}}current-level{{/if}}">
<span class="vip-img " style="background-size:contain;">
</span>
<span class="vip-price ">{{text}}</span>
</li>
{{/ list}}
</ul>
<span class="vip-price ">{{text}}</span>
</li>
{{/ list}}
</ul>
{{/ vipLevel}}
{{/unless}}
... ...
... ... @@ -348,8 +348,18 @@ AsideSlider.prototype.init = function() {
var _scope = this;
var y = this.y;
var lastY = this.lastY;
$(asliders).bind('webkitTransitionEnd', $.proxy(this.onTransitionEnd, this));
$(asliders).bind('transitionEnd', $.proxy(this.onTransitionEnd, this));
var me=this;
// $(asliders).bind('webkitTransitionEnd', $.proxy(this.onTransitionEnd, this));
// $(asliders).bind('transitionEnd', $.proxy(this.onTransitionEnd, this));
//
// // Safari 3.1 到 6.0 代码
// $(asliders)[0].addEventListener("webkitTransitionEnd", function () {
// alert(1);
// });
// 标准语法
$(asliders).on("webkitTransitionEnd", $.proxy(this.onTransitionEnd, this));
$(asliders).on("transitionend", $.proxy(this.onTransitionEnd, this));
$(asliders).on('click', '.close', $.proxy(this.onClose, this));
$(document).on('click', '[data-aslider="' + $(asliders).data('aslider') + '"]', $.proxy(this.onClose, this));
... ... @@ -384,6 +394,10 @@ AsideSlider.prototype.init = function() {
* 每次点击开始时,先重置lastY
*/
$slider.on('touchstart', function(e) {
if(me.isFirst){
y=0;
me.isFirst=false;
}
lastY = e.originalEvent.touches[0].pageY;
});
... ... @@ -462,6 +476,7 @@ AsideSlider.prototype._bindAsideSlider = function($initialator, $slider) {
isShow = isShow === 'true' ? true : false;
}
if (isShow) {
this.isFirst=true;
this.asideSlideIn($slider);
} else {
tip.show('请先选择省份');
... ... @@ -493,12 +508,34 @@ AsideSlider.prototype._findAslider = function(el) {
return $(theSlider);
};
// function supportCss3(style) {
// var prefix = ['webkit', 'Moz', 'ms', 'o'],
// i,
// humpString = [],
// htmlStyle = document.documentElement.style,
// _toHumb = function (string) {
// return string.replace(/-(\w)/g, function ($0, $1) {
// return $1.toUpperCase();
// });
// };
//
// for (i in prefix)
// humpString.push(_toHumb(prefix[i] + '-' + style));
//
// humpString.push(_toHumb(style));
//
// for (i in humpString)
// if (humpString[i] in htmlStyle) return true;
//
// return false;
// }
/**
* @public
* 遍历所有侧边栏,滑出隐藏当前显示的那个
* @return {null}
*/
AsideSlider.prototype.asideSlideOut = AsideSlider.prototype.slideOut = function($el) {
$el = typeof $el === 'string' ? $($el) : $el;
if ($el.css('display') != 'none') {
var isFade = $el.data('aslider-fade');
... ... @@ -508,6 +545,7 @@ AsideSlider.prototype.asideSlideOut = AsideSlider.prototype.slideOut = function(
}
$el.find('.asilder_wrapper').removeClass('slide_in');
$el.find('.asilder_wrapper').addClass('slide_out');
}
this.visibleStack.pop();
if (this.visibleStack.length === 0)
... ...
... ... @@ -5,6 +5,8 @@ var yas = window._yas || {
sendCustomInfo: function() {}
};
var STUDENTCOOKIES = 'STUDENTCOOKIES';
var C_ID,
getChannel,
asideSlider = new AsideSlider();//eslint-disable-line
... ... @@ -106,6 +108,10 @@ function changeSuccess() {
},
msg;
if (province.selected() && province.selected().areaCode) {
data.procode = province.selected().areaCode;
data.provinceName = $('#s-province-tb').val();
}
msg = isValidate(ruleMap, data);
if (!msg) {
$('.s-submit').addClass('succ');
... ... @@ -118,6 +124,34 @@ function changeSuccess() {
};
}
function setFormByCookes(item) {
var msg;
item = item ? JSON.parse(item) : {};
item.cert_no && $('#tb_cert_no').val(item.cert_no);
item.name && $('#tb_name').val(item.name);
item.college_name && $('#s-school-tb').val(item.college_name);
item.education_degree && $('#s-education-tb').val(item.education_degree);
item.enrollment_year && $('#s-year-tb').val(item.enrollment_year);
item.provinceName && $('#s-province-tb').val(item.provinceName);
if (item.procode) {
province.selected().areaCode = item.procode;
province.selected().addresseeName = item.provinceName;
}
if ($.trim($('#s-school-tb').val())) {
$('#s-school-tb').parent('section').attr('aslider-isshow', true);
}
if (item.isread) {
$('.checkbox', '.s-shenming').addClass('icon-s-checked');
}
msg = isValidate(ruleMap, item);
if (!msg) {
$('.s-submit').addClass('succ');
} else {
$('.s-submit').removeClass('succ');
}
}
/*
* 筛选器
*/
... ... @@ -125,7 +159,7 @@ function Filter(ele, title, feild, data) {
this.__ele__ = ele;
this.__title__ = title;
this.__data__ = data || null;
this.__select__ = null;
this.__select__ = {};
this.__feild__ = feild;
}
Filter.prototype = {
... ... @@ -225,6 +259,7 @@ Filter.prototype = {
$('#s-' + name + '-tb').val(item[that.__feild__]);
if (name === 'province') {
$('#s-school-tb').val('');
$('[data-aslider-in=\'school|fade\']').attr('aslider-isShow', 'true');
}
changeSuccess();
... ... @@ -322,6 +357,11 @@ window.JI_getselectvalue = function(type, value) {
changeSuccess();
};
$('.s-blue').click(function() {
localStorage.setItem(STUDENTCOOKIES, JSON.stringify(changeSuccess().data));
});
setFormByCookes(localStorage.getItem(STUDENTCOOKIES));
// data-aslider-in="education|fade"
... ...
... ... @@ -76,38 +76,41 @@ $('.on-lingqu').on('click', function() {
if (getUrlParam('uid')) {
req += '&uid=' + getUrlParam('uid');
}
$.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) {
$curDom.html('<span class="received"></span>');
tip.show('领券成功');
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 {
tip.show(msg);
if (status) {
$curDom.html('').removeClass('on-receive').removeClass('no-bg');
$curDom.addClass('received');
tip.show('领券成功');
} else {
tip.show(msg);
}
}
},
error: function() {
tip.show('网络异常!');
}
},
error: function() {
tip.show('网络异常!');
}
});
return false;
});
return false;
}
});
... ...
... ... @@ -339,19 +339,20 @@
height: 80px;
line-height: 80px;
bottom: 0;
width: 100%;
width: 640px;
.s-renzhen {
background-color: #d10922;
border-radius: 20px;
font-size: 22px;
font-size: 20px;
width: 140px;
height: 50px;
line-height: 50px;
height: 48px;
line-height: 48px;
color: #fff;
background-color: #d10922;
border-radius: 20px;
text-align: center;
vertical-align:middle;
display: block;
position: absolute;
right: 30px;
... ...