Authored by zhangxiaoru

merge

... ... @@ -27,6 +27,11 @@ const app = express();
app.locals.devEnv = app.get('env') === 'development';
app.locals.version = pkg.version;
// zookeeper
if (config.zookeeperServer) {
require('yoho-zookeeper')(config.zookeeperServer, 'wap', app.locals.wap = {});
}
// 访问域名层级
app.set('subdomain offset', 3);
... ...
... ... @@ -27,6 +27,13 @@ app.use(global.yoho.hbs({
helpers: Object.assign({}, global.yoho.helpers, helpers)
}));
// for zookeeper, inject locals
app.use((req, res, next) => {
req.app.locals.wap = app.locals.wap;
next();
});
// router
app.use(require('./router'));
... ...
... ... @@ -15,6 +15,13 @@ app.on('mount', function(parent) {
Object.assign(app.locals, parent.locals);
});
// for zookeeper, inject locals
app.use((req, res, next) => {
req.app.locals.wap = app.locals.wap;
next();
});
// router
app.use(require('./router'));
... ...
... ... @@ -4,7 +4,6 @@
'use strict';
const co = require('bluebird').coroutine;
const seckillModel = require('../models/seckill');
const buyNowModel = require('../models/buynow');
const headerModel = require('../../../doraemon/models/header'); // 头部model
const BAD_REQUEST = '非法请求';
... ... @@ -41,7 +40,7 @@ exports.ensure = (req, res, next) => {
paymentOption.activity_id = skillData.activityId;
// 获取结算 数据
let paymentInfo = yield buyNowModel.payment(paymentOption, orderInfo);
let paymentInfo = yield seckillModel.payment(paymentOption, orderInfo);
let view;
if (paymentInfo.code !== 200) {
... ... @@ -101,7 +100,7 @@ exports.compute = (req, res, next) => {
activity_id: activityId
};
return buyNowModel.compute(options)
return seckillModel.compute(options)
.then(result => {
res.json(result.data);
})
... ... @@ -154,7 +153,7 @@ exports.submit = (req, res, next) => {
uid
};
return buyNowModel.submit(options)
return seckillModel.submit(options)
.then(result => {
res.clearCookie('order-info');
res.json(result);
... ...
... ... @@ -4,27 +4,21 @@
* @date: 2016/09/26
*/
var express = require('express'),
path = require('path');
var express = require('express');
var app = express();
// set view engin
var doraemon = path.join(__dirname, '../../doraemon/views'); // parent view root
app.on('mount', function(parent) {
delete parent.locals.settings; // 不继承父 App 的设置
Object.assign(app.locals, parent.locals);
});
// app.use(global.yoho.hbs({
// extname: '.hbs',
// defaultLayout: 'layout',
// layoutsDir: doraemon,
// partialsDir: path.join(__dirname, 'views/partial'),
// views: path.join(__dirname, 'views/action'),
// helpers: global.yoho.helpers
// }));
// for zookeeper, inject locals
app.use((req, res, next) => {
req.app.locals.wap = app.locals.wap;
next();
});
// router
app.use(require('./router'));
... ...
'use strict';
const API = global.yoho.API;
const paymentProcess = require(global.utils + '/payment-process');
/**
* 获取 获取秒杀信息接口
... ... @@ -14,3 +15,39 @@ exports.skillData = product_skn => {
return API.post('', queryData);
};
exports.payment = (options, orderInfo) => {
let queryData = Object.assign({
method: 'app.Seckill.payment',
}, options);
return API.post('', queryData)
.then(result => {
// TODO 数据处理
if (result.code === 200 && result.data) {
result.data = paymentProcess.tranformPayment(result.data, orderInfo);
}
return result;
});
};
exports.compute = options => {
let url = '';
let queryData = Object.assign({
method: 'app.Seckill.compute',
}, options);
return API.post(url, queryData);
};
exports.submit = options => {
let url = '';
let queryData = Object.assign({
method: 'app.Seckill.submit'
}, options);
return API.post(url, queryData);
};
... ...
... ... @@ -26,6 +26,13 @@ app.use(global.yoho.hbs({
helpers: global.yoho.helpers
}));
// for zookeeper, inject locals
app.use((req, res, next) => {
req.app.locals.wap = app.locals.wap;
next();
});
// router
app.use(require('./router'));
... ...
... ... @@ -26,6 +26,13 @@ app.use(global.yoho.hbs({
helpers: global.yoho.helpers
}));
// for zookeeper, inject locals
app.use((req, res, next) => {
req.app.locals.wap = app.locals.wap;
next();
});
// router
app.use(require('./router'));
... ...
... ... @@ -127,8 +127,8 @@ const getResources = (params, options) => {
list = {
id: res.template_id,
title: res.data.title,
more_url: res.data.more_url,
more_name: res.data.more_name,
moreUrl: res.data.more_url,
moreName: res.data.more_name,
image: res.data.image
};
... ... @@ -137,8 +137,8 @@ const getResources = (params, options) => {
case 'titleFloor':
list = {
name: res.data.title.name,
more_url: res.data.title.more_url,
more_name: res.data.title.more_name
moreUrl: res.data.title.more_url,
moreName: res.data.title.more_name
};
if (res.data.title.name === '热门商品') {
... ...
... ... @@ -47,7 +47,7 @@
<div class="focus-left-right speck-title-image" data-fid='{{result.focus2.id}}' data-name='焦点图'>
{{#each result.focus2.data}}
<a href="{{url}}" title="{{title}}">
<img class="lazy" data-original="{{image src 250 250}}">
<img src="{{image src 250 250}}">
</a>
{{/each}}
</div>
... ...
... ... @@ -42,7 +42,7 @@ exports.address = (req, res, next) => {
*/
exports.addressAct = (req, res, next) => {
addressModel.address({
id: decodeURIComponent(req.params.id),
id: decodeURIComponent(req.query.id),
uid: req.user.uid
}).then(result => {
let responseData = {
... ... @@ -114,7 +114,7 @@ exports.saveAddress = (req, res, next) => {
area_code: req.body.area_code,
consignee: req.body.consignee,
email: req.body.email,
id: req.body.id,
id: decodeURIComponent(req.body.id),
mobile: req.body.mobile,
zip_code: req.body.zip_code
}).then(result => {
... ... @@ -130,7 +130,7 @@ exports.saveAddress = (req, res, next) => {
*/
exports.delAddress = (req, res, next) => {
addressModel.delAddress({
id: req.body.id,
id: decodeURIComponent(req.body.id),
uid: req.user.uid
}).then(result => {
res.json(result);
... ...
... ... @@ -26,6 +26,13 @@ app.use(global.yoho.hbs({
helpers: global.yoho.helpers
}));
// for zookeeper, inject locals
app.use((req, res, next) => {
req.app.locals.wap = app.locals.wap;
next();
});
// router
app.use(require('./router'));
... ...
... ... @@ -100,14 +100,14 @@ const address = (params) => {
/* 加密地址 ID */
_.forEach(selfAddress.data, (value, key) => {
selfAddress.data[key].address_id = crypto.encryption(null, selfAddress.data[key].address_id);
selfAddress.data[key].address_id = encodeURIComponent(crypto.encryption(null, selfAddress.data[key].address_id));
});
/* 如果有 ID 是地址编辑页面 */
if (params.id) {
return {
address: camelCase(_.find(selfAddress.data, o => {
return o.address_id === params.id;
return decodeURIComponent(o.address_id) === params.id;
})),
addressList: camelCase(result[1] ? result[1].data : []),
navTitle: '编辑地址'
... ...
... ... @@ -6,7 +6,7 @@
<span class="tel">{{mobile}}</span>
<p class="address-info">{{area}} {{address}}</p>
<div class="action iconfont">
<a class="edit" href="/home/addressAct/{{addressId}}">&#xe61e;</a>
<a class="edit" href="/home/addressAct?id={{addressId}}">&#xe61e;</a>
<span class="del" data-id="{{addressId}}">&#xe621;</span>
</div>
</div>
... ...
... ... @@ -31,11 +31,11 @@
</a>
</div>
<div class="connect-item connect-online">
<a href="tel:4008869646" target="_blank" title="热线客服">
<a href="tel:4008899646" target="_blank" title="热线客服">
<span class="icon iconfont icon-chat">&#xe63e;</span>
热线客服 <span class="call-time">(9:00-22:30)</span>
<span class="iconfont icon-yoho-enter call-number">400-886-9646</span>
<span class="iconfont icon-yoho-enter call-number">400-889-9646</span>
</a>
</div>
</div>
</div>
\ No newline at end of file
</div>
... ...
... ... @@ -28,6 +28,12 @@ app.use(global.yoho.hbs({
helpers: global.yoho.helpers
}));
// for zookeeper, inject locals
app.use((req, res, next) => {
req.app.locals.wap = app.locals.wap;
next();
});
require('./auth');
app.use(passport.initialize());
... ...
... ... @@ -27,6 +27,13 @@ app.use(global.yoho.hbs({
helpers: global.yoho.helpers
}));
// for zookeeper, inject locals
app.use((req, res, next) => {
req.app.locals.wap = app.locals.wap;
next();
});
// router
app.use(require('./router'));
... ...
... ... @@ -16,9 +16,8 @@ module.exports = {
siteUrl: '//m.yohobuy.com',
assetUrl: '//localhost:5001',
domains: {
// api: 'http://api.yoho.cn/',
api: 'http://api-test3.yohops.com:9999/', // 测试接口
service: 'http://service.yoho.cn/',
api: 'http://api.yoho.yohoops.org/',
service: 'http://service.yoho.yohoops.org/',
liveApi: 'http://api.live.yoho.cn/',
singleApi: 'http://single.yoho.cn/'
... ... @@ -78,7 +77,8 @@ module.exports = {
appID: 'wx75e5a7c0c88e45c2',
appSecret: 'ce21ae4a3f93852279175a167e54509b'
}
}
},
zookeeperServer: false // '10.66.1.97:2181'
};
if (isProduction) {
... ...
... ... @@ -2,5 +2,7 @@
<a href="{{@root.cartUrl}}">
<span class="iconfont">&#xe62c;</span>
</a>
{{#unless @root.wap.common.removeCartCount}}
<span class="cart-count hide">0</span>
{{/unless}}
</div>
... ...
{
"name": "m-yohobuy-node",
"version": "5.0.11",
"version": "5.0.14",
"private": true,
"description": "A New Yohobuy Project With Express",
"repository": {
... ... @@ -38,11 +38,14 @@
"request-promise": "^3.0.0",
"serve-favicon": "^2.3.0",
"uuid": "^2.0.3",
"yoho-node-lib": "0.1.23"
"yoho-node-lib": "0.1.23",
"yoho-zookeeper": "^1.0.3"
},
"devDependencies": {
"autoprefixer": "^6.3.7",
"ava": "^0.16.0",
"babel-core": "^6.14.0",
"babel-loader": "^6.2.5",
"babel-plugin-transform-runtime": "^6.12.0",
"babel-preset-es2015": "^6.14.0",
"babel-runtime": "^6.11.6",
"eslint": "^3.7.1",
... ...
... ... @@ -193,7 +193,7 @@ gulp.task('postcss', ['assets'], () => {
// webpack dev server
gulp.task('webpack-dev-server', () => {
const useDashboard = 0; // process.platform === 'darwin' || process.platform === 'linux';
const useDashboard = process.platform === 'darwin' || process.platform === 'linux';
const devConfig = Object.assign({}, webpackConfig, {
devtool: '#inline-source-map',
vue: {
... ...
... ... @@ -44,6 +44,6 @@
{{#if isSeckill}}
<a class="item-link" href='/product/seckill/show_{{{productSkn}}}{{#if @root.isApp}}?openby:yohobuy={"action":"go.productDetail","params":{"product_skn":"{{productSkn}}", "is_seckill": "Y"}}{{/if}}'></a>
{{else}}
<a class="item-link" href='/product/seckill/show_{{{productSkn}}}{{#if @root.isApp}}?openby:yohobuy={"action":"go.productDetail","params":{"product_skn":"{{productSkn}}"}}{{/if}}'></a>
<a class="item-link" href='/product/show_{{{productSkn}}}{{#if @root.isApp}}?openby:yohobuy={"action":"go.productDetail","params":{"product_skn":"{{productSkn}}"}}{{/if}}'></a>
{{/if}}
</div>
\ No newline at end of file
... ...
... ... @@ -343,7 +343,7 @@ function givePoint(parameter) {
*/
(function() {
var channel = cookie('_Channel');
var header = $('#yoho-header');
var header = $('#yoho-header, .homebuttom');
if (!/^\/home/.test(location.pathname)) {
switch (channel) {
... ...
... ... @@ -2,8 +2,7 @@ var $ = require('yoho-jquery'),
tip = require('../plugin/tip'),
Swiper = require('yoho-swiper'),
loading = require('../plugin/loading'),
debounce = require('lodash/debounce'),
lazyLoad = require('yoho-jquery-lazyload');
debounce = require('lodash/debounce');
var plusstar = {},
$footer = $('#yoho-footer');
... ... @@ -19,6 +18,7 @@ var scrollFn,
sid: ''
};
require('yoho-jquery-lazyload');
require('../common');
plusstar = {
... ... @@ -186,16 +186,7 @@ plusstar = {
that.resInit();
lazyLoad($('img.lazy'));
// 处理左右滑动,未加载的图片
setTimeout(function() {
$('img.lazy').each(function() {
if ($(this).attr('src') !== $(this).data('original')) {
$(this).attr('src', $(this).data('original'));
}
});
}, 40);
$('.plusstar-resources').find('img.lazy').lazyload();
// 设置滚动条的位置
if (window.localStorage) {
... ... @@ -277,8 +268,7 @@ plusstar = {
$('.plusstar-resources .goods').append(data);
lazyLoad($('.plusstar-resources .goods').find('img.lazy:not([src])'));
$('.plusstar-resources .goods').find('img.lazy:not([src])').lazyload();
$('.resources .goods .page-total').remove();
},
error: function() {
... ... @@ -315,7 +305,7 @@ $(function() {
}
// 男:1,女:2,潮童:3,创意生活:4
speckParamApp.CID = window.queryString.yh_channel || window._ChannelVary[window.cookie('_Channel')] || 1;
speckParamApp.CID = window.queryString.yh_channel || window._ChannelVary[window.cookie('_Channel')] || 1;
if (!(window.queryString.app_version || window.queryString.appVersion)) {
$('.tab-nav').css({
... ...
... ... @@ -14,8 +14,9 @@ var $loading,
/** modify by liangzhifeng at 2015.11.2 */
// 初始化
function init($container) {
var html = '<div class="loading-mask hide">' +
function init($container, options) {
var className = options && options.className || '';
var html = '<div class="loading-mask ' + className + ' hide">' +
'<div class="loading">' +
'<div></div><div></div><div></div>' +
'</div>' +
... ...
... ... @@ -169,36 +169,42 @@ $search.on('touchend', function() {
history,
historys, i, num = 1;
if (localStorage) {
historys = localStorage.getItem(historyval);
try {
if (localStorage) {
historys = localStorage.getItem(historyval);
if (historys && historys.length > 0) {
historys = historys.split(ranToken);
for (i = historys.length; i > 0; i--) {
history = historys[i - 1];
if (historys && historys.length > 0) {
historys = historys.split(ranToken);
for (i = historys.length; i > 0; i--) {
history = historys[i - 1];
if (history === '') {
continue;
}
if (history === '') {
continue;
}
if (num++ > 10) {
break;
if (num++ > 10) {
break;
}
html += '<li><a href="javascript:void(0);">' + history + '</li>';
}
html += '<li><a href="javascript:void(0);">' + history + '</li>';
}
$history.html(html);
$history.html(html);
if (html !== '') {
$clearHistory.removeClass('hide');
$historySearch.removeClass('hide');
}
if (html !== '') {
$clearHistory.removeClass('hide');
$historySearch.removeClass('hide');
window.rePosFooter();
} else {
$historySearch.hide();
$clearHistory.hide();
}
window.rePosFooter();
} else {
$historySearch.hide();
$clearHistory.hide();
}
} catch (e) {
console.log(e);
$historySearch.hide();
$clearHistory.hide();
}
}());
... ...
... ... @@ -20,17 +20,21 @@ function getHistoryval() {
function setHistoryValFun(query) {
var historys;
if (localStorage) {
historys = localStorage.getItem(historyval);
try {
if (localStorage) {
historys = localStorage.getItem(historyval);
historys = historys ? historys.replace(new RegExp((query + ranToken), 'g'), '') : '';
historys = historys ? historys.replace(new RegExp((query + ranToken), 'g'), '') : '';
if (historys === '') {
query = ranToken + query;
}
if (historys === '') {
query = ranToken + query;
}
historys += query + ranToken;
localStorage.setItem(historyval, historys);
historys += query + ranToken;
localStorage.setItem(historyval, historys);
}
} catch (e) {
console.log(e);
}
}
... ...
... ... @@ -11,7 +11,9 @@ var $ = require('yoho-jquery'),
lazyload = require('yoho-jquery-lazyload'),
tip = require('plugin/tip');
loading.init($(document.body));
loading.init($(document.body), {
className: 'loading-mask-opactiy'
});
var seckillObj = {};
... ... @@ -22,6 +24,7 @@ seckillObj = {
$productList: null, // DOMContentLoaded的时候 赋值,即init
pageTemplate: require('product/seckill/index.hbs'),
listTemplate: require('product/seckill/product-list.hbs'),
diff: 0, // 客户端与服务端时间的误差
el: {},
... ... @@ -277,7 +280,8 @@ seckillObj = {
second = offsetTime % 60;
if (offsetTime <= 0) { // 结束倒计时刷新状态
that.refreshList(elem);
// that.refreshList(elem);
location.reload();
} else {
$(elem).find('.tick.hour').text(hour < 0 ? '00' : (hour < 10 ? ('0' + hour) : hour));
$(elem).find('.tick.minute').text(minute < 0 ? '00' : (minute < 10 ? ('0' + minute) : minute));
... ... @@ -286,7 +290,7 @@ seckillObj = {
$el.currentTick = setTimeout(function() {
var curSec = Math.floor(Date.now() / 1000);
offsetTime = offsetTime - (curSec - nowTime);
offsetTime = offsetTime - (curSec - nowTime) - that.diff;
that.startTick(elem, offsetTime, curSec);
}, 1000);
}
... ... @@ -387,6 +391,10 @@ seckillObj = {
isApp: yoho.isApp
}))
);
if (result && result.currentTime) {
self.diff = Math.round((Date.now() - result.currentTime) / 1000);
}
lazyload('img.lazy');
window.rePosFooter();
callback();
... ...
... ... @@ -927,13 +927,12 @@ $nav2.on('touchstart', 'li', function(e) {
// // stopPropagation(e);
// });
$('#shop-category').click(function() {
var subGroup = $('.sub-group');
$('.shop-foot-wrapper .buriedpoint').click(function() {
var subGroup = $(this).find('.sub-group');
if (subGroup.hasClass('hide')) {
$('.sub-group').removeClass('hide');
subGroup.removeClass('hide');
} else {
$('.sub-group').addClass('hide');
subGroup.addClass('hide');
}
});
... ...
.coupon-area-page {
max-width: 640px;
overflow: hidden;
.swiper-slide {
img {
max-width: 640px;
max-height: 310.303px;
}
}
}
.just-img{
... ...
... ... @@ -163,13 +163,11 @@
a {
display: inline-block;
margin: 0 15px;
width: 213px;
height: 213px;
}
img {
width: 100%;
height: 100%;
width: 213px;
height: 213px;
}
}
... ... @@ -180,7 +178,11 @@
a {
display: inline-block;
width: 50%;
overflow: hidden;
img {
width: 320px;
height: 320px;
}
}
}
... ...
... ... @@ -64,4 +64,9 @@
background: #fff;
}
}
&.loading-mask-opactiy {
background: transparent;
.loading > div {background-color: #444;}
}
}
... ...