Authored by 郭成尧

'mergemaster'

/**
* 邀请好友赢福利
* <xiaoxiao.hao@yoho.cn>
* 2016/07/13
*/
'use strict';
const inviteModel = require('../models/invite');
const inviteTitle = '有货 邀请好友赢福利';
const _ = require('lodash');
const md5 = require('md5');
const secretKey = '5466ee572bcbc75830d044e66ab429bc';// 秘钥
// 简介、好友领取列表页面
exports.index = (req, res, next) => {
let actId = req.query.act_id * 1 || 0;
let uid = req.query.uid || 0;
let renderPage = 'invite/list';
inviteModel.index({
uid: uid,
activityId: actId
}).then((result) => {
// 非法参数跳到首页
if (result.isGo) {
res.redirect('/');
return false;
}
if (result.isNil) {
renderPage = 'invite/intro';
}
res.render(renderPage, {
module: 'activity',
page: 'invite',
result: result,
title: inviteTitle
});
}).catch(next);
};
// 微信好友获取红包方法(即分享出去的地址)页面
exports.share = (req, res, next) => {
let shareUid = req.params[0];
let actId = req.params[1];
let nums = req.params[2];
let shareUrl = inviteModel.createShareUrl(shareUid, actId, nums);
let callback = 'http://m.yohobuy.com/activity/invite/getwxinfo?url=' + shareUrl;
let url = inviteModel.getWxOauthUrl(callback);
let wxUserInfo = req.cookies.wxUserInfo || {};
if (_.isEmpty(wxUserInfo) || _.isEmpty(wxUserInfo.unionid)) {
res.redirect(url);
return false;
}
inviteModel.shareModel({
uid: shareUid,
activityId: actId,
nums: nums,
openId: wxUserInfo.unionid,
nickName: wxUserInfo.nickname,
headImgUrl: wxUserInfo.headimgurl
}).then(result => {
if (result.code * 1 !== 200) {
res.redirect('/');
return false;
}
if (_.isEmpty(result.data.list)) {
res.render('invite/myshare', {
module: 'activity',
page: 'invite',
result: {
shareUid: shareUid,
nums: nums,
actId: actId,
openId: wxUserInfo.unionid
},
title: inviteTitle
});
} else {
// 是自己分享的连接
res.render('invite/list', {
module: 'activity',
page: 'invite',
result: result.data.list,
title: inviteTitle
});
}
}).catch(next);
};
// 发送短信验证码API
exports.sendRegCodeToMobile = (req, res, next) => {
let mobile = req.query.mobile || '';
inviteModel.sendRegCodeToMobile({
area: 86,
mobile: mobile
}).then((result) => {
res.json(result);
}).catch(next);
};
// 发送已注册用户参与活动的优惠券API
exports.checkOldUserCoupon = (req, res, next) => {
let mobile = req.query.mobile || '';
let actId = req.query.actId || '';
inviteModel.checkOldUserCoupon({
mobile: mobile,
activityId: actId
}).then((result) => {
res.json(result);
}).catch(next);
};
// 验证手机验证码是否正确API
exports.validRegCode = (req, res, next) => {
let mobile = req.query.mobile || '';
let code = req.query.code || '';
inviteModel.validRegCode({
area: 86,
mobile: mobile,
code: code
}).then((result) => {
res.json(result);
}).catch(next);
};
// 手机注册账号API
exports.register = (req, res, next) => {
let mobile = req.query.mobile || '';
let activityName = req.query.activityName || 'invite';
inviteModel.register({
mobile: mobile,
activityName: activityName
}).then((result) => {
res.json(result);
}).catch(next);
};
// 领福利-领取优惠券API
exports.receiveCoupons = (req, res, next) => {
let uid = req.query.uid;
let actId = req.query.actId;
let nums = req.query.nums;
let shareUid = req.query.shareUid;
let openId = req.query.openId;
inviteModel.receiveCoupons({
uid: uid,
activityId: actId,
nums: nums,
shareUid: shareUid,
openId: openId
}).then((result) => {
if (result.code === 200) {
result.data.goUrl = result.data.goUrl +
'?amount=' + result.data.couponAmount +
'&sign=' + md5(result.data.couponAmount + secretKey);
}
res.json(result);
}).catch(next);
};
// 好友领取优惠券成功页面
exports.myCoupons = (req, res, next) => {
let shareUid = req.params[0];
let amount = req.params[1];
let actId = req.params[2];
let nums = req.params[3];
let sign = req.query.sign;
let uid = req.cookies.inviteUid || '';
// 这个只是过滤一下非法的参数
if (md5(amount + secretKey) !== sign || _.isEmpty(uid)) {
res.redirect('/');
return false;
}
inviteModel.myCoupons({
uid: uid,
shareUid: shareUid,
nums: nums,
amount: amount,
activityId: actId
}).then((result) => {
// 非法参数跳到首页
if (result[0].isGo || result[0].isEmpty) {
res.redirect('/');
return false;
}
res.render('invite/mycoupons', {
module: 'activity',
page: 'invite',
result: result[0],
userInfo: result[1],
amount: amount,
title: inviteTitle
});
}).catch(next);
};
// 好友领取完页面
exports.shareover = (req, res) => {
let amount = req.query.amount * 1 || 5;
let sign = req.query.sign;
if (md5(amount + secretKey) !== sign) {
res.redirect('/');
return false;
}
res.render('invite/shareover', {
module: 'activity',
page: 'invite',
result: {
amount: amount
},
title: inviteTitle
});
};
// 接收微信返回后的信息
exports.getwxinfo = (req, res, next) => {
let url = req.query.url;
let code = req.query.code;
inviteModel.getWxUserInfo({
code: code
}).then((result) => {
if (result === false) {
res.redirect('/');
} else {
res.cookie('wxUserInfo', result, {
domain: 'yohobuy.com'
});
res.redirect(url);
}
}).catch(next);
};
// 活动结束页面
exports.over = (req, res) => {
res.render('invite/over', {
module: 'activity',
page: 'invite',
result: [],
title: inviteTitle
});
};
... ...
'use strict';
const api = global.yoho.API;
const camelCase = global.yoho.camelCase;
const _ = require('lodash');
/* 微信相关 */
const wxCode = {
wxAppId: 'wx75e5a7c0c88e45c2',
wxAppSecret: 'ce21ae4a3f93852279175a167e54509b'
};
/**
* 获取微信授权地址
* @param callback
* @returns {string}
*/
const getWxOauthUrl = (callback) => {
return 'https://open.weixin.qq.com/connect/oauth2/authorize?appid=' +
wxCode.wxAppId + '&redirect_uri=' + callback +
'&response_type=code&scope=snsapi_userinfo#wechat_redirect';
};
/**
* 生成分享url
* @param shareUid
* @param actId
* @param nums
* @returns {string}
*/
const createShareUrl = (shareUid, actId, nums) => {
return 'http://m.yohobuy.com/activity/invite/share_' + shareUid + '_' + actId + '_' + nums + '.html';
};
/**
* 根据第三方id,查询绑定信息
* @param {[string || array]} openIds 第三方id数组
* @return {[array]}
*/
const getBindLogByOpenId = (openIds) => {
openIds = _.isArray(openIds) ? openIds : [openIds];
return api.get('', {
method: 'wap.invite.getBindLogByOpenId',
openIds: openIds.join(',')
});
};
/**
* 合并第三方头像和昵称
* @param {[array]} data 邀请的用户列表,最主要的是openId字段
* @return {[array]}
*/
const mergeBindLogDate = (data) => {
let openIds = [];
let photo = '//static.yohobuy.com/m/v1/activity/newyear/images/108.png';
// 取5条
data = _.slice(data, 0, 5);
_.forEach(data, (req) => {
openIds.push(req.openId);
});
return getBindLogByOpenId(openIds).then(result => {
if (!_.isEmpty(result.data)) {
_.forEach(data, (req, key) => {
data[key].img = photo;
_.forEach(result.data, (bind) => {
if (req.openId === bind.openId) {
data[key].img = _.isEmpty(bind.snsHeadimg) ?
photo : bind.snsHeadimg;
data[key].nick = bind.snsNick;
}
});
});
}
return data;
});
};
/**
* 获取分享页面列表数据
* @param {[int]} uid 用户id
* @param {[int]} activityId 活动id
* @return {[array]}
*/
const index = (params) => {
params = params || {};
return api.get('', Object.assign({
method: 'wap.invite.index'
}, params
)).then((result) => {
let firstData = {
isNil: false,
isEmpty: false,
isFive: false,
isGo: false,
remainData: ['', '', '', '', ''],
data: []
};
switch (result.code) {
case 401:
// 没有分享记录
firstData.isNil = true;
break;
case 200:
return mergeBindLogDate(result.data).then(data => {
let len = data.length;
// 判断是否否5条分享
result.data = data;
if (len === 0) {
firstData.isEmpty = true;
} else if (len < 5) {
firstData.remainData =
_.slice(firstData.remainData, 0, 5 - len);
} else {
firstData.isFive = true;
firstData.remainData = [];
}
return Object.assign(firstData, camelCase(result));
});
default:
// 活动状态不正确
firstData.isGo = true;
break;
}
return Object.assign(firstData, camelCase(result));
});
};
/**
* 通过手机号发送验证码
* @param {[int]} area 区域,中国:86
* @param {[string]} mobile 手机号
* @return {[array]}
*/
const sendRegCodeToMobile = (params) => {
return api.get('', Object.assign({
method: 'app.register.sendRegCodeToMobile'
}, params));
};
/**
* 发送已注册用户参与活动的优惠券
* @param {[string]} mobile 手机号
* @param {[int]} activityId 活动id
* @return {[array]}
*/
const checkOldUserCoupon = (params) => {
return api.get('', Object.assign({
method: 'wap.invite.checkOldUserCoupon'
}, params));
};
/**
* 验证手机验证码是否正确
* @param {[int]} area 区域,中国:86
* @param {[string]} mobile 手机号
* @param {[int]} code 验证码
* @return {[array]}
*/
const validRegCode = (params) => {
return api.get('', Object.assign({
method: 'app.register.validRegCode'
}, params));
};
/**
* 手机账号注册
* @param {[string]} mobile 手机号
* @param {[string]} activityName 活动名称
* @return {[array]}
*/
const register = (params) => {
return api.get('', Object.assign({
method: 'wap.invite.register'
}, params));
};
/**
* 微信好友获取红包方法(即分享出去的地址)
* @param {[int]} uid 分享用户id
* @param {[int]} activityId 活动id
* @param {[int]} nums 发送优惠券的数量
* @param {[String]} openId 微信的union_id
* @param {[String]} nickName 微信昵称
* @param {[String]} headImgUrl 微信头像
* @returns {[array]}
*/
const shareModel = (params) => {
let firstData = {
isEmpty: false,
isFive: false,
isGo: false,
remainData: ['', '', '', '', ''],
data: []
};
let listData = [];
// 这里面的逻辑就是获取第三方用户的头像和昵称,然后插入数据和更新数据
return api.get('', Object.assign({
method: 'wap.invite.share'
}, params))
.then((result) => {
// list为空,说明不是分享者本人
if (result.code !== 200 || _.isEmpty(result.data.list)) {
return result;
}
return mergeBindLogDate(result.data.list).then(data => {
let len = data.length;
// 判断是否满5条分享
listData = data;
if (len === 0) {
firstData.isEmpty = true;
} else if (len < 5) {
firstData.remainData =
_.slice(firstData.remainData, 0, 5 - len);
} else {
firstData.isFive = true;
firstData.remainData = [];
}
firstData.data = listData;
result.data.list = firstData;
// 释放内存
listData = [];
return camelCase(result);
});
});
};
/**
* 邀请好友赢福利之后领取优惠券
* @param {[int]} uid 用户id
* @param {[int]} activityId 活动id
* @param {[int]} nums 发送优惠券的数量
* @param {[int]} shareUid 分享者的uid
* @param {[string]} openId 微信的union_id
* @returns {[array]}
*/
const receiveCoupons = (params) => {
return api.get('', Object.assign({
method: 'wap.invite.receiveCoupons'
}, params));
};
/**
* 获取分享列表和用户信息
* @param {[int]} uid 用户id
* @param {[int]} shareUid 分享着uid
* @param {[int]} nums 发送优惠券的数量
* @param {[int]} amount 金额
* @param {[int]} activityId 活动id
* @return {[array]}
*/
const myCoupons = (params) => {
let mobile;
let firstData = {
isEmpty: false,
isFive: false,
isGo: false,
remainData: ['', '', '', '', ''],
data: []
};
let listData = [];
return api.get('', Object.assign({
method: 'wap.invite.myCoupons'
}, params)).then((result) => {
if (result.code !== 200) {
return result;
}
return mergeBindLogDate(result.data.list).then(data => {
listData = data;
if (listData.length < 5) {
firstData.remainData =
_.slice(firstData.remainData, 0, 5 - listData.length);
} else {
firstData.isFive = true;
firstData.remainData = [];
}
firstData.data = listData;
result.data.list = firstData;
mobile = result.data.myProfile.mobile;
result.data.myProfile.encMobile = mobile.replace(mobile.substring(3, 7), '****');
// 释放内存
listData = [];
return camelCase([result.data.list, result.data.myProfile]);
});
});
};
/**
* 授权后获取微信用户信息
* @return {[array]}
*/
const getWxUserInfo = (params) => {
let url1 = 'https://api.weixin.qq.com/sns/oauth2/access_token?appid=' +
wxCode.wxAppId + '&secret=' + wxCode.wxAppSecret + '&code=' +
params.code + '&grant_type=authorization_code';
let url2 = 'https://api.weixin.qq.com/sns/userinfo?lang=zh_CN';
return api._requestFromAPI({
url: url1,
qs: {},
json: true,
gzip: true,
timeout: 3000
})
.then((result) => {
if (_.isEmpty(result.openid)) {
return false;
}
url2 = url2 + '&access_token=' + result.access_token +
'&openid=' + result.openid;
return api._requestFromAPI({
url: url2,
qs: {},
json: true,
gzip: true,
timeout: 3000
})
.then((result2) => {
return result2;
});
});
};
module.exports = {
index,
shareModel,
getBindLogByOpenId,
sendRegCodeToMobile,
checkOldUserCoupon,
validRegCode,
register,
receiveCoupons,
myCoupons,
createShareUrl,
getWxOauthUrl,
getWxUserInfo
};
... ...
... ... @@ -11,6 +11,7 @@ const cRoot = './controllers';
const coupon = require(`${cRoot}/coupon`);
const wechat = require(`${cRoot}/wechat`);
const invite = require(`${cRoot}/invite`);
// routers
... ... @@ -22,4 +23,18 @@ router.get('/coupon/verify', coupon.verify);
router.get('/wechat/share', wechat.wechatShare);
router.get('/invite', invite.index);
router.get('/invite/index', invite.index);
router.get(/\/invite\/share_([\d]+)_([\d]+)_([\d]+).html/, invite.share);
router.get('/invite/sendRegCodeToMobile', invite.sendRegCodeToMobile);
router.get('/invite/checkOldUserCoupon', invite.checkOldUserCoupon);
router.get('/invite/validRegCode', invite.validRegCode);
router.get('/invite/register', invite.register);
router.get('/invite/receiveCoupons', invite.receiveCoupons);
router.get(/\/invite\/mycoupons_([\d]+)_([\d]+)_([\d]+)_([\d]+).html/, invite.myCoupons); // 好友领取完优惠券的页面
router.get('/invite/getwxinfo', invite.getwxinfo);
router.get('/invite/shareover', invite.shareover);
router.get('/invite/over', invite.over);
module.exports = router;
... ...
<div class="invite-page invite-page-bg">
<div class="invite-content-list">
<div>
<img src="//cdn.yoho.cn/m-yohobuy-node/assets/img/activity/invite/title_new.png" />
<br />
<p class="fz14">只需1位小伙伴领取,<br/>即得<strong class="fz17">10元现金券</strong><br/>全部领完,可继续发,上不封顶!<br/>奔跑吧,潮人们!</p>
<a href="javascript:void(0)" class="weal-btn fz16" id="send_gift">立刻发福利</a>
<h2 class="rule-tit fz15">活动细则</h2>
<ol class="rule-con hide">
<li>本次活动所获现金券仅限Yoho!Buy有货商城购买商品使用,不得转借他人,不可兑换现金;</li>
<li>一个订单只可使用一张优惠券,优惠券需在有效期内使用,过期则无法使用;</li>
<li>使用优惠券支付的订单,退款结算按照实际支付金额退款,优惠券返还账户,且有效期不变;</li>
<li>本活动仅限普通消费者参与,如有代购或批发行为Yoho!Buy有货有权取消订单并做相关处理;</li>
<li>每位会员有10次发福利机会,超过10次不再赠送现金券;</li>
<li>Yoho!Buy有货在法律允许范围内拥有本规则解释权。</li>
</ol>
</div>
<div class="share-tag"><img src="//static.yohobuy.com/m/v1/img/invite/yd_share.png"></div>
</div>
</div><!--/invite-page-->
\ No newline at end of file
... ...
<div class="invite-page invite-page-bg">
<div class="invite-content-list">
{{#if result.isEmpty}}
<div class="coupon-box coupon-box02 relative mar-top-a">
<p class="fz9 bold">YUAN</p>
<strong class="fz18">现金券</strong>
<p class="fz9 bold">CPOUPON</p>
<div class="pirbox absolute">
<em class="absolute"></em>0
</div>
</div>
<p class="draw-coupon fz19 bold t-shadow">至少1位小伙伴领取<br />才能获得现金券!</p>
<p class="goon fz11 t-shadow">~继续呼唤小伙伴吧~</p>
<p class="t-shadow">(点击右上角可以继续召集哦)</p>
<ul class="list-port">
<li><p class="pic"></p></li>
<li><p class="pic"></p></li>
<li><p class="pic"></p></li>
<li><p class="pic"></p></li>
<li><p class="pic"></p></li>
</ul>
<p><a href="javascript:void(0)" class="weal-btn fz16">再次分享</a></p>
{{else if result.isFive}}
<!-- 现金券 start -->
<div class="coupon-box coupon-box02 relative mar-top-a">
<p class="fz9 bold">YUAN</p>
<strong class="fz18">现金券</strong>
<p class="fz9 bold">CPOUPON</p>
<div class="pirbox absolute">
<em class="absolute"></em>10
</div>
<div class="count-not fz11 absolute"><hr class="fn-left"><hr class="fn-right">已送达您的账户</div>
</div>
<!-- 现金券 end -->
<p class="draw-coupon fz16 bold t-shadow">您的号召力爆棚!!!</p>
<p class="fz11">已有5位小伙伴领取红包</p>
<ul class="list-port">
{{# result.data}}
<li><img class="pic" src="{{img}}"><p class="name">{{nick}}</p><p class="pon">{{couponAmount}}</p></li>
{{/ result.data}}
</ul>
<br />
<p><a href="javascript:void(0)" class="weal-btn fz16">还要发福利</a></p>
<br />
<p class="fz11 t-shadow">优惠券有效期:优惠券到账以后7天内有效(自然天)</p>
{{else}}
<!-- 现金券 start -->
<div class="coupon-box coupon-box02 relative mar-top-a">
<p class="fz9 bold">YUAN</p>
<strong class="fz18">现金券</strong>
<p class="fz9 bold">CPOUPON</p>
<div class="pirbox absolute">
<em class="absolute"></em>10
</div>
<div class="count-not fz11 absolute"><hr class="fn-left"><hr class="fn-right">已送达您的账户</div>
</div>
<!-- 现金券 end -->
<p class="draw-coupon fz19 bold t-shadow">召集5位小伙伴领取,<br>即可再发福利,赶快召唤吧!</p>
<br /><br />
<ul class="list-port">
{{# result.data}}
<li><img class="pic" src="{{img}}"><p class="name">{{nick}}</p><p class="pon">{{couponAmount}}</p></li>
{{/ result.data}}
{{# result.remainData}}
<li><p class="pic"></p></li>
{{/ result.remainData}}
</ul>
<p><a href="javascript:void(0)" class="weal-btn fz16">继续发福利</a></p>
<br />
<p class="fz11 t-shadow">优惠券有效期:优惠券到账以后7天内有效(自然天)</p>
{{/if}}
<div class="share-tag"><img src="//static.yohobuy.com/m/v1/img/invite/yd_share.png"></div>
</div>
</div><!--/invite-page-->
\ No newline at end of file
... ...
<div class="invite-page invite-page-bg">
<div class="invite-content-list">
<!-- 已有小伙伴 start -->
<div class="coupon-box coupon-box02 relative mar-top-a">
<p class="fz9 bold">YUAN</p>
<strong class="fz18">现金券</strong>
<p class="fz9 bold">CPOUPON</p>
<div class="pirbox absolute">
<em class="absolute"></em>{{amount}}
</div>
<div class="count-not fz11 absolute"><hr class="fn-left"><hr class="fn-right">已送达您的账户</div>
</div>
<p class="congratu-coupon fz15 t-shadow">{{amount}}元现金券<br/>已自动存入YOHO!有货账户 {{userInfo.encMobile}}</p>
<p class="fz11">(首次下载客户端还能再次领取10元现金券)</p>
<a href="javascript:void(0)" onclick="downLoadApp()" class="download-btn fz16" style="margin-top: 30px;">下载客户端查看</a>
<p><a href="//m.yohobuy.com" class="now-login fz14" style="border-bottom: 1px solid #fff; text-decoration:none;color:#FFF;line-height: normal;">立即登录网站使用</a></p>
<br />
<p class="fz11 t-shadow">优惠券有效期:优惠券到账以后7天内有效(自然天)</p>
<ul class="list-port">
{{# result.data}}
<li><img class="pic" src="{{img}}"><p class="name">{{nick}}</p><p class="pon">{{couponAmount}}</p></li>
{{/ result.data}}
{{# result.remainData}}
<li><p class="pic"></p></li>
{{/ result.remainData}}
</ul>
<!-- 已有小伙伴 end -->
</div>
</div><!--/invite-page-->
\ No newline at end of file
... ...
<div class="invite-page invite-page-bg">
<div class="invite-content-page">
<img src="//cdn.yoho.cn/m-yohobuy-node/assets/img/activity/invite/title_new.png" />
<h2 class="bold fz16">YoHo!Buy有货福利来袭,即领即用!</h2>
<p>全球1000+潮流品牌每日上新!</p>
<div class='invite-group relative'>
<p class="fz13">&nbsp;&nbsp;&nbsp;&nbsp;<span class='bold'>填写您的手机号码,来YOHO潮流!</span>&nbsp;&nbsp;&nbsp;&nbsp;</p>
<p class='fz11'>已注册YOHO!Buy有货的手机号不能领取哦</p><br />
<span class='send-validate-btn'>发送验证码</span>
<input type='text' placeholder='输入手机号' class='invite-mobile' />
<input type='text' placeholder='输入验证码' class='invite-code' />
<input type='hidden' name="actId" class='invite-actId' value='{{result.actId}}' />
<input type="hidden" name="nums" value="{{result.nums}}" />
<input type="hidden" name="shareUid" value="{{result.shareUid}}" />
<input type="hidden" name="openId" value="{{result.openId}}" />
<input type='button' value='领福利' class='invite-btn receive-btn'/>
</div>
<div class='invite-dialog oldget hide'>
<div class='invite-dialog-center'>
<p class="fz13 mtTop03">您已是Yoho!Buy有货的顾客,</p>
<p class="fz13">此福利仅限新用户领取,</p>
<p class="fz13">您只需下载Yoho!Buy有货手机客户端,</p>
<p class="fz13">在【我的】栏目中邀请好友领福利,</p>
<p class="fz13 mtTop04">即可赢取<strong class="fz18">10元现金券</strong></p>
<div class='btn-group'>
<input type='button' class='invite-btn cancelbtn' value='重新输入' />
<input type='button' class='invite-btn download-btn' value='立即查看' />
</div>
</div>
</div><!--/oldget-->
<div class="invite-dialog isreg hide">
<br />
<br />
<p class="fz13 mtTop03">您已经领取福利券!</p>
<p class="fz13">下载Yoho!Buy有货手机客户端,</p>
<p class="fz13">在【我的】栏目中邀请好友领福利,</p>
<p class="fz13 mtTop04">还可赢取<strong class="fz18">10元现金券</strong></p>
<br />
<div class='btn-group'>
<input type='button' class='invite-btn cancelbtn' value='重新输入' />
<input type='button' class='invite-btn download-btn' value='立即查看' />
</div>
</div><!--/isreg-->
<div class="invite-dialog ishint hide">
<div class="fz13 ishint-content">操作失败!</div>
<div class='btn-group'>
<input type='button' class='invite-btn closeBtn fw90' value='确定' />
</div>
</div><!--/ishint-->
</div>
</div><!--/invite-page-->
\ No newline at end of file
... ...
<div class="invite-page invite-page-bg">
<div class="invite-content-list">
<div>
<img src="//cdn.yoho.cn/m-yohobuy-node/assets/img/activity/invite/title_new.png" />
<br />
<p class="fz14">只需1位小伙伴领取,<br/>即得<strong class="fz17">10元现金券</strong><br/>全部领完,可继续发,上不封顶!<br/>奔跑吧,潮人们!</p>
<a href="javascript:void(0)" class="invite-btn fz16">立刻发福利</a>
<h2 class="rule-tit fz15">活动细则</h2>
</div>
<div class='invite-dialog-bg'></div>
<div class='invite-dialog over-color'>
<div class='bold invite-dialog-center'>
<br />
<br />
<p class="fz14 mtTop03">来晚了?!</p>
<p class="fz16">活动已结束!</p>
<br />
<a href='//m.yohobuy.com' class='invite-btn fw90'>继续逛潮牌</a>
</div>
</div>
</div>
</div><!--/invite-page-->
\ No newline at end of file
... ...
<div class="invite-page invite-page-bg">
<div class="invite-content-list">
<div class='mar-top-a'>
<h2 class="fz37 bold">太可惜了,</h2>
<p class="fz15 t-shadow">您与88元现金券擦肩而过!别伤心,</p>
<p class="fz22 bold">赠您{{result.amount}}元现金券</p>
<p class="t-shadow">(仅限Yobo!Buy有货客户端使用)</p>
<!-- 现金券 start -->
<div class="coupon-box coupon-box02 relative mar-top-a">
<p class="fz9 bold">YUAN</p>
<strong class="fz18">现金券</strong>
<p class="fz9 bold">CPOUPON</p>
<div class="pirbox absolute">
<em class="absolute"></em>{{result.amount}}
</div>
<div class="count-not fz11 absolute"><hr class="fn-left"><hr class="fn-right">已送达您的账户</div>
</div>
<!-- 现金券 end -->
<p class="hurry-size fz16 bold">赶紧来Yobo!Buy有货<br/>逛潮牌吧!</p>
<a href="javascript:void(0)" class="download-btn fz16">立即下载客户端</a>
<p class="fz11">优惠券有效期:优惠券到账以后7天内有效(自然天)</p>
</div>
</div>
</div><!--/invite-page-->
\ No newline at end of file
... ...
... ... @@ -120,12 +120,12 @@ const _processSideBar = (list, choosed) => {
const _getChannelResource = (params) => {
params.gender = params.gender || 'boys';
params = Object.assign({
gender: genderData[params.gender],
params = Object.assign(params, {
gender: genderData[params.gender] || '1,2,3',
content_code: contentCode[params.gender], // eslint-disable-line
page: 1,
limit: 30
}, params);
});
if (!params.uid) {
params.new_device = true; // eslint-disable-line
}
... ...
... ... @@ -11,7 +11,6 @@ const isTest = process.env.NODE_ENV === 'test';
module.exports = {
app: 'h5',
appVersion: '4.6.0', // 调用api的版本
port: 6001,
siteUrl: '//m.yohobuy.com',
domains: {
... ... @@ -40,6 +39,17 @@ module.exports = {
timeout: 1000,
retries: 0
},
interfaceShunt: {
useInterfaceShunt: false,
tencentServers: {
api: ['123.206.1.98', '123.206.2.80'],
service: ['123.206.1.98', '123.206.2.80']
},
awsServers: {
api: 'app-java-168863769.cn-north-1.elb.amazonaws.com.cn',
service: 'service-yoho-579825100.cn-north-1.elb.amazonaws.com.cn'
}
},
loggers: {
infoFile: {
name: 'info',
... ... @@ -86,7 +96,18 @@ if (isProduction) {
retries: 0
},
useOneapm: true,
useCache: true
useCache: true,
interfaceShunt: {
useInterfaceShunt: false,
tencentServers: {
api: ['123.206.1.98', '123.206.2.80'],
service: ['123.206.1.98', '123.206.2.80']
},
awsServers: {
api: 'app-java-168863769.cn-north-1.elb.amazonaws.com.cn',
service: 'service-yoho-579825100.cn-north-1.elb.amazonaws.com.cn'
}
}
});
} else if (isTest) {
Object.assign(module.exports, {
... ...
{
"name": "m-yohobuy-node",
"version": "4.8.10",
"version": "4.8.11",
"private": true,
"description": "A New Yohobuy Project With Express",
"repository": {
... ... @@ -56,7 +56,7 @@
"uuid": "^2.0.2",
"winston": "^2.2.0",
"winston-daily-rotate-file": "^1.1.4",
"yoho-node-lib": "0.0.32"
"yoho-node-lib": "0.0.40"
},
"devDependencies": {
"autoprefixer": "^6.3.7",
... ...

29.3 KB | W: | H:

29.7 KB | W: | H:

  • 2-up
  • Swipe
  • Onion skin

48.6 KB | W: | H:

47.3 KB | W: | H:

  • 2-up
  • Swipe
  • Onion skin
require('./invite/index');
... ...
var $ = require('yoho-jquery'),
loading = require('../../plugin/loading'),
tip = require('../../plugin/tip'),
inviteObj = {};
require('../../common');
inviteObj = {
el: {
$sendValidateBtn: $('.send-validate-btn'),
$inviteDialog: $('.invite-dialog'),
$isreg: $('.isreg'),
$oldget: $('.oldget'),
$receiveBtn: $('.receive-btn'),
$wealBtn: $('.weal-btn'),
$shareTag: $('.share-tag'),
$ruleTit: $('.rule-tit'),
$downloadBtn: $('.download-btn'),
// 变量
inter: 0, // 定时器变量
ischeckCode: false, // 是否成功发送验证码
actId: $('.invite-group input[name="actId"]').val(), // 活动id
shareUid: $('.invite-group input[name="shareUid"]').val(), // 分享者id
openId: $('.invite-group input[name="openId"]').val(), // 微信openId
nums: $('.invite-group input[name="nums"]').val() // 发送优惠券的次数
},
init: function() {
var $el = this.el, that = this, isreceiveBtn = false;
// 设置大背景,因为body只能后来设置,前期设置page里面
if ($('.invite-page').length > 0) {
$('body').addClass('invite-page-bg');
$('.invite-page').removeClass('invite-page-bg');
// 活动已结束背景
$('.invite-dialog-bg').css({
height: $(window).height()
});
}
// 发送验证码
$el.$sendValidateBtn.click(function() {
var mobile = $('.invite-mobile').val();
if (mobile === '' || $(this).hasClass('gray-info')) {
return true;
}
$el.ischeckCode = false;
$.ajax({
url: '/activity/invite/sendRegCodeToMobile',
data: {
mobile: mobile
},
success: function(result) {
switch (result.code) {
case 404:
// 老用户
that.ischeckOldUserCoupon(mobile);
break;
case 200:
that.setGrayInfo();
$el.ischeckCode = true;
break;
default:
that.ishintDialog(result.message);
break;
}
},
error: function() {
tip.show('发送验证码失败~');
}
});
});
// 立即分享
$el.$wealBtn.click(function() {
$el.$shareTag.fadeIn();
setTimeout(function() {
$el.$shareTag.fadeOut();
}, 2000);
});
// 活动细节
$el.$ruleTit.click(function() {
$('.rule-con').toggle();
});
// 下载app
$el.$downloadBtn.click(function() {
that.downLoadApp();
});
// 领取福利
$el.$receiveBtn.click(function() {
if (isreceiveBtn) {
return true;
}
isreceiveBtn = true;
loading.showLoadingMask();
that.receiveFun();
loading.hideLoadingMask();
isreceiveBtn = false;
});
},
// 发送已注册用户参与活动的优惠券
ischeckOldUserCoupon: function(mobile) {
var that = this, $el = this.el;
$.ajax({
url: '/activity/invite/checkOldUserCoupon',
data: {
mobile: mobile,
actId: $el.actId
},
async: false,
success: function(result) {
switch (result.code) {
case 201:
// 已经领取过
that.showDialog($el.$isreg);
break;
case 200:
// 发送慰问劵--不须要发送验证码,后台自动发送
that.showDialog($el.$oldget);
break;
default:
tip.show('发送验证码失败~');
break;
}
},
error: function() {
tip.show('发送验证码失败~');
}
});
},
// 发送验证码提示
setGrayInfo: function() {
var $el = this.el,
that = this,
timeoutPutCount = 60;
$el.$sendValidateBtn.html(timeoutPutCount + 'S');
$el.$sendValidateBtn.addClass('gray-info');
// 设置定时器
clearInterval($el.inter);
$el.inter = setInterval(function() {
$el.$sendValidateBtn.html(timeoutPutCount-- + 'S');
if (timeoutPutCount <= 0) {
that.clearGrayInfo();
}
}, 1000);
},
// 取消 验证码提示
clearGrayInfo: function() {
var $el = this.el;
clearInterval($el.inter);
$el.$sendValidateBtn.removeClass('gray-info');
$el.$sendValidateBtn.html('发送验证码');
},
// 验证验证码
receiveFun: function() {
var that = this,
$el = this.el,
mobile = $('.invite-mobile').val(),
code = $('.invite-code').val();
if (mobile === '') {
that.ishintDialog('请输入手机号!');
return true;
}
if (code === '') {
that.ishintDialog('请输入验证码!');
return true;
}
// 如果未单击发送验证码
if ($el.ischeckCode === false) {
that.ishintDialog('该验证码或已失效,请单击发送验证码!');
that.clearGrayInfo();
return true;
}
$.ajax({
url: '/activity/invite/validRegCode',
data: {
mobile: mobile,
code: code
},
async: false,
success: function(result) {
if (result.code === 200) {
// 跳注册方法
that.registerFun();
} else {
that.ishintDialog(result.message);
}
},
error: function() {
tip.show('账号注册失败,请稍后在试~');
}
});
},
// 验证码通过,跳注册方法
registerFun: function() {
var that = this,
mobile = $('.invite-mobile').val();
if (mobile === '') {
that.ishintDialog('请输入手机号!');
return true;
}
$.ajax({
url: '/activity/invite/register',
data: {
mobile: mobile
},
async: false,
success: function(result) {
switch (result.code) {
case 205:
that.ischeckOldUserCoupon(mobile);
break;
case 200:
that.receiveCouponsFun(result.data.uid);
break;
default:
that.ishintDialog(result.message);
break;
}
},
error: function() {
tip.show('操作失败~');
}
});
},
// 领取优惠券
receiveCouponsFun: function(uid) {
var that = this,
$el = this.el;
window.setCookie('inviteUid', uid);
$.ajax({
url: '/activity/invite/receiveCoupons',
data: {
actId: $el.actId,
shareUid: $el.shareUid,
openId: $el.openId,
uid: uid,
nums: $el.nums
},
async: false,
success: function(result) {
switch (result.code) {
case 200:
document.location.href = result.data.goUrl;
break;
default:
that.ishintDialog(result.message);
break;
}
},
error: function() {
tip.show('操作失败~');
}
});
},
// 弹出框
showDialog: function($dom) {
var that = this,
$bg = $('<div>').addClass('invite-dialog-bg');
$dom.show();
$('.invite-dialog-bg').remove();
$bg.css({
height: $(window).height()
});
$('.invite-content-page').append($bg);
// 弹框重置
$dom.find('.cancelbtn').unbind('click').bind('click', function() {
$('.invite-mobile').val('');
that.clearShowDialog();
});
// 错误信息提示,确定按钮
$dom.find('.closeBtn').unbind('click').bind('click', function() {
that.clearShowDialog();
});
},
// 错误提示弹框
ishintDialog: function(msg) {
this.showDialog($('.ishint'));
$('.ishint-content').html(msg);
},
clearShowDialog: function() {
var $el = this.el,
that = this;
$('.invite-dialog-bg').remove();
$el.$inviteDialog.hide();
that.clearGrayInfo();
},
// 下载app
downLoadApp: function() {
var appUrl = 'http://a.app.qq.com/o/simple.jsp?pkgname=com.yoho&g_f=995445';
setTimeout(function() {
window.location = appUrl;
}, 200);
}
};
inviteObj.init();
... ...
.invite-page-bg {
background-image: resolve("activity/invite/body_bg.png");
min-height: 200px;
}
.invite-page {
* {
margin: 0;
padding: 0;
font-size: 28px;
}
font-family: "Microsoft YaHei";
color: #fff;
/* 手机号 领福利 */
.invite-content-page {
text-align: center;
color: #fff;
.bold {
font-weight: bold;
}
.fz9 {
-webkit-transform: scale(0.75);
font-size: 18px;
-webkit-transform-origin: top left;
}
.fz11 {
-webkit-transform: scale(0.92);
font-size: 22px;
}
.fz13 {
font-size: 26px;
}
.fz14 {
font-size: 28px;
}
.fz15 {
font-size: 30px;
}
.fz16 {
font-size: 32px;
}
.fz17 {
font-size: 34px;
}
.fz18 {
font-size: 36px;
}
.t-shadow {
text-shadow: 0 4px 10px #797979;
}
.invite-group {
text-align: left;
margin: 20px 40px 0;
input {
width: 100%;
height: 70px;
margin-bottom: 20px;
border-radius: 4px;
border: none;
padding: 10px;
}
p {
text-align: center;
}
.send-validate-btn,
.gray-info {
position: absolute;
background-color: #ff7900;
height: 70px;
line-height: 70px;
cursor: pointer;
right: 0;
padding: 0 10px;
width: 160px;
}
.gray-info {
color: #b7ad80;
background-color: #fef7d8;
cursor: none;
text-align: center;
font-size: 36px;
}
}
}
.invite-dialog-bg {
background-color: #0d0d0d;
opacity: 0.5;
width: 100%;
height: 664px;
position: fixed;
top: 0;
left: 0;
z-index: 1;
}
.relative {
position: relative;
right: 0;
}
.invite-dialog {
position: fixed;
background-color: #272624;
height: 400px;
top: 32%;
left: 10%;
width: 80%;
z-index: 2;
overflow-y: auto;
.invite-dialog-center {
text-align: center;
padding: 30px 20px;
p {
line-height: 50px;
}
}
}
.invite-btn {
width: 48%;
border: 1px solid #ff7900;
background-color: #ff7900;
color: #fff;
line-height: 50px;
font-weight: bold;
margin-top: 10px;
cursor: pointer;
display: inline-block;
padding: 14px 20px;
}
.btn-group .invite-btn {
color: #ede6c9;
}
.over-color a {
color: #fff;
}
.fw90 {
width: 90%;
}
.ishint-content {
margin-top: 80px;
height: 180px;
padding: 20px;
}
/** 分享列表 **/
.invite-content-list {
text-align: center;
.bold {
font-weight: bold;
}
.center {
text-align: center;
}
.relative {
position: relative;
overflow: hidden;
}
.absolute {
position: absolute;
top: 0;
left: 0;
z-index: 0;
}
.fz9 {
-webkit-transform: scale(0.75);
font-size: 18px;
-webkit-transform-origin: top left;
}
.fz11 {
-webkit-transform: scale(0.92);
font-size: 22px;
}
.fz13 {
font-size: 26px;
}
.fz14 {
font-size: 28px;
}
.fz15 {
font-size: 30px;
}
.fz16 {
font-size: 32px;
}
.fz17 {
font-size: 34px;
}
.fz18 {
font-size: 36px;
}
.fz19 {
font-size: 38px;
}
.fz20 {
font-size: 40px;
}
.fz22 {
font-size: 44px;
}
.fz37 {
font-size: 74px;
}
.mar-top-a {
margin-top: 14%;
}
.mar-top-b {
margin-top: 4%;
}
.mar-top-c {
margin-top: 80px;
}
.mar-top-d {
margin-top: 40px;
}
.t-shadow {
text-shadow: 0 8px 20px #797979;
}
/* 红包已领完 */
.invite-box {
width: 100%;
min-width: 320px;
font-family: "Microsoft YaHei";
color: #fff;
padding-bottom: 5%;
}
.fn-left {
float: left !important;
}
.fn-right {
float: right !important;
}
.coupon-box {
width: 384px;
height: 220px;
padding: 32px 0 0 240px;
background-color: #f4a70f;
margin: 80px auto 0;
text-align: left;
border-left: 1px dashed #000;
border-right: 1px dashed #000;
}
.coupon-box strong {
display: inline-block;
margin-top: -4px;
}
.coupon-box .pirbox {
width: 200px;
height: 160px;
font-size: 120px;
font-weight: bold;
font-family: arial;
padding-left: 44px;
left: 40px;
letter-spacing: -0.07em;
text-align: left;
overflow: hidden;
}
.coupon-box .pirbox em {
font-size: 50px;
font-weight: normal;
font-family: "Microsoft YaHei";
top: 32px;
line-height: normal;
}
.coupon-box .count-not {
text-align: center;
overflow: hidden;
margin-top: 144px;
padding: 0 24px;
width: 100%;
}
.coupon-box .count-not hr {
height: 0;
border: 0;
width: 60px;
margin: 12px;
border-top: 1px solid #e4e4e4;
}
.coupon-box.mar-top-a {
margin-top: 14%;
padding-top: 40px;
}
.hurry-size {
line-height: 1.4em;
margin-top: 60px;
}
.download-btn,
.weal-btn {
width: 410px;
height: 88px;
line-height: 88px;
background-color: #ff7800;
color: #fef7d8;
display: inline-block;
margin: 40px 0 6px;
border-radius: 4px;
}
/* 活动细则 */
.rule-tit {
text-decoration: underline;
margin-top: 36px;
}
ol.rule-con {
padding: 20px 30px;
text-align: left;
margin: 0;
}
ol.rule-con li {
list-style-type: decimal;
list-style-position: inside;
padding-bottom: 6px;
}
/* 邀请小伙伴 */
.draw-coupon {
margin-top: 30px;
text-align: center;
}
.goon {
margin: 60px 0 12px;
}
.congratu-coupon {
margin-top: 68px;
}
ul.list-port {
display: inline-block;
margin-top: 60px;
}
ul.list-port li {
width: 120px;
float: left;
overflow: hidden;
}
ul.list-port li .pic {
width: 80px;
height: 80px;
background-color: #808080;
border-radius: 50%;
margin: 0 20px;
}
ul.list-port li .name,
ul.list-port li .pon {
-webkit-transform: scale(0.84);
font-size: 20px;
}
ul.list-port li .name {
height: 1.3em;
line-height: 1.4em;
white-space: nowrap;
text-overflow: ellipsis;
overflow: hidden;
}
ul.list-port li .pon {
color: #ebd518;
}
ul.list-firends {
margin-top: 172px;
}
/* 新用户10元领券 */
.now-login {
margin: 12px 0 20px;
text-decoration: underline;
display: inline-block;
}
/* 引导层 */
.share-tag {
width: 100%;
height: 100%;
position: fixed;
top: 0;
left: 0;
z-index: 100;
overflow: hidden;
background-color: #0d0d0d;
opacity: 0.5;
display: none;
img {
float: right;
}
}
/* v4 */
.cgreen {
color: #3e7e27;
}
.cfe {
color: #fef7d8;
}
.ts {
text-shadow: 0 2px 6px #5b5b59;
}
}
}
... ...
@charset "utf-8";
@import "me/index";
@import "layout/reset";
@import "layout/common";
@import "layout/loading";
... ... @@ -9,6 +10,7 @@
@import "channel/index";
@import "product/index";
@import "activity/index";
@import "activity/invite";
@import "passport/index";
@import "guang/index";
@import "cart/chose-panel";
... ...