Authored by 张丽霞

分享领券模板

'use strict';
const mRoot = '../models';
// const couponModel = require(`${mRoot}/coupon`); // 领取优惠券 model
// const cookie = require('../../../utils/cookie');
exports.index = (req, res) => {
// res.render('coupon', {aa: 1});
// var renderData = {
// layout: false, // 原有活动移植,忽略公有模板
// module: 'coupon/index',
// title: 'YOHO!BUY有货微信分享',
// isApp: req.isApp,
// appUrl: 'http://www.yohoshow.com/about/index/yohobuyqr', // APP 下载地址
// };
// var uid = cookie.getUid(req);
// var couponId = res.app.locals.proEnv ? '22184' : '13061';
// couponModel({
// uid: uid,
// couponId: couponId,
// }).then((couponData) => {
// var couponInfo = JSON.parse(couponData[0]);
// if (couponData.length && couponInfo.code === 200) {
// //领券成功
// console.log('领券成功');
// }
// }).then((couponData) => {
// var couponInfo = JSON.parse(couponData[0]);
// if (couponInfo.code === 401) {
// renderData.geted = true;
// }
// if (couponInfo.code !== 401 && couponInfo.code !== 200) {
// renderData.fail = true;
// }
// res.render('coupon/index', renderData); // 渲染页面
// }).catch((err) => {
// errUtil.webError(err, res); // 抓取 Promise 链的错误
// });
res.render('coupon', {
module: 'coupon',
page: 'index'
... ...
// var Http = require('../../../library/api');
// var http = new Http();
// module.exports = (data) => {
// var defaultParam = {
// method: 'app.promotion.getCoupon'
// },
// requestList = [],
// requestData = _.cloneDeep(data);
// // 处理完成后,发给后端
// data = Object.assign(defaultParam, data);
// return api.get('/', data); // 所有数据返回一个 Promise,方便 Promise.all 调用
// var defaultParam = {
// method: 'app.promotion.getCoupon'
// },
// requestList = [],
// requestData = _.cloneDeep(data);
// // 根据券号取优惠券
// if (data.couponId) {
// return http.post(defaultParam,data);
// };
// // 处理完成后,发给后端
// data = Object.assign(defaultParam, data);
// return http.get('/', data); // 所有数据返回一个 Promise,方便 Promise.all 调用
// };
... ...
... ... @@ -4,15 +4,16 @@
</div>
<div class="coupon-centent">
<div class="title">
<img src="../img/coupon/coupon-title.png">
</div>
<div class="input-content">
<div class="input-content hidden">
<input id="phone" type="text" placeholder="请输入手机号" maxlength="11"/>
<div>获取红包</div>
</div>
<div class="input-content hidden">
<input id="verification hidden" type="text" placeholder="请输入验证码" maxlength="4"/>
<div class="input-content">
<input id="verification" type="text" placeholder="请输入验证码" maxlength="4"/>
<div>验证领红包</div>
</div>
... ... @@ -22,27 +23,41 @@
</div>
<div class="gain-coupon-centent hidden">
<div class="gain-coupon-centent">
<div class="coupon">
<!-- <img src="/activity/cocacola/images/cokeCoupon.png"> -->
<!-- <img src="{{img}}"> -->
<img src="../img/coupon/coupon.png">
</div>
<p class="phone" id="mobile"></p>
<p>登录Yoho!Buy有货客户端即可使用</p>
<div class="use-coupon-btn">
<!-- <img src="/activity/cocacola/images/cokeBtn.png"> -->
马上去Yoho!Buy有货使用
</div>
<span>活动说明</span>
<span class="description">活动说明&#xe604;</span>
</div>
</div>
</div>
{{#if fail}}
<div class="tip-wrap">
<div class="tip fail">
<div class="header">
</div>
<div class="title">
本次活动已结束
<!-- 优惠券已领光 -->
</div>
<div class="logo">
</div>
</div>
</div>
{{/if}}
<div class="messages hidden" id="dialog">
<div class="content"></div>
</div>
<div class="keep-out hidden"></div>
<div class="mask hidden"></div>
<div class="dialog hidden" id="message">
<span class="close"></span>
<div class="activity-message">
... ...

2.15 KB | W: | H:

1.92 KB | W: | H:

  • 2-up
  • Swipe
  • Onion skin

11.4 KB | W: | H:

7.76 KB | W: | H:

  • 2-up
  • Swipe
  • Onion skin

84.5 KB | W: | H:

83.4 KB | W: | H:

  • 2-up
  • Swipe
  • Onion skin
... ... @@ -7,21 +7,21 @@ var $ = require('yoho-jquery'),
$('#phone').bind('input propertychange', function() {
if ($(this).val().length === 11) {
$('.centent span').eq('0').addClass('verification-code');
$('.input-content div').eq('0').addClass('verification-code');
} else {
$('.centent span').eq('0').removeClass();
$('.input-content div').eq('0').removeClass();
}
});
$('#verification').bind('input propertychange', function() {
if ($(this).val().length === 4) {
$('.centent span').eq('1').addClass('get');
$('.input-content div').eq('1').addClass('get');
} else {
$('.centent span').eq('1').removeClass();
$('.input-content div').eq('1').removeClass();
}
});
$('.centent').on('click', '.verification-code', function() {
$('.centent span').eq('0').removeClass('verification-code');
$('.input-content').on('click', '.verification-code', function() {
$('.input-content div').eq('0').removeClass('verification-code');
phone = $(this).siblings('input').val();
reg = /[0-9]{11}/;
if (!reg.test(phone)) {
... ... @@ -47,11 +47,11 @@ $('.centent').on('click', '.verification-code', function() {
num++;
if (num > 60) {
num = 0;
$('.centent span').eq('0').addClass('verification-code').html('获取验证码');
$('.input-content div').eq('0').addClass('verification-code').html('获取验证码');
clearInterval(time);
} else {
$('.centent span').eq('0').removeClass('verification-code').html('重新发送' + (60 - num));
$('.input-content div').eq('0').removeClass('verification-code').html('重新发送' + (60 - num));
}
}, 1000);
} else {
... ... @@ -67,8 +67,8 @@ $('.centent').on('click', '.verification-code', function() {
}
});
});
$('.centent').on('click', '.get', function() {
$('.centent span').eq('1').removeClass('get');
$('.input-content').on('click', '.get', function() {
$('.input-content div').eq('1').removeClass('get');
if ($(this).siblings('input').val().length === 4) {
$.ajax({
url: '/activity/cocacola/CocacolaController/validRegCodeAndSendCode',
... ... @@ -109,13 +109,16 @@ $('.close').on('click', function() {
$('.keep-out').addClass('hidden');
$('#dialog .content').html(' ');
});
$('.footer span').on('click', function() {
$('.coupon-description span').on('click', function() {
$('#message').removeClass('hidden');
$('.keep-out').removeClass('hidden');
});
$('.description').on('click', function() {
$('#message').removeClass('hidden');
$('.keep-out').removeClass('hidden');
});
$('.centent').on('click', '.get', function() {
$('.input-content').on('click', '.get', function() {
if (window._yas) {
window._yas.sendCustomInfo({
receiveCoupon: 'Y'
... ...
... ... @@ -25,101 +25,125 @@
background: #9d1a15;
}
.coupon-centent .title {
width: 100%;
height: 111px;
background: url("../img/coupon/coupon-title.png");
}
.coupon-centent {
.title {
padding: 40px 90px;
height: 111px;
background: #9d1a15;
.coupon-centent .input-content {
height: 206px;
margin: 30px 30px 0;
}
img {
width: 100%;
height: auto;
}
}
.coupon-centent .input-content input {
height: 88px;
width: 100%;
margin-bottom: 30px;
border: 1px solid #fff;
font-size: 18px;
color: #fff;
background: #9d1a15;
border-radius: 0.3rem;
text-align: center;
outline: none;
}
.input-content {
height: 206px;
margin: 30px 30px 0;
.coupon-centent .input-content div {
height: 88px;
width: 100%;
text-align: center;
font-size: 18px;
border-radius: 0.3rem;
background: #fff;
color: #444;
line-height: 88px;
}
input {
height: 88px;
width: 100%;
margin-bottom: 30px;
border: 1px solid #fff;
font-size: 18px;
color: #fff;
background: #9d1a15;
border-radius: 0.3rem;
text-align: center;
outline: none;
}
.coupon-description {
width: 100%;
height: 173px;
position: relative;
background: url("../img/coupon/coupon-footer.png");
}
div {
height: 88px;
width: 100%;
text-align: center;
font-size: 18px;
border-radius: 0.3rem;
background: #b0b0b0;
color: #e0e0e0;
line-height: 88px;
}
.coupon-description span {
position: absolute;
bottom: 0;
left: 40%;
width: 20%;
height: 2rem;
.get {
background: #fff;
color: #444;
}
}
.coupon-description {
width: 100%;
height: 173px;
position: relative;
background: url("../img/coupon/coupon-footer.png");
span {
position: absolute;
bottom: 0;
left: 40%;
width: 20%;
height: 2rem;
}
}
}
.gain-coupon-centent {
width: 100%;
height: auto;
overflow: hidden;
padding-top: 2rem;
padding-bottom: 0.6rem;
background: #e10c1e;
}
p {
width: 100%;
height: 40px;
line-height: 40px;
text-align: center;
color: #fff;
font-size: 17px;
}
.gain-coupon-centent p {
width: 100%;
height: auto;
overflow: hidden;
text-align: center;
color: #fff;
line-height: 2rem;
font-size: 0.9rem;
}
p.phone {
margin-top: 10px;
font-size: 30px;
font-weight: bold;
}
.gain-coupon-centent p.phone {
font-size: 1.3rem;
font-weight: bold;
line-height: 2.6rem;
}
.coupon {
padding-top: 50px;
width: 100%;
height: 220px;
background: ##9d1a15;
}
.coupon {
width: 81.25%;
height: auto;
overflow: hidden;
margin: 0 auto;
background: url("../img/coupon/close.png");
}
.coupon img {
width: 100%;
height: auto;
}
.coupon img {
width: 100%;
height: auto;
.use-coupon-btn {
height: 88px;
line-height: 88px;
margin: 30px 55px;
background: #444;
color: #fff;
text-align: center;
font-size: 18px;
border-radius: 4px;
}
span {
font-weight: bold;
display: inline-block;
width: 139px;
height: 42px;
align: center;
color: #fff;
margin: 0 40%;
}
}
.dialog {
width: 82%;
height: 14rem;
width: 84%;
height: 410px;
position: absolute;
background: #fff;
border-radius: 0.6rem;
left: 9%;
left: 8%;
top: 45%;
margin-top: -7rem;
z-index: 2;
... ... @@ -131,7 +155,6 @@
overflow: hidden;
background: url("../img/coupon/close.png");
color: #f1f1f1;
border-radius: 20px;
position: absolute;
top: -20px;
right: -20px;
... ... @@ -139,17 +162,6 @@
text-align: center;
}
.use-coupon-btn .btn {
width: 75.25%;
height: auto;
margin: 0 auto 1.6rem;
}
.use-coupon-btn .btn img {
width: 100%;
height: auto;
}
.hidden {
display: none;
}
... ... @@ -159,7 +171,7 @@
line-height: 14rem;
}
.keep-out {
.mask {
width: 100%;
height: 100%;
overflow: hidden;
... ... @@ -193,12 +205,12 @@
}
.messages {
width: 82%;
width: 84%;
height: 4rem;
position: absolute;
background: rgba(0, 0, 0, 0.9);
border-radius: 0.6rem;
left: 9%;
left: 8%;
top: 45%;
margin-top: -2rem;
z-index: 2;
... ... @@ -208,5 +220,68 @@
.messages p {
line-height: 4rem;
}
.tip-wrap {
width: 100%;
height: 100%;
background: #9d1a15;
position: absolute;
top: 0;
left: 0;
z-index: 3;
}
.tip {
width: 100%;
height: 100%;
background: #9d1a15;
position: absolute;
top: 0;
left: 0;
.header {
width: 170px;
height: 170px;
margin-top: 40%;
margin-left: auto;
margin-right: auto;
background: url("../img/coupon/unfortunately.png");
}
.title {
margin-top: 30px;
font-size: 28px;
color: #fff;
text-align: center;
margin-left: auto;
margin-right: auto;
}
.logo {
width: 391px;
height: 78px;
margin-top: 190px;
margin-left: auto;
margin-right: auto;
background: url("../img/coupon/logo.png");
}
.desc {
font-size: 24px;
color: #444;
}
.button {
display: block;
margin: 30px auto;
width: 270px;
height: 56px;
font-size: 26px;
line-height: 56px;
text-align: center;
color: #fff;
background: #000;
}
}
}
... ...
// 获取 UID
exports.getUid = (req) => {
var _uid = 0,
cookie = req.cookies._UID,
cookieList;
if (req.isApp) {
return req.query.uid || 0;
}
if (cookie) {
cookieList = cookie.split('::');
if (cookieList[1] && !isNaN(cookieList[1])) {
_uid = cookieList[1];
}
}
return _uid;
};
... ...