me-gift.js
2.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
/**
* 个人中心---我的礼品卡
* @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);
};