Authored by 陈峰

Merge branch 'release/0110' into 'master'

Release/0110



See merge request !1666
Showing 50 changed files with 723 additions and 135 deletions
... ... @@ -2,6 +2,15 @@ const _ = require('lodash');
const {YOLUCK_LIST_TYPE, YoLuckService} = require('../models/yoluck-service');
function _handelErrorMessage(e) {
if (e && e.statusCode === 503) {
e.title = '人数过多。。。';
e.message = '目前参与人数过多请点击刷新';
}
return e;
}
function index(req, res, next) {
let type = +req.query.type || YOLUCK_LIST_TYPE.running;
let uid = req.user.uid;
... ... @@ -17,7 +26,7 @@ function index(req, res, next) {
`/signin.html?refer=//m.yohobuy.com/activity/yoluck/index.html?type=${YOLUCK_LIST_TYPE.joined}`
);
} else {
return next(result.error);
return Promise.reject(result.error);
}
}
... ... @@ -30,8 +39,7 @@ function index(req, res, next) {
width750: true,
wechatShare: true
});
}).catch(next);
}).catch(e => next(_handelErrorMessage(e)));
}
function nextPage(req, res, next) {
... ... @@ -82,7 +90,7 @@ function detail(req, res, next) {
wechatShare: true
});
}).catch(next);
}).catch(e => next(_handelErrorMessage(e)));
}
... ... @@ -92,9 +100,9 @@ function getCode(req, res, next) {
const uid = req.user.uid;
if (!actPrizeId) {
return {
return res.json({
error: '活动参数错误'
};
});
}
req.ctx(YoLuckService).getCode({shareUid, uid, actPrizeId}).then(result => {
... ... @@ -106,11 +114,30 @@ function getCode(req, res, next) {
}).catch(next);
}
function getActivityCodeList(req, res, next) {
const actPrizeId = req.body.id;
const uid = req.user.uid;
if (!actPrizeId || !uid) {
return res.json({code: 200, data: []});
}
req.ctx(YoLuckService).getActivityCodeList(req.user.uid, actPrizeId).then(result => {
if (result.error) {
return res.json({code: 404, message: result.error});
}
res.json({code: 200, data: result});
}).catch(next);
}
module.exports = {
index,
nextPage,
detail,
getCode
getCode,
getActivityCodeList
};
... ...
... ... @@ -69,7 +69,9 @@ class YoLuckApi extends global.yoho.BaseModel {
*/
getList({page, type}) {
return yoLuckApi.get(MODULE + '/list', {
page, type
page,
type,
channel: 0
}).then(result => {
if (result.code === 200) {
const products = result.data;
... ... @@ -111,7 +113,10 @@ class YoLuckApi extends global.yoho.BaseModel {
* @returns {Promise}
*/
getRecommend({actPrizeId}) {
return yoLuckApi.get(MODULE + '/list/recommend', {actPrizeId}).then(result => {
return yoLuckApi.get(MODULE + '/list/recommend', {
actPrizeId,
channel: 0
}).then(result => {
if (result.code === 200) {
const products = result.data;
const newProducts = products.map((p) => {
... ... @@ -145,7 +150,17 @@ class YoLuckApi extends global.yoho.BaseModel {
* @returns {Promise}
*/
getMyList({page, type, limit, uid}) {
return yoLuckApi.get(MODULE + '/list/mine', {type, page, uid, limit});
return yoLuckApi.get(MODULE + '/list/mine', {type, page, uid, limit, channel: 0});
}
/**
* 我的抽奖码列表(单个活动)
* @param uid
* @param actPrizeId
* @returns {Promise}
*/
getMyListWithActid(uid, actPrizeId) {
return yoLuckApi.get(MODULE + '/code/mine', {uid, actPrizeId});
}
/**
... ... @@ -184,6 +199,12 @@ class YoLuckApi extends global.yoho.BaseModel {
}
_getUsreInfo(uid) {
if (!uid) {
return Promise.resolve({
code: 400
});
}
return this.get({
data: {
method: 'app.passport.profile',
... ...
... ... @@ -212,14 +212,18 @@ class YoLuckService extends global.yoho.BaseModel {
}
async getDetail(actPrizeId, uid) {
const [r1, r2, r3] = await Promise.all([
let userName = uid && _.get(this.ctx.req, 'user.NAME');
const [r1, r2, r3, r4] = await Promise.all([
this._getDetail(actPrizeId, uid),
this._getRecentAvatars(actPrizeId),
this.getDetailBanner()
this.getDetailBanner(),
userName ? Promise.resolve({}) : this.api._getUsreInfo(uid)
]);
const result = {};
result.userName = userName || _.get(r4, 'data.nickname', '') || '';
result.actPrizeId = actPrizeId;
result.product = !r1.error ? r1 : {};
result.avatars = !r2.error ? r2.map(i => {
... ... @@ -237,7 +241,19 @@ class YoLuckService extends global.yoho.BaseModel {
participantCount = r1.limit;
}
result.product.participantCount = this.formatN('000000', participantCount).split('');
let notice;
try {
notice = JSON.parse(result.product.notice);
} catch (e) {} // eslint-disable-line
notice = _.assign({}, notice);
notice.content = notice.content || '关注公众号“潮流有货”,发送“开奖”查看中奖结果';
notice.h5BtnName = notice.h5BtnName || '关注';
result.product.notice = notice;
result.product.participantCount = participantCount;
result.actionStatus = this.setActionStatus(result.product);
result.resource = r3;
... ... @@ -441,7 +457,11 @@ class YoLuckService extends global.yoho.BaseModel {
};
}
return result.data;
if (userThumb.indexOf('?') > 0) {
userThumb = _.split(userThumb, '?')[0] + '?imageView2/2/w/70/h/70/q/60';
}
return _.assign({userThumb}, result.data);
} catch (e) {
logger.error(e);
... ... @@ -450,6 +470,33 @@ class YoLuckService extends global.yoho.BaseModel {
};
}
}
async getActivityCodeList(uid, actPrizeId) {
let result = await this.api.getMyListWithActid(uid, actPrizeId);
let codeList = [];
let nearAvatar = '//img10.static.yhbimg.com/headimg/2013/11/28/09/01cae078abe5fe320c88cdf4c220212688.gif?imageView/2/w/100/h/100'; // eslint-disable-line
_.forEach(_.get(result, 'data', []), value => {
if (value.prize_code) {
if (value.user_thumb.indexOf('headimg') > 0) {
value.user_thumb = nearAvatar;
} else {
if (value.user_thumb.indexOf('?') > 0) {
value.user_thumb = _.split(value.user_thumb, '?')[0] + '?imageView2/2/w/70/h/70/q/60';
}
nearAvatar = value.user_thumb;
}
codeList.push({
prizeCode: value.prize_code,
userThumb: value.user_thumb
});
}
});
return codeList;
}
}
module.exports = {
... ...
... ... @@ -361,5 +361,6 @@ router.get('/yoluck/next', yoluck.nextPage);
router.get('/yoluck/:id.html', yoluck.detail);
router.post('/yoluck/:id.html', auth, yoluck.getCode);
router.post('/yoluck/detail/mylist.html', yoluck.getActivityCodeList);
module.exports = router;
... ...
... ... @@ -16,12 +16,12 @@
{{! 侧悬浮}}
{{#isEqualOr param.linkTarget '1' '3'}}
<a href="{{param.sidebarPageId}}" class="sidebar-link" target="_blank">
<img src="{{param.icon}}">
<img src="{{imageslim param.icon}}">
</a>
{{/isEqualOr}}
{{#isEqualOr param.linkTarget '2'}}
<div id="sidebar" pageid="{{param.sidebarPageId}}">
<img src="{{param.icon}}">
<img src="{{imageslim param.icon}}">
</div>
{{/isEqualOr}}
{{/isEqualOr}}
... ...
{{#result}}
<div id="hide-info" data-username="{{userName}}"></div>
{{#if product.status}}
{{#unless @root.isApp}}
<div class="fellow-bar-wrap">
{{> yoluck/fellow-bar}}
</div>
{{/unless}}
{{/if}}
<div class="header">
{{> yoluck/product-detail-header product=product avatars=avatars}}
</div>
{{> yoluck/lottery-machine}}
<div class="help">
{{> yoluck/help}}
</div>
... ... @@ -11,14 +23,8 @@
<div class="line"></div>
{{#if product.status}}
<div class="fellow-bar">
{{> yoluck/fellow-bar}}
</div>
{{/if}}
<div class="action-bar-wrap">
{{> yoluck/action-bar status=actionStatus num=myPrizeCount actPrizeId=actPrizeId}}
{{> yoluck/action-bar status=actionStatus num=myPrizeCount actPrizeId=actPrizeId lotteryInfo=product.lottery_info}}
</div>
<div class="foot"></div>
... ...
... ... @@ -21,7 +21,7 @@
{{#ifcond list.length '!==' 0}}
<div class="js-panel-header">
<img
src="http://img11.static.yhbimg.com/yhb-img01/2018/12/07/15/0188307712613ce043d4b68a94761ee1ff.gif"
src="//img11.static.yhbimg.com/yhb-img01/2018/12/07/15/0188307712613ce043d4b68a94761ee1ff.gif"
alt="">
</div>
{{/ifcond}}
... ...
... ... @@ -24,8 +24,8 @@
</a>
<div class="sales-imgs-new">
{{#isEqualOr isAdvance '1'}}
<div class="advance" style="background-image: url({{advanceBgImg}});">
<img src="{{advanceBgImg}}" class="img-seat">
<div class="advance" style="background-image: url({{imageslim advanceBgImg}});">
<img src="{{imageslim advanceBgImg}}" class="img-seat">
<span class="advance-price"></span>
</div>
{{/isEqualOr}}
... ...
... ... @@ -21,8 +21,8 @@
<img class="product-detail-img lazy" src="">
<div class="sales-imgs-old sales-product-pool">
{{#isEqualOr isAdvance '1'}}
<div class="advance" style="background-image: url({{advanceBgImg}});">
<img src="{{advanceBgImg}}" class="img-seat">
<div class="advance" style="background-image: url({{imageslim advanceBgImg}});">
<img src="{{imageslim advanceBgImg}}" class="img-seat">
<span class="advance-price"></span>
</div>
{{/isEqualOr}}
... ...
... ... @@ -31,7 +31,7 @@
我的抽奖码({{num}})
</a>
<div class="action-item ok js-fellow">
<div class="action-item ok js-lottery" data-lottery='{{lotteryInfo}}'>
查看开奖结果
</div>
{{/ifcond}}
... ...
<div class="fellow-bar-comp">
<div class="fellow-bar">
<div class="title">关注有货公众号“潮流有货”,开奖后查看中奖结果</div>
<div class="btn js-fellow">去关注</div>
<div id="fellow-bar" class="fellow-bar" data-type='{{product.notice.h5BtnType}}' data-tip='{{product.notice.h5Tip}}' data-copy='{{product.notice.h5Copy}}' data-link='{{product.notice.h5Link}}'>
<div class="title">{{product.notice.content}}</div>
<div class="btn js-fellow">{{product.notice.h5BtnName}}</div>
</div>
</div>
... ...
<div class="lottery-machine">
<div class="machine">
<img src="//img12.static.yhbimg.com/sns/2018/12/21/14/0231fa07f32886117eccea846e03f453a3.png">
<div class="lottery-block">
<div id="lottery-list" class="lottery-list">
<div class="lottery lottery-tpl">
<div class="l-thumb"></div>
<p class="l-title">我的<br>抽奖码</p>
<p class="l-code"></p>
</div>
<p class="more-lottery">
<a href="/activity/yoluck/index.html?type=3">
<span class="iconfont">&#xe64f;</span>
</a>
</p>
</div>
</div>
</div>
</div>
... ...
... ... @@ -17,7 +17,7 @@
{{/ifcond}}
{{#ifcond status '===' 4}}
<div class="btn more js-fellow">查看中奖信息</div>
<div class="btn more js-fellow" data-id="{{act_prize_id}}" data-lottery="{{lottery_info}}">查看中奖信息</div>
{{/ifcond}}
{{#ifcond status '===' 5}}
... ...
... ... @@ -182,6 +182,19 @@ const common = {
}
next();
},
wechatQuickLoginCheck: (req, res, next) => {
let refer = req.query.refer;
// 仅yoluck业务展示快捷登陆引导页
if (req.yoho.isWechat && refer && refer.indexOf('activity/yoluck') > 0) {
_.assign(res.locals, {
wechatQuickLoginRefer: encodeURIComponent(refer),
useWechatQuickLogin: true
});
}
next();
},
clearCookie: (req, res, next) => {
res.clearCookie('_SESSION_KEY', {
domain: 'yohobuy.com'
... ...
... ... @@ -147,6 +147,7 @@ const loginNew = new LoginNew();
router.get('/passport/login',
login.common.clearCookie,
login.common.wechatQuickLoginCheck,
validateCode.load,
login.common.beforeLogin,
loginNew.loginPage); // 普通登录
... ... @@ -164,6 +165,7 @@ router.post('/passport/register-new',
reg.register); // 注册请求
router.get('/passport/sms_login',
login.common.clearCookie,
login.common.wechatQuickLoginCheck,
validateCode.load,
smsLogin.smsLoginPage); // 短信验证码登录
router.post('/passport/sms_login/step1_check', validateCode.check, smsLogin.indexCheck);
... ... @@ -174,6 +176,7 @@ router.get('/signin.html',
login.common.thirdLogin,
// login.common.weixinCheck,
login.common.wechatQuickLoginCheck,
validateCode.load,
login.common.beforeLogin,
smsLogin.smsLoginPage); // 短信验证码登录
... ... @@ -181,6 +184,7 @@ router.get('/signin.html',
router.get('/signin.htm',
login.common.clearCookie,
login.common.thirdLogin,
login.common.wechatQuickLoginCheck,
validateCode.load,
login.common.beforeLogin,
smsLogin.smsLoginPage); // 短信验证码登录
... ...
... ... @@ -26,7 +26,7 @@
<a id="getPswrdBtn" href="javascript:void(0);">忘记密码?</a>
</div>
</form>
{{!-- <div class="third-party-login">
{{!-- <div class="third-party-login">
<div class="tip-box">
<span class="left-line"></span>
<span class="tip">使用第三方登录</span>
... ... @@ -48,4 +48,5 @@
<a class="by-mobile" onclick="location.href='{{phoneRetriveUrl}}'">手机找回</a>
</div>
</div>
{{> passport/wechat-quick-login}}
</div>
... ...
... ... @@ -35,7 +35,7 @@
<a id="getPswrdBtn" href="javascript:void(0);">忘记密码?</a>
</div>
</form>
{{!-- <div class="third-party-login">
{{!-- <div class="third-party-login">
<div class="tip-box">
<span class="left-line"></span>
<span class="tip">使用第三方登录</span>
... ... @@ -56,4 +56,5 @@
<a class="by-mobile" onclick="location.href='{{phoneRetriveUrl}}'">手机找回</a>
</div>
</div>
{{> passport/wechat-quick-login}}
</div>
... ...
{{#if @root.useWechatQuickLogin}}
<div class="wechat-quick-wrap">
<div class="quick-login-main">
<div class="quick-login-logo"></div>
<div class="local-login-btn quick-btn">使用有货账号登录</div>
<div class="quick-login-btn quick-btn">
<a href="/passport/login/wechat?refer={{@root.wechatQuickLoginRefer}}">微信快捷登录</a>
</div>
</div>
</div>
{{/if}}
... ...
... ... @@ -25,6 +25,33 @@ const forceNoCache = (res) => {
}
};
const _err503 = (req, res, code, err) => {
res.status(code);
if (req.xhr) {
return res.json({
code: err.code,
message: err.message || '服务器繁忙请稍后重试!'
});
}
return res.render('error/510', {
err: err,
module: 'common',
page: 'error',
title: err.title || '服务器繁忙 | Yoho!Buy有货 | 潮流购物逛不停',
pageHeader: headerModel.setNav({
navTitle: err.title || err.message || '服务器繁忙请稍后重试!'
}),
showRefresh: {
message: err.message,
btnName: '刷新重试'
},
pageFooter: true,
isErr: true
});
};
const _err510 = (req, res, code, err) => {
res.status(code);
... ... @@ -196,6 +223,8 @@ exports.serverError = () => {
} else if (err.code === 9999991 || err.code === 9999992) {
return _err510(req, res, 510, err);
} else if (+err.statusCode === 503) {
return _err503(req, res, 510, err);
}
if (!res.headersSent) {
... ...
<div class="err-page yoho-page">
<div class="err-bg"></div>
<div class="err-bg {{#if showRefresh}}err-refresh{{/if}}">
{{#showRefresh}}
<div class="refresh-wrap">
<p class="refresh-msg">{{message}}</p>
<a class="refresh-btn" href="javascript:void(0)" onclick="location.reload()" >{{btnName}}</a>
</div>
{{/showRefresh}}
</div>
</div>
... ...
{
"name": "yohobuywap-node",
"version": "6.8.67",
"version": "6.8.71",
"private": true,
"description": "A New Yohobuy Project With Express",
"repository": {
... ... @@ -88,7 +88,7 @@
"xml2js": "^0.4.19",
"yoho-express-session": "^2.0.0",
"yoho-md5": "^2.0.0",
"yoho-node-lib": "=0.6.41",
"yoho-node-lib": "=0.6.43",
"yoho-zookeeper": "^1.0.10"
},
"devDependencies": {
... ... @@ -134,7 +134,7 @@
"workbox-sw": "^2.1.2",
"workbox-webpack-plugin": "^3.4.1",
"yo-cli": "=2.1.9",
"yoho-activity-sdk": "1.1.2",
"yoho-activity-sdk": "1.1.3",
"yoho-cookie": "^1.2.0",
"yoho-fastclick": "^1.0.6",
"yoho-hammer": "^2.0.8",
... ...
No preview for this file type
... ... @@ -20,13 +20,6 @@ Created by iconfont
/>
<missing-glyph />
<glyph glyph-name="x" unicode="x" horiz-adv-x="1001"
d="M281 543q-27 -1 -53 -1h-83q-18 0 -36.5 -6t-32.5 -18.5t-23 -32t-9 -45.5v-76h912v41q0 16 -0.5 30t-0.5 18q0 13 -5 29t-17 29.5t-31.5 22.5t-49.5 9h-133v-97h-438v97zM955 310v-52q0 -23 0.5 -52t0.5 -58t-10.5 -47.5t-26 -30t-33 -16t-31.5 -4.5q-14 -1 -29.5 -0.5
t-29.5 0.5h-32l-45 128h-439l-44 -128h-29h-34q-20 0 -45 1q-25 0 -41 9.5t-25.5 23t-13.5 29.5t-4 30v167h911zM163 247q-12 0 -21 -8.5t-9 -21.5t9 -21.5t21 -8.5q13 0 22 8.5t9 21.5t-9 21.5t-22 8.5zM316 123q-8 -26 -14 -48q-5 -19 -10.5 -37t-7.5 -25t-3 -15t1 -14.5
t9.5 -10.5t21.5 -4h37h67h81h80h64h36q23 0 34 12t2 38q-5 13 -9.5 30.5t-9.5 34.5q-5 19 -11 39h-368zM336 498v228q0 11 2.5 23t10 21.5t20.5 15.5t34 6h188q31 0 51.5 -14.5t20.5 -52.5v-227h-327z" />
<glyph glyph-name="more" unicode="&#58886;" d="M109.3993 511.067c49.7953 0 90.1676-40.3716 90.1676-90.1649s-40.3723-90.1659-90.1676-90.1659c-49.7973 0-90.1696 40.3726-90.1696 90.1659S59.603 511.067 109.3993 511.067zM515.1578 511.067c49.7953 0 90.1686-40.3716 90.1686-90.1649s-40.3723-90.1659-90.1686-90.1659c-49.7963 0-90.1696 40.3726-90.1696 90.1659S465.3616 511.067 515.1578 511.067zM920.9144 511.067c49.7963 0 90.1696-40.3716 90.1696-90.1649s-40.3723-90.1659-90.1696-90.1659c-49.7943 0-90.1686 40.3726-90.1686 90.1659S871.1201 511.067 920.9144 511.067z" horiz-adv-x="1000" />
... ... @@ -270,6 +263,9 @@ t9.5 -10.5t21.5 -4h37h67h81h80h64h36q23 0 34 12t2 38q-5 13 -9.5 30.5t-9.5 34.5q-
<glyph glyph-name="2" unicode="&#58957;" d="M561.511784 223.813189l109.097514 0 0-110.702703-109.097514 0 0 110.702703ZM888.942703 223.813189l109.097514 0 0-110.702703-109.097514 0 0 110.702703ZM561.594811 113.387243l109.097514 0 0-110.702703-109.097514 0 0 110.702703ZM437.524757 458.447568 0 458.447568 0 896l437.524757 0L437.524757 458.447568zM110.702703 569.15027l216.119351 0L326.822054 785.297297 110.702703 785.297297 110.702703 569.15027zM999.507027 458.087784 561.98227 458.087784 561.98227 895.612541l437.524757 0L999.507027 458.087784zM672.684973 568.790486l216.119351 0 0 216.147027-216.119351 0L672.684973 568.790486zM437.524757-105.776432 0-105.776432l0 437.552432 437.524757 0L437.524757-105.776432zM110.702703 4.92627l216.119351 0 0 216.147027L110.702703 221.073297 110.702703 4.92627zM561.207351 334.792649l221.405405 0 0-110.702703-221.405405 0 0 110.702703ZM888.942703 333.934703l109.097514 0 0-110.702703-109.097514 0 0 110.702703ZM779.540757 112.695351l109.097514 0 0-110.702703-109.097514 0 0 110.702703ZM562.065297 2.407784l217.945946 0 0-110.702703-217.945946 0 0 110.702703ZM888.942703 2.407784l109.097514 0 0-110.702703-109.097514 0 0 110.702703Z" horiz-adv-x="1024" />
<glyph glyph-name="more-down" unicode="&#58959;" d="M503.074 322.55100000000004a51.6864 51.6864 0 0 1 73.3184 0l369.707 370.492a52.224 52.224 0 0 1 0 73.6597 51.6693 51.6693 0 0 1-73.3184 0L539.716 432.93 206.652 766.703a51.6693 51.6693 0 0 1-73.3184 0 52.2667 52.2667 0 0 1 0-73.6597l369.741-370.492Zm369.707 122.871L539.716 111.65899999999999 206.652 445.423a51.6693 51.6693 0 0 1-73.3184 0 52.2496 52.2496 0 0 1 0-73.6427l369.732-370.492a51.7035 51.7035 0 0 1 73.3184 0l369.741 370.492a52.2581 52.2581 0 0 1 0 73.6427 51.7035 51.7035 0 0 1-73.344 0Z" horiz-adv-x="1079" />
<glyph glyph-name="cuxiaobiaoqian" unicode="&#59061;" d="M512 896C228.505967 896 0 667.494033 0 384 0 101.727924 228.505967-128 512-128 794.272076-128 1024 101.727924 1024 384 1024 667.494033 794.272076 896 512 896z m277.384248-526.663484l-85.536993-85.536993-51.322195 51.322195 64.763723 64.763724 1.221957 183.293556-182.071599-1.221957-277.384248-276.162292c-2.443914-2.443914-2.443914-7.331742 0-9.775656l171.073985-171.073986c3.665871-3.665871 6.109785-3.665871 9.775657 0L601.202864 285.02148l51.322196-51.322196-160.076373-161.298329c-15.885442-15.885442-36.658711-23.217184-57.431981-23.217184s-41.546539 7.331742-57.43198 23.217184l-171.073986 171.073985c-31.770883 31.770883-31.770883 81.871122 0 113.642005l296.935561 296.935561 287.159904 2.443914-1.221957-287.159904z" horiz-adv-x="1024" />
... ...
No preview for this file type
No preview for this file type
... ... @@ -17,7 +17,7 @@
{{/ifcond}}
{{#ifcond status '===' 4}}
<div class="btn more js-fellow">查看中奖信息</div>
<div class="btn more js-fellow" data-id="{{act_prize_id}}">查看中奖信息</div>
{{/ifcond}}
{{#ifcond status '===' 5}}
... ...
... ... @@ -9,11 +9,13 @@ let formatCountDown = require('./yoluck/formatCountDown');
let YolukcApi = require('./yoluck/api');
let api = new YolukcApi();
let tip = require('js/plugin/tip');
let dialog = require('js/plugin/dialog');
let yoSdk = require('yoho-activity-sdk');
let yoho = require('js/yoho-app');
let Clipboard = require('clipboard');
let makeShareData = require('./yoluck/share');
let Lottery = require('./yoluck/lottery');
let versionCompare = require('./yoluck/version');
function reload() {
... ... @@ -21,6 +23,7 @@ function reload() {
}
require('js/plugin/modal.alert');
require('js/common');
let store = {
running: false,
... ... @@ -29,6 +32,9 @@ let store = {
targetVersion: '6.8.3',
};
let hideInfo = $('#hide-info').remove().data();
let $fellowBar = $('#fellow-bar');
let $product = $('.product_name');
let name = $product.data('name');
let img = $product.data('img');
... ... @@ -37,6 +43,9 @@ let id = $product.data('id');
let user;
let shareData;
let lottery = new Lottery('#lottery-list');
let sharePlugin = require('js/common/share');
loading.init($(document.body), {timeout: 20000});
new Swiper('.swiper-container', {
direction: 'vertical',
... ... @@ -46,7 +55,14 @@ new Swiper('.swiper-container', {
autoplay: 4000
});
function fellow() {
function fellow(content) {
if (content) {
$.yAlert({
content: `<div class="fellow-tip-content">${content}</div>` // eslint-disable-line
});
return;
}
$.yAlert({
content: `<div>公众号
<span style="font-weight: bolder">“潮流有货”</span>已经复制成功,</div>
... ... @@ -71,8 +87,11 @@ function getUser() {
imgUrl: img,
price: price,
shareUid: user && user.uid,
userName: hideInfo && hideInfo.username,
actPrizeId: id
});
sharePlugin(shareData.h5);
});
} catch (e) {
return Promise.resolve();
... ... @@ -81,6 +100,16 @@ function getUser() {
getUser();
(function() {
api.getDetailMyCode({id}).then(res => {
if (res.code !== 200) {
return;
}
lottery.print(res.data);
});
}());
function share() {
if (yoSdk.env === 'app') {
// 由于app版本兼容性问题
... ... @@ -102,6 +131,9 @@ function share() {
loading.hideLoading();
store.running = false;
});
} else if (/QQ/i.test(navigator.userAgent) ||
/MicroMessenger/i.test(navigator.userAgent)) {
dialog.showDialog({hasClass: 'yoluck-guide-mask'});
} else if (yoSdk.env === 'h5') {
$('.js-clipbroad').trigger('click');
}
... ... @@ -137,20 +169,69 @@ let luckAlert = {
}
};
let clipboardFellow = new Clipboard('.js-fellow', {
text: function() {
return '潮流有货';
let fellowInfo = $fellowBar.data() || {};
if (+fellowInfo.type === 2) {
$fellowBar.on('click', '.js-fellow', function() {
if (fellowInfo.link) {
window.location.href = fellowInfo.link;
}
});
} else {
let clipboardFellow = new Clipboard('.js-fellow', {
text: function() {
return fellowInfo.copy || '潮流有货';
}
});
clipboardFellow.on('success', function(e) {
fellow(fellowInfo.tip);
tip.show('内容已复制', 2000);
e.clearSelection();
});
}
(function() {
let lotteryInfo = $('.js-lottery').data('lottery') || {};
let clipboardLottery = new Clipboard('.js-lottery', {
text: function() {
return lotteryInfo.h5Copy || '潮流有货';
}
});
clipboardLottery.on('success', function(e) {
fellow(lotteryInfo.h5Tip);
tip.show('内容已复制', 2000);
e.clearSelection();
});
let clickFn;
if (lotteryInfo) {
if (yoSdk.env === 'app' && lotteryInfo.app) {
clickFn = function() {
$.yAlert({
content: `<div>本期中奖号码: <span style="font-weight: bolder;">${lotteryInfo.app}</span></div>` // eslint-disable-line
});
};
} else if (yoSdk.env === 'h5' && +lotteryInfo.h5Type) {
if (+lotteryInfo.h5Type === 2 && lotteryInfo.h5Link) {
clickFn = function() {
window.location.href = lotteryInfo.h5Link;
};
}
}
}
});
clipboardFellow.on('success', function(e) {
fellow();
e.clearSelection();
});
if (clickFn) {
clipboardLottery.destroy();
$('.js-lottery').on('click', clickFn);
}
}());
let clipboardShare = new Clipboard('.js-clipbroad', {
text: function() {
return shareData && shareData.h5.link;
return shareData && shareData.h5.copyDeac;
}
});
... ... @@ -163,6 +244,11 @@ clipboardShare.on('success', function(e) {
e.clearSelection();
});
if (window.cookie('yoluck_share') && store.shareUid) {
window.setCookie('yoluck_share', null);
share();
}
luckAlert.init();
setInterval(() => {
... ... @@ -185,6 +271,7 @@ $('.action-bar-comp').on('click', '.js-join', function() {
store.running = true;
api.getCode({shareUid: store.shareUid, ...yoSdk.getQueryObj()}).then(result => {
if (result.code === 200) {
lottery.print(result.data);
luckAlert.show(result.data.prizeCode);
} else {
if (result.code === 400) {
... ...
import 'scss/activity/yoluck/yoluck-list.page.scss';
const cookie = require('yoho-cookie');
const loading = require('js/plugin/loading');
let $ = require('yoho-jquery');
let Api = require('./yoluck/api');
... ... @@ -10,12 +9,11 @@ let timeCountDownTpl = require('hbs/activity/yoluck/time-countdown.hbs');
let formatCountDown = require('./yoluck/formatCountDown');
let yoSdk = require('yoho-activity-sdk');
let yoho = require('js/yoho-app');
const tip = require('js/plugin/tip');
const makeShareData = require('./yoluck/share');
const DETAIL_URI = location.protocol + '//m.yohobuy.com/activity/yoluck';
let tip = require('js/plugin/tip');
let Clipboard = require('clipboard');
let versionCompare = require('./yoluck/version');
let publicCopyInfo = '';
require('js/plugin/modal.alert');
... ... @@ -52,8 +50,24 @@ let tabpanelStore = {
footer: null
};
let currentVersion = cookie.get('app_version');
let targetVersion = '6.8.3';
let prizeListStore = {
push(arr) {
if (!arr || !arr.length) {
return;
}
this.list = this.list || {};
$.each(arr, (index, value) => {
if (value && value.act_prize_id) {
this.list[value.act_prize_id] = value;
}
});
},
get(id) {
return this.list && this.list[id];
}
};
function initStore() {
// 初始化为
... ... @@ -125,6 +139,8 @@ function fetchPage(page, index) {
let $node = tabpanelStore.nodes.eq(index);
let $products = prizeListTpl({running: result.data[0], finished: result.data[1]});
prizeListStore.push(result.data[1]);
$node.find('.js-panel-body').html($products);
} else {
let $node = tabpanelStore.nodes.eq(index);
... ... @@ -180,7 +196,40 @@ function onReachBottom(type) {
fetchPage(page, store.tabIndex);
}
function fellow() {
function fellow(id, lottery) {
let info = prizeListStore.get(id);
let lotteryInfo;
if (info && info.lottery_info) {
try {
lotteryInfo = $.parseJSON(info.lottery_info);
} catch(e) {} // eslint-disable-line
}
lotteryInfo = lotteryInfo || lottery;
if (lotteryInfo) {
if (yoSdk.env === 'app' && lotteryInfo.app) {
$.yAlert({
content: `<div class="modal-view-lottery">本期中奖号码: <span style="font-weight: bolder;">${lotteryInfo.app}</span></div>` // eslint-disable-line
});
return;
} else if (yoSdk.env === 'h5' && +lotteryInfo.h5Type) {
if (+lotteryInfo.h5Type === 1) {
$.yAlert({
content: `<div class="modal-view-lottery">${lotteryInfo.h5Tip}</div>` // eslint-disable-line
});
publicCopyInfo = lotteryInfo.h5Copy || '';
$('.js-clipbroad').trigger('click');
} else if (lotteryInfo.h5Link) {
window.location.href = lotteryInfo.h5Link;
}
return;
}
}
$.yAlert({
content: `<div>微信搜索公众号</div>
<div><span style="font-weight: bolder;">“潮流有货”</span>并关注,发送</div>
... ... @@ -188,10 +237,6 @@ function fellow() {
});
}
function alertVersion() {
$.yAlert({content: '您的版本较低,请更新最新版本体验'});
}
function getUser() {
try {
if (store.user) {
... ... @@ -209,61 +254,20 @@ function getUser() {
}
}
function share($el) {
let name = $el.data('name');
let img = $el.data('img');
let price = $el.data('price');
let id = $el.data('id');
store.shareData = makeShareData({
name,
imgUrl: img,
price: price,
actPrizeId: id,
shareUid: store.user && store.user.uid
});
if (yoSdk.env === 'app') {
// 由于app版本兼容性问题
if (versionCompare(currentVersion, targetVersion) < 0) {
alertVersion();
return;
}
loading.showLoading();
if (store.running) {
return;
}
store.running = true;
getUser().then(() => {
yoho.invokeMethod('go.showshareaction', store.shareData && store.shareData.app);
loading.hideLoading();
store.running = false;
});
} else if (yoSdk.env === 'h5') {
$('.js-clipbroad').trigger('click');
}
}
bus$.add(onTabClick);
bus$.add(onReachBottom);
function initClipboard() {
let clipboardShare = new Clipboard('.js-clipbroad', {
let _clipboard = new Clipboard('.js-clipbroad', {
text: function() {
return store.shareData && store.shareData.h5.link;
return publicCopyInfo;
}
});
clipboardShare.on('success', function(e) {
if (yoSdk.env === 'app') {
return;
_clipboard.on('success', function() {
if (publicCopyInfo) {
tip.show('内容已复制', 2000);
}
tip.show('复制成功,发送给好友为您助力', 3500);
e.clearSelection();
});
}
... ... @@ -308,12 +312,8 @@ $tabpanel
return false;
})
.on('click', '.js-share', function() {
share($(this));
return false;
})
.on('click', '.js-fellow', function() {
fellow();
fellow($(this).data('id'), $(this).data('lottery'));
return false;
});
... ...
... ... @@ -18,6 +18,10 @@ class Api {
getCode(params) {
return $.post('', params);
}
getDetailMyCode(params) {
return $.post(this.url + '/detail/mylist.html', params);
}
}
module.exports = Api;
... ...
let $ = require('yoho-jquery');
class Lottery {
constructor(seletor) {
this.$list = $(seletor);
if (!this.$list.length) {
return;
}
this.$block = this.$list.parent();
this.$tpl = this.$list.find('.lottery-tpl');
this.tpl = this.$tpl.prop('outerHTML');
}
print(lottery) {
if (!this.$list.length) {
return;
}
if (lottery) {
if (!Array.isArray(lottery)) {
lottery = [lottery];
}
if (lottery.length > 3) {
lottery.length = 3;
this.$list.addClass('more');
}
for (let i = 0; i < lottery.length; i++) {
let info = lottery[i];
if (!info || !info.prizeCode) {
return;
}
let $lottery = $(this.tpl).removeClass('lottery-tpl');
$lottery.find('.l-code').text(info.prizeCode);
$lottery.find('.l-thumb').html('<img src="' + info.userThumb + '">');
this.$tpl.after($lottery);
}
}
this.$block.animate({
height: this.$list.height()
}, this.$list.children().length * 300);
}
}
module.exports = Lottery;
... ...
... ... @@ -12,38 +12,43 @@ function h5Path(shareUid, actPrizeId) {
return location.protocol + `//m.yohobuy.com/activity/yoluck/${actPrizeId}.html?shareUid=${shareUid}`;
}
function h5Name(name) {
return `【0元抽奖】${name}`;
function shareName(userName) {
return `${userName || ''}邀请你参加0元抽奖活动`;
}
function h5Desc(name) {
return `【限时抽奖】0元免费拿${name}`;
function shareDesc(name) {
return `奖品:${name}`;
}
function shareData({name, imgUrl, price, shareUid, actPrizeId}) {
function shareData({name, imgUrl, price, shareUid, userName, actPrizeId}) {
let link = h5Path(shareUid, actPrizeId);
let urls = imgUrl.split('?');
let shareImg = urls[0] || imgUrl;
if (urls[0]) {
shareImg = `${shareImg}?imageView2/2/w/375/h/235/q/60`;
}
userName = userName || '';
return {
app: {
shareType: 'yoluck',
title: name,
title: shareName(userName),
imgUrl: shareImg,
market_price: price,
miniProgramUrl: miniPath(shareUid, actPrizeId),
miniProgramQCodeUrl: miniQrcode(shareUid, actPrizeId),
link: h5Path(shareUid, actPrizeId),
desc: h5Desc(name),
link: link,
desc: shareDesc(name),
hideType: ['7', '8', '9']
},
h5: {
title: h5Name(name),
title: shareName(userName),
imgUrl: imgUrl,
link: h5Path(shareUid, actPrizeId),
desc: h5Desc(name)
link: link,
desc: shareDesc(name),
copyDeac: `【0元抽奖】点一下免费拿走${name} ${link} (分享自@Yoho!Buy有货APP)`
}
};
}
... ...
... ... @@ -14,6 +14,8 @@ const validate = new Validate($captcha, {
}
});
require('./wechat-quick-login');
class Login {
constructor() {
this.view = {
... ...
const $ = require('yoho-jquery');
(function() {
let $quickWrap = $('.wechat-quick-wrap');
if (!$quickWrap.length) {
return;
}
$quickWrap.on('click', '.local-login-btn', function() {
$quickWrap.hide();
});
}());
... ...
... ... @@ -13,6 +13,8 @@ const validate = new Validate($captcha, {
}
});
require('../login/wechat-quick-login');
class SmsLoginNew extends Page {
constructor() {
super();
... ...
.fellow-bar-comp {
height: 66px;
.fellow-bar {
display: flex;
justify-content: space-between;
... ... @@ -12,19 +14,32 @@
}
.title {
max-width: 76%;
color: white;
font-size: 20px;
margin-bottom: 0 !important;
text-overflow: -o-ellipsis-lastline;
overflow: hidden;
text-overflow: ellipsis;
display: -webkit-box;
-webkit-line-clamp: 2;
line-clamp: 2;
-webkit-box-orient: vertical;
}
.btn {
max-width: 160px;
display: inline-block;
color: white;
width: 100px;
padding: 0 16px;
height: 40px;
font-size: 24px;
line-height: 40px;
background-color: #d0021b;
text-align: center;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
box-sizing: border-box;
}
}
... ...
.lottery-machine {
position: relatve;
display: flex;
justify-content: center;
.machine {
width: 620px;
min-height: 300px;
margin-right: -20px;
> img {
width: 100%;
position: relative;
z-index: -1;
}
}
.lottery-block {
width: 414px;
margin-left: 84px;
margin-top: -146px;
overflow: hidden;
height: 0;
position: relative;
z-index: 1;
&:before {
content: "";
width: 100%;
height: 10px;
position: absolute;
left: 0;
top: -12px;
z-index: 10;
box-shadow: 0 10px 20px #000;
}
}
.lottery-list {
position: absolute;
bottom: 0;
.lottery:first-child {
margin-top: -144px;
}
.lottery {
width: 414px;
height: 166px;
background: url("img/activity/yoluck/lottery.png");
background-size: 100% 100%;
margin-top: -14px;
padding: 0 20px 10px;
display: flex;
align-items: center;
.l-thumb {
width: 60px;
height: 60px;
border-radius: 50%;
overflow: hidden;
margin-left: 14px;
background-image: url("//img10.static.yhbimg.com/headimg/2013/11/28/09/01cae078abe5fe320c88cdf4c220212688.gif");
background-size: 100% 100%;
}
.l-title {
font-size: 16px;
margin-left: 8px;
}
.l-code {
font-size: 30px;
color: #222;
flex-grow: 1;
text-align: center;
}
}
.more-lottery {
font-size: 22px;
line-height: 60px;
text-align: center;
color: #555;
display: none;
&:before {
content: "";
width: 100%;
height: 40px;
margin-top: -40px;
background: url("img/activity/yoluck/lottery-more.png");
background-size: 100%;
background-repeat: no-repeat;
display: block;
position: relative;
z-index: -1;
}
a {
display: block;
width: 100%;
}
}
&.more {
.lottery:last-child {
background-color: #eee;
}
.more-lottery {
display: block;
}
}
}
}
... ...
... ... @@ -14,13 +14,14 @@
color: #444;
margin-left: 32px;
margin-right: 32px;
text-align: left;
}
.product_lucky_bg {
display: flex;
flex-direction: row;
align-items: baseline;
justify-content: center;
justify-content: space-between;
margin-left: 32px;
margin-right: 32px;
}
... ...
@import "help";
@import "product-detail-header";
@import "lottery-machine";
@import "desc";
@import "more";
@import "fellow-bar";
... ... @@ -24,7 +25,6 @@
position: relative;
text-align: center;
overflow: hidden;
margin-top: 56px;
}
.help {
... ... @@ -113,3 +113,23 @@
text-align: center;
border-top: 1px solid #e0e0e0;
}
.dialog-wrapper .dialog-box.yoluck-guide-mask {
width: 284px;
height: 278px;
background: url("img/activity/yoluck/share-tip.png");
background-size: 100% 100%;
margin: 0 !important;
border: 0;
right: 92px;
top: 28px !important;
left: auto;
> * {
display: none !important;
}
}
.yoho-tip {
top: 350px;
}
... ...
... ... @@ -79,3 +79,17 @@
.bottom-banner {
width: 100%;
}
.bottom-banner-img {
width: 100%;
height: 234px;
}
.modal-view-lottery {
padding-top: 20px;
word-break: break-all;
}
.yoho-tip {
top: 350px;
}
... ...
... ... @@ -6,7 +6,7 @@
bottom: 0;
left: 0;
display: none;
z-index: 2;
z-index: 20;
.dialog-box {
width: 540px;
... ...
... ... @@ -10,4 +10,31 @@
background: url("img/common/404.png") no-repeat;
background-size: 100% 100%;
}
.err-refresh {
margin-top: -250px;
}
.refresh-wrap {
width: 460px;
position: absolute;
left: 50%;
top: 100%;
margin-left: -230px;
text-align: center;
.refresh-msg {
line-height: 1.4;
padding: 20px 0;
}
.refresh-btn {
width: 200px;
line-height: 60px;
background-color: #414141;
display: block;
color: #fff;
margin: 10px auto;
}
}
}
... ...
... ... @@ -100,7 +100,7 @@ button {
color: #fff;
font-size: 24px;
border: none;
z-index: 100;
z-index: 1000;
box-sizing: border-box;
border-radius: 10PX;
}
... ...
@import "~scss/layout/img-check";
@import "wechat-quick-login";
@mixin banner-box-elem {
position: absolute;
... ...
@import "~scss/layout/img-check";
@import "wechat-quick-login";
@mixin banner-box-elem {
position: absolute;
... ...
.wechat-quick-wrap {
position: fixed;
top: 0;
bottom: 0;
left: 0;
right: 0;
background: #fff;
z-index: 9999;
display: flex;
justify-content: center;
align-items: center;
.quick-login-main {
width: 100%;
margin-top: -50px;
}
.quick-login-logo {
width: 372px;
height: 374px;
background-image: url("img/passport/quick-login-logo.png");
background-size: 100% 100%;
margin: auto;
margin-bottom: 180px;
}
.quick-btn {
width: 68%;
height: 80px;
color: #fff;
line-height: 82px;
background-color: #444;
margin: 30px auto;
text-align: center;
border-radius: 40px;
overflow: hidden;
a {
width: 100%;
color: #fff;
display: block;
}
}
}
... ...
This diff could not be displayed because it is too large.