Authored by 王水玲

Merge branch 'release/5.2' of git.yoho.cn:fe/yohobuywap-node into release/5.2

/**
* 支付成功页
* @author: jing.li<jing.li@yoho.cn>
* @date: 2016/10/25
*/
'use strict';
const mRoot = '../models';
const payModel = require(`${mRoot}/pay`);
const headerModel = require('../../../doraemon/models/header'); // 头部model
// 货到付款
const payCod = (req, res, next) => {
let headerData = headerModel.setNav({
navTitle: '支付完成'
});
let responseData = {
pageHeader: headerData,
module: 'cart',
page: 'pay',
title: '支付中心 | Yoho!Buy有货 | 潮流购物逛不停'
};
let param = {
uid: req.user.uid,
udid: req.sessionID || require('md5')(req.ip) || 'yoho',
orderCode: req.query.order_code,
contentCode: '05afedf76886d732573f10f7451a1703'
};
// 如果没有uid,跳转到首页
if (!param.uid) {
res.redirect('/');
return;
}
payModel.getPayCod(param).then(result => {
if (result.match === true) {
res.render('pay/pay-cod', Object.assign(responseData, result));
} else {
res.redirect('/');
}
}).catch(next);
};
// 支付宝支付
const payAli = (req, res, next) => {
let headerData = headerModel.setNav({
navTitle: '支付完成'
});
let responseData = {
pageHeader: headerData,
module: 'cart',
page: 'pay',
title: '支付中心 | Yoho!Buy有货 | 潮流购物逛不停'
};
let param = {
uid: req.user.uid,
udid: req.sessionID || require('md5')(req.ip) || 'yoho',
orderCode: req.query.out_trade_no,
contentCode: '05afedf76886d732573f10f7451a1703'
};
// 如果没有uid,跳转到首页
if (!param.uid) {
res.redirect('/');
return;
}
payModel.getPayAli(param).then(result => {
if (result.match === true) {
res.render('pay/pay-ali', Object.assign(responseData, result));
} else {
res.redirect('/');
}
}).catch(next);
};
module.exports = {
payCod,
payAli
};
... ...
/**
<<<<<<< HEAD
* sub app cart
* @author: xuan.chen@yoho.cn<xuan.chen@yoho.cn>
* @date: 2016/09/26
=======
* sub app guang
* @author: Bi Kai<kai.bi@yoho.cn>
* @date: 2016/05/09
>>>>>>> feature/payment
*/
var express = require('express'),
... ...
/**
* 支付成功页
* @author: jing.li<jing.li@yoho.cn>
* @date: 2016/10/25
*/
'use strict';
const api = global.yoho.API;
const serviceAPI = global.yoho.ServiceAPI;
const utils = '../../../utils';
const productProcess = require(`${utils}/product-process`);
// 资源位
const _getBanner = (param) => {
return serviceAPI.get('operations/api/v5/resource/get', {
content_code: param.contentCode
}, {
code: 200
}).then((result) => {
result = result.data;
return result;
});
};
// 购买此商品的用户也购买了
const _getOthersBuy2 = (param) => {
return api.get('', {
method: 'app.recommend.purchased',
productSkn: param.skn,
udid: param.uid,
rec_pos: '100005',
limit: 2
}, {
code: 200
}).then((result) => {
if (result && result.data && result.data.product_list) {
return productProcess.processProductList(result.data.product_list);
}
});
};
// 订单信息
const _getOtherDetail = (param) => {
return api.get('', {
method: 'app.SpaceOrders.detail',
uid: param.uid,
order_code: param.orderCode
}, {
code: 200
}).then((result) => {
return result;
});
};
// 购买此商品的用户也购买了,要先从订单详情获取商品skn
const _getOthersBuy = (param) => {
return api.all([
_getOtherDetail(param)
]).then((result) => {
let goodSkn = '';
if (result && result[0] && result[0].data && result[0].data.order_goods) {
goodSkn = result[0].data.order_goods[0].product_skn;
}
return _getOthersBuy2(Object.assign(param, {skn: goodSkn}));
}).then((result) => {
return result;
});
};
// 货到付款
const getPayCod = (param) => {
return api.all([
_getBanner(param),
_getOthersBuy(param),
_getOtherDetail(param)
]).then((result) => {
let resu = {
match: true,
banner: [],
othersBuy: []
};
if (result && result[0]) {
resu.banner = result[0];
}
if (result && result[1]) {
resu.othersBuy = result[1];
}
if (result && result[2] && result[2].data && result[2].data.payment_amount) {
resu.payment = result[2].data.payment_amount;
} else {
resu.match = false;
}
resu.orderCode = param.orderCode;
resu.orderUrl = '/home/orders/detail?order_code=' + param.orderCode;
return resu;
});
};
// 支付宝支付
const getPayAli = (param) => {
return api.all([
_getBanner(param),
_getOthersBuy(param),
_getOtherDetail(param)
]).then((result) => {
let resu = {
match: true,
banner: [],
othersBuy: []
};
if (result && result[0]) {
resu.banner = result[0];
}
if (result && result[1]) {
resu.othersBuy = result[1];
}
if (result && result[2] && result[2].data && result[2].data.payment_amount) {
resu.payment = result[2].data.payment_amount;
} else {
resu.match = false;
}
resu.orderCode = param.orderCode;
resu.orderUrl = '/home/orders/detail?order_code=' + param.orderCode;
return resu;
});
};
module.exports = {
getPayCod,
getPayAli
};
... ...
... ... @@ -12,6 +12,7 @@ const authMW = require('../../doraemon/middleware/auth');
const seckill = require(cRoot + '/seckill');
const countController = require(`${cRoot}/count`);
const payController = require(`${cRoot}/pay`);
// Your controller here
router.all('/index/seckill/', authMW);
... ... @@ -21,5 +22,7 @@ router.post('/index/seckill/compute', seckill.compute);
router.post('/index/seckill/submit', seckill.submit);
router.get('/index/count', countController.cartCount);
router.get('/paySuccess/payCod', payController.payCod);// 支付成功,货到付款
router.get('/shopping/pay/aliwapreturn', payController.payAli);// 支付成功,支付宝付款
module.exports = router;
... ...
<div class="pay-success">
<div class="top-tip">
<div class="img-c"></div>
<p class="ok-tip">恭喜您,付款成功!</p>
</div>
<div class="info-table-c">
<table class="info-table">
<tr>
<td>订单编号</td>
<td>{{orderCode}}</td>
</tr>
<tr>
<td>付款金额</td>
<td>¥{{payment}}</td>
</tr>
<tr>
<td>付款方式</td>
<td>支付宝</td>
</tr>
</table>
</div>
<div class="btn-c">
<a href="/">随便逛逛</a>
<a href="{{orderUrl}}">查看订单</a>
</div>
{{# banner}}
{{#data}}
<a href="{{url}}" class="ad-pic" alt="{{alt}}">
<img src="{{image src 640 200}}" />
</a>
{{/data}}
{{/banner}}
<div class="others-buy clearfix">
<p>购买此商品的用户也购买了</p>
{{# othersBuy}}
{{> common/goods}}
{{/ othersBuy}}
</div>
{{> home/maybe-like}}
</div>
... ...
<div class="pay-success">
<div class="top-tip">
<div class="img-c"></div>
<p class="ok-tip">订单提交成功</p>
<p class="left-tip">您需要在收货时向售货员支付¥{{payment}}</p>
</div>
<div class="info-table-c">
<table class="info-table">
<tr>
<td>订单编号</td>
<td>{{orderCode}}</td>
</tr>
<tr>
<td>付款金额</td>
<td>¥{{payment}}</td>
</tr>
<tr>
<td>付款方式</td>
<td>货到付款</td>
</tr>
</table>
</div>
<div class="btn-c">
<a href="/">随便逛逛</a>
<a href="{{orderUrl}}">查看订单</a>
</div>
{{# banner}}
{{#data}}
<a href="{{url}}" class="ad-pic" alt="{{alt}}">
<img src="{{image src 640 200}}" />
</a>
{{/data}}
{{/banner}}
<div class="others-buy clearfix">
<p>购买此商品的用户也购买了</p>
{{# othersBuy}}
{{> common/goods}}
{{/ othersBuy}}
</div>
{{> home/maybe-like}}
</div>
... ...
... ... @@ -130,6 +130,12 @@ let verifyMobile = (req, res, next) => {
let token = sign.makeToken(mobile);
_.set(req.session, 'phoneReg.step', 2); // go step 2
--req.session.phoneReg.count;
// count is 0, will freeze;
if (!req.session.phoneReg.count) {
_.set(req.session, 'phoneReg.expire', Date.now() + 5 * 60 * 1000);
}
result.data = helpers.urlFormat('/passport/reg/code', {
token: token,
... ... @@ -194,7 +200,7 @@ let sendCodeBusyBoy = (req, res, next) => {
} else {
return res.json({
code: 400,
message: '错误次数太多, 5分钟稍后再试'
message: '发送次数太多, 5分钟稍后再试'
});
}
... ... @@ -242,6 +248,7 @@ let sendCode = (req, res, next) => {
}
}).catch(next);
};
let verifyCode = (req, res, next) => {
let data = {
code: 400,
... ... @@ -298,20 +305,19 @@ let verifyCode = (req, res, next) => {
/**
* Step3: set Password
*/
let passwordAction = (req, res) => {
let passwordAction = (req, res, next) => {
let token = req.query.token;
let mobile = +req.query.phoneNum;
let area = +(req.query.areaCode || 86);
let smsCode = +req.query.smsCode;
// 判断是否允许访问, 不允许则跳转到错误页面
// if (!smsCode || !_.isString(token) || !_.isNumber(mobile) || !_.isNumber(area) || !sign.verifyToken(mobile, token)) {
// return next({
// code: 403,
// message: 'error token, mobile or verifyCode'
// });
// }
if (!smsCode || !_.isString(token) || !_.isNumber(mobile) || !_.isNumber(area) || !sign.verifyToken(mobile, token)) {
return next({
code: 403,
message: 'error token, mobile or verifyCode'
});
}
res.render('reg/password', {
page: 'password',
... ...
/* eslint no-unused-vars: ["error", { "args": "none" }] */
'use strict';
const _ = require('lodash');
const helpers = global.yoho.helpers;
const cookie = global.yoho.cookie;
const RegService = require('../models/reg-service');
const PhoneService = require('../models/phone-service');
const AuthHelper = require('../models/auth-helper');
const captchaService = require('../models/captcha-service');
// constrant
const CODE_REQUIRED = '请输入校验码';
... ... @@ -23,7 +25,7 @@ exports.beforeIn = (req, res, next) => {
});
if (!req.xhr && req.user.uid) {
return res.redirect(req.cookies.refer);
return res.redirect(req.cookies.refer || '/');
}
next();
... ... @@ -31,6 +33,12 @@ exports.beforeIn = (req, res, next) => {
// 短信登录 第一步: 展现页面
const _step1 = (req, res, next) => {
_.set(req.session, 'smsLogin.step', 1);
if (req.session.smsLogin.count == null) { // eslint-disable-line
req.session.smsLogin.count = 5;
}
let template = 'sms/login';
let viewData = {
module: 'passport',
... ... @@ -38,6 +46,7 @@ const _step1 = (req, res, next) => {
title: '手机短信登录',
isPassportPage: true,
headerText: '手机号码快捷登录',
captchaUrl: helpers.urlFormat('/passport/sms_login/captcha.png', {t: Date.now()}),
areaCode: '+86', // 默认的区号
countrys: RegService.getAreaData() // 地区信息列表
};
... ... @@ -58,7 +67,7 @@ const _step2 = (req, res, next) => {
title: '手机短信登录',
isPassportPage: true,
headerText: '手机号码快捷登录',
canResend: interval < Date.now(),
countdown: Math.ceil((interval - Date.now()) / 1000),
mobile,
area
};
... ... @@ -83,7 +92,7 @@ const _step3 = (req, res, next) => {
// 短信 登录
exports.loginPage = (req, res, next) => {
let step = Number(req.query.step) || 1;
let smsLoginStep = req.session.smsLoginStep || 1;
let smsLoginStep = _.get(req.session, 'smsLogin.step', 1);
if (step === 2 && smsLoginStep !== 2) {
return res.redirect(req.path);
... ... @@ -109,23 +118,54 @@ exports.loginPage = (req, res, next) => {
exports.tokenBefore = (req, res, next) => {
let area = req.query.area = (req.query.area || '').trim();
let mobile = req.query.mobile = (req.query.mobile || '').trim();
let step = _.get(req.session, 'smsLogin.step');
let count = _.get(req.session, 'smsLogin.count');
let interval = _.get(req.session, 'smsLogin.interval');
if (!req.xhr) {
if (!req.xhr && !req.session.smsLogin) {
return next(404);
}
if (req.session.smsLogin && req.session.smsLogin.interval > Date.now()) {
if ([area, mobile].some(val => val === '')) {
return res.json({
code: 429,
message: TOO_MANY
code: 401,
message: '请求参数,无法处理'
});
}
// step1 要 校验图形验证码
if (step === 1) {
let captcha1 = _.get(req.session, 'smsLogin.captcha');
let captcha2 = (req.query.captcha || '').trim();
if ([area, mobile].some(val => val === '')) {
if (captcha1 !== captcha2) {
return res.json({
code: 400,
message: VERIFY_ERROR
});
}
}
let now = Date.now();
// 重发次数用完了, 回冻结5min
// 1. 过了冻结期, count 重设为 5次
// 2. 没过冻结期, end
// 没有用完, 判断是否请求太频繁
if (!count) {
if (interval > now) {
return res.json({
code: 400,
message: TOO_MANY,
during: Math.ceil((interval - now) / 1000)
});
} else {
_.set(req.session, 'smsLogin.count', 5);
}
} else if (interval > now) {
return res.json({
code: 401,
message: '请求参数,无法处理'
code: 429,
message: TOO_MANY
});
}
... ... @@ -139,12 +179,18 @@ exports.token = (req, res, next) => {
PhoneService.sendSMS(mobile, area, 1).then(result => {
if (result.code === 200) {
req.session.smsLogin = {
interval: Date.now() + 60 * 1000, // 重发验证码 间隔: 60s
area,
mobile
};
req.session.smsLoginStep = 2; // 进入短信登录 step2
_.set(req.session, 'smsLogin.step', 2);
_.set(req.session, 'smsLogin.area', area);
_.set(req.session, 'smsLogin.mobile', mobile);
--req.session.smsLogin.count;
if (!req.session.smsLogin.count) {
_.set(req.session, 'smsLogin.interval', Date.now() + 5 * 60 * 1000);
} else {
_.set(req.session, 'smsLogin.interval', Date.now() + 60 * 1000);
}
result.redirect = '/passport/sms_login?step=2';
res.json(result);
... ... @@ -157,8 +203,9 @@ exports.token = (req, res, next) => {
exports.checkBefore = (req, res, next) => {
let code = req.query.code = (req.query.code || '').trim();
let step = _.get(req.session, 'smsLogin.step');
if (!req.xhr && req.session.smsLoginStep !== 2) {
if (!req.xhr && step !== 2) {
return next(404);
}
... ... @@ -214,7 +261,7 @@ exports.check = (req, res, next) => {
// 手机号码 没注册
if (r1.data.is_register !== 'Y') {
redirect = '/passport/sms_login?step=3';
req.session.smsLoginStep = 3;
_.set(req.session, 'smsLogin.step', 3);
res.json({
code: 200,
... ... @@ -247,7 +294,6 @@ exports.check = (req, res, next) => {
});
delete req.session.smsLogin;
delete req.session.smsLoginStep;
})
.catch(error => {
res.json(error);
... ... @@ -259,7 +305,9 @@ exports.check = (req, res, next) => {
// AJAX 短信登录 设置密码 in step3
exports.password = (req, res, next) => {
if (req.session.smsLoginStep !== 3) {
let step = _.get(req.session, 'smsLogin.step');
if (step !== 3) {
return next();
}
... ... @@ -269,9 +317,8 @@ exports.password = (req, res, next) => {
message: BAD_PASSWORD
};
let smsLogin = req.session.smsLogin || {};
let mobile = smsLogin.mobile;
let area = smsLogin.area;
let mobile = _.get(req.session, 'smsLogin.mobile');
let area = _.get(req.session, 'smsLogin.area');
let password = (req.body.password || '').trim();
let smsCode = +req.body.smsCode || 0;
... ... @@ -306,11 +353,23 @@ exports.password = (req, res, next) => {
res.json({
code: 200,
message: LOGIN_SUCCSS,
redirect: req.cookies.refer
redirect: req.cookies.refer || '/'
});
delete req.session.smsLogin;
delete req.session.smsLoginStep;
}).catch(next);
};
/**
* 生成 校验码
*/
exports.genCaptcha = (req, res) => {
let captcha = captchaService.generateCaptcha(90, 52, 4);
_.set(req.session, 'smsLogin.captcha', captcha.text);
res.type('png')
.set('Cache-Control', 'no-cache')
.status(200)
.send(captcha.image);
};
... ...
... ... @@ -13,7 +13,7 @@ const back = require(cRoot + '/back');
const bind = require(cRoot + '/bind');
const reg = require(cRoot + '/reg');
// const smsLogin = require(cRoot + '/sms');
const smsLogin = require(cRoot + '/sms');
const update = require(cRoot + '/update');
const agreement = require(cRoot + '/app-agreement');
... ... @@ -37,15 +37,16 @@ router.get('/passport/international', login.common.beforeLogin, login.local.inte
router.post('/passport/login/auth', login.local.login);
// SMS 短信
// router.use('/passport/sms_login', login.common.beforeLogin, smsLogin.beforeIn);
// router.get('/passport/sms_login', smsLogin.loginPage);
// router.get('/passport/sms_login/token.json',
// smsLogin.tokenBefore,
// smsLogin.token); // only ajax;
// router.get('/passport/sms_login/check.json',
// smsLogin.checkBefore,
// smsLogin.check); // only ajax
// router.post('/passport/sms_login/password.json', smsLogin.password);
router.use('/passport/sms_login', login.common.beforeLogin, smsLogin.beforeIn);
router.get('/passport/sms_login', smsLogin.loginPage);
router.get('/passport/sms_login/token.json',
smsLogin.tokenBefore,
smsLogin.token); // only ajax;
router.get('/passport/sms_login/check.json',
smsLogin.checkBefore,
smsLogin.check); // only ajax
router.post('/passport/sms_login/password.json', smsLogin.password);
router.get('/passport/sms_login/captcha.png', smsLogin.genCaptcha);
// 微信登录
router.get('/passport/login/wechat', login.common.beforeLogin, login.wechat.login);
... ...
... ... @@ -7,8 +7,10 @@
<input id="phone-num" class="input phone-num" type="text" placeholder="手机号">
</div>
<div class="passport-captcha row">
<input id="verify-code" type="text" placeholder="验证码">
<div class="passport-captcha-img"><img id="verify-code-img" src="{{verifySrc}}" alt="verify code"></div>
<div class="passport-captcha-input">
<input id="verify-code" type="text" placeholder="验证码">
</div>
</div>
<span id="btn-next" class="btn btn-next disable row">下一步</span>
</div>
... ...
... ... @@ -8,10 +8,12 @@
</div>
<!-- 验证码: start-->
<div class="passport-captcha row">
<input id="js-captcha" type="text" placeholder="验证码">
<div class="passport-captcha-img">
<img class="passport-captcha-png" src="{{captchaUrl}}">
</div>
<div class="passport-captcha-input">
<input id="js-captcha" type="text" placeholder="验证码">
</div>
</div>
<!-- 验证码: end-->
<span id="btn-next" class="btn btn-next disable row">下一步</span>
... ...
... ... @@ -15,5 +15,5 @@
<input type="hidden" name="area" id="area" value="{{area}}">
</div>
<script>
var canResend = {{canResend}};
var countdown = {{countdown}};
</script>
\ No newline at end of file
... ...
... ... @@ -7,6 +7,12 @@
<input id="phone-num" class="input phone-num" type="text" placeholder="手机号">
<button class="clear-input" type="button"></button>
</div>
<div class="passport-captcha row">
<div class="passport-captcha-img"><img src="{{captchaUrl}}" alt=""></div>
<div class="passport-captcha-input">
<input id="js-captcha" type="text" placeholder="验证码">
</div>
</div>
<button id="btn-next" class="btn btn-next disable row" disabled>获取短信验证码</button>
</div>
</div>
\ No newline at end of file
... ...
... ... @@ -16,6 +16,11 @@ module.exports = () => {
req.url = `/activity${req.url}`;
}
if (/^\/shopping\/pay\/aliwapreturn/.test(req.url)) {
// 兼容php的url
req.url = `/cart${req.url}`;
}
if (/^\/sale/.test(req.url)) {
// sale 兼容php的url
res.redirect(301, helpers.urlFormat('/product/sale', req.query, 'default'));
... ...
var $ = require('yoho-jquery'),
lazyLoad = require('yoho-jquery-lazyload');
require('../common');
lazyLoad($('img.lazy'));
function getGender() {
return window.cookie('_Channel') || 'boys';
}
require('../channel/maybe-like')(getGender());
if ($('#goods-list').length === 0) {
$('.maybe-like').hide();
}
... ...
... ... @@ -14,20 +14,25 @@ var $footer = $('#yoho-footer'),
var RECID = (new Date().getTime() + '_H5_YOHOBUY_' + Math.floor(Math.random() * 1000000 + 1000000) +
'_' + Math.floor(Math.random() * 1000000 + 1000000));
var _ChannelVary = {boys: 1, girls: 2, kids: 3, lifestyle: 4};
var _ChannelVary = {
boys: 1,
girls: 2,
kids: 3,
lifestyle: 4
};
function cookie(name) {
var cookies = document.cookie,
cookieVal,
offset;
if (document.cookie && document.cookie !== '') {
offset = cookies.indexOf(name + '=');
if (offset > -1) {
offset += name.length + 1;
cookieVal = decodeURIComponent($.trim(cookies.substring(offset, cookies.indexOf(';', offset))));
}
cookieVal;
if (cookies) {
cookies = cookies.split(';');
cookies.forEach(function(c) {
if (c.indexOf(name) > -1) {
cookieVal = decodeURIComponent($.trim(c.replace(name + '=', '')));
return;
}
});
}
return cookieVal;
... ... @@ -204,7 +209,9 @@ $.extend({
// 单击下载按钮 - 接受微信商城或者第三方来源的数据埋点信息
if (queryString().union_type) {
setCookie('unionTypeYas', queryString().union_type, {path: '/'});
setCookie('unionTypeYas', queryString().union_type, {
path: '/'
});
}
}());
... ... @@ -229,7 +236,7 @@ $.extend({
uid = uid === 0 ? '' : uid;
window._ozuid = uid;// 暴露ozuid
window._ozuid = uid; // 暴露ozuid
if (window._yas) {
window._yas(1 * new Date(), '1.0.18', 'yohobuy_m', uid, '', '');
... ... @@ -323,7 +330,10 @@ function downLoadApp() {
if (window._yas && window._yas.sendCustomInfo) {
window._yas.sendCustomInfo({
op: 'YB_DOWNLOAD_C',
param: JSON.stringify({C_ID: _ChannelVary[cookie('_Channel')] || 1, TO_URL: appUrl})
param: JSON.stringify({
C_ID: _ChannelVary[cookie('_Channel')] || 1,
TO_URL: appUrl
})
}, true);
}
... ... @@ -369,6 +379,7 @@ function givePoint(parameter) {
(function() {
var channel = cookie('_Channel');
var header = $('#yoho-header, .homebuttom');
var footer = $('.footer-tab .tab-item.current');
if (!/^\/home/.test(location.pathname)) {
switch (channel) {
... ... @@ -399,6 +410,34 @@ function givePoint(parameter) {
break;
}
}
switch (channel) {
case 'boys':
if (footer) {
footer.addClass('boys');
}
break;
case 'girls':
if (footer) {
footer.addClass('girls');
}
break;
case 'lifestyle':
if (footer) {
footer.addClass('life-style');
}
break;
case 'kids':
if (footer) {
footer.addClass('kids');
}
break;
default:
if (footer) {
footer.addClass('boys');
}
break;
}
}());
// 暴露公共接口
... ...
... ... @@ -23,10 +23,12 @@ window.reMarginFooter('.footer-tab');
// 部分老用户没有头像,显示默认头像
avatar = $userAvatar.data('avatar');
myImage.src = avatar;
myImage.onload = function() {
$userAvatar.css('background-image', 'url(' + avatar + ')');
};
if (avatar) {
myImage.src = avatar;
myImage.onload = function() {
$userAvatar.css('background-image', 'url(' + avatar + ')');
};
}
noticeScroll('.notice', $('.notice').data('time') * 1000);
... ... @@ -36,4 +38,3 @@ $('.yoho-page').on('touchstart', '.list-item, .type-item, .order-title', functio
}).on('touchend touchcancel', '.list-item, .type-item, .order-title', function() {
$(this).removeClass('highlight');
});
... ...
... ... @@ -44,7 +44,7 @@ if (qs.selected && qs.selected === 'N') {
$('.pitch').removeClass('select').html('&#xe647;');
}
if(qs.pwd) {
if (qs.pwd) {
$pwd.val(qs.pwd);
if (trim($pwd.val()) === '') {
... ... @@ -64,6 +64,31 @@ $('.pitch').on('click', function() {
}
});
function setPassword() {
return $.ajax({
type: 'POST',
url: '/passport/reg/setpassword',
data: {
password: trim($pwd.val()),
phoneNum: $('#phone-num').val(),
areaCode: $('#area-code').val(),
smsCode: $('#sms-code').val(),
token: $('#token').val()
},
success: function(data) {
var res = data.data;
if (data.code === 200) {
showErrTip('注册成功');
location.href = res.href;
} else {
showErrTip(data.message);
}
}
});
}
$btnSure.on('touchstart', function() {
var pwd = trim($pwd.val());
... ... @@ -74,30 +99,8 @@ $btnSure.on('touchstart', function() {
if (!validatePWD(pwd)) {
showErrTip('密码6-20位,请重新输入');
} else {
if ($('.pitch').hasClass('select')) {
$.ajax({
type: 'POST',
url: '/passport/reg/setpassword',
data: {
password: pwd,
phoneNum: $('#phone-num').val(),
areaCode: $('#area-code').val(),
smsCode: $('#sms-code').val(),
token: $('#token').val()
},
success: function(data) {
var res = data.data;
if (data.code === 200) {
showErrTip('注册成功');
location.href = res.href;
} else {
showErrTip(data.message);
}
}
});
setPassword();
} else {
$('.prompt').show();
... ... @@ -106,27 +109,7 @@ $btnSure.on('touchstart', function() {
$('.pitch').addClass('select');
$('.pitch').html('&#xe60a;');
$.ajax({
type: 'POST',
url: '/passport/reg/setpassword',
data: {
password: pwd,
phoneNum: $('#phone-num').val(),
areaCode: $('#area-code').val(),
token: $('#token').val()
},
success: function(data) {
var res = data.data;
if (data.code === 200) {
showErrTip('注册成功');
location.href = res.href;
} else {
showErrTip(data.message);
}
}
});
setPassword();
});
$('.deny').on('click', function() {
... ...
... ... @@ -22,8 +22,8 @@ page = {
init: function() {
this.domInit();
this.bindEvents();
if (!window.canResend) {
this.countDown();
if (window.countdown > 0) {
this.countDown(window.countdown);
}
},
... ... @@ -72,11 +72,14 @@ page = {
});
},
countDown: function() {
countDown: function(during) {
var self = this;
var second = this.time;
if (this.timerId) {
if (during) {
clearInterval(this.timerId);
second = during;
} else if (this.timerId) {
return;
}
... ... @@ -116,6 +119,8 @@ page = {
if (res.code === 200) {
self.countDown();
return;
} else {
res.during && (self.countDown(res.during));
}
tip.show(res.message);
... ...
... ... @@ -6,7 +6,10 @@ var $countrySelect,
$areaCode,
$nextBtn,
$resetBtn,
$captcha,
$captchaPNG,
$phoneNum;
var page;
require('js/common');
... ... @@ -25,6 +28,8 @@ page = {
$nextBtn = $('#btn-next');
$phoneNum = $('#phone-num');
$resetBtn = $('.clear-input');
$captcha = $('.passport-captcha input');
$captchaPNG = $('.passport-captcha-img img');
},
bindEvent: function() {
var self = this;
... ... @@ -36,6 +41,12 @@ page = {
self.toggleNextBtn();
});
$captcha.on('input', function() {
self.toggleNextBtn();
});
$captchaPNG.on('click', $.proxy(this.refreshCapatch, this));
$nextBtn.on('click', function() {
self.goNext();
});
... ... @@ -51,7 +62,7 @@ page = {
// 切换$nextBtn disable状态
toggleNextBtn: function() {
var bool = Boolean($.trim($phoneNum.val()));
var bool = Boolean($.trim($phoneNum.val())) && Boolean($.trim($captcha.val()));
$nextBtn
.toggleClass('disable', !bool)
... ... @@ -60,10 +71,16 @@ page = {
$resetBtn.toggle(bool);
},
refreshCapatch: function() {
$captchaPNG.attr('src', '/passport/sms_login/captcha.png?t=' + Date.now());
},
// 提交按钮
goNext: function() {
var self = this;
var areaCode = $countrySelect.val();
var phone = $.trim($phoneNum.val());
var captcha = $.trim($captcha.val());
if ($nextBtn.prop('disabled')) {
return;
... ... @@ -77,7 +94,8 @@ page = {
$nextBtn.prop('disabled', true);
$.get('/passport/sms_login/token.json', {
area: areaCode.replace('+', ''),
mobile: phone
mobile: phone,
captcha: captcha
})
.done(function(data) {
if (data.code === 200) {
... ... @@ -85,6 +103,7 @@ page = {
$nextBtn.off();
location.href = data.redirect;
} else {
self.refreshCapatch();
tip.show(data.message);
}
})
... ...
... ... @@ -38,6 +38,8 @@ var $input = $('#search-input input'),
var shopId, sort, brand, outlets, app_type, age_level, msort, misort, coin, app_version;
var size, color, style, standard, gender, price, p_d, query, limited, specialoffer, specialsale_id, promotion;
// 默认筛选条件
var defaultOpt = require('../../common/query-param');
... ... @@ -207,12 +209,25 @@ function getQueryString(name) {
shopId = getQueryString('shop_id');
sort = getQueryString('sort');
outlets = getQueryString('outlets');
age_level = getQueryString('age_level');
age_level = getQueryString('ageLevel');
app_type = getQueryString('app_type');
msort = getQueryString('msort');
misort = getQueryString('misort');
coin = getQueryString('coin');
app_version = getQueryString('app_version') || getQueryString('appVersion');
size = getQueryString('size');
color = getQueryString('color');
style = getQueryString('style');
standard = getQueryString('standard');
gender = getQueryString('gender');
price = getQueryString('price');
p_d = getQueryString('p_d');
brand = getQueryString('brand');
query = getQueryString('query');
limited = getQueryString('limited');
specialoffer = getQueryString('specialoffer');
specialsale_id = getQueryString('specialsale_id');
promotion = getQueryString('promotion');
/**
* 筛选注册的回调,筛选子项点击后逻辑
... ... @@ -296,6 +311,11 @@ function search(opt) {
outlets: opt.id
};
break;
case 'p_d':
ext = {
p_d: opt.id
};
break;
default:
break;
}
... ... @@ -373,6 +393,54 @@ function search(opt) {
params.app_version = app_version;
}
if (size) {
params.size = size;
}
if (color) {
params.color = color;
}
if (style) {
params.style = style;
}
if (standard) {
params.standard = standard;
}
if (gender) {
params.gender = gender;
}
if (price) {
params.price = price;
}
if (p_d) {
params.p_d = p_d;
}
if (query) {
params.query = query;
}
if (limited) {
params.limited = limited;
}
if (specialoffer) {
params.specialoffer = specialoffer;
}
if (specialsale_id) {
params.specialsale_id = specialsale_id;
}
if (promotion) {
params.promotion = promotion;
}
$.extend(setting, defaultOpt, params);
searching = true;
loading.showLoadingMask();
... ... @@ -479,26 +547,109 @@ if ($brandHeader.data('isbaseshop') === true) {
Object.assign(defaultOpt, {shop_id: $brandHeader.data('id')});
}
// console.log(defaultOpt)
(function() {
var pars = {};
$.ajax({
type: 'GET',
url: location.protocol + '//m.yohobuy.com/product/search/filter',
data: defaultOpt,
success: function(data) {
$goodsContainer.append(data);
if (age_level) {
pars.age_level = age_level;
}
// 初始化filter&注册filter回调
filter.initFilter({
fCbFn: search,
hCbFn: function() {
if (size) {
pars.size = size;
}
// 切换active状态到$pre上
$pre.addClass('active');
$pre.siblings('.filter').removeClass('active');
}
});
if (color) {
pars.color = color;
}
});
if (style) {
pars.style = style;
}
if (standard) {
pars.standard = standard;
}
if (gender) {
pars.gender = gender;
}
if (price) {
pars.price = price;
}
if (p_d) {
pars.p_d = p_d;
}
if (brand) {
pars.brand = brand;
}
if (sort) {
pars.sort = sort;
}
if (msort) {
pars.msort = msort;
}
if (misort) {
pars.misort = misort;
}
if (outlets) {
pars.outlets = outlets;
}
if (app_type) {
pars.app_type = app_type;
}
if (query) {
pars.query = query;
}
if (limited) {
pars.limited = limited;
}
if (specialoffer) {
pars.specialoffer = specialoffer;
}
if (specialsale_id) {
pars.specialsale_id = specialsale_id;
}
if (promotion) {
pars.promotion = promotion;
}
$.extend(defaultOpt, pars);
$.ajax({
type: 'GET',
url: location.protocol + '//m.yohobuy.com/product/search/filter',
data: defaultOpt,
success: function(data) {
$goodsContainer.append(data);
// 初始化filter&注册filter回调
filter.initFilter({
fCbFn: search,
hCbFn: function() {
// 切换active状态到$pre上
$pre.addClass('active');
$pre.siblings('.filter').removeClass('active');
}
});
}
});
}());
lazyLoad($('.lazy'));
... ...
require('./shop/shop');
require('./shop/coupon');
require('./shop/shop');
... ...
... ... @@ -23,16 +23,17 @@ shopCoupon = {
_url = location.protocol + '//m.yohobuy.com';
if (that.common.shopId === '') {
//品牌领券
// 品牌领券
_url += '/product/index/getBrandCouponsList';
} else {
//店铺领券
// 店铺领券
_url += '/product/index/getShopCouponsList';
}
$.ajax({
method: 'GET',
url: _url,
async: false,
data: {
shopId: that.common.shopId,
brandId: that.common.brandId,
... ... @@ -88,7 +89,8 @@ shopCoupon = {
$('#shop-login').remove();
$('body').append('<a href=\'' + data.url + '\'><span id="shop-login"><span></a>');
$('#shop-login').click();
//未登录状态下
// 未登录状态下
window.setCookie('shopBrandCoupon', code);
} else if (data.code === 401) {
tip.show('已领取过');
... ... @@ -103,7 +105,8 @@ shopCoupon = {
});
});
},
//登录状态下,领取优惠券
// 登录状态下,领取优惠券
loginCoupon: function() {
var $self = this,
code = window.cookie('shopBrandCoupon') || false;
... ... @@ -130,4 +133,4 @@ shopCoupon = {
$(function() {
shopCoupon.init();
});
\ No newline at end of file
});
... ...
.pay-success {
width: 100%;
overflow: hidden;
position: relative;
background-color: #f0f0f0;
.top-tip {
width: 100%;
height: 240px;
border-bottom: solid 1px #e0e0e0;
text-align: center;
background-color: #fff;
.img-c {
margin-top: 25px;
width: 102px;
height: 102px;
background: resolve("cart/pay-ok.png") no-repeat;
background-size: 100% 100%;
display: inline-block;
}
.ok-tip {
font-size: 24px;
color: #d0021b;
line-height: 60px;
}
.left-tip {
font-size: 19px;
color: #b0b0b0;
}
}
.info-table-c {
height: 160px;
border-bottom: solid 1px #e0e0e0;
padding: 20px 25px;
background-color: #fff;
table {
width: 100%;
tr {
height: 40px;
}
td {
font-size: 24px;
color: #444;
}
td:nth-child(2) {
text-align: right;
}
}
}
.btn-c {
width: 100%;
height: 102px;
background-color: #fff;
border-bottom: solid 1px #e0e0e0;
padding: 0 25px;
a {
width: 270px;
height: 53px;
border: solid 2px #444;
display: block;
float: left;
line-height: 53px;
text-align: center;
border-radius: 5px;
box-sizing: border-box;
-moz-box-sizing: border-box;
margin-top: 24px;
font-size: 24px;
color: #444;
}
a:nth-child(2) {
margin-left: 50px;
}
}
.ad-pic {
width: 100%;
height: 200px;
display: block;
background-color: #fff;
margin: 25px 0;
}
.others-buy {
width: 100%;
margin-bottom: 25px;
background-color: #fff;
padding: 25px 0;
border-top: solid 1px #e4e4e4;
padding-left: 15px;
p {
text-align: center;
color: #444;
font-size: 27px;
}
}
}
... ...
... ... @@ -11,19 +11,35 @@
background: #fff;
border-top: 1px solid #b0b0b0;
z-index: 3;
.tab-item {
float: left;
width: 20%;
text-align: center;
color: #b0b0b0;
&.current {
&.current.boys {
color: #414141;
}
&.current.girls {
color: #ff88ae;
}
&.current.kids {
color: #7ad9f9;
}
&.current.lifestyle {
color: #4f4138;
}
}
.tab-icon {
font-size: 40px;
line-height: 1;
}
.tab-name {
margin-top: 10px;
font-size: 20px;
... ...
... ... @@ -27,3 +27,4 @@
@import "cart/index";
@import "home/index";
@import "me/index";
@import "cart/pay-success"
... ...
... ... @@ -7,21 +7,27 @@ div.passport-captch
img
emmet:
div.passport-captcha>input+div.passport-captcha-img>img
div.passport-captcha>(div.passport-captcha-input>input)+div.passport-captcha-img>img
*/
.passport-captcha {
text-align: left;
border-radius: 5PX;
overflow: hidden;
}
.passport-captcha-input {
overflow: hidden;
input {
position: relative;
padding-left: 15px;
height: 52PX;
width: 100%;
font-size: 20PX;
background-color: #575757;
border: 1px solid #606060;
border-radius: 5PX;
color: #fff;
}
}
... ...