Authored by 周少峰

Merge branch 'release/6.1' into gray

Conflicts:
	apps/passport/models/login-service.js
	config/common.js
Showing 44 changed files with 2969 additions and 118 deletions
... ... @@ -6,6 +6,7 @@
'use strict';
const _ = require('lodash');
const crypto = global.yoho.crypto;
const logger = global.yoho.logger;
... ... @@ -58,6 +59,17 @@ const convertCoupons = (req, res, next) => {
}).catch(next);
};
// 获取礼品卡列表
const getGiftCards = (req, res, next) => {
req.ctx(oeModel).getGiftCards(req.user.uid).then(data => {
if (data.data) {
data.data.userMobile = req.user.mobile;
}
res.send(data);
}).catch(next);
};
// 订单金额计算
const compute = (req, res, next) => {
let params = req.body;
... ... @@ -72,9 +84,39 @@ const compute = (req, res, next) => {
res.send(data);
}).catch(next);
}
};
// 发送虚拟资产使用校验短信(目前仅有礼品卡 --- giftCard)
const sendCheckSms = (req, res, next) => {
let params = req.body;
if (params.giftCard) {
return req.ctx(oeModel).sendGiftCardCkeckSms(req.user.uid, req.yoho.udid).then(result => {
res.json(result);
}).catch(next);
}
return next();
};
// 订单提交前置校验
const submitCheck = (req, res, next) => {
let checkCode = req.body.checkCode;
// 带礼品卡号和短信验证码,则校验短信验证码,否则删除使用礼品卡
if (req.body.giftCard && checkCode) {
return req.ctx(oeModel).checkGiftCardSmsCode(req.user.uid, checkCode, req.yoho.udid).then(result => {
if (result.code === 200) {
return next();
}
res.json(result);
}).catch(next);
} else {
_.unset(req.body, 'giftCard');
}
return next();
};
// 提交订单
... ... @@ -150,7 +192,16 @@ const submit = (req, res, next) => {
userAgent: userAgent
});
params.udid = req.cookies._yasvd || 'yoho_pc';
params.udid = req.yoho.udid;
// 5.8.1 发票优化需求
// 只接受电子发票(1 纸质 2 电子),发票内容为明细(id 12:明细)
if (params.invoicesType) {
Object.assign(params, {
invoicesType: 2,
invoicesContent: 12
});
}
if (params.sku) { // 快捷结算
req.ctx(easypayModel).easypayOrderSubmit(uid, 'ordinary', params, remoteIp).then(result => {
... ... @@ -173,6 +224,9 @@ module.exports = {
index,
getCoupons,
convertCoupons,
getGiftCards,
compute,
sendCheckSms,
submitCheck,
submit
};
... ...
... ... @@ -39,10 +39,11 @@ const ticketEnsure = (req, res, next) => {
const ticketSubmit = (req, res, next) => {
let uid = req.user.uid;
let sku = req.body.sku || 0;
let count = req.body.count || 0;
let mobile = req.body.mobile || 0;
let yohoCoin = req.body.coin || 0;
let params = req.body;
let sku = params.sku || 0;
let count = params.count || 0;
let mobile = params.mobile || 0;
let yohoCoin = params.coin || 0;
if (!sku || !count || !mobile) {
return res.json({
... ... @@ -51,7 +52,9 @@ const ticketSubmit = (req, res, next) => {
});
}
req.ctx(ticketService).submitTicket(uid, sku, count, mobile, yohoCoin).then(result => {
params.udid = req.yoho.udid;
req.ctx(ticketService).submitTicket(uid, sku, count, mobile, yohoCoin, params).then(result => {
return res.json(result);
}).catch(next);
};
... ... @@ -62,7 +65,7 @@ const ticketCompute = (req, res, next) => {
let buyNumber = req.body.count || 0;
let yohoCoin = req.body.coin || 0;
req.ctx(ticketService).addTicket(uid, sku, buyNumber, yohoCoin).then(result => {
req.ctx(ticketService).addTicket(uid, sku, buyNumber, yohoCoin, req.body).then(result => {
if (_.isEmpty(result)) {
return res.json({
code: 401,
... ...
/**
* address api
* easypay api
* @author: yyq<yanqing.yang@yoho.cn>
* @date: 2016/11/04
*/
... ... @@ -68,6 +68,12 @@ module.exports = class extends global.yoho.BaseModel {
});
}
if (other.giftCard) {
Object.assign(param, {
gift_card_code: other.giftCard
});
}
if (other.promotionCode) {
Object.assign(param, {
promotion_code: other.promotionCode
... ... @@ -153,6 +159,20 @@ module.exports = class extends global.yoho.BaseModel {
});
}
// 礼品卡
if (other.giftCard) {
Object.assign(param, {
gift_card_code: other.giftCard
});
}
// 优惠码
if (other.promotionCode) {
Object.assign(param, {
promotion_code: other.promotionCode
});
}
// 优惠券码
if (other.couponCode) {
Object.assign(param, {
... ...
... ... @@ -70,6 +70,17 @@ module.exports = class extends global.yoho.BaseModel {
}
/**
* 获取用户可用礼品卡信息API
* @param uid [number] uid
*/
getGiftCardAsync(uid) {
return this.get({data: {
method: 'app.Shopping.listGiftCard',
uid: uid
}});
}
/**
* 订单计算API
* @param uid [number] uid
* @param cartType [string] 购物车类型,ordinary表示普通, advance表示预售
... ... @@ -103,6 +114,12 @@ module.exports = class extends global.yoho.BaseModel {
});
}
if (other.giftCard) {
Object.assign(param, {
gift_card_code: other.giftCard
});
}
if (other.couponCode) {
Object.assign(param, {
coupon_code: other.couponCode
... ... @@ -118,6 +135,31 @@ module.exports = class extends global.yoho.BaseModel {
}
/**
* 发送礼品卡使用校验短信API
* @param uid [number] uid
*/
sendGiftCardCkeckSmsAsync(uid, udid) {
return this.get({data: {
method: 'app.giftcard.sendSms',
uid: uid,
udid: udid
}});
}
/**
* 校验礼品卡使用短信验证码API
* @param code [number] code
*/
checkGiftCardSmsCodeAsync(uid, code, udid) {
return this.get({data: {
method: 'app.giftcard.validRegCode',
uid: uid,
code: code,
udid: udid
}});
}
/**
* 订单提交API
* @param uid [number] uid
* @param cartType [String] 购物车类型,ordinary表示普通, advance表示预售
... ... @@ -176,6 +218,13 @@ module.exports = class extends global.yoho.BaseModel {
});
}
// 礼品卡
if (other.giftCard) {
Object.assign(param, {
gift_card_code: other.giftCard
});
}
// 备注
if (other.remark) {
Object.assign(param, {
... ... @@ -221,4 +270,3 @@ module.exports = class extends global.yoho.BaseModel {
}});
}
};
... ...
... ... @@ -83,21 +83,35 @@ module.exports = class extends global.yoho.BaseModel {
});
}
// 获取礼品卡列表
getGiftCards(uid) {
return new EnsureApi(this.ctx).getGiftCardAsync(uid).then(result => {
if (!_.isEmpty(_.get(result, 'data.usable_giftCards', []))) {
_.map(result.data.usable_giftCards, value => {
return Object.assign(value, {price: _.replace(value.remainAmount, /[^(0-9.)]/ig, '')});
});
}
return result;
});
}
// 发送礼品卡使用校验短信
sendGiftCardCkeckSms(uid, udid) {
return new EnsureApi(this.ctx).sendGiftCardCkeckSmsAsync(uid, udid);
}
// 校验礼品卡使用短信验证码
checkGiftCardSmsCode(uid, code, udid) {
return new EnsureApi(this.ctx).checkGiftCardSmsCodeAsync(uid, code, udid);
}
// 订单提交
submit(uid, cartType, p, remoteIp) {
if (p.addressId) {
p.addressId = crypto.decrypt('', `${p.addressId}`);
}
// 5.8.1 发票优化需求
// 只接受电子发票(1 纸质 2 电子),发票内容为明细(id 12:明细)
if (p.invoicesType) {
Object.assign(p, {
invoicesType: 2,
invoicesContent: 12
});
}
return new EnsureApi(this.ctx).orderSubmitAsync(uid, cartType, p.addressId, p.deliveryTime,
p.deliveryWay, p.paymentType, p.paymentId, p.printPrice, p, remoteIp).then(result => {
if (result.code === 200) {
... ...
... ... @@ -15,7 +15,7 @@ module.exports = class extends global.yoho.BaseModel {
* @param mobile 手机号码
* @param yohoCoin 有货币
*/
submit(uid, sku, count, mobile, yohoCoin) {
submit(uid, sku, count, mobile, yohoCoin, other = {}) {
let params = {
method: 'app.shopping.submitTicket',
uid,
... ... @@ -28,6 +28,18 @@ module.exports = class extends global.yoho.BaseModel {
params.use_yoho_coin = yohoCoin / 100;
}
if (other.giftCard) {
Object.assign(params, {
gift_card_code: other.giftCard
});
}
if (other.udid) {
Object.assign(params, {
udid: other.udid
});
}
return this.get({data: params});
}
... ... @@ -38,7 +50,7 @@ module.exports = class extends global.yoho.BaseModel {
* @param count 购买数量 1-4
* @param yohoCoin 有货币
*/
add(uid, sku, count, yohoCoin) {
add(uid, sku, count, yohoCoin, other = {}) {
let params = {
method: 'app.shopping.ticket',
uid,
... ... @@ -50,6 +62,12 @@ module.exports = class extends global.yoho.BaseModel {
params.use_yoho_coin = yohoCoin / 100;
}
if (other.giftCard) {
Object.assign(params, {
gift_card_code: other.giftCard
});
}
return this.get({data: params});
}
};
... ...
... ... @@ -24,8 +24,8 @@ module.exports = class extends global.yoho.BaseModel {
return _.get(info, 'data.shopping_cart_data.last_order_amount', 0);
}
addTicket(uid, sku, count, yohoCoin) {
return new TicketApi(this.ctx).add(uid, sku, count, yohoCoin).then(ticketInfo => {
addTicket(uid, sku, count, yohoCoin, other) {
return new TicketApi(this.ctx).add(uid, sku, count, yohoCoin, other).then(ticketInfo => {
let result = {};
if (_.isEmpty(ticketInfo)) {
... ... @@ -54,8 +54,8 @@ module.exports = class extends global.yoho.BaseModel {
});
}
submitTicket(uid, sku, count, mobile, yohoCoin) {
return new TicketApi(this.ctx).submit(uid, sku, count, mobile, yohoCoin).then(result => {
submitTicket(uid, sku, count, mobile, yohoCoin, other) {
return new TicketApi(this.ctx).submit(uid, sku, count, mobile, yohoCoin, other).then(result => {
if (_.isEmpty(result)) {
return {
code: 500,
... ...
... ... @@ -30,16 +30,18 @@ router.post('/address/setdefault', address.setDefault); // 设置默认地址
router.get('/ensure', auth, ensure.index); // 限购商品快捷结算页
router.get('/ensure/coupons', auth, ensure.getCoupons); // 结算优惠券列表
router.get('/ensure/giftcards', auth, ensure.getGiftCards); // 结算礼品卡列表
router.get('/ensure/couponcode', auth, ensure.convertCoupons); // 优惠码兑换券
router.post('/ensure/compute', auth, ensure.compute); // 价格重新计算
router.post('/ensure/submit', auth, ensure.submit); // 价格重新计算
router.post('/ensure/submit', auth, ensure.submitCheck, ensure.submit); // 订单提交
router.post('/property/checksms', ensure.sendCheckSms); // 虚拟资产使用校验
router.get('/easypay', auth, easypay.index); // 限购商品快捷结算页
router.post('/easypay/compute', auth, easypay.compute); // 价格重新计算
router.post('/easypay/submit', auth, easypay.submit); // 限购商品订单提交
router.get('/ticketEnsure', auth, ticket.ticketEnsure);
router.post('/ticketSubmit', auth, ticket.ticketSubmit);
router.post('/ticketSubmit', auth, ensure.submitCheck, ticket.ticketSubmit);
router.post('/ticketCompute', auth, ticket.ticketCompute);
router.get('/cart', cart.cart);
... ...
... ... @@ -100,7 +100,7 @@
{{/each}}
</ul>
</div>
<p class="package-shipping">运费:¥{{shopping_cost}}元(原价{{shopping_orig_cost}}元,优惠{{shopping_cut_cost}}元)</p>
<p class="package-shipping"></p>
</div>
{{/each}}
</div>
... ... @@ -251,6 +251,27 @@
</div>
</dd>
{{/if}}
<dt id="use-gift-card" class="hide"><span class="locker-switch"></span>使用礼品卡<span class="can-use-tip"></span></dt>
<dd class="gift-card-box hide">
<table>
<thead>
<tr>
<th width="260">卡号</th>
<th>面值</th>
<th>卡内余额</th>
<th width="230">有效期</th>
<th width="86">选择</th>
</tr>
</thead>
<tbody>
<tr>
<td colspan="5">暂无礼品卡</td>
</tr>
</tbody>
</table>
</dd>
<dt><span class="locker-switch"></span>添加备注信息</dt>
<dd id="remark-box" class="remark-box">
<div class="note-text-box">
... ... @@ -284,7 +305,7 @@
</div>
<div class="sum-wrap">
应付金额:<span id="order-price" class="price">¥ {{round last_order_amount 2}}</span>
应付金额:<span id="order-price" class="price" data-price="{{last_order_amount}}">¥ {{round last_order_amount 2}}</span>
<button id="order-submit">提交订单</button>
</div>
{{/ shoppingCartData}}
... ...
... ... @@ -100,10 +100,30 @@
</dd>
</dl>
<dt id="use-gift-card" class="hide"><span class="locker-switch"></span>使用礼品卡<span class="can-use-tip"></span></dt>
<dd class="gift-card-box hide">
<table>
<thead>
<tr>
<th width="260">卡号</th>
<th>面值</th>
<th>卡内余额</th>
<th width="230">有效期</th>
<th width="86">选择</th>
</tr>
</thead>
<tbody>
<tr>
<td colspan="5">暂无礼品卡</td>
</tr>
</tbody>
</table>
</dd>
</div>
<div class="sum-wrap">
应付金额:<span id="order-price" class="price">¥ {{round last_order_amount 2}}</span>
应付金额:<span id="order-price" class="price" data-price="{{last_order_amount}}">¥ {{round last_order_amount 2}}</span>
<button id="order-submit" data-url="{{productUrl}}">提交订单</button>
</div>
... ...
... ... @@ -106,7 +106,7 @@
<li class="invoice-personal-name invoice-row personal-row">
<span class="row-title"></span>
<div class="row-content">
<input id="personal-name" class="personal-name" type="text" placeholder="个人( 可修改 )">
<input id="personal-name" class="personal-name" type="text" placeholder="个人( 可修改 )" maxlength="100">
</div>
</li>
<li class="invoice-title-name invoice-row company-row hide">
... ... @@ -115,7 +115,7 @@
单&nbsp;位&nbsp;名&nbsp;称:
</span>
<div class="row-content">
<input id="company-name" class="company-name" type="text" placeholder="请填写单位名称">
<input id="company-name" class="company-name" type="text" placeholder="请填写单位名称" maxlength="100">
<span class="input-tip company-name-tip red hide">
<span class="iconfont">&#xe629;</span>
<em>请填写发票抬头</em>
... ...
'use strict';
const ordersService = require('../models/orders-service');
const invoiceModel = require('../models/invoice');
const index = (req, res, next) => {
let page = parseInt(req.query.page, 10) || 1;
let limit = parseInt(req.query.limit, 10) || 10;
return req.ctx(ordersService).index(req.user.uid, page, limit, 8).then(result => {
res.render('invoice', {
meOrders: result
});
}).catch(next);
};
const detail = (req, res, next) => {
return req.ctx(invoiceModel).getInvoiceDetail(req.query.orderCode, req.user.uid).then(result => {
res.send(result);
}).catch(next);
};
const supply = (req, res, next) => {
let params = req.body;
// 5.8.1 发票优化需求
// 只接受电子发票(1 纸质 2 电子),发票内容为明细(id 12:明细)
Object.assign(params, {
invoicesType: 2,
contentId: 12
});
return req.ctx(invoiceModel).submitInvoiceSupply(params, req.user.uid).then(result => {
res.send(result);
}).catch(next);
};
module.exports = {
index,
detail,
supply
};
... ...
/**
* 个人中心---我的礼品卡
* @author xiaoxiao <xiaoxiao.hao@yoho.cn>
* @date: 2017/9/1
*/
'use strict';
const meGiftService = require('../models/me-gift-service');
/**
* 礼品卡列表
*/
exports.index = (req, res, next) => {
let uid = req.user.uid;
let responseData = {
module: 'home',
page: 'me-gift'
};
req.ctx(meGiftService).getList(req.query, uid).then(result => {
responseData.meGiftPage = true;
Object.assign(responseData, result);
res.render('home/gift/me-gift', responseData);
}).catch(next);
};
/**
* 消费明细
*/
exports.detail = (req, res, next) => {
let uid = req.user.uid;
let responseData = {
module: 'home',
page: 'me-gift',
layout: false
};
return req.ctx(meGiftService).consumeList(req.query, uid).then(result => {
Object.assign(responseData, result);
return res.render('home/gift/me-detail', responseData);
}).catch(next);
};
/**
* 激活礼品卡
*/
exports.activateGift = (req, res, next) => {
let uid = req.user.uid;
req.ctx(meGiftService).activateGift(req.body, uid).then(result => {
res.json(result);
}).catch(next);
};
/**
* 发送邮箱验证码
*/
exports.sendEmailCode = (req, res, next) => {
let uid = req.user.uid;
req.ctx(meGiftService).sendEmailCode(req.body, uid).then(result => {
res.json(result);
}).catch(next);
};
/**
* 验证邮箱验证码
*/
exports.verifyEmail = (req, res, next) => {
let uid = req.user.uid;
req.ctx(meGiftService).verifyEmail(req.body, uid).then(result => {
res.json(result);
}).catch(next);
};
/**
* 发验证码
*/
exports.smsBind = (req, res, next) => {
req.ctx(meGiftService).smsBind(req.body).then(result => {
res.json(result);
}).catch(next);
};
/**
* 修改绑定的手机号
*/
exports.changeMobile = (req, res, next) => {
let uid = req.user.uid;
req.ctx(meGiftService).changeMobile(req.body, uid).then(result => {
res.json(result);
}).catch(next);
};
... ...
... ... @@ -72,7 +72,7 @@ const modifyAddress = (req, res, next) => {
return '';
}
}());
let udid = req.cookies._yasvd || 'yoho_pc';
let udid = req.yoho.udid;
if (!orderId || !userName || !areaCode || !address) {
return res.json({
... ...
... ... @@ -27,6 +27,7 @@ module.exports = class extends global.yoho.BaseModel {
{name: '我的红包', href: '/home/redenvelopes'},
{name: '我的优惠券', href: '/home/coupons'},
{name: '我的邀请好友', href: '/home/spread'},
{name: '我的礼品卡', href: '/home/megift'},
{name: '我的VIP', href: '/home/vip'}
]
},
... ... @@ -34,6 +35,7 @@ module.exports = class extends global.yoho.BaseModel {
title: '服务中心',
subNav: [
{name: '我的退/换货', href: '/home/returns'},
{name: '我的发票', href: '/home/invoice'},
{name: '我的咨询', href: '/home/consult'},
{name: '我的评论', href: '/home/comment'},
... ... @@ -70,7 +72,7 @@ module.exports = class extends global.yoho.BaseModel {
'/home/account/modifymobile'
]},
{name: '地址管理', href: '/home/address'},
{name: '兑换礼品卡', href: '/home/gift'}
// {name: '兑换礼品卡', href: '/home/gift'} // @韩施超-产品让注释的
]
}
];
... ...
/**
* 我的消息model
* @author: yyq<yanqing.yang@yoho.cn>
* @date: 2016/8/29
*/
'use strict';
const _ = require('lodash');
module.exports = class extends global.yoho.BaseModel {
constructor(ctx) {
super(ctx);
}
getInvoiceDetail(orderCode, uid) {
return this.get({data: {
method: 'app.invoice.detail',
uid: uid,
order_code: orderCode
}}).then(result => {
if (result.code === 200) {
_.unset(result, 'data.uid');
_.set(result, 'data.invoicesType', _.get(result, 'data.invoices_type') === 2 ? '电子发票' : '纸质发票');
}
return result;
});
}
submitInvoiceSupply(info, uid) {
let param = {
order_code: info.orderCode,
invoices_type: info.invoicesType,
invoices_title: info.titleName,
invoice_content: info.contentId,
receiverMobile: info.receiver,
buyerTaxNumber: info.taxNumber,
invoice_payable_type: info.taxNumber ? 2 : 1
};
return this.get({data: Object.assign(param, {
method: 'app.invoice.supply',
uid: uid
})}).then(result => {
_.unset(result, 'data.uid');
return result;
});
}
};
... ...
'use strict';
module.exports = class extends global.yoho.BaseModel {
constructor(ctx) {
super(ctx);
}
/**
* [获取礼品卡列表]
* @param {[type]} uid [用户id]
* @param {[type]} status [1-可使用,2-已冻结,3-已过期,4-已用完]
* @return {[type]} [{}]
*/
getList(uid, status, page, limit) {
let options = {
method: 'app.giftcard.pagelist',
uid: uid,
status: status,
page: page,
limit: limit || 10
};
return this.get({data: options});
}
/**
* [获取礼品卡消费记录]
* @param {[type]} cardCode [礼品卡号]
* @param {[type]} uid [用户id]
* @param {[type]} page [当前页]
* @param {[type]} limit [页大小]
* @return {[type]} [{}]
*/
consumeList(params, uid) {
let options = {
method: 'app.giftcard.consumelist',
cardCode: params.cardCode,
uid: uid,
page: params.page,
limit: params.limit || 10
};
if (params.type) {
options.type = params.type;
}
return this.get({data: options});
}
/**
* [发送邮箱验证码]
* @param {[type]} email [邮箱]
* @param {[type]} uid [用户id]
* @return {[type]} [{}]
*/
sendEmailCode(email, uid) {
let options = {
method: 'app.giftcard.emailcode',
email: email,
uid: uid
};
return this.get({data: options});
}
/**
* [验证邮箱验证码]
* @param {[type]} code [邮箱验证码]
* @param {[type]} uid [用户id]
* @return {[type]} [{}]
*/
verifyEmail(code, uid) {
let options = {
method: 'app.giftcard.verifyemail',
uid: uid,
code: code
};
return this.get({data: options});
}
/**
* [激活礼品卡]
* @param {[type]} uid [用户id]
* @param {[type]} cardCode [礼品卡卡号]
* @param {[type]} cardPwd [礼品卡卡密]
* @return {[type]} [{}]
*/
activateGift(uid, cardCode, cardPwd) {
let options = {
method: 'app.giftcard.activate',
uid: uid,
cardCode: cardCode,
cardPwd: cardPwd
};
return this.get({data: options});
}
/**
* [检查是否绑定手机号]
* @param {[type]} area [区号]
* @param {[type]} mobile [手机号]
* @return {[type]} [{}]
*/
checkIsCanBind(area, mobile) {
let options = {
method: 'app.passport.checkIsCanBind',
area: area,
mobile: mobile
};
return this.get({data: options});
}
/**
* [发验证码]
* @param {[type]} area [区号]
* @param {[type]} mobile [手机号]
* @return {[type]} [{}]
*/
smsbind(area, mobile) {
let options = {
method: 'app.passport.smsbind',
area: area,
mobile: mobile
};
return this.get({data: options});
}
/**
* [修改绑定的手机号]
* @param {[type]} area [区号]
* @param {[type]} mobile [手机号]
* @param {[type]} code [验证码]
* @param {[type]} uid [用户id]
* @return {[type]} [{}]
*/
changeMobile(area, mobile, code, uid) {
let options = {
method: 'app.passport.changeMobile',
area: area,
mobile: mobile,
code: code,
uid: uid
};
return this.get({data: options});
}
/**
* [获取用户信息]
* @param {[type]} uid [用户id]
* @return {[type]} [{}]
*/
getProfile(uid) {
let options = {
uid: uid,
method: 'app.passport.profile'
};
return this.get({data: options});
}
};
... ...
/**
* 我的礼品卡列表
* @author xiaoxiao <xiaoxiao.hao@yoho.cn>
* @date: 2017/9/1
*/
'use strict';
const Promise = require('bluebird');
const _ = require('lodash');
const helpers = global.yoho.helpers;
const MeGiftAPi = require('./me-gift-api');
const setPager = require(`${global.utils}/pager`).setPager;
const crypto = global.yoho.crypto;
module.exports = class extends global.yoho.BaseModel {
constructor(ctx) {
super(ctx);
this.meGiftAPi = new MeGiftAPi(this.ctx);
}
headTab(params) {
let type = params.type;
let tabs = [{
name: '使用中',
url: helpers.urlFormat('/home/megift'),
active: false
}, {
name: '已过期',
url: helpers.urlFormat('/home/megift', {type: 1}),
active: false
}, {
name: '已用完',
url: helpers.urlFormat('/home/megift', {type: 2}),
active: false
}, {
name: '已冻结',
url: helpers.urlFormat('/home/megift', {type: 3}),
active: false
}, {
name: '添加礼品卡',
class: 'add-gift',
active: false
}];
tabs[type].active = true;
return tabs;
}
// 礼品卡列表-status=[1-可使用,2-已冻结,3-已过期,4-已用完]
getList(params, uid) {
let status = 1;
params.type = Number(params.type > -1 && params.type < 4 ? params.type : 0);
params.page = Number(params.page) || 1;
switch (params.type) {
case 1: status = 3; break;
case 2: status = 4; break;
case 3: status = 2; break;
default: status = 1;
}
return Promise.all([
this.meGiftAPi.getList(uid, status, params.page),
this.verifyBinMobile(uid)
]).then(rlist => {
let giftData = {};
giftData.data = _.get(rlist[0], 'data.giftCardInfoBOList', []);
giftData.pager = Object.assign({
count: _.get(rlist[0], 'data.total', 0),
curPage: params.page,
totalPages: _.get(rlist[0], 'data.pageSize', 0)
}, setPager(_.get(rlist[0], 'data.pageSize', 0), params));
return {
giftData: giftData,
userInfo: rlist[1],
tabs: this.headTab(params)
};
});
}
// 获取礼品卡消费记录
consumeList(params, uid) {
let types = ['类型', '消费', '退款'];
params.page = Number(params.page) || 1;
params.type = Number(params.type) || 0;
return this.meGiftAPi.consumeList(params, uid).then(rlist => {
let giftData = {};
giftData.data = _.get(rlist, 'data', {});
giftData.pager = Object.assign({
count: _.get(rlist, 'data.total', 0),
curPage: params.page,
totalPages: _.get(rlist, 'data.pageSize', 0)
}, setPager(_.get(rlist, 'data.pageSize', 0), params));
_.set(giftData, 'data.types', types[params.type] || types[0]);
return giftData;
});
}
// 验证手机是否绑定
verifyBinMobile() {
let userInfo = {
isBinMobile: Number(!!_.get(this.ctx, 'req.user.mobile', false))
};
return Promise.resolve(userInfo);
}
// 发送邮箱验证码
sendEmailCode(params, uid) {
return this.meGiftAPi.sendEmailCode(params.email, uid);
}
// 验证邮箱验证码
verifyEmail(params, uid) {
return this.meGiftAPi.verifyEmail(params.code, uid);
}
// 发验手机证码
smsBind(params) {
return this.meGiftAPi.checkIsCanBind(params.area, params.mobile).then(res => {
if (_.get(res, 'data.isCanBind') === 'N') {
return {
code: 401,
message: '<p>绑定失败,该手机号已被绑定</p><p>请更换手机号</p>'
};
}
return this.meGiftAPi.smsbind(params.area, params.mobile);
});
}
// 修改绑定的手机号
changeMobile(params, uid) {
return this.meGiftAPi.changeMobile(params.area, params.mobile, params.code, uid).then(res => {
if (res.code === 200) {
_.set(this.ctx, 'req.session.USER_MOBILE', params.mobile.replace(/(\d{3})\d{4}(\d{4})/, '$1****$2'));
}
return res;
});
}
// 激活礼品卡
activateGift(params, uid) {
return this.meGiftAPi.activateGift(uid, params.cardCode, crypto.encryption('yoho9646yoho9646', params.cardPwd));
}
};
... ...
... ... @@ -4,7 +4,7 @@ const api = global.yoho.API;
exports.getUserSuccessfulOrders = (uid)=>{
return api.get('', {
method: 'app.SpaceOrders.get',
method: 'app.SpaceOrders.list',
uid: uid,
type: 5,
page: 1,
... ...
... ... @@ -18,7 +18,7 @@ module.exports = class extends global.yoho.BaseModel {
*/
getUserOrders(uid, page, limit, type) {
let options = {
method: 'app.SpaceOrders.get',
method: 'app.SpaceOrders.list',
uid: uid,
type: type,
page: page,
... ...
... ... @@ -26,7 +26,8 @@ module.exports = class extends global.yoho.BaseModel {
this.ORDER_EMPTY_DESC = {
1: '您还没有任何订单',
5: '您目前还没有成功的订单',
7: '您还没有任何取消的订单'
7: '您还没有任何取消的订单',
8: '您还没有相关订单'
};
this.TABS = [
... ... @@ -368,6 +369,33 @@ module.exports = class extends global.yoho.BaseModel {
newOrder.payType = _.get(order, 'payment_type');
newOrder.title = _.get(order, 'order_title');
// 补开发票订单
if (type === 8) {
let iop = _.get(order, 'links', []);
let issueType = +_.get(order, 'invoice.issueType');
newOrder.invoiceType = '';
newOrder.issueType = issueType === 2;
newOrder.invoiceOperation = _.zipObject(iop, iop);
if (!newOrder.invoiceOperation || (!newOrder.invoiceOperation.invoiceDetail &&
!newOrder.invoiceOperation.supplyInvoice)) {
_.set(newOrder, 'invoiceOperation.invoiceSupplying', issueType === 1);
}
if (+order.refund_status === 1 || +order.exchange_status === 1) {
Object.assign(newOrder, {
invoiceOperation: {unsupportSupply: true},
unsupportSupplyTip: +order.refund_status === 1 ?
'订单商品已申请退货,暂无发票信息' : '换货订单暂不支持补开发票'
});
}
if (newOrder.issueType) {
newOrder.invoiceType = _.get(order, 'invoice.type', 0) === 2 ? '电子发票' : '纸质发票';
}
}
if (order.is_cancel === 'Y' || order.status === 6) {
newOrder.canDelete = true; // 删除订单
}
... ...
... ... @@ -46,6 +46,9 @@ const ordersController = require(`${cRoot}/orders`);
const AddressController = require(`${cRoot}/address`);
const giftController = require(`${cRoot}/gift`);
const invoiceController = require(`${cRoot}/invoice`);
const meGiftController = require(`${cRoot}/me-gift`);
// 首页
... ... @@ -268,7 +271,22 @@ router.get('/gift', tabsMiddleware.getCommonHeader, captcha.tryGeetest, giftCont
router.post('/gift/exchange', giftController.exchange);
// 我的发票
router.get('/invoice', tabsMiddleware.getCommonHeader, invoiceController.index);
router.get('/invoice/detail', invoiceController.detail);
router.post('/invoice/supply', invoiceController.supply);
// 是否新客(仅操作cookie)
router.get('/newuser', newUserController.check);
// 我的礼品卡
router.get('/megift', tabsMiddleware.getCommonHeader, meGiftController.index);
router.post('/megift/sendEmailCode', meGiftController.sendEmailCode);// 发送邮箱验证码
router.post('/megift/verifyEmail', meGiftController.verifyEmail);// 验证邮箱验证码
// 检查是否绑定手机号、发验证码
router.post('/megift/smsBind', meGiftController.smsBind);
router.post('/megift/changeMobile', meGiftController.changeMobile);// 修改绑定手机
router.post('/megift/activateGift', meGiftController.activateGift);// 激活礼品卡
router.get('/megift/detail', meGiftController.detail);// 消费明细
module.exports = router;
... ...
{{# data}}
<table class="info-gift-header" data-card-code={{cardCode}}>
<tr>
<td class="text-left">卡号:{{cardCode}}</td>
<td>状态:{{statusStr}}</td>
<td class="text-right validity-time">有效期:{{dateStr}}{{#if willExpire}}{{willExpire}}{{/if}}</td>
</tr>
<tr>
<td class="text-left">面值:{{round amount 2}} </td>
<td colspan="2">余额:{{round remainAmount 2}}</td>
</tr>
</table>
<div class="me-gift-info-table">
<div class="me-gift-header">
<div>时间</div>
<div>订单编号</div>
<div>
<span class="gift-filter">
<em class="gift-type">{{types}}</em>
<ul class="ul-list">
<li data-cc="1">消费</li>
<li data-cc="2">退款</li>
</ul>
</span>
</div>
<div>金额(元)</div>
</div>
{{#if giftCardConsumeInfoBOList}}
{{# giftCardConsumeInfoBOList}}
<div class="me-gift-tr">
<div>{{dateFormat 'YYYY-MM-DD HH:mm:ss' createTime}}</div>
<div>{{orderCode}}</div>
{{#isEqual type 1}}
<div class="consume">消费</div>
<div class="consume">-{{round ../changeAmount 2}}</div>
{{/isEqual}}
{{#isEqual type 2}}
<div class="refund">退款</div>
<div class="refund">+{{round ../changeAmount 2}}</div>
{{/isEqual}}
{{#isEqual type 3}}
<div class="refund">退款</div>
<div class="refund">+{{round ../changeAmount 2}}</div>
{{/isEqual}}
</div>
{{/giftCardConsumeInfoBOList}}
{{^}}
<div class="cart-list-empty"></div>
{{/if}}
</div>
{{/data}}
{{> pager}}
... ...
<div class="me-gift-page me-page yoho-page clearfix">
{{> path}}
{{> navigation}}
<div class="me-main">
<div class="me-gift block">
<div class="title">
<h2>礼品卡</h2>
</div>
<div class="me-content" data-is-bin-mobile={{userInfo.isBinMobile}} data-email={{userInfo.email}}>
{{> tabs}}
<div class="me-gift-table">
<div class="me-gift-header">
<div class="card-number">卡号</div>
<div class="card-price">卡片面值(元)</div>
<div class="card-balance">卡片余额(元)</div>
<div class="activate-time">激活时间</div>
<div class="invalid-time">失效时间</div>
<div class="cart-operation">操作</div>
</div>
{{#if giftData.data}}
{{#giftData.data}}
<div class="me-gift-tr" data-card-code={{cardCode}}>
<div>{{cardCode}}</div>
<div>{{amount}}</div>
<div>{{remainAmount}}</div>
<div>{{dateFormat 'YYYY-MM-DD' activateTime}}</div>
<div>{{dateFormat 'YYYY-MM-DD' endTime}}</div>
<div class="info-list">消费明细</div>
</div>
{{/giftData.data}}
{{^}}
<div class="cart-list-empty"></div>
{{/if}}
</div>
</div>
{{#giftData}}
{{> pager}}
{{/giftData}}
</div>
</div>
</div>
{{!-- 验证邮箱模板 --}}
<script id="verify-email-tpl" type="text/html">
<div class="title">验证邮箱</div>
<div class="gift-group">您的账户还未绑定手机,绑定手机前需要验证您的邮箱</div>
<div class="gift-group">短信验证码已发送至您的邮箱“{{userInfo.email}}</div>
<div class="gift-group verify-input">
<input type="text" placeholder="短信验证码" class="left email-code" />
<span class="left email-btn">获取短信验证码</span>
</div>
</script>
{{!-- 绑定手机模板 --}}
<script id="verify-mobile-tpl" type="text/html">
<div class="title">绑定手机号</div>
<div class="verify-input">
<div class="gift-group">
<span class="mobile-area left">
<em>+86</em>
<i class="iconfont">&#xe60b;</i>
<ul class="ul-list mobile-area-list">
<li data-cc="+86">中国 +86</li>
<li data-cc="+853">中国澳门 +853</li>
<li data-cc="+886">中国台湾 +886</li>
<li data-cc="+852">中国香港 +852</li>
<li data-cc="+1">美国 +1</li>
<li data-cc="+61">澳大利亚 +61</li>
<li data-cc="+82">韩国 +82</li>
<li data-cc="+1">加拿大 +1</li>
<li data-cc="+60">马来西亚 +60</li>
<li data-cc="+81">日本 +81</li>
<li data-cc="+65">新加坡 +65</li>
<li data-cc="+44">英国 +44</li>
</ul>
</span>
<input type="text" placeholder="请输入手机号" class="right mobile" />
</div>
<div class="gift-group bind-mobile-input">
<input type="text" placeholder="短信验证码" class="left mobile-code" />
<span class="right mobile-btn">获取短信验证码</span>
</div>
</div>
</script>
{{!-- 激活礼品卡模板 --}}
<script id="activate-gift-tpl" type="text/html">
<div class="title">激活礼品卡</div>
<div class="verify-input activate-center">
<div class="gift-group"><input type="text" placeholder="请输入礼品卡卡号" class="card-code" /></div>
<div class="gift-group activate-input-last"><input type="text" placeholder="请输入礼品卡卡密" class="card-pwd" /></div>
</div>
</script>
{{!-- 消费明细 --}}
<script id="detail-gift-tpl" type="text/html">
<div class="detail-gift-list">
<div class="info-title">消费明细</div>
<div class="verify-input detail-gift-content">
</div>
</div>
</script>
... ...
<div class="orders-me-page invoice-me-page me-page yoho-page clearfix">
{{> path}}
{{> navigation}}
{{# meOrders}}
<div class="me-main">
<div class="orders block">
<h2 class="title">我的发票</h2>
<div id="me-invoice-orders" class="me-orders">
<p class="order-table-header table-header clearfix">
<span class="info">商品信息</span>
<span class="price">单价(元)</span>
<span class="count">数量</span>
<span class="pay">发票类型</span>
<span class="order-status">状态</span>
<span class="operation">操作</span>
</p>
{{#if orders.empty}}
<p class="empty-tip">您还没有相关订单<br><span>未开票的订单可以在这里补开发票</span></p>
{{^}}
{{# orders.list}}
<div class="order" data-id="{{orderNum}}" data-time="{{time}}" data-paytype="{{payType}}">
<p class="order-title">
{{title}}
<span class="order-time">下单时间:{{orderTime}}</span>
{{#if unsupportSupplyTip}}
<span class="right unsupport-tip"><i class="iconfont">&#xe6c9;</i>{{unsupportSupplyTip}}</span>
{{/if}}
</p>
<div class="order-wrap">
<ul>
{{# goods}}
<li>
<div class="info clearfix">
<a class="thumb-wrap" href="{{href}}" target="_blank">
<img class="thumb" src="{{thumb}}">
{{> home/orders/order-goods-tags}}
</a>
<div class="text-info">
{{#if refundStatus}}
<a href="{{goRefundUrl}}"><span class="had-refund">已退换</span></a>
{{/if}}
<a class="name" href="{{href}}" target="_blank">{{name}}</a>
<span class="color-size">
{{#if virtualGood}}
{{#if color}}
日期:{{color}}&nbsp;&nbsp;
{{/if}}
{{#if size}}
区域:{{size}}
{{/if}}
{{else}}
{{#if color}}
<b title="{{color}}">颜色:{{color}}&nbsp;&nbsp;</b>
{{/if}}
{{#if size}}
尺码:{{size}}
{{/if}}
{{#if arrivalDate}}
<i class="arrival-date">上市期:{{arrivalDate}}</i>
{{/if}}
{{/if}}
</span>
</div>
</div>
<div class="price">
<p>{{price}}</p>
{{#if linePrice}}
<p class="line-through">{{linePrice}}</p>
{{/if}}
{{#isVipPrice}}
<p class="tip-message">(VIP)</p>
{{/isVipPrice}}
{{#isStuPrice}}
<p class="tip-message">(学生价)</p>
{{/isStuPrice}}
{{#if free}}
<span class="free-icon">免单</span>
{{/if}}
</div>
<div class="count">{{count}}</div>
</li>
{{/ goods}}
</ul>
<div class="pay">
<span class="pay-tip">{{invoiceType}}</span>
</div>
<div class="order-status">
<span class="no-pay">{{#if issueType}}已开票{{^}}未开票{{/if}}</span>
</div>
<div class="operation">
{{# invoiceOperation}}
{{#if invoiceDetail}}
<span class="op-item view-invoice" data-id="{{../orderNum}}">查看发票</span>
{{/if}}
{{#if invoiceSupplying}}
<span class="op-item" data-id="{{../orderNum}}">开票中</span>
{{/if}}
{{#if supplyInvoice}}
<span class="op-item supply-invoice" data-id="{{../orderNum}}">申请补开</span>
{{/if}}
{{#if unsupportSupply}}
<span class="op-item" data-id="{{../orderNum}}">不支持补开</span>
{{/if}}
{{/ invoiceOperation}}
</div>
</div>
</div>
{{/ orders.list}}
{{/if}}
</div>
{{> pager}}
</div>
</div>
{{/ meOrders}}
</div>
<div id="invoice-hide-dg" class="hide">
<p class="invoice-header">补开发票</p>
<div class="invoice-content el-content">
<p class="invoice-type-text">
<span class="row-title">&nbsp;&nbsp;&nbsp;型:</span>
电子发票
</p>
<p class="el-tip">
※ 电子发票是税务局认可的有效凭证,其法律效力、基本用途及使用规定同纸质发票,如需纸质发票可自行下载打印。<br>
<a href="/help/detail?id=33&contId=139" target="_blank">查看发票须知</a>
</p>
<ul>
<li class="invoice-title invoice-row">
<span class="row-title">
<em>*</em>
&nbsp;&nbsp;&nbsp;头:
</span>
<div class="row-content">
<span class="radio-wrap">
<label class="rbt-1 radio-btn on" data-id="1"></label> 个人
</span>
<span class="radio-wrap">
<label class="rbt-2 radio-btn" data-id="2"></label> 单位
</span>
</div>
</li>
<li class="invoice-personal-name invoice-row personal-row">
<span class="row-title"></span>
<div class="row-content">
<input id="personal-name" class="personal-name" type="text" placeholder="个人( 可修改 )" maxlength="100">
</div>
</li>
<li class="invoice-title-name invoice-row company-row hide">
<span class="row-title">
<em>*</em>
&nbsp;&nbsp;&nbsp;称:
</span>
<div class="row-content">
<input id="company-name" class="company-name" type="text" placeholder="请填写单位名称" maxlength="100">
<span class="input-tip company-name-tip red hide">
<span class="iconfont">&#xe629;</span>
<em>请填写发票抬头</em>
</span>
</div>
</li>
<li class="invoice-tax-num invoice-row company-row hide">
<span class="row-title">
<em>*</em>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;号:
</span>
<div class="row-content">
<input id="company-tax-num" class="company-tax-num" type="text" placeholder="请输入正确的纳税人识别号">
<span class="input-tip company-tax-tip red hide">
<span class="iconfont">&#xe629;</span>
<em>请填写纳税人识别号</em>
</span>
</div>
</li>
<li class="receiver invoice-row">
<span class="row-title">
<em>*</em>
&nbsp;&nbsp;&nbsp;码:
</span>
<div class="row-content">
<input id="receiver-phone" class="receiver-phone" type="text" placeholder="可通过手机号码在发票服务平台查询">
<span class="input-tip receiver-tip red hide">
<span class="iconfont">&#xe629;</span>
<em></em>
</span>
</div>
</li>
</ul>
</div>
</div>
... ...
<ul class="tabs clearfix">
{{# tabs}}
<li {{#if active}}class="active"{{/if}}>
<a href="{{url}}">{{name}}</a>
<li class="{{#if active}}active{{/if}}{{#if class}} {{class}}{{/if}}">
<a href="{{#if url}}{{url}}{{^}}javascript:;{{/if}}">{{name}}</a>
</li>
{{/ tabs}}
</ul>
... ...
... ... @@ -125,6 +125,7 @@ module.exports = class extends global.yoho.BaseModel {
req.session.TOKEN_ = publicToken;
req.session.LOGIN_UID_ = uid;
req.session.USER_MOBILE = data.mobile;
res.cookie('_TOKEN', publicToken, {
domain: config.cookieDomain,
... ...
... ... @@ -19,15 +19,15 @@ module.exports = {
// test3
singleApi: 'http://api-test3.yohops.com:9999/',
api: 'http://api-test3.yohops.com:9999/',
service: 'http://service-test3.yohops.com:9999/',
serviceNotify: 'http://service-test3.yohops.com:9999/',
service: 'http://api-test3.yohops.com:9999/',
serviceNotify: 'http://api-test3.yohops.com:9999/',
global: 'http://global-test-soa.yohops.com:9999/',
platformApi: 'http://192.168.102.48:8088/',
// test2
// singleApi: 'http://api-test2.yohops.com:9999/',
// api: 'http://api-test2.yohops.com:9999/',
// service: 'http://service-test2.yohops.com:9999/',
// service: 'http://api-test2.yohops.com:9999/',
// serviceNotify: 'http://service-test2.yohops.com:9999/',
// global: 'http://global-test-soa.yohops.com:9999/',
// platformApi: 'http://192.168.102.48:8088/',
... ... @@ -35,23 +35,23 @@ module.exports = {
// prod
// singleApi: 'http://single.yoho.cn/',
// api: 'http://api.yoho.cn/',
// service: 'http://service.yoho.cn/',
// service: 'http://api.yoho.cn/',
// serviceNotify: 'http://service.yoho.cn/',
// global: 'http://api-global.yohobuy.com/',
// platformApi: 'http://172.16.6.210:8088/',
// gray
singleApi: 'http://single.gray.yohops.com/',
api: 'http://api.gray.yohops.com/',
service: 'http://service.gray.yohops.com/',
platformApi: 'http://172.16.6.210:8088/',
// singleApi: 'http://single.gray.yohops.com/',
// api: 'http://api.gray.yohops.com/',
// service: 'http://api.gray.yohops.com/',
// platformApi: 'http://172.16.6.210:8088/',
// dev
// api: 'http://dev-api.yohops.com:9999/',
// service: 'http://dev-service.yohops.com:9999/',
// service: 'http://dev-api.yohops.com:9999/',
// serviceNotify: 'http://dev-service.yohops.com:9999/',
// singleApi: 'http://dev-api.yohops.com:9999/',
// platformApi: 'http://192.168.102.48:8088/',,
// platformApi: 'http://192.168.102.48:8088/',
imSocket: 'ws://socket.yohobuy.com:10240',
imCs: 'http://im.yohobuy.com/api',
... ... @@ -171,10 +171,10 @@ if (isProduction) {
domains: {
singleApi: 'http://single.yoho.cn/',
api: 'http://api.yoho.yohoops.org/',
service: 'http://service.yoho.yohoops.org/',
service: 'http://api.yoho.yohoops.org/',
search: 'http://search.yohoops.org/yohosearch/',
global: 'http://api-global.yohobuy.com/',
serviceNotify: 'http://service.yoho.cn/',
serviceNotify: 'http://api.yoho.yohoops.org/',
imSocket: 'wss://imsocket.yohobuy.com:443',
imCs: 'https://imhttp.yohobuy.com/api',
platformApi: 'http://api.platform.yohoops.org',
... ... @@ -223,10 +223,10 @@ if (isProduction) {
domains: {
singleApi: process.env.TEST_API || 'http://192.168.102.31:8092/brower',
api: process.env.TEST_API || 'http://testapi.yoho.cn:28078/',
service: process.env.TEST_SERVICE || 'http://testservice.yoho.cn:28077/',
service: process.env.TEST_API || 'http://testapi.yoho.cn:28078/',
global: process.env.TEST_GOLBAL || 'http://global-test-soa.yohops.com:9999/',
search: process.env.TEST_SEARCH || 'http://192.168.102.216:8080/yohosearch/',
serviceNotify: process.env.TEST_SERVICE || 'http://testservice.yoho.cn:28077/',
serviceNotify: process.env.TEST_API || 'http://testapi.yoho.cn:28078/',
imSocket: 'ws://socket.yohobuy.com:10240',
imCs: 'http://im.yohobuy.com/api'
},
... ...
... ... @@ -76,7 +76,7 @@ module.exports = () => {
// uuid
yoho.udid = (function() {
let udid = req.cookies.udid;
let udid = req.cookies._yasvd || req.cookies.udid;
if (!udid) {
udid = md5(yoho.clientIp);
... ...
... ... @@ -33,6 +33,7 @@ module.exports = () => {
req.user.name = getName(userInfo); // 0
req.user.vip = getVip(userInfo); // 2
req.user.token = getToken(userInfo); // 3
req.user.mobile = req.session.USER_MOBILE;
req.user.isStudent = req.cookies.isStudent || 0;
req.user.uid = {
... ...
{
"name": "yohobuy-node",
"version": "6.0.20",
"version": "6.0.21",
"private": true,
"description": "A New Yohobuy Project With Express",
"repository": {
... ...
{{# usable_giftCards}}
<tr>
<td>{{cardCode}}</td>
<td>{{amount}}</td>
<td>{{remainAmount}}</td>
<td>{{dateStr}}</td>
<td><span class="gift-card-radio" data-id="{{cardCode}}" data-price="{{price}}"></span></td>
</tr>
{{/ usable_giftCards}}
... ...
<h2 class="title">发票详情</h2>
<p class="order-info">订单号:{{order_code}}</p>
<table>
<tr>
<td width="80"><span class="lt">发票类型</span></td>
<td>{{invoicesType}}</td>
</tr>
<tr>
<td><span class="lt">发票内容</span></td>
<td>{{invoice_content}}</td>
</tr>
<tr>
<td><span class="lt">发票抬头</span></td>
<td>{{title}}</td>
</tr>
{{#if buyerTaxNumber}}
<tr>
<td><span class="lt">税号</span></td>
<td>{{buyerTaxNumber}}</td>
</tr>
{{/if}}
<tr>
<td colspan=2 class="line"></td>
</tr>
<tr>
<td><span class="lt">收票人姓名</span></td>
<td>{{userName}}</td>
</tr>
<tr>
<td><span class="lt">收票人手机</span></td>
<td>{{receiverMobile}}</td>
</tr>
</table>
{{#if showInvoice}}
<p>
<a href="{{pdfUrl}}" class="download-btn">下载电子发票</a>
</p>
{{/if}}
... ...
... ... @@ -22,12 +22,16 @@ var payWay,
multiPackage,
coupon,
yohoCoin,
giftCard,
refund;
var lastOrderPrice = $orderPrice.data('price');
var address = require('./order/address'),
invoice = require('./order/invoice'),
esaypayInfo = require('./order/easypay');
var giftCardTpl = require('hbs/cart/ensure-gift-card-list.hbs');
var coinTpl = Hbs.compile($('#yoho-coin-tpl').html());
var promotionTpl = Hbs.compile($('#promotion-list-tpl').html());
... ... @@ -97,6 +101,11 @@ function compute(coin, cb) {
reqData.redEnvelopes = order.redEnvelopes;
}
// 礼品卡
if (order.giftCard) {
reqData.giftCard = order.giftCard;
}
if (esaypayInfo) {
if (order.sku) {
reqData.sku = order.sku;
... ... @@ -135,11 +144,15 @@ function compute(coin, cb) {
yohoCoin.$el.html(coinTpl(res));
// update last order amount
lastOrderPrice = res.last_order_amount;
$orderPrice.html('¥ ' + res.last_order_amount);
// update promotion formula list
$balanceDetail.html(promotionTpl(res));
// update giftCard use status
giftCard.setUseStatus(lastOrderPrice);
}
// callback
... ... @@ -674,6 +687,93 @@ yohoCoin = {
}
};
// 礼品卡
giftCard = {
$el: $('#use-gift-card'),
init: function() {
if (!this.$el.length) {
return;
}
this.$giftCardWrap = this.$el.next();
this.getList();
this.eventBind();
},
getList: function() {
var that = this;
$.ajax({
type: 'GET',
url: '/cart/ensure/giftcards'
}).then(function(data) {
if (data.code === 200) {
if (data.data && data.data.usable_giftCards && data.data.usable_giftCards.length) {
that.$el.removeClass('hide').next().removeClass('hide');
$('.can-use-tip', that.$el).text('(' + data.data.usable_giftCards.length + '张可用)');
}
if (data.data.usable_giftCards.length) {
$('tbody', that.$giftCardWrap).html(giftCardTpl(data.data));
that.$radios = $('.gift-card-radio', that.$giftCardWrap);
}
that.checkContent = '<h2>安全验证</h2>' +
'<p class="tip-info">您正在使用礼品卡支付,为了保证您的账户安全,需要进行安全验证。</p>' +
'<p class="receiver-info">验证码已发送至' + (data.data.userMobile || '您绑定的') + '手机号</p>' +
'<p><input type="text" placeholder="短信验证码" maxlength="8"><span class="send-sms">获取验证码</span></p>';
}
});
},
eventBind: function() {
var that = this;
this.$giftCardWrap.on('click', '.gift-card-radio', function() {
var $this = $(this);
if ($this.hasClass('disabled')) {
return;
}
if ($this.hasClass('on')) {
// 取消使用礼品卡,设置其他礼品卡可用
that.setUseStatus(2);
} else if (+$this.data('price') >= lastOrderPrice * 1) { // 已选礼品卡总价大于订单总价,设置其他礼品卡不可选
that.setUseStatus();
}
$this.toggleClass('on');
that.changeCardUse();
});
},
changeCardUse: function() {
var codes = [];
if (!this.$radios) {
return;
}
this.$radios.filter('.on').each(function() {
codes.push($(this).data('id'));
});
order.giftCard = codes.join(',');
compute(order.coin);
},
setUseStatus: function(price) {
if (!this.$radios) {
return;
}
if (price && price * 1 > 0) {
this.$radios.filter('.disable').removeClass('disable');
} else {
this.$radios.not('.on').addClass('disable');
}
}
};
// 退换货提示
refund = {
$el: $('.special-tip'),
... ... @@ -691,8 +791,6 @@ refund = {
}
};
$('.locker-switch').click(function() {
var $this = $(this),
$par = $this.parent();
... ... @@ -740,58 +838,19 @@ $('.locker-switch').click(function() {
});
}());
$('#remark-box').on('keyup', '.note-text', function() {
var $this = $(this);
var val = $.trim($this.val());
if (val) {
$this.addClass('has-text');
if (val.length > 100) {
val = val.substring(0, 99);
$this.val(val);
}
order.remark = val;
} else {
$this.removeClass('has-text');
}
}).on('click', '.radio-btn', function() {
var $this = $(this);
if ($this.hasClass('on')) {
return;
}
if ($this.hasClass('unprint')) {
order.printPrice = 'N';
} else {
order.printPrice = 'Y';
}
$this.siblings('.on').removeClass('on');
$this.addClass('on');
});
$('#order-submit').click(function() {
var invoiceInfo = invoice.getInvoice();
order.addressId = address.getAddress();
// 发票信息
if (invoiceInfo) {
$.extend(order, invoiceInfo);
}
// 订单参数校验
if (!validateOrderInfo(order)) {
return;
}
function sendCkeckSms() {
return $.ajax({
type: 'POST',
url: '/cart/property/checksms',
data: {giftCard: order.giftCard}
});
}
function submitOrder(reqData) {
$.ajax({
type: 'POST',
url: '/cart/ensure/submit',
data: order
data: reqData
}).then(function(data) {
var rdata, subTip, newUser,
tongJi = {
... ... @@ -800,6 +859,7 @@ $('#order-submit').click(function() {
sku: [],
py: []
};
var errAlert;
if (data.code === 200) {
rdata = data.data;
... ... @@ -877,9 +937,131 @@ $('#order-submit').click(function() {
location.href = rdata.url;
}
} else if (data.message) {
new dialog.Alert(data.message).show();
errAlert = new dialog.Alert(data.message);
errAlert.$el.addClass('ensure-alert');
errAlert.show();
}
});
}
$('#remark-box').on('keyup', '.note-text', function() {
var $this = $(this);
var val = $.trim($this.val());
if (val) {
$this.addClass('has-text');
if (val.length > 100) {
val = val.substring(0, 99);
$this.val(val);
}
order.remark = val;
} else {
$this.removeClass('has-text');
}
}).on('click', '.radio-btn', function() {
var $this = $(this);
if ($this.hasClass('on')) {
return;
}
if ($this.hasClass('unprint')) {
order.printPrice = 'N';
} else {
order.printPrice = 'Y';
}
$this.siblings('.on').removeClass('on');
$this.addClass('on');
});
$('#order-submit').click(function() {
var invoiceInfo = invoice.getInvoice();
var checkDg;
order.addressId = address.getAddress();
// 发票信息
if (invoiceInfo) {
$.extend(order, invoiceInfo);
}
// 订单参数校验
if (!validateOrderInfo(order)) {
return;
}
// 使用礼品卡时候进行短信校验
if (order.giftCard) {
checkDg = new dialog.Dialog({
content: giftCard.checkContent || '',
className: 'gift-card-check-dialog',
btns: [{
id: 'check-cancel',
btnClass: ['check-cancel'],
name: '取消',
cb: function() {
checkDg.close();
}
}, {
id: 'check-sure',
btnClass: ['check-sure'],
name: '确定',
cb: function() {
order.checkCode = $('input', checkDg.$el).val();
if (order.checkCode) {
submitOrder(order);
checkDg.close();
}
}
}]
});
checkDg.$sendBtn = $('.send-sms', checkDg.$el);
checkDg.sendSms = function() {
var that = this;
if (!this.$sendBtn || this.seconds > 0) {
return;
}
sendCkeckSms(); // 发送验证码
if (!this.seconds || this.seconds < 1) {
this.seconds = 59;
}
this.timer && clearInterval(this.timer);
this.$sendBtn.text('重新获取(' + (this.seconds--) + ')').addClass('timer');
this.timer = setInterval(function() {
if (that.seconds > 0) {
that.$sendBtn.text('重新获取(' + (that.seconds--) + ')').addClass('timer');
} else {
that.$sendBtn.text('重新获取').removeClass('timer');
clearInterval(that.timer);
}
}, 1000);
return this;
};
checkDg.$sendBtn.click(function() {
checkDg.sendSms();
});
checkDg.sendSms().show();
return;
} else {
order.checkCode && delete order.checkCode;
}
submitOrder(order);
});
payWay.init();
... ... @@ -887,6 +1069,7 @@ deliveryWay.init();
multiPackage.init();
coupon.init();
yohoCoin.init();
giftCard.init();
refund.init();
// 获取用户是否新客(品众统计)写cookie
... ...
... ... @@ -11,9 +11,14 @@ var yas = require('../common/data-yas'),
var $orderPrice = $('#order-price');
var order = {};
var yohoCoin;
var yohoCoin,
giftCard;
var lastOrderPrice = $orderPrice.data('price');
var submitting = false;
var giftCardTpl = require('hbs/cart/ensure-gift-card-list.hbs');
require('../common');
require('../simple-header');
... ... @@ -85,7 +90,11 @@ function compute(coin) {
order.coin = result.data.usedCoinNum;
yohoCoin.maxCoin = result.data.canUseCoinNum;
$orderPrice.html('¥ ' + result.data.last_order_amount);
lastOrderPrice = result.data.last_order_amount;
$orderPrice.html('¥ ' + lastOrderPrice);
giftCard.setUseStatus(lastOrderPrice);
}
});
}
... ... @@ -133,44 +142,213 @@ yohoCoin = {
}
};
$('.locker-switch').click(function() {
var $this = $(this),
$par = $this.parent();
// 礼品卡
giftCard = {
$el: $('#use-gift-card'),
init: function() {
if (!this.$el.length) {
return;
}
$par.toggleClass('open');
});
this.$giftCardWrap = this.$el.next();
this.getList();
this.eventBind();
},
getList: function() {
var that = this;
$('#order-submit').on('click', function() {
$.ajax({
type: 'GET',
url: '/cart/ensure/giftcards'
}).then(function(data) {
if (data.code === 200) {
if (data.data && data.data.usable_giftCards && data.data.usable_giftCards.length) {
that.$el.removeClass('hide').next().removeClass('hide');
$('.can-use-tip', that.$el).text('(' + data.data.usable_giftCards.length + '张可用)');
}
if (data.data.usable_giftCards.length) {
$('tbody', that.$giftCardWrap).html(giftCardTpl(data.data));
that.$radios = $('.gift-card-radio', that.$giftCardWrap);
}
that.checkContent = '<h2>安全验证</h2>' +
'<p class="tip-info">您正在使用礼品卡支付,为了保证您的账户安全,需要进行安全验证。</p>' +
'<p class="receiver-info">验证码已发送至' + (data.data.userMobile || '您绑定的') + '手机号</p>' +
'<p><input type="text" placeholder="短信验证码" maxlength="8"><span class="send-sms">获取验证码</span></p>';
}
});
},
eventBind: function() {
var that = this;
this.$giftCardWrap.on('click', '.gift-card-radio', function() {
var $this = $(this);
if (submitting) {
if ($this.hasClass('disabled')) {
return;
}
order = handleOrderInfo(order);
if ($this.hasClass('on')) {
// 取消使用礼品卡,设置其他礼品卡可用
that.setUseStatus(2);
} else if (+$this.data('price') >= lastOrderPrice * 1) { // 已选礼品卡总价大于订单总价,设置其他礼品卡不可选
that.setUseStatus();
}
if (!validateUserInfo(order)) {
$this.toggleClass('on');
that.changeCardUse();
});
},
changeCardUse: function() {
var codes = [];
if (!this.$radios) {
return;
}
this.$radios.filter('.on').each(function() {
codes.push($(this).data('id'));
});
order.giftCard = codes.join(',');
compute(order.coin);
},
setUseStatus: function(price) {
if (!this.$radios) {
return;
}
if (price && price * 1 > 0) {
this.$radios.filter('.disable').removeClass('disable');
} else {
this.$radios.not('.on').addClass('disable');
}
}
};
function submitOrder(reqData, url) {
submitting = true;
$.ajax({
type: 'POST',
url: '/cart/ticketSubmit',
data: order
data: reqData
}).then(function(data) {
if (data.code === 200) {
window.location.href = data.data.refer;
} else if (data.code === 500) {
errorInfo(data.message, $this.data('url'));
errorInfo(data.message, url);
} else {
new dialog.Alert(data.message || '网络异常~').show();
}
}).always(function() {
submitting = false;
});
}
function sendCkeckSms() {
return $.ajax({
type: 'POST',
url: '/cart/property/checksms',
data: {giftCard: order.giftCard}
});
}
$('.locker-switch').click(function() {
var $this = $(this),
$par = $this.parent();
$par.toggleClass('open');
});
$('#order-submit').on('click', function() {
var errUrl = $(this).data('url'),
checkDg;
if (submitting) {
return;
}
order = handleOrderInfo(order);
if (!validateUserInfo(order)) {
return;
}
// 使用礼品卡时候进行短信校验
if (order.giftCard) {
checkDg = new dialog.Dialog({
content: giftCard.checkContent || '',
className: 'gift-card-check-dialog',
btns: [{
id: 'check-cancel',
btnClass: ['check-cancel'],
name: '取消',
cb: function() {
checkDg.close();
}
}, {
id: 'check-sure',
btnClass: ['check-sure'],
name: '确定',
cb: function() {
order.checkCode = $('input', checkDg.$el).val();
if (order.checkCode) {
submitOrder(order, errUrl);
checkDg.close();
}
}
}]
});
checkDg.$sendBtn = $('.send-sms', checkDg.$el);
checkDg.sendSms = function() {
var that = this;
if (!this.$sendBtn || this.seconds > 0) {
return;
}
sendCkeckSms(); // 发送验证码
if (!this.seconds || this.seconds < 1) {
this.seconds = 59;
}
this.timer && clearInterval(this.timer);
this.$sendBtn.text('重新获取(' + (this.seconds--) + ')').addClass('timer');
this.timer = setInterval(function() {
if (that.seconds > 0) {
that.$sendBtn.text('重新获取(' + (that.seconds--) + ')').addClass('timer');
} else {
that.$sendBtn.text('重新获取').removeClass('timer');
clearInterval(that.timer);
}
}, 1000);
return this;
};
checkDg.$sendBtn.click(function() {
checkDg.sendSms();
});
checkDg.sendSms().show();
return;
}
order.checkCode && delete order.checkCode;
submitOrder(order, errUrl);
});
yohoCoin.init();
giftCard.init();
// 获取用户是否新客(品众统计)写cookie
$.ajax({type: 'GET', url: '/home/newuser'});
... ...
/**
* 我的发票
* @author: yyq<yanqing.yang@yoho.cn>
* @date: 201/2/17
*/
var $ = require('yoho-jquery');
var dialog = require('../common/dialog');
var Dialog = dialog.Dialog,
Alert = dialog.Alert;
var $hideDg = $('#invoice-hide-dg');
var detailTpl = require('hbs/home/invoice/detail.hbs');
var invoiceTpl = $hideDg.html();
var defaultReceiver;
require('../common');
$hideDg.remove();
function bindSupplyDialogEvent($el) {
var $titleWrap = $('.invoice-title', $el),
$personalRow = $('.personal-row', $el),
$companyRow = $('.company-row', $el);
$titleWrap.on('click', '.radio-btn', function() {
var $this = $(this),
id = $this.data('id');
if ($this.hasClass('on')) {
return;
}
if (id * 1 === 2) {
$companyRow.removeClass('hide');
$personalRow.addClass('hide');
} else {
$companyRow.addClass('hide');
$personalRow.removeClass('hide');
}
$titleWrap.find('.on').removeClass('on');
$this.addClass('on');
});
}
function packInvoiceInfo($el) {
var resData = { // 5.8.1需求,只支持电子发票(type: 2),发票内容只能开明细(id:12)
invocesType: 2,
contentId: 12,
contentName: '明细'
},
receiver = $('#receiver-phone', $el).val();
resData.titleId = $('.invoice-title .on', $el).data('id') || 1;
if (resData.titleId * 1 === 1) {
resData.titleName = $.trim($('#personal-name', $el).val()) || '个人';
} else {
resData.titleName = $.trim($('#company-name', $el).val());
resData.taxNumber = $.trim($('#company-tax-num', $el).val());
}
if (receiver) {
resData.receiver = receiver;
}
return resData;
}
function validateInvoice($el, info) {
var pass = true;
var $receiverTip;
// 发票抬头
if (!info.titleName) {
pass = false;
$('.company-name-tip', $el).removeClass('hide');
} else {
$('.company-name-tip', $el).addClass('hide');
}
if (info.titleId === 2) {
if (!info.taxNumber) {
pass = false;
$('.company-tax-tip', $el).removeClass('hide');
} else {
$('.company-tax-tip', $el).addClass('hide');
}
}
// 收票人手机号
if (info.invocesType * 1 === 2) {
$receiverTip = $('.receiver-tip', $el);
if (!info.receiver) {
$receiverTip.removeClass('hide').find('em').html('请填写手机号码');
pass = false;
} else if (defaultReceiver && info.receiver === defaultReceiver.hide) {
$receiverTip.addClass('hide');
} else if (!/^[0-9]{11}$/.test(info.receiver)) {
$receiverTip.removeClass('hide').find('em').html('请输入正确手机号');
pass = false;
} else {
$receiverTip.addClass('hide');
}
}
return pass;
}
function viewInvoice(code) {
if (!code) {
return;
}
$.ajax({
url: '/home/invoice/detail',
type: 'GET',
data: {orderCode: code}
}).done(function(res) {
if (res.code !== 200) {
return;
}
new Dialog({
className: 'invoice-me-page invoice-detail-dialog',
content: detailTpl(res.data)
}).show();
});
}
function supplyInvoice(info, cb) {
$.ajax({
url: '/home/invoice/supply',
type: 'POST',
data: info
}).done(function(res) {
var _dg, _btn;
cb && cb(res); // eslint-disable-line
if (res.code === 200) {
if (res.data.issueType === 2) {
_btn = {
name: '查看发票',
cb: function() {
viewInvoice(res.data.order_code);
}
};
} else {
_btn = {name: '我知道了'};
}
_dg = new Dialog({
className: 'invoice-me-page supply-success-dialog',
content: '<h2>提交成功</h2><p>您的服务申请已提交,您可以在我的发票中下载电子发票</p>',
btns: [{
id: 'close-dg',
name: _btn.name,
btnClass: ['close-dg'],
cb: function() {
_dg.close();
_btn.cb && _btn.cb();
}
}]
}).show();
}
});
}
$('#me-invoice-orders').on('click', '.supply-invoice', function() {
var $this = $(this);
var dg = new Dialog({
className: 'invoice-me-page invoice-supply-dialog',
content: invoiceTpl,
btns: [{
id: 'sure-apply',
name: '提交',
btnClass: ['sure-apply'],
cb: function() {
var info = packInvoiceInfo(dg.$el);
var errAlert;
if (!validateInvoice(dg.$el, info)) {
return;
}
info.orderCode = $this.data('id');
supplyInvoice(info, function(data) {
if (data.code !== 200) {
dg.$el.hide();
errAlert = new Alert(data.message).show();
errAlert.$el.on('click', '.close', function() {
dg.$el.show();
}).on('click', '.alert-sure', function() {
dg.$el.show();
});
return;
}
dg.close();
if (+data.issueType === 2) {
$this.removeClass('supply-invoice').addClass('view-invoice').text('查看发票');
} else {
$this.removeClass('supply-invoice').text('开票中');
}
});
}
}, {
id: 'cancel-apply',
name: '取消',
btnClass: ['cancel-apply'],
cb: function() {
dg.close();
}
}]
}).show();
// 事件绑定
bindSupplyDialogEvent(dg.$el);
}).on('click', '.view-invoice', function() {
viewInvoice($(this).data('id'));
});
... ...
var $ = require('yoho-jquery'),
Hbs = require('yoho-handlebars'),
dialog = require('../common/dialog');
var meGift;
require('yoho-jquery-placeholder');
require('../common');
meGift = {
isFlag: false, // 防止用户频繁点击
// 验证邮箱模板
emailTpl: Hbs.compile($('#verify-email-tpl').html()),
// 绑定手机模板
mobileTpl: Hbs.compile($('#verify-mobile-tpl').html()),
// 激活礼品卡模板
giftTpl: Hbs.compile($('#activate-gift-tpl').html()),
// 消费明细模板
detailGiftTpl: Hbs.compile($('#detail-gift-tpl').html()),
// 添加礼品卡按钮
$addGift: $('.add-gift'),
// 是否绑定手机
isBinMobile: +$('.me-content').data('is-bin-mobile'),
// 用户邮箱
userEmail: $('.me-content').data('email'),
init: function() {
var that = this;
// 添加礼品卡
this.$addGift.click(function() {
if (that.isBinMobile) {
that.activateGift();
} else {
that.getMobileCode();
}
});
// 显示手机区号或类型下拉列表
$('body').on('click', '.mobile-area,.gift-filter', function() {
$(this).find('.ul-list').toggle();
});
// 选择手机区号
$('body').on('click', '.mobile-area-list', function(event) {
var $li = $(event.target).closest('li');
$('.mobile-area').find('em').text($li.data('cc'));
});
// 消费明细
$('.me-gift-table').on('click', '.info-list', function() {
new dialog.Dialog({
content: that.detailGiftTpl({}),
className: 'me-page me-gift-page me-gift-confirm'
}).show();
that.infoList('?' + $.param({
cardCode: $(this).closest('.me-gift-tr').data('card-code')
}));
});
// 消费明细-选择类型筛选
$('body').on('click', '.gift-filter ul', function(event) {
var $li = $(event.target).closest('li');
$('.gift-filter').find('em').text($li.text());
that.infoList('?' + $.param({
cardCode: $('.info-gift-header').data('card-code'),
type: $li.data('cc')
}));
});
// 消费明细翻页
$('body').on('click', '.detail-gift-content .pager a', function() {
if ($(this).hasClass('cur')) {
return false;
}
that.infoList($(this).attr('href'));
return false;
});
},
postAjax: function(url, data, verifyData) {
var deferred = $.Deferred(); // eslint-disable-line
var that = this;
var x;
if (that.isFlag) {
return deferred.resolve({
code: 401,
message: '数据请求中...'
});
}
if (verifyData) {
for (x in verifyData) {
if (!data[x]) {
that.meAlert(verifyData[x], false);
return deferred.resolve({
code: 401,
message: verifyData[x]
});
}
}
}
that.isFlag = true;
return $.ajax({
url: url,
type: 'post',
data: data
}).then(function(res) {
if (res.code !== 200) {
that.meAlert(res.message, false);
}
that.isFlag = false;
return res;
}, function() {
that.isFlag = false;
});
},
intTimer: function($dom) {
var intTime = 60;
var intval = setInterval(function() {
if (intTime-- <= 0) {
clearInterval(intval);
$dom.removeClass('int-timer').html('获取短信验证码');
return false;
}
$dom.html(intTime + 's');
}, 1000);
$dom.addClass('int-timer');
$dom.html(intTime + 's');
},
// 获取邮箱验证码
getEmailCode: function() {
var that = this;
this.postAjax('/home/megift/sendEmailCode', {
email: this.userEmail
}, {}).then(function(res) {
if (res.code === 200) {
that.intTimer($('.email-btn'));
}
});
},
// 效验邮箱验证码
verifyEmailCode: function() {
var that = this;
var dg = new dialog.Dialog({
closeIcon: false,
content: that.emailTpl({}),
className: 'me-gift-confirm',
btns: [{
id: 'confirm-email-btn',
name: '绑定手机号',
btnClass: ['alert-sure'],
cb: function() {
var emailCode = $('.email-code').val();
var verifyData = {code: '验证码不能为空'};
that.postAjax('/home/megift/verifyEmail', {
email: that.userEmail,
code: emailCode
}, verifyData).then(function(res) {
if (res.code === 200) {
dg.close();
that.getMobileCode();
}
});
}
}]
}).show();
setTimeout(function() {
$('[placeholder]', dg.$el).placeholder(); // ie8 兼容 placeholder
}, 10);
// 发送邮箱验证码
$('.me-gift-confirm').find('.email-btn').unbind('click').bind('click', function() {
if (!$(this).hasClass('int-timer')) {
that.getEmailCode();
}
});
},
// 获取手机验证码
getMobileCode: function() {
var that = this;
var dg = new dialog.Dialog({
closeIcon: false,
content: that.mobileTpl({}),
className: 'me-gift-confirm',
btns: [{
id: 'confirm-mobile-cancel',
name: '取消',
btnClass: ['confirm-cancel'],
cb: function() {
dg.close();
}
}, {
id: 'confirm-mobile-sure',
name: '激活',
btnClass: ['confirm-sure'],
cb: function() {
var verifyData = {
area: '请选择手机区号',
mobile: '手机号不能为空',
code: '手机验证码不能为空'
};
that.postAjax('/home/megift/changeMobile', {
area: ($('.mobile-area').find('em').text() || '').replace(/^\+/, ''),
mobile: $('input.mobile').val(),
code: $('input.mobile-code').val()
}, verifyData).then(function(res) {
if (res.code === 200) {
that.isBinMobile = 1;
dg.close();
that.activateGift();
}
});
}
}]
}).show();
setTimeout(function() {
$('[placeholder]', dg.$el).placeholder(); // ie8 兼容 placeholder
}, 10);
// 发送邮箱验证码
$('.me-gift-confirm').find('.mobile-btn').unbind('click').bind('click', function() {
if (!$(this).hasClass('int-timer')) {
that.smsBind();
}
});
},
// 发送手机验证码
smsBind: function() {
var that = this;
var area = ($('.mobile-area').find('em').text() || '').replace(/^\+/, '');
var mobile = $('input.mobile').val();
var verifyData = {
area: '请选择手机区号',
mobile: '手机号不能为空'
};
this.postAjax('/home/megift/smsBind', {
area: area,
mobile: mobile
}, verifyData).then(function(res) {
if (res.code === 200) {
that.intTimer($('.mobile-btn'));
}
});
},
// 激活礼品卡
activateGift: function() {
var that = this;
var dg = new dialog.Dialog({
closeIcon: false,
content: that.giftTpl({}),
className: 'me-gift-confirm',
btns: [{
id: 'confirm-gift-cancel',
name: '取消',
btnClass: ['confirm-cancel'],
cb: function() {
dg.close();
}
}, {
id: 'confirm-gift-sure',
name: '激活',
btnClass: ['confirm-sure'],
cb: function() {
var $confirm = $('.me-gift-confirm');
var verifyData = {
cardCode: '礼品卡卡号不能为空',
cardPwd: '礼品卡卡密不能为空'
};
that.postAjax('/home/meGift/activateGift', {
cardCode: $confirm.find('.card-code').val(),
cardPwd: $confirm.find('.card-pwd').val()
}, verifyData).then(function(res) {
if (res.code === 200) {
dg.close();
that.meAlert('<p>您的礼品卡激活成功</p>', false, function() {
location.reload();
});
}
});
}
}]
}).show();
setTimeout(function() {
$('[placeholder]', dg.$el).placeholder(); // ie8 兼容 placeholder
}, 10);
},
// 消费明细
infoList: function(url) {
url = url || '';
$.get('/home/megift/detail' + url).then(function(res) {
if (!res) {
return false;
}
$('.detail-gift-content').html(res);
});
},
// 我的弹框
meAlert: function(content, mask, callback) {
var dg;
var meAlertDialog = $('.me-gift-confirm');
meAlertDialog.addClass('hide');
dg = new dialog.Dialog({
closeIcon: false,
content: content,
className: 'me-gift-alert',
mask: !!mask,
btns: [{
name: '我知道了',
id: 'alert-gift-cancel',
btnClass: ['alert-sure'],
cb: function() {
dg.close();
meAlertDialog.removeClass('hide');
callback && callback();
}
}]
}).show();
}
};
$(function() {
meGift.init();
});
... ...
... ... @@ -1244,6 +1244,43 @@
}
}
.gift-card-box {
> table {
width: 100%;
text-align: center;
border: 1px solid #e8e8e8;
}
th,
td {
background-color: #f0f0f0;
line-height: 30px;
text-align: center;
}
td {
padding: 20px 0;
background-color: #fff;
border-top: 1px solid #e8e8e8;
}
.gift-card-radio {
display: inline-block;
width: 15px;
height: 15px;
margin-right: 6px;
background-image: url(/cart/radio-off.png);
vertical-align: middle;
position: relative;
top: -1px;
cursor: pointer;
&.on {
background-image: url(/cart/radio-check.png);
}
}
}
.remark-box {
padding: 30px 20px 0;
background-color: #f0f0f0;
... ... @@ -1835,3 +1872,75 @@
padding: 0 6px;
}
}
.gift-card-check-dialog {
font-size: 14px;
.close {
display: none;
}
.content {
width: 352px;
padding: 0 30px;
h2 {
font-size: 18px;
margin-bottom: 26px;
}
> p {
line-height: 2;
}
input {
width: 160px;
height: 30px;
padding-left: 10px;
box-sizing: border-box;
}
.send-sms {
width: 120px;
height: 30px;
color: #fff;
margin-left: 20px;
background-color: #494949;
display: inline-block;
cursor: pointer;
}
.send-sms.timer {
background-color: #b0b0b0;
cursor: default;
}
}
.tip-info {
text-align: left;
}
.receiver-info {
padding: 24px 0 30px;
}
.btns {
padding-top: 30px;
.btn {
min-width: 100px;
padding: 0;
}
.check-sure {
background-color: #000;
color: #fff;
margin-left: 96px;
}
}
}
.alert-dialog.ensure-alert > .content {
padding-bottom: 0;
padding-top: 60px;
}
... ...
... ... @@ -22,3 +22,5 @@
@import "../variables";
@import "returns-detail";
@import "returns-save";
@import "me-gift";
@import "invoice";
... ...
.invoice-me-page {
.orders > .title {
font-size: 16px;
font-weight: bold;
padding-left: 10px;
background: #e3e3e3;
margin-bottom: 10px;
}
.order-title {
overflow: hidden;
.unsupport-tip {
color: #999;
.iconfont {
font-size: 14px;
margin: 0 4px;
}
}
}
.operation {
> .op-item {
color: #999;
cursor: default;
}
> .view-invoice {
color: #468fa2;
cursor: pointer;
}
> .supply-invoice {
display: inline-block;
box-sizing: border-box;
width: 68px;
height: 18px;
border-radius: 5px;
text-align: center;
color: #000;
border: 1px solid #000;
cursor: pointer;
}
}
.empty-tip {
font-size: 16px;
line-height: 1.5;
padding: 10px 0 300px;
&:before {
content: "";
display: block;
width: 70px;
height: 90px;
background: resolve("home/empty-content.jpg");
margin: 30px auto;
}
> span {
font-size: 14px;
color: #ccc;
}
}
&.invoice-detail-dialog {
background: #fff;
> .close {
position: absolute;
top: 10px;
right: 12px;
cursor: pointer;
.iconfont {
font-size: 32px;
}
}
.content {
width: 450px;
text-align: left;
font-size: 14px;
color: #666;
line-height: 1.6;
padding-bottom: 10px;
}
.title {
font-size: 16px;
color: #222;
padding-bottom: 14px;
border-bottom: 1px solid #ccc;
}
.order-info {
line-height: 50px;
color: #555;
}
table {
width: 100%;
margin-bottom: 20px;
td {
padding: 6px 20px;
border: 1px solid #e3e4e5;
}
.lt {
text-align: justify;
text-align-last: justify;
display: block;
color: #555;
&:after {
content: "";
display: block;
overflow: hidden;
width: 100%;
height: 0;
}
}
.line {
background-color: #eff0f1;
}
}
.download-btn {
display: block;
width: 130px;
line-height: 30px;
color: #fff;
background-color: #444;
text-align: center;
margin: auto;
margin-top: 10px;
}
}
&.invoice-supply-dialog {
$red: #d0021b;
width: 690px;
padding: 20px 58px;
font-size: 14px;
color: #444;
background-color: #fff;
box-sizing: border-box;
> .close {
position: absolute;
top: 10px;
right: 12px;
cursor: pointer;
.iconfont {
font-size: 32px;
}
}
.radio-btn {
&:before {
content: "";
width: 15px;
height: 15px;
margin-right: 4px;
background-image: url(/cart/radio-off.png);
display: inline-block;
vertical-align: middle;
position: relative;
top: -2px;
cursor: pointer;
}
&.on:before {
content: ".";
background-image: url(/cart/radio-on.png);
text-indent: -9999px;
}
}
> .content {
text-align: left;
}
.invoice-header {
font-size: 14px;
padding: 24px 0 20px;
border-bottom: 1px solid #e8e8e8;
}
.invoice-content {
font-weight: 300;
}
.row-title {
font-weight: normal;
}
.el-tip {
background-color: #f5f5f5;
padding: 14px;
line-height: 1.5;
> a {
display: inline-block;
padding-top: 12px;
font-weight: 500;
}
}
.invoice-type-text {
line-height: 20px;
padding: 20px 10px;
.row-title {
margin-right: 10px;
}
}
.invoice-row {
padding-top: 16px;
padding-left: 92px;
overflow: hidden;
.row-content {
width: 110%;
}
.row-title {
line-height: 30px;
position: absolute;
margin-left: -92px;
> em {
color: $red;
margin-right: 3px;
position: relative;
top: 2px;
}
}
.radio-wrap {
width: 92px;
display: inline-block;
padding: 8px 0;
}
input {
width: 220px;
height: 30px;
padding: 0 10px;
background: #f5f5f5;
border: 1px solid #e0e0e0;
}
.red {
color: $red;
}
}
.btns {
padding-top: 28px;
padding-bottom: 10px;
.btn {
width: 140px;
height: 40px;
line-height: 38px;
box-sizing: border-box;
}
.sure-apply {
background-color: #000;
color: #fff;
font-weight: 300;
margin-right: 30px;
}
}
}
&.supply-success-dialog {
background-color: #fff;
font-size: 14px;
.content {
width: 300px;
padding: 0 30px 40px;
line-height: 2;
color: #444;
h2 {
font-size: 18px;
margin-bottom: 26px;
}
}
}
}
... ...
.me-gift-page {
.me-gift .me-content {
min-height: 370px;
}
.tabs li.add-gift {
margin-top: -5px;
background-image: none;
background-color: #000;
float: right;
a {
color: #fff;
}
}
.me-gift-table,
.me-gift-info-table {
display: table;
width: 775px;
text-align: center;
border: 1px solid #e6e6e6;
margin: 0 10px 30px;
.me-gift-header {
display: table-row;
background-color: #efefef;
div {
height: 30px;
display: table-cell;
vertical-align: middle;
font-size: 13px;
width: 120px;
&:first-child {
width: 174px;
}
}
}
.me-gift-tr {
display: table-row;
&:first-child div {
border-top: none;
}
div {
display: table-cell;
height: 50px;
vertical-align: middle;
font-size: 13px;
border-top: 1px solid #e6e6e6;
}
div.info-list {
color: #4a90e2;
cursor: pointer;
}
}
}
.me-gift-info-table {
margin-bottom: 0;
}
.me-gift-info-table .me-gift-tr div {
width: auto;
height: 40px;
}
.cart-list-empty {
background: resolve("home/gift.png") no-repeat center;
background-size: 110px 132px;
width: 775px;
height: 300px;
display: table-caption;
caption-side: bottom;
border: 1px solid #e6e6e6;
border-top: none;
}
.refund {
color: #86bf4a;
}
.consume {
color: #d0021b;
}
div.content {
padding: 0 !important;
}
}
.me-gift-alert {
width: 350px;
.content {
color: #444;
padding: 62px 0;
font-size: 18px;
p {
margin-top: 10px;
}
}
.btns {
margin-bottom: 10px;
}
.btn {
width: 160px;
height: 30px;
line-height: 30px;
}
}
.me-gift-confirm {
color: #444;
.title,
.info-title {
font-size: 18px;
padding-bottom: 25px;
margin: 0 20px;
}
.info-title {
border-bottom: 1px solid #e6e6e6;
}
.gift-group {
margin-top: 10px;
overflow: hidden;
}
.left {
float: left;
}
.right {
float: right;
}
.verify-input {
font-size: 14px;
input {
height: 30px;
line-height: 30px;
padding: 0 5px;
font-size: 14px;
color: #444;
border: 1px solid #e6e6e6;
outline: none;
box-sizing: border-box;
}
.email-btn,
.mobile-btn {
border: 1px solid #e6e6e6;
font-size: 13px;
background-color: #444;
color: #fff;
height: 30px;
cursor: pointer;
width: 110px;
line-height: 30px;
}
.email-code {
margin-left: 35px;
}
.email-btn {
margin-left: 20px;
}
.int-timer {
background-color: #b0b0b0 !important;
}
}
input.mobile {
width: 260px;
border-left: none;
}
.mobile-area {
width: 70px;
line-height: 26px;
height: 30px;
text-align: center;
border: 1px solid #e6e6e6;
outline: none;
box-sizing: border-box;
border-right: none;
background-color: #fff;
cursor: pointer;
}
.ul-list {
position: absolute;
width: 130px;
margin-left: -25px;
background-color: #fff;
margin-top: -3px;
border: 1px solid #e6e6e6;
display: none;
cursor: pointer;
z-index: 1;
li {
border-bottom: 1px solid #e6e6e6;
height: 30px;
line-height: 30px;
&:hover {
color: #4a90e2;
}
}
}
input.mobile-code {
width: 200px;
}
.card-code,
.card-pwd {
width: 330px;
}
.border-top-info {
border-top: 1px solid #e6e6e6;
}
.info-gift-header {
width: 777px;
text-align: center;
margin: 25px 10px 15px;
font-size: 14px;
.text-left {
text-align: left;
}
.text-right {
text-align: right;
}
td {
height: 25px;
}
.validity-time {
width: 330px;
}
}
.gift-type {
background: resolve("home/gift-filter.png") no-repeat center;
background-size: 69px 21px;
width: 69px;
height: 21px;
line-height: 21px;
display: inline-block;
cursor: pointer;
}
.gift-filter .ul-list {
width: 69px;
margin-left: 52px;
margin-top: 0;
}
.img-check-main .img-check-tip {
top: 115px;
}
.detail-gift-list {
width: 797px;
min-height: 500px;
.me-pager {
width: 755px;
margin: 0 10px;
border: 1px solid #e6e6e6;
border-top: none;
}
}
div.content {
padding: 10px 30px;
}
.btns {
margin-bottom: 10px;
}
.btn {
min-width: 100px;
height: 30px;
line-height: 30px;
}
.confirm-sure {
margin-left: 65px;
}
.alert-sure {
width: 160px;
}
.activate-input-last {
margin-top: 30px;
}
.activate-center {
padding-bottom: 30px;
}
.bind-mobile-input {
margin: 30px 0 50px;
}
}
.me-gift-confirm.me-page {
width: auto !important;
}
... ...