Authored by 毕凯

Merge remote-tracking branch 'origin/master' into feature/refund

Showing 44 changed files with 341 additions and 155 deletions
... ... @@ -39,6 +39,7 @@ module.exports = class extends global.yoho.BaseModel {
getQuestionList() {
return this.get({
url: 'activity/question/questionList',
data: {uid: _.get(this.ctx, 'req.user.uid', 0)},
api: global.yoho.ServiceAPI
}).then(result => {
let list = _.get(result, 'data.rows', []);
... ...
... ... @@ -7,13 +7,9 @@ const shareBuyModel = require('../models/share-buy'),
exports.index = (req, res, next) => {
let activityId = req.query.act_id || 2023,
isApp = req.yoho.isApp,
uid = req.user.uid,
protocol = req.app.locals.isProduction ? 'https:' : 'http:';
co(function* () {
let isStudent = yield req.ctx(shareBuyModel).checkStudent(uid);
let indexData = yield req.ctx(shareBuyModel).shareIndex(activityId, isApp, uid, isStudent, protocol);
uid = req.user.uid;
req.ctx(shareBuyModel).shareIndex(activityId, isApp, uid).then(indexData => {
res.render('share-buy/share-buy', {
pageHeader: headerModel.setNav({
navTitle: '分享购'
... ... @@ -29,7 +25,7 @@ exports.index = (req, res, next) => {
banner: indexData.banner,
isStudent: indexData.isStudent
});
})().catch(next);
}).catch(next);
};
exports.detail = (req, res, next) => {
... ... @@ -73,3 +69,13 @@ exports.myRebeat = (req, res, next) => {
});
}).catch(next);
};
exports.getCouponCode = (req, res, next) => {
let uid = req.user.uid,
couponId = req.query.couponId,
protocol = req.app.locals.isProduction ? 'https:' : 'http:';
req.ctx(shareBuyModel).getCouponCode(uid, couponId, protocol).then(result => {
res.json(result);
})
};
... ...
... ... @@ -11,9 +11,9 @@ module.exports = class extends global.yoho.BaseModel {
/**
* 首页数据
*/
shareIndex(activityId, isApp, uid, isStudent, protocol) {
shareIndex(activityId, isApp, uid) {
return api.all([this._CouponInfo(activityId, uid, isStudent), this._redeatList(),
return api.all([this._CouponInfo(activityId, uid), this._redeatList(),
this._banner()]).then(result => {
const indexData = {
... ... @@ -23,8 +23,6 @@ module.exports = class extends global.yoho.BaseModel {
const rebeatUrl = '//m.yohobuy.com/activity/share-buy/my-rebeat',
strategyUrl = 'http://activity.yoho.cn/feature/115.html?share_id=2023&title=分享购攻略';
indexData.isStudent = isStudent;
if (result[0] && result[0].data && result[0].data.userCouponBoList) {
_.forEach(result[0].data.userCouponBoList, function(val) {
... ... @@ -36,22 +34,8 @@ module.exports = class extends global.yoho.BaseModel {
val.couponDescribe = '任意商品使用';
} else if (val.shopNames) {
val.couponDescribe = '限' + val.shopNames + '使用';
}
val.detailUrl = helpers.urlFormat('/activity/share-buy/detail', {
couponId: val.couponId,
couponCode: val.couponCode
});
if (isApp) {
val.detailUrl = protocol + val.detailUrl +
'&openby:yohobuy={"action":"go.h5","params":{"islogin":"N","url":"' + protocol +
val.detailUrl + '","params":{"couponId":"' + val.couponId + '","couponCode":"' +
val.couponCode + '"}}}';
}
if (!indexData.isStudent) {
val.detailUrl = '';
} else if (val.shareCoupon === '商品券') {
val.couponDescribe = '指定商品可用';
}
});
... ... @@ -102,12 +86,11 @@ module.exports = class extends global.yoho.BaseModel {
/**
* 首页获取优惠券信息
*/
_CouponInfo(activityId, uid, isStudent) {
_CouponInfo(activityId, uid) {
return api.get('', {
method: 'app.activity.getActivityCouponInfo',
activity_id: activityId,
uid: uid,
isStudent: isStudent
uid: uid
}, {
code: 200
}).then((result) => {
... ... @@ -145,7 +128,8 @@ module.exports = class extends global.yoho.BaseModel {
code: 200
}).then((result) => {
let moreUrl,
detailData;
detailData,
couponDetail = _.get(result, 'data.userCouponBoList[0]', {});
if (result && result.code === 200 && result.data) {
detailData = _.assign(detailData, param);
... ... @@ -166,14 +150,17 @@ module.exports = class extends global.yoho.BaseModel {
detailData.finish = parseInt(result.data.expiredTime, 10) > 0 ? false : true;
if (result.data.userCouponBoList[0].sortNames) {
if (couponDetail.sortNames) {
detailData.detailDes = '限品类: ' + result.data.userCouponBoList[0].sortNames;
} else if (result.data.userCouponBoList[0].brandNames) {
} else if (couponDetail.brandNames) {
detailData.detailDes = '限品牌: ' + result.data.userCouponBoList[0].brandNames;
} else if (result.data.userCouponBoList[0].shareCoupon === '全场通用') {
} else if (couponDetail.shareCoupon === '全场通用') {
detailData.detailDes = result.data.userCouponBoList[0].shareCoupon;
} else if (result.data.userCouponBoList[0].shopNames) {
detailData.detailDes = result.data.userCouponBoList[0].shopNames;
} else if (couponDetail.shopNames) {
detailData.detailDes = '限店铺:' + result.data.userCouponBoList[0].shopNames;
} else if (couponDetail.shareCoupon === '商品券') {
detailData.detailDes = '限商品:指定商品可用';
detailData.goodsCoupon = true;
}
detailData = _.assign(detailData, {
... ... @@ -191,23 +178,24 @@ module.exports = class extends global.yoho.BaseModel {
});
}
/**
* 判断是不是学生
/**
* 获取分享码
*/
checkStudent(uid) {
getCouponCode(uid, couponId, protocol) {
return api.get('', {
method: 'app.student.checkIsStudent',
uid: uid
method: 'app.activity.getActivityCouponCode',
uid: uid,
coupon_id: couponId
}).then(result => {
let isStudent;
if (result && result.data && result.code === 200) {
isStudent = parseInt(result.data.isStudent, 10) === 1 ? true : false;
if (result && result.code === 200 && result.data) {
result.data.detailUrl = helpers.urlFormat('/activity/share-buy/detail', {
couponId: couponId,
couponCode: result.data.couponCode
});
result.data.protocol = protocol;
}
return isStudent;
return result;
});
}
... ...
... ... @@ -257,7 +257,7 @@ router.get('/getCoupon', birthday.getCoupon); // 获取生日卷状态
router.get('/share-buy', update('5.7.0'), auth, shareBuy.index); // 分享购首页
router.get('/share-buy/detail', update('5.7.0'), shareBuy.detail); // 分享购详情页
router.get('/share-buy/my-rebeat', update('5.7.0'), auth, shareBuy.myRebeat); // 我的返利
router.get('/share-buy/get-coupon-code', auth, shareBuy.getCouponCode); // 获取分享购券码
router.get('/user-recommend', userRecommend.index); // 广点通投放落地页
router.get('/user-recommend/moreGoods', userRecommend.moreGoods); // 获取商品分页
... ...
... ... @@ -16,11 +16,7 @@
<p class="coupon-type">{{shareCouponType}}</p>
</div>
<div class="coupon-right">
{{#if detailUrl}}
<a href="{{detailUrl}}" class="join">立即参与</a>
{{else}}
<span class="join">立即参与</span>
{{/if}}
<span class="join" data-id="{{couponId}}">立即参与</span>
<p class="coupon-mold">{{shareCoupon}}</p>
<p class="coupon-limit">{{couponDescribe}}</p>
</div>
... ...
... ... @@ -40,7 +40,13 @@
</div>
<div class="info-bottom">
<span class="share-coupon">{{detailDes}}</span>
<span class="coupon-tip">特列商品(秒杀、限定、境外、预售等)暂不支持使用优惠券。</span>
<span class="coupon-tip">
{{#if goodsCoupon}}
下方为优惠劵适用商品,也可兑换劵码后到优惠券列表查看指定商品。
{{else}}
特列商品(秒杀、限定、境外、预售等)暂不支持使用优惠券。
{{/if}}
</span>
<span class="validity">有效期: {{couponValidity}}</span>
</div>
... ...
... ... @@ -18,7 +18,9 @@ const index = (req, res) => {
let isLogin = req.user && req.user.uid,
pageData = {
isLogin,
signurl: helpers.urlFormat('/signin.html')
signurl: helpers.urlFormat('/signin.html', {
refer: req.originalUrl
})
};
// 唤起 APP 的路径
... ... @@ -38,7 +40,8 @@ const index = (req, res) => {
text: ' '
},
navBtn: false
})
}),
isWechat: req.yoho.isWechat || req.yoho.isMarsApp // 默认判断微信,mars下同微信
}));
};
... ...
... ... @@ -129,6 +129,7 @@ const index = (params) => {
signinUrl: helpers.urlFormat('/signin.html', {
refer: helpers.urlFormat('/home')
}),
referUrl: helpers.urlFormat('/home'),
verifyUrl: helpers.urlFormat('/activity/student/register')
};
... ...
... ... @@ -9,7 +9,7 @@
</label>
<label class="mobile">
联系电话:
<input type="text" name="mobile" value="{{address.mobile}}">
<input type="tel" name="mobile" value="{{address.mobile}}">
</label>
<label class="area">
所在地区:
... ...
... ... @@ -20,7 +20,7 @@
{{/unless}}
{{^}}
<div class="user-info">
<a class="login-btn" href="{{signinUrl}}">
<a class="login-btn" href="{{signinUrl}}" data-refer="{{referUrl}}">
登录/注册
</a>
{{#if @root.studentSwitch}}
... ... @@ -106,7 +106,7 @@
</a>
</div>
<div class="group-list">
<a class="list-item invite" href="https://activity.yoho.cn/feature/357.html?share_id=2391&title=">
<a class="list-item invite" href="http://activity.yoho.cn/feature/357.html?share_id=2391&title=邀请好友50元现金券无限赚">
<span class="horn"></span>
邀请好友,50元现金券无限赚
<span class="iconfont num">&#xe604;</span>
... ...
... ... @@ -13,7 +13,7 @@ const list = (req, res, next) => {
}
let param = {
limit: 12,
limit: 24,
order: 's_t_desc',
page: 1,
uid: req.user.uid || 0
... ...
... ... @@ -228,7 +228,7 @@ const category = (req, res, next) => {
type: 'default',
order: '0',
page: 1,
limit: 12,
limit: 24,
isApp: params.app_version
}, params);
... ...
... ... @@ -71,7 +71,8 @@ const newDetail = {
`YOHO!BUY 有货${result.brandName}官网专卖店提供${result.brandName}正品、${result.brandName}真品、 ${result.brandName}打折、${result.brandName}代购等。`, // eslint-disable-line
pageFooter: true,
localCss: true,
appPath: appPath
appPath: appPath,
isMarsApp: req.yoho.isMarsApp // 判断mars
});
}).catch(next);
},
... ...
... ... @@ -334,7 +334,8 @@ const shop = {
shopPage: true,
appPath: 'yohobuy://yohobuy.com/goapp?openby:yohobuy={"action":"go.shop","params":{"shop_template_type":"2","shop_id":"' +
shopId + '","shop_name":"' + result.seoTitle + '"}}',
localCss: true
localCss: true,
isMarsApp: req.yoho.isMarsApp
});
});
... ...
... ... @@ -37,7 +37,7 @@ const blkNewGoods = (req, res, next) => {
type: 'default',
order: '0',
page: 1,
limit: 12,
limit: 24,
isApp: params.app_version
}, params);
... ...
... ... @@ -49,7 +49,7 @@ const list = (req, res, next) => {
type: 'default',
order: '0',
page: 1,
limit: 12
limit: 24
}, params);
if (uid) {
... ...
... ... @@ -504,7 +504,7 @@ const getSearchKeywordData = (params, uid) => {
type: 'default',
order: '0',
page: 1,
limit: 12
limit: 24
}, params);
if (uid) {
... ...
... ... @@ -14,8 +14,8 @@ const domains = {
// api: 'http://192.168.103.59:8080/gateway',
// service: 'http://192.168.103.59:8080/gateway',
api: 'http://api-test2.yohops.com:9999/',
service: 'http://service-test2.yohops.com:9999/',
api: 'http://api-test3.yohops.com:9999/',
service: 'http://service-test3.yohops.com:9999/',
singleApi: 'http://api-test2.yohops.com:9999/',
global: 'http://global-test-soa.yohops.com:9999',
liveApi: 'http://testapi.live.yohops.com:9999/',
... ... @@ -26,7 +26,7 @@ const domains = {
module.exports = {
app: 'h5',
appVersion: '5.9.0', // 调用api的版本
appVersion: '5.9.1', // 调用api的版本
port: 6001,
siteUrl: '//m.yohobuy.com',
assetUrl: '//127.0.0.1:5001',
... ...
... ... @@ -23,6 +23,9 @@ module.exports = () => {
if (req.query.nogoback || req.cookies.nogoback) {
res.locals.nogoback = true;
}
if (req.yoho.isMarsApp) {
res.locals.nodownload = true;
}
next();
};
... ...
... ... @@ -67,7 +67,7 @@ exports.serverError = () => {
return res.render('error/app-auth', {
module: 'common',
page: 'app-redirect-login',
message: '验证失败,请登录',
message: '请登录',
localCss: true,
refer: err.refer
});
... ...
... ... @@ -104,7 +104,13 @@ const sortParams = (req, res, next) => {
if (_.every(matched, match => match)) {
return next();
} else {
return res.redirect(helpers.urlFormat('/', sorts, 'list'));
let subdomain = 'list';
if (req.hostname.indexOf('search') === 0) {
subdomain = 'search';
}
return res.redirect(helpers.urlFormat('/', sorts, subdomain));
}
};
... ...
... ... @@ -43,8 +43,6 @@ module.exports = () => {
pageChannel: {}
};
let ua = (req.get('User-Agent') || '').toLowerCase();
const channel = req.query.channel || req.cookies._Channel || 'boys';
// IP 地址
... ... @@ -57,12 +55,15 @@ module.exports = () => {
yoho.channel = channel;
// 判断请求是否来自app
yoho.isApp = (req.query.app_version && req.query.app_version !== 'false') ||
(req.query.appVersion && req.query.appVersion !== 'false') ||
req.cookies.app_version || /YohoBuy/i.test(req.get('User-Agent') || '');
yoho.isMarsApp = /yohomars/i.test(req.get('User-Agent') || '');
yoho.isApp = yoho.isMarsApp ||
req.cookies.app_version ||
/YohoBuy/i.test(req.get('User-Agent') || '') ||
(req.query.app_version && req.query.app_version !== 'false') ||
(req.query.appVersion && req.query.appVersion !== 'false');
yoho.isMobile = /(nokia|iphone|android|ipad|motorola|^mot\-|softbank|foma|docomo|kddi|up\.browser|up\.link|htc|dopod|blazer|netfront|helio|hosin|huawei|novarra|CoolPad|webos|techfaith|palmsource|blackberry|alcatel|amoi|ktouch|nexian|samsung|^sam\-|s[cg]h|^lge|ericsson|philips|sagem|wellcom|bunjalloo|maui|symbian|smartphone|midp|wap|phone|windows ce|iemobile|^spice|^bird|^zte\-|longcos|pantech|gionee|^sie\-|portalmmm|jig\s browser|hiptop|^ucweb|^benq|haier|^lct|opera\s*mobi|opera\*mini|320x320|240x320|176x220)/i.test(req.get('User-Agent') || ''); // eslint-disable-line
yoho.isWechat = /micromessenger/i.test(req.get('User-Agent') || '');
yoho.isWeibo = ua.indexOf('weibo') !== -1;
yoho.isWeibo = /weibo/i.test(req.get('User-Agent') || '');
yoho.isqq = /MQQBrowser/i.test(req.get('User-Agent') || '');
Object.assign(res.locals, yoho);
... ...
... ... @@ -77,6 +77,8 @@ module.exports = () => {
res.cookie('app_version', appVersion);
res.cookie('app_client_type', appSessionType);
}
next();
};
};
... ...
... ... @@ -59,7 +59,7 @@
<link rel="apple-touch-startup-image" sizes="640x920" href="http://static.yohobuy.com/m/v1/img/startup/startup-retina.png" media="screen and (max-device-width: 480px) and (-webkit-min-device-pixel-ratio: 2)">
<link rel="apple-touch-startup-image" sizes="320x460" href="http://static.yohobuy.com/m/v1/img/startup/startup.png" media="screen and (max-device-width: 320)">
</head>
<body class="{{pageStyle}} {{#if isWechat}}wechat-body{{/if}} {{#if width750}}width750{{/if}} {{#if isPassportPage}}passport-body{{/if}} {{#if isStarIndexPage}}star-index-bg{{/if}} {{#if isStarDetailPage}}star-class-body{{/if}} {{#if isInstallmentPage}}installment-body{{/if}}">
<body class="{{pageStyle}} {{#if isWechat}}wechat-body{{/if}} {{#if isMarsApp}}is-mars-app{{/if}} {{#if width750}}width750{{/if}} {{#if isPassportPage}}passport-body{{/if}} {{#if isStarIndexPage}}star-index-bg{{/if}} {{#if isStarDetailPage}}star-class-body{{/if}} {{#if isInstallmentPage}}installment-body{{/if}}">
<div class="main-wrap" id="main-wrap" {{#if appPath}}data-apppath='{{{appPath}}}'{{/if}}>
{{#if systemUpdate}}
{{> updata}}
... ...
... ... @@ -12,7 +12,7 @@
a.async = 1;
a.src = j;
m.parentNode.insertBefore(a, m);
}(window, document, 'script', (document.location.protocol === 'https:' ? 'https:' : 'http:') + '//cdn.yoho.cn/yas-jssdk/2.4.1/yas.js', '_yas'));
}(window, document, 'script', (document.location.protocol === 'https:' ? 'https:' : 'http:') + '//cdn.yoho.cn/yas-jssdk/2.4.2/yas.js', '_yas'));
var _hmt = _hmt || [];
... ... @@ -56,7 +56,7 @@
uid = uid === 0 ? '' : uid;
window._ozuid = uid; // 暴露ozuid
if (window._yas) {
window._yas(1 * new Date(), '2.4.1', 'yohobuy_m', uid, '', '');
window._yas(1 * new Date(), '2.4.2', 'yohobuy_m', uid, '', '');
}
setTimeout(function() {
... ...
{
"name": "m-yohobuy-node",
"version": "5.9.0",
"version": "5.9.13",
"private": true,
"description": "A New Yohobuy Project With Express",
"repository": {
... ...
... ... @@ -220,8 +220,14 @@ let question = {
}
}).then(function(data) {
that.saving = false;
if (data.code === 200) {
tipDg.show('调查问卷已成功提交,感谢您的帮助!');
if (data.code === 200 || data.code === 206) {
let tip = '调查问卷已成功提交,感谢您的帮助!';
if (data.code === 206 && data.message) {
tip = data.message;
}
tipDg.show(tip);
setTimeout(function() {
if (yoho.isApp) {
... ...
... ... @@ -2,8 +2,8 @@
require('activity/share-buy.page.css');
let $ = require('yoho-jquery'),
dialog = require('plugin/dialog'),
yoho = require('yoho-app');
yoho = require('yoho-app'),
tip = require('plugin/tip');
let $news = $('.news'),
newsLiL = $news.find('li').length,
... ... @@ -12,7 +12,7 @@ let $news = $('.news'),
let shareData = {
title: '【有货】参与分享购,大家一起拿返利~',
link: location.href,
desc: '学生用户专享,返利升级购物可直接抵现金,超级福利等你来嗨~',
desc: '返利升级购物可直接抵现金,超级福利等你来嗨~',
imgUrl: 'http://img11.static.yhbimg.com/yhb-img01/2017/05/10/16/011568a808f9b10e098b6542d3a8cb3d6b.png'
};
... ... @@ -58,17 +58,27 @@ if (newsLiL > 1) {
}
$('.join').click(function() {
if ($('.coupon-list').data('student') === false) {
dialog.showDialog({
dialogText: '完成学生认证即可参与活动哦~',
fast: true,
hasFooter: {
rightBtnText: '去认证'
$.ajax({
type: 'GET',
url: '/activity/share-buy/get-coupon-code',
data: {
couponId: $(this).data('id')
},
success: function(result) {
if (result.code === 200) {
let link = result.data.detailUrl;
if (yoho.isApp) {
link = result.data.protocol + link;
yoho.goH5(link);
} else {
window.location.href = link;
}
} else {
tip.show(result.message);
}
}, function() {
yoho.goH5('http://m.yohobuy.com/activity/student/register', '{"action":"go.h5","params":{"islogin":"N","type":"13","url":"http://m.yohobuy.com/activity/student/register"}}');
}, null, true);
}
}
});
});
... ...
... ... @@ -20,20 +20,23 @@ let params = {
endTime: [endTime] // 时间差数组
};
let noResultHbs = require('product/search/no-result-new.hbs');
let couponSum = $('.coupon-money').find('span').text();
let shareData = {
title: '发福利啦!专享优惠速来领~',
title: '【YOHO!BUY有货】送你' + couponSum + '元专享福利啦!速来领~',
link: location.href,
desc: '来YOHO玩潮流~甄选好货等你来BUY~',
desc: '1400+潮流品牌每日上新,等你来BUY!',
imgUrl: 'http://img11.static.yhbimg.com/yhb-img01/2017/05/10/16/011568a808f9b10e098b6542d3a8cb3d6b.png'
};
let appVersion, link;
let couponId = $('.coupon-info').data('id');
let initial = true;
let beforeScroll = document.body.scrollTop; // 滚动前位置记录
let listEnd = false;
require('common/share')(shareData);
require('common');
... ... @@ -42,6 +45,10 @@ if (yoho.isApp) {
shareData.link = link;
if (yoho.isAndroid) {
shareData.desc = encodeURIComponent('1400+潮流品牌每日上新,等你来BUY!');
}
yoho.ready(function() {
yoho.invokeMethod('set.shareInfo', shareData);
});
... ... @@ -111,6 +118,10 @@ function productData() {
noLazy: true,
};
if (listEnd) {
return false;
}
if (appVersion) {
setting.app_version = appVersion;
}
... ... @@ -125,6 +136,7 @@ function productData() {
if (!onloading) {
onloading = true;
page = page + 1;
$.ajax({
type: 'GET',
... ... @@ -133,20 +145,28 @@ function productData() {
xhrFields: {
withCredentials: true
},
complete: function() {
onloading = false;
},
success: function(data) {
if (data === '' || (data.list && data.list.length <= 0)) {
$container.html(noResultHbs());
if (initial) {
$('.commodity').hide();
}
listEnd = true;
return false;
} else {
$container.append(data);
}
onloading = false;
initial = false;
}
});
}
page = page + 1;
}
// 滚动加载
... ... @@ -160,7 +180,16 @@ function scrollHandler() {
}
$(window).scroll(function() {
window.requestAnimationFrame(scrollHandler);
setTimeout(function() {
let afterScroll = document.body.scrollTop;
if (afterScroll - beforeScroll > 0) {
window.requestAnimationFrame(scrollHandler);
beforeScroll = afterScroll;
} else {
return false;
}
}, 5);
});
$(function() {
... ...
... ... @@ -256,28 +256,30 @@ $.extend({
5. yas的cookies 种在 .yohobuy.com 根域下
周奇琪
*/
let isWechat = /micromessenger/i.test(navigator.userAgent || '');
let mktc = queryString().mkt_code || queryString().union_type || '';
function saveMktCode() {
if (mktc) {
setCookie('mkt_code', mktc, {
path: '/',
domain: 'yohobuy.com',
expires: 7 // 7天
});
}
}
mkt_code 控制移动到 YAS 2017.07.13
*/
if (isWechat) {
saveMktCode();
} else {
if (!cookie('mkt_code') || mktc === '100000000000349') {
saveMktCode();
}
}
// let isWechat = /micromessenger/i.test(navigator.userAgent || '');
// let mktc = queryString().mkt_code || queryString().union_type || '';
// function saveMktCode() {
// if (mktc) {
// setCookie('mkt_code', mktc, {
// path: '/',
// domain: 'yohobuy.com',
// expires: 7 // 7天
// });
// }
// }
// if (isWechat) {
// saveMktCode();
// } else {
// if (!cookie('mkt_code') || mktc === '100000000000349') {
// saveMktCode();
// }
// }
// 尝试打开 APP
require('./common/open-app');
... ...
... ... @@ -186,16 +186,18 @@ class ChosePanel {
$yohoPage.on('touchstart', '#chose-btn-buynow', (e) => {
let sku = this._checkSku(this.buyNum);
window._yas.sendCustomInfo({
op: 'YB_GDS_BUYNOW_BTN',
param: JSON.stringify({
C_ID: this.C_ID,
PRD_ID: this.data.cartInfo.productId,
PRD_NUM: this.buyNum,
PRD_SKN: this.data.cartInfo.productSkn,
PRD_SKU: sku && sku.skuId
})
}, true);
if (window._yas && window._yas.sendCustomInfo) {
window._yas.sendCustomInfo({
op: 'YB_GDS_BUYNOW_BTN',
param: JSON.stringify({
C_ID: this.C_ID,
PRD_ID: this.data.cartInfo.productId,
PRD_NUM: this.buyNum,
PRD_SKN: this.data.cartInfo.productSkn,
PRD_SKU: sku && sku.skuId
})
}, true);
}
return this._choseBtnSureClick(e, true);
});
}
... ...
... ... @@ -71,6 +71,7 @@ $usernameInput.bind('input propertychange', function() {
// 提交表单请求
$addressForm.on('submit', function() {
let username = $usernameInput.val().replace(/(^\s+)|(\s+$)/g, '');
let phone = $(this).find('[name="mobile"]').val();
if (isSubmiting) {
return false;
... ... @@ -95,6 +96,12 @@ $addressForm.on('submit', function() {
tip.show('手机号不能为空');
return false;
}
if (!(/^[0-9]{11}$/.test(phone))) {
tip.show('请填写正确的手机号');
return false;
}
if (!$(this).find('[name="area_code"]').val() || !$(this).find('[name="area"]').val() ||
$(this).find('[name="area_code"]').val().length < 6) {
tip.show('省市区不能为空');
... ...
... ... @@ -82,3 +82,4 @@ $('.res-c').on('click', 'a', function() {
}, true);
}
});
... ...
... ... @@ -17,7 +17,7 @@ let introUrl = $('#introUrl').val(),
end = false;
$('#is-deposit-advance').on('click', function() {
tip.show('定金预售商品只能在APP端购买');
tip.show('定金预售商品只能在有货App购买');
});
// 判断是否要显示向左滑动提示
... ...
let $ = require('yoho-jquery'),
tip = require('plugin/tip');
tip = require('plugin/tip'),
yoho = require('yoho-app');
let functions = {
/**
... ... @@ -68,6 +69,17 @@ let functions = {
* 添加到购物车
*/
addToCart(sku, skn, buyNum) {
if (!yoho.isLogin()) {
let preInfo = `${sku}_${skn}_${buyNum}`;
let actCkOpthn = {
path: '/',
expires: 1
};
window.setCookie('tmp-cart-info', preInfo, actCkOpthn);
window.location.href = '//m.yohobuy.com/signin.html?refer=' + encodeURIComponent(window.location.href);
return false;
}
if (window._yas && window._yas.sendCustomInfo) {
window._yas.sendCustomInfo({
op: 'YB_GDS_DT_ADD_TO_SC',
... ... @@ -100,6 +112,7 @@ let functions = {
cartNum = '99+';
}
$('.num-tag').html(cartNum).removeClass('hide');
window.setCookie('tmp-cart-info', '');
}
if (res.message) {
... ...
... ... @@ -151,7 +151,7 @@ function render(data) {
if (data.isDepositAdvance === 'Y') {
setTimeout(function() {
$('#addtoCart').text('立即购买').off('touchstart').on('touchstart', function() {
tip.show('定金预售商品只能在APP端购买');
tip.show('定金预售商品只能在有货App购买');
return false;
});
}, 200);
... ...
... ... @@ -7,6 +7,7 @@ let productSkn = $('#productSkn').val();
let brandId = $('#brand-id').val();
let shopId = $('#shopId').val();
let bundleType = $('#bundleType').val();
let yoho = require('yoho-app');
require('common');
... ... @@ -21,6 +22,26 @@ require('./detail/recommend-for-you-product-desc');
let detailFuns = require('./detail/functions');
let productName = $('.goods-name .name').text();
let productPic = $('.banner-container').find('img:first').attr('src');
if (productPic && productPic.indexOf('http:') < 0) {
productPic = `http:${productPic}`;
}
let shareData = {
title: `推荐这本城市指南给你:${productName}`,
link: location.href,
desc: '最近很多 KOL 在推!据说是探索城市必备神器',
desCircle: `最近被刷屏的这本城市指南终于可以买到了!${productName}`,
imgUrl: productPic
};
if (yoho.isMarsApp) {
yoho.ready(function() {
yoho.invokeMethod('set.shareInfo', shareData);
});
}
window.rePosFooter && window.rePosFooter();
setTimeout(() => {
... ... @@ -87,7 +108,7 @@ setTimeout(() => {
setTimeout(function() {
$('#isDepositAdvance').on('touchstart', function() {
tip.show('定金预售商品只能在APP端购买');
tip.show('定金预售商品只能在有货App购买');
return false;
});
}, 200);
... ... @@ -155,6 +176,16 @@ setTimeout(() => {
let chosePanel = require('common/chose-panel-new');
if (window.cookie('tmp-cart-info') && yoho.isLogin()) {
let preInfo = window.cookie('tmp-cart-info').split('_');
if (preInfo[1] === $('#productSkn').val()) {
detailFuns.addToCart(preInfo[0], preInfo[1], preInfo[2]);
} else {
window.setCookie('tmp-cart-info', '');
}
}
$('#addtoCart, #ticketsToCart').on('touchstart', function() {
let productCode = $('#limitProductCode').val();
let seckill = $('.seckill-time').length;
... ... @@ -180,8 +211,14 @@ setTimeout(() => {
return;
}
if (result.buyNow) { // 立即购买
location.href = '/cart/index/buynow/orderensure?product_sku=' +
let nextUrl = location.origin + '/cart/index/buynow/orderensure?product_sku=' +
result.sku.skuId + '&buy_number=' + result.buyNum;
if (yoho.isMarsApp && !yoho.isLogin()) {
yoho.goLogin(nextUrl);
} else {
location.href = nextUrl;
}
return;
}
detailFuns.addToCart(result.sku.skuId, productSkn, result.buyNum);
... ... @@ -368,7 +405,8 @@ setTimeout(() => {
// 加载详情页的返回顶部按钮并注册事件
$(document).scroll(function() {
if ($(document).scrollTop() >= $(document).height() - $(window).height() - 120) {
if (($(document).scrollTop() >= $(document).height() - $(window).height() - 120) &&
$('.back-to-top').length > 0) {
let top = $('.back-to-top').offset().top - $('.float-top').offset().top +
($('.back-to-top').height() - $('.float-top').height()) / 2;
let left = $('.back-to-top').offset().left - $('.float-top').offset().left;
... ...
... ... @@ -37,7 +37,10 @@ yoho = {
/**
* 判断是否是 APP
*/
isApp: /YohoBuy/i.test(navigator.userAgent || '') || qs && qs.app_version || cookie.get('app_version'),
isMarsApp: /YohoMars/i.test(navigator.userAgent || ''),
isApp: /YohoMars/i.test(navigator.userAgent || '') ||
/YohoBuy/i.test(navigator.userAgent || '') ||
qs && qs.app_version || cookie.get('app_version'),
isiOS: /\(i[^;]+;( U;)? CPU.+Mac OS X/i.test(navigator.userAgent || ''),
isAndroid: /Android/i.test(navigator.userAgent || ''),
... ... @@ -46,13 +49,6 @@ yoho = {
*/
data: window.yohoInterfaceData,
/**
* 判断是否是 登录
*/
isLogin: function() {
return cookie.get('_YOHOUID');
},
ready: function(callback) {
if (this.isApp) {
document.addEventListener('deviceready', callback);
... ... @@ -121,17 +117,29 @@ yoho = {
getUid: function() {
if (yoho.isApp) {
return qs.uid;
return qs.uid || cookie.get('_YOHOUID') || cookie.get('app_uid');
}
return window.getUid();
},
/**
* 判断是否是 登录
*/
isLogin: function() {
return this.getUid();
},
goLogin: function(refer, data) {
let url;
if (refer.indexOf('//') === 0) {
refer = location.protocol + refer;
}
url = 'http://m.yohobuy.com/signin.html?refer=' + encodeURIComponent(refer);
refer = yoho.parseUrl(refer || location.href);
if (this.isApp) {
url = location.href;
if (this.isAndroid) {
... ...
... ... @@ -353,3 +353,9 @@
}
}
}
.is-mars-app {
.my-page {
padding-bottom: 120px;
}
}
... ...
... ... @@ -257,3 +257,9 @@
}
}
}
.is-mars-app {
.yoho-header {
display: none;
}
}
... ...
... ... @@ -1190,3 +1190,29 @@ $basicBtnC: #eb0313;
iframe {
display: none;
}
.is-mars-app {
.good-detail-page {
margin-bottom: 140px;
.addto-cart,
.sold-out {
background-color: #000;
margin-left: 100px;
}
.cart-bar {
.num-tag {
background-color: #89b374;
}
.new-foot-ico.fav {
display: none;
}
}
.suspend-home {
display: none;
}
}
}
... ...
... ... @@ -715,3 +715,9 @@
left: 0;
}
}
.is-mars-app {
.collect {
display: none;
}
}
... ...
... ... @@ -76,3 +76,9 @@
background-size: contain;
}
}
.is-mars-app {
#collect {
display: none;
}
}
... ...
... ... @@ -2,7 +2,7 @@
* @Author: Targaryen
* @Date: 2017-03-23 11:02:31
* @Last Modified by: Targaryen
* @Last Modified time: 2017-05-26 16:42:29
* @Last Modified time: 2017-07-18 14:29:33
*/
/* 红人店铺数据处理 */
... ... @@ -152,13 +152,18 @@ const _tools = {
* @param {*} moduleData
*/
tripleImage(moduleData) {
let displayType = _.get(moduleData, 'properties.displayType', 0);
let displayType = parseInt(_.get(moduleData, 'properties.displayType', 0), 10);
// 没有展示方式,不展示此模块,处理接口返回数据异常的情况
if (!displayType) {
return {};
}
return {
module_type: 'TripleImage',
pics: _picsHandle(moduleData),
isModuleMargin: _.get(moduleData, 'properties.isModuleMargin', 0),
displayType: parseInt(displayType, 10),
displayType: displayType,
};
},
... ...