...
|
...
|
@@ -106,3 +106,45 @@ exports.couponSend = (req, res, next) => { |
|
|
res.jsonp(result);
|
|
|
}).catch(next);
|
|
|
};
|
|
|
|
|
|
exports.redenvelope = (req, res, next) => {
|
|
|
let token = req.query.token || '',
|
|
|
uid = req.user.uid,
|
|
|
app = req.query.app || {};
|
|
|
|
|
|
let resultData = {
|
|
|
code: 403,
|
|
|
message: '参数错误',
|
|
|
data: ''
|
|
|
};
|
|
|
|
|
|
// 接口要加 session 校验,跨域异步请求未添加相关参数
|
|
|
if (req.yoho.isApp || app.client_type === 'miniapp') {
|
|
|
if (app.app_version && app.client_type && app.session_key && app.uid) {
|
|
|
// 小程序调接口获取 session 的方式不同,H5 嵌小程序,client_type 标记为 h5
|
|
|
let isMiniApp = app.client_type === 'miniapp';
|
|
|
|
|
|
uid = {
|
|
|
toString: () => {
|
|
|
return _.parseInt(app.uid);
|
|
|
},
|
|
|
sessionKey: app.session_key,
|
|
|
appVersion: isMiniApp ? _.get(global, 'yoho.config.appVersion') : app.app_version,
|
|
|
appSessionType: app.client_type
|
|
|
};
|
|
|
}
|
|
|
}
|
|
|
|
|
|
if (uid === '' || uid === 0 || token === '' || token === 0) {
|
|
|
return res.jsonp(resultData);
|
|
|
}
|
|
|
|
|
|
req.ctx(model).getRedEnvelope(uid, token).then(result => {
|
|
|
res.set({
|
|
|
'Cache-Control': 'no-cache',
|
|
|
Pragma: 'no-cache',
|
|
|
Expires: (new Date(1900, 0, 1, 0, 0, 0, 0)).toUTCString()
|
|
|
});
|
|
|
res.jsonp(result);
|
|
|
}).catch(next);
|
|
|
}; |
...
|
...
|
|