Authored by 徐炜

Merge remote-tracking branch 'origin/release/4.9.1.0' into release/4.9.1.0

... ... @@ -149,6 +149,7 @@ exports.index = (req, res, next) => {
banner,
icons,
link,
// url,
// param,
couponids = [];
... ... @@ -398,6 +399,7 @@ exports.detail = (req, res) => {
exports.isLogin = (req, res, next) => {
// let refer = req.cookies.refer;
let url = req.get('referer') || '/activity/student/register';
getPlatForm(req).then((yoho)=>{
... ... @@ -415,8 +417,12 @@ exports.isLogin = (req, res, next) => {
// refer = '/activity/student/register';
// }
if (req.path === '/student/register' && !yoho.isStudent) {
url = '/activity/student/register';
}
res.redirect(helpers.urlFormat('/signin.html', {
refer: req.get('referer') || '/activity/student/register'
refer: url
}));
}).catch(next);
... ...
... ... @@ -13,7 +13,7 @@
{{#each data.list}}
<div class='s-section'>
<a href="javascript:void(0)">
<img src='{{image src 357 174}}' title="{{title}}">
<img src='{{image src 320 149}}' title="{{title}}">
</a>
</div>
{{/each}}
... ... @@ -24,8 +24,9 @@
{{#coupons}}
<section class='s-section clearfix' data-template-id="{{template_id}}">
<h1>领券中心
<a class='more' href="{{link}}">...</a>
<a class='more iconfont' href="{{link}}">&#xe618;</a>
</h1>
<div class='s-coupon-contain'>
<style type="text/css">
.no-bg{
... ... @@ -76,7 +77,7 @@
{{/activities}}
<section class='s-section clearfix'>
<h1>学生专享商品<a class="more" href="//search.m.yohobuy.com/?students=1&title=学生专享商品&uid={{uid}}{{#isApp}}&app_version=1{{/isApp}}">...</a></h1>
<h1>学生专享商品<a class="more iconfont" href="//search.m.yohobuy.com/?students=1&title=学生专享商品&uid={{uid}}{{#isApp}}&app_version=1{{/isApp}}">&#xe618;</a></h1>
<div class='goods-list clearfix'>
{{#each goods}}
<div class="good-info">
... ...
... ... @@ -20,7 +20,7 @@
</section>
{{/if}}
<section class='s-section clearfix'>
<h1>学生专享商品<a class="more" href="//search.m.yohobuy.com/?students=1&title=学生专享商品&uid={{uid}}{{#isApp}}&app_version=1{{/isApp}}">...</a></h1>
<h1>学生专享商品<a class="more iconfont" href="//search.m.yohobuy.com/?students=1&title=学生专享商品&uid={{uid}}{{#isApp}}&app_version=1{{/isApp}}">&#xe618;</a></h1>
<div class='goods-list clearfix'>
{{#each goods}}
<div class="good-info">
... ...
... ... @@ -235,8 +235,9 @@ const _detailDataPkg = (origin, uid, vipLevel, ua) => {
if (originPrice.yohoCoinNum) {
dest.commodityReturn = originPrice.yohoCoinNum;
}
//学生有货币
if(originPrice.studentCoinNum){
// 学生有货币
if (originPrice.studentCoinNum) {
dest.studentCoinNum = originPrice.studentCoinNum;
}
}
... ...
... ... @@ -13,7 +13,7 @@
<p class="good-tag sale-tag">SALE</p>
{{/ is_discount}}
{{# is_yohood}}
<div class="good-tag running-man-tag">跑男同款</div>
<p class="good-tag new-festival-tag">新品节</p>
{{/ is_yohood}}
{{# is_limited}}
<p class="good-tag limit-tag">限量商品</p>
... ...
# 代码规范说明文档
开发前请务必仔细阅读,遵守规范,保持团队代码风格统一
## 文件命名
* 中划线分隔小写单词
* Ex: `your-file`
## 缩进
* 统一4个Space
* 建议将编辑器Tab映射成4个Space
## 注释
* 为每个你创建的JS文件添加注释
```
/**
* 对文件实现功能的描述
* @date: 2016-11-11
* @author: name<emial@yoho.cn>
*/
```
* 为重要的函数添加注释
```
/**
* 对函数功能的说明
* @params name paramType 参数描述
* @return name returnType 返回值描述
*/
```
* 为重要的代码、逻辑复杂的代码或者有特殊处理的代码添加注释
```
// Your comments for the code
```
* 减少不必要的注释
类似于:**进入循环****循环结束**等垃圾话的注释请谨慎添加,大家都是程序员,不用你注释也能知道的
## html
* 见名知意,不要有1,2,3这种名字出现
* class、id等属性命名为中划线分隔小写单词
* html中请不要出现不必要的嵌套以及不要将标签滥用,比如使用`a`标签作为不跳转的按钮的标签
* 属性按顺序出现:`id -> class -> name -> data-* -> src,for,type,href -> title,alt -> aria-*,role`
## js
[Link](doc/code-norm/js.md)
## css
[Link](doc/code-norm/css.md)
\ No newline at end of file
# css代码规范
## 选择器
* 使用class进行样式匹配,而不是id和标签
* 尽量避免使用属性选择器
* 尽可能精确的元素定位
## 规则细节
.ele-header, /*规则1:每个选择器声明总是使用新的一行*/
.ele-body,
.ele-footer { /*规则2:'{' 前需要添加1个空格*/
line-height: 1.2; /*规则3:样式声明以;结束,每个样式声明独占一行*/
font-weight: normal; /*规则4:属性声明的:后添加1个空格*/
margin: 0; /*规则5:属性值为0时不添加单位*/
background-color: #f3d; /*规则6:十六进制小写和缩写*/
}
/*规则7:没组选择器声明之间适用一空行间隔*/
.ele2 {
font-family: "open sans", arial, sans-serif; /*规则8:使用" ",而不是' '*/
padding: 0 1em 2em; /*规则9:适当缩写但不滥用*/
border-top: 1px;
background-color: rgba(0,0,0,.5); /*规则10:颜色值rgba等中不需要增加空格,并且去除浮点数前面不必要的0*/
}
## 声明顺序(不做强制要求,尽量实现)
这是一个选择器内书写CSS属性顺序的大致轮廓,作为最佳实践,我们应该遵循以下顺序:
* Position属性 (position,top,right,z-index...)
* Box Model属性 (display,float,width...)
* Typographic属性 (font,line-height,color,text-align...)
* Visual属性 (background,border,border-radius...)
因为Position属性可以是一个元素脱离正常的文本流并可以覆盖盒模型相关样式,所以Position排第一位。盒模型决定一个元素位置和大小紧跟其后。后面属性属于元素内部或不会对前两者产生影响的,排在后面。
完整属性顺序参考[Recsss](http://twitter.github.com/recess)
## Sass风格
* 控制嵌套层级,禁止超过5层,尽量控制在3层以内
# JavaScript代码规范
## 行的长度
每行长度不应该超过**120**个字符,如果一行多余120个字符,应该在一个运算符后换行,下一行增加**2**级缩进,即8个空格)
```
doSomething(argument1, argument2, argument3, argument4,
argument5);
```
## 运算符间距
二元运算符前后必须使用一个空格保持表达式的整洁,操作符包括赋值运算符和逻辑运算符
```
var name = 'xuqi'; // GOOD
var name='xuqi'; // BAD
```
## 括号间距
当使用括号时,紧接左括号之后和紧接右括号之前不应该有空格。
```
doSomething(arg); // GODD
doSomething( arg ); // BAD
```
## 变量声明
* 所有变量在使用前应该先定义
* 变量定义应该放在函数开头
* 使用var,const,let表达式定义变量,每行定义一个
* 除了首行,所有行都应该多一层缩进使变量声明对齐
* 初始化的变量放在未初始化的变量之前
* 所有的变量命名必须使用英文单词
* 浮点变量必须指明实部(即便以0.开头)和小数点后一位
```
var name = 'xuqi',
age,
sex,
...;
const $ = require('yoho.jquery');
let i;
```
另外,晦涩的变量名最好给出注释,否则别人很难读懂接下来代码的意思。
## 函数声明
* 函数在使用前应该先定义
* 函数名和开始圆括号之间无空格(包括匿名函数的function关键字与圆括号之间)
* 开始圆括号和结束圆括号之间无空格
* 参数名之间应该在逗号之后保留一个空格
* 开始花括号应该同function关键字保持同一行,结束圆括号和开始花括号之间应该保留一个空格
* 函数体保持一级缩进
```
function doSomething(arg1, arg2) {
doThing1();
doThing2();
}
const method = function() {
doSomething();
};
```
另外,IIFE的标准格式也在这里指出:
```
(function(args) {
//
}(args)); //(args)位于外层括号内
```
## 对象直接量
* 起始左括号应该与表达式保持一行
* 每个属性的键名前保持一个缩进,第一个属性应该在左括号后另一起行
* 每个属性的键名不包含引号,其后跟一个冒号(前无空格,后有空格),然后是值
* 如果属性值为函数,函数体应该在属性名之下另起一行,并且其前后均应保留一个空行
* 一组相关属性的前后插入空行以提高代码的可读性
* 结束的右括号独占一行
```
var person = {
name: 'xuqi',
age: 25,
groupAttr1: xx1,
groupAttr2: xx2,
walk: function() {
//your walk fn
}
};
```
* 当对象字面量作为函数参数时,起始括号应该与函数名同行
```
doSomething({
//do something
});
```
## 命名
### 变量:
* 采用小驼峰命名格式
* 变量命名为名词(区别函数)
* 变量中不使用_
### 函数:
* 采用小驼峰命名格式
* 函数命名为动词(区别变量)
* 函数名中不使用_
### 构造函数:
* 采用大驼峰命名格式
* 命名应该是名词
### 私有成员:
* 一个对象中不希望外部访问的以下划线开头(约定)
## 等号运算符
使用`===`和`!==`,禁止使用`==`和`!=`
## undefined
禁止使用`name === undefined`判断一个变量是否定义。应该使用`typeof(name) === 'undefined'`;
## 常用语句规范
### if语句
```
if (condition) {
doSomething();
} else if (condition1) {
doSomething2();
} else {
soOtherThing();
}
```
### for语句
```
// GOOD
var i;
for (i = 0; i < len; i++) {
doSomething();
}
for (i in collection) {
if (collection.hasOwnProperty(i)) {
doSomething();
}
}
// BAD
for (var i = 0; i < len; i++) {
doSomething();
}
for (i in collection) {
doSomething();
}
```
### while,do语句
```
while (condition) {
doSomething();
}
do {
doSomething();
} while (condition)
```
### switch语句
* 每一个case保持一个缩进
* 每一组语句都应该以break,return等结尾,或者用一行注释表示跳过(falling through)
* 无default的情况也要注释特别说明
```
switch (val) {
case 1:
//nothing
case 2:
doSomething();
break;
default:
doDefault();
}
```
### try语句
```
try {
doSomething();
} catch (err) {
doSomething2();
} finally {
doSomething3();
}
```
## 模块化规范
* 模块开头require加载所有依赖模块
```
var $ = require('yoho.jquery'),
flip = require('../plugin/flip'); //普通文件
require('../plguin/login');
```
* 模块抛出接口应该给予注释说明功能和使用方法
\ No newline at end of file
##公共头部模拟数据
```javascript
var pageHeader = {
navBack: true,
navTitle: '逛',
navBtn: {
indexUrl: '#',
categoryUrl: '#',
shoppingCartUrl: '#',
mineUrl: '#'
}
};
```
##公共底部模拟数据
```javascript
var pageFooter = true;
```
... ... @@ -11,9 +11,9 @@
{{# isDiscount}}
<p class="good-tag sale-tag">SALE</p>
{{/ isDiscount}}
{{# isYohoood}}
<p class="good-tag running-man-tag">跑男同款</p>
{{/ isYohoood}}
{{# isYohood}}
<p class="good-tag new-festival-tag">新品节</p>
{{/ isYohood}}
{{# isLimited}}
<p class="good-tag limit-tag">限量商品</p>
{{/ isLimited}}
... ...

29.4 KB | W: | H:

36.6 KB | W: | H:

  • 2-up
  • Swipe
  • Onion skin
... ... @@ -445,6 +445,7 @@ AsideSlider.prototype.init = function() {
'transform': translate,
'-webkit-transform': translate,
});
me.isFirst=false;
y = deltaY;
})
... ...
var $ = require('yoho-jquery');
var tip = require('../plugin/tip');
var AsideSlider = require('./aslider');
var yas = window._yas || {
sendCustomInfo: function() {}
};
// var yas = window._yas || {
// sendCustomInfo: function() {}
// };
var STUDENTCOOKIES = 'STUDENTCOOKIES';
... ... @@ -71,6 +72,7 @@ function isValidate(rules, datas) {
reg,
rule;
datas = datas || {};
for (name in rules) {
if (datas.hasOwnProperty(name)) {
data = datas[name];
... ... @@ -89,6 +91,9 @@ function isValidate(rules, datas) {
if (rule.is !== void (0) && data !== rule.is) {
message = rule.msg;
}
}else {
message = 'cookie 存储数据不全';
break;
}
}
return message;
... ... @@ -134,7 +139,7 @@ function setFormByCookes(item) {
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) {
if (item.procode && item.procode !== 'undefined') {
province.selected().areaCode = item.procode;
province.selected().addresseeName = item.provinceName;
}
... ... @@ -229,7 +234,7 @@ Filter.prototype = {
var html = [],
name;
if (this.__select__ && this.__title__) {
if (this.__select__ && this.__title__ && this.__select__[this.__feild__]) {
html.push('<h6 class=\'s-title\'>当前地区</h6>');
html.push('<div class=\'s-item close\'>' + this.__select__[this.__feild__] + '</div>');
}
... ... @@ -400,12 +405,15 @@ $(document).on('click', '.s-submit', function() {
data: obj.data
}).then(function(data) {
if (+data.code === 200) {
yas.sendCustomInfo({
EVENT: 'YB_STUDENT_ATTCT_SUBMIT',
C_ID: C_ID,
SRC_ID: 5,
SUBMIT_RES: 1
}, false);
if (window._yas && window._yas.sendCustomInfo) {
window._yas.sendCustomInfo({
EVENT: 'YB_STUDENT_ATTCT_SUBMIT',
C_ID: C_ID,
SRC_ID: 5,
SUBMIT_RES: 1
}, false);
}
location.href = data.data;
} else {
tip.show(data.message);
... ... @@ -421,13 +429,16 @@ $(document).on('click', '.s-submit', function() {
} else {
FAILURE_CAUSE = 2;
}
yas.sendCustomInfo({
EVENT: 'YB_STUDENT_ATTCT_SUBMIT',
C_ID: C_ID,
SRC_ID: 5,
SUBMIT_RES: 2,
FAILURE_CAUSE: FAILURE_CAUSE
}, true);
if (window._yas && window._yas.sendCustomInfo) {
window._yas.sendCustomInfo({
EVENT: 'YB_STUDENT_ATTCT_SUBMIT',
C_ID: C_ID,
SRC_ID: 5,
SUBMIT_RES: 2,
FAILURE_CAUSE: FAILURE_CAUSE
}, true);
}
}
});
... ... @@ -447,8 +458,14 @@ $('#tb-is-read').change(function() {
// 埋点 学生认证-信息填写页面
yas.sendCustomInfo({
EVENT: 'YB_STUDENT_ATTCT_INFO',
C_ID: C_ID,
SRC_ID: 5
}, true);
setTimeout(function() {
if (window._yas && window._yas.sendCustomInfo) {
window._yas.sendCustomInfo({
EVENT: 'YB_STUDENT_ATTCT_INFO',
C_ID: C_ID,
SRC_ID: 5
}, true);
}
}, 2000);
... ...
... ... @@ -6,9 +6,6 @@ var $ = require('yoho-jquery'),
var _weChatInterface = '//m.yohobuy.com/life/getSignPackage',
wx = window.wx,
yas = window.yas || {
sendCustomInfo: function() {}
},
C_ID,
getChannel;
... ... @@ -199,22 +196,30 @@ if (typeof wx !== 'undefined') {
wx.onMenuShareWeibo(shareData);
});
}
if ($('.s-verify-fail').size()) {
yas.sendCustomInfo({
EVENT: 'YB_STUDENT_ATTCT_RESULT',
C_ID: C_ID,
SRC_ID: 5,
ATTCT_RES: 1,
FAILURE_CAUSE: ''
}, true);
} else {
// 埋点 学生营销宣传首页
yas.sendCustomInfo({
EVENT: 'YB_STUDENT_HOME',
C_ID: C_ID,
SRC_ID: 1
}, true);
}
setTimeout(function() {
if ($('.s-verify-fail').size()) {
if (window._yas && window._yas.sendCustomInfo) {
window._yas.sendCustomInfo({
EVENT: 'YB_STUDENT_ATTCT_RESULT',
C_ID: C_ID,
SRC_ID: 5,
ATTCT_RES: 1,
FAILURE_CAUSE: ''
}, true);
}
} else {
// 埋点 学生营销宣传首页
if (window._yas && window._yas.sendCustomInfo) {
window._yas.sendCustomInfo({
EVENT: 'YB_STUDENT_HOME',
C_ID: C_ID,
SRC_ID: 1
}, true);
}
}
}, 3000);
... ... @@ -234,9 +239,11 @@ $('.swiper-slide', '.banner-top').click(function() {
F_INDEX: 1,
I_INDEX: index
};
yas.sendCustomInfo(options, false);
if (window._yas && window._yas.sendCustomInfo) {
window._yas.sendCustomInfo(options, true);
}
// return false;
// return false;
});
$('.s-activity', '.s-section').click(function() {
var options;
... ... @@ -253,7 +260,9 @@ $('.s-activity', '.s-section').click(function() {
F_INDEX: 3,
I_INDEX: index
};
yas.sendCustomInfo(options, false);
if (window._yas && window._yas.sendCustomInfo) {
window._yas.sendCustomInfo(options, true);
}
});
$('.good-info', '.goods-list').click(function() {
var options;
... ... @@ -270,5 +279,9 @@ $('.good-info', '.goods-list').click(function() {
F_INDEX: 4,
I_INDEX: index
};
yas.sendCustomInfo(options, false);
if (window._yas && window._yas.sendCustomInfo) {
window._yas.sendCustomInfo(options, true);
}
});
... ...
... ... @@ -10,6 +10,7 @@ var plusstar = {},
require('../common');
plusstar = {
scrollObj: {},
init: function() {
var that = this,
$liDom,
... ... @@ -49,6 +50,12 @@ plusstar = {
tabNav: function(code) {
var that = this;
if (typeof this.scrollObj[code] === 'undefined') {
// 如果不是第一次点击,回顶部
$(document).scrollTop(0);
this.scrollObj[code] = true;
}
loading.showLoadingMask();
$.ajax({
type: 'GET',
... ... @@ -71,7 +78,7 @@ plusstar = {
loading.hideLoadingMask();
lazyLoad($('img.lazy'));
//处理左右滑动,未加载的图片
// 处理左右滑动,未加载的图片
setTimeout(function() {
$('img.lazy').each(function() {
if ($(this).attr('src') !== $(this).data('original')) {
... ...
... ... @@ -239,13 +239,15 @@
.s-title {
padding: 30px 0;
}
.s-content{
border-top: 1px solid #e0e0e0;
}
.s-section {
border-left: 1px solid #e0e0e0;
border-bottom: 1px solid #e0e0e0;
width: 50%;
/* padding:30px 0px 30px 40px; */
height: 174px;
height: 152px;
background-color: #ffffff;
display: table;
float: left;
... ... @@ -397,6 +399,10 @@
border-bottom: 1px solid #e0e0e0;
position: relative;
input::-webkit-input-placeholder{
font-family: helvetica, Arial, "黑体";
font-weight:lighter;
}
label {
width: 174px;
display: inline-block;
... ...
... ... @@ -43,9 +43,12 @@
}
.new-festival-tag {
width: 90px;
background-color: #000;
color: #fff;
color: #000;
width: 100px;
background-image: resolve("product/new-festival.png");
background-repeat: no-repeat;
background-color: #fff;
background-size: 100px 28px;
}
.limit-tag {
... ...
... ... @@ -14,6 +14,9 @@
height: 80px;
font-size: 16px;
text-align: center;
position: fixed;
z-index: 10;
background-color: #fff;
li {
display: block;
... ... @@ -49,6 +52,12 @@
}
}
.plusstar-resources:before {
height: 72px;
content: "";
display: inline-block;
}
.resources {
background: #f6f6f6;
... ... @@ -72,15 +81,13 @@
.header-title {
position: relative;
width: 100%;
height: 100px;
height: 70px;
font-size: 28px;
line-height: 100px;
line-height: 70px;
text-align: center;
font-weight: bold;
border-top: 1px solid #eee;
margin: 0;
margin-top: 20px;
background: #fff;
.more {
position: absolute;
... ... @@ -88,6 +95,8 @@
right: 0;
width: 100px;
height: 100px;
color: #b0b0b0;
font-size: 50px;
}
&:first-child {
... ... @@ -178,14 +187,12 @@
a {
display: inline-block;
width: 50%;
height: 375px;
overflow: hidden;
}
}
img {
width: 100%;
height: 100%;
}
.goods {
background-color: #fff;
}
}
}
... ...
... ... @@ -156,8 +156,12 @@ $basicBtnC: #eb0313;
}
.new-festival-tag {
background-color: #000;
color: #fff;
color: #000;
width: 120px;
background-image: resolve("product/new-festival.png");
background-repeat: no-repeat;
background-color: #fff;
background-size: 120px 38px;
}
.yohood-tag {
... ...