Authored by 郝肖肖

'coupon-ctx'

... ... @@ -17,13 +17,7 @@ exports.sendCoin = (req, res, next) => {
uid = req.query.app.uid;
}
// if (!uid) {
// data.code = 401;
// data.message = "未登录";
// return res.jsonp(data);
// }
coinModel.sendCoin({
req.ctx(coinModel).sendCoin({
token: req.query.token,
uid: uid
}).then((result) => {
... ...
... ... @@ -17,9 +17,7 @@ exports.index = (req, res, next) => {
renderData.mobile = mobile;
renderData.ordercode = ordercode;
// 测试假数据
// res.render('coupon', renderData); // 渲染页面
couponModel.getPageInfo({
req.ctx(couponModel).getPageInfo({
ordercode: ordercode,
uid: uid
}).then((couponData) => {
... ... @@ -49,9 +47,7 @@ exports.getCoupon = (req, res, next) => {
renderData.mobile = mobile;
renderData.ordercode = ordercode;
// //测试假数据
// res.render('coupon', renderData); // 渲染页面
couponModel.getCoupon({
req.ctx(couponModel).getCoupon({
ordercode: ordercode,
mobile: mobile
}).then((couponData) => {
... ... @@ -59,8 +55,6 @@ exports.getCoupon = (req, res, next) => {
// 获取信息成功
couponData.ordercode = ordercode;
}
// console.log(couponData);
res.json({
result: couponData
});
... ... @@ -72,8 +66,6 @@ exports.verify = (req, res, next) => {
module: 'activity',
page: 'coupon'
};
var ordercode = req.query.ordercode,
mobile = req.query.mobile,
identifycode = req.query.identifycode;
... ... @@ -82,9 +74,7 @@ exports.verify = (req, res, next) => {
renderData.ordercode = ordercode;
renderData.identifycode = identifycode;
// //测试假数据
// res.render('coupon', renderData); // 渲染页面
couponModel.registerAndSendCoupon({
req.ctx(couponModel).registerAndSendCoupon({
ordercode: ordercode,
mobile: mobile,
identifycode: identifycode
... ... @@ -93,8 +83,6 @@ exports.verify = (req, res, next) => {
// 获取信息成功
couponData.ordercode = ordercode;
}
// console.log(couponData);
res.json({
result: couponData
});
... ...
... ... @@ -2,12 +2,19 @@
* 领取有货币
*/
const api = global.yoho.API;
module.exports = class extends global.yoho.BaseModel {
constructor(ctx) {
super(ctx);
}
module.exports = {
sendCoin: function(params) {
return api.get('', Object.assign({
method: 'app.activity.receviceYohoCoin'
}, params));
sendCoin(params) {
return this.get({
data: Object.assign({
method: 'app.activity.receviceYohoCoin'
}, params),
param: {
cache: true
}
});
}
};
... ...
var api = global.yoho.API;
/**
* 分享页面基础参数
* @param {object} sizeInfo [接口原始数据]
... ... @@ -72,50 +70,62 @@ const getUserStatus = (param) => {
return dest;
};
module.exports = class extends global.yoho.BaseModel {
constructor(ctx) {
super(ctx);
}
/**
* 获取分享页面数据
*/
exports.getPageInfo = (data) => {
var defaultParam = {
/**
* 获取分享页面数据
*/
getPageInfo(data) {
let defaultParam = {
method: 'app.activity.getInfoOfOrderShare'
},
infoData = Object.assign(defaultParam, data); // 处理完成后,发给后端
return api.get('', infoData).then(result => {
return getPageInfo(result);
}); // 所有数据返回一个 Promise,方便 Promise.all 调用
};
};
let infoData = Object.assign(defaultParam, data); // 处理完成后,发给后端
return this.get({
data: infoData
}).then(result => {
return getPageInfo(result);
}); // 所有数据返回一个 Promise,方便 Promise.all 调用
}
/**
* 输入手机号领券,新用户返回验证码
*/
exports.getCoupon = (data) => {
var defaultParam = {
/**
* 输入手机号领券,新用户返回验证码
*/
getCoupon(data) {
let defaultParam = {
method: 'wap.order.drawOrderShareCoupon'
},
};
// 处理完成后,发给后端
phoneData = Object.assign(defaultParam, data);
let phoneData = Object.assign(defaultParam, data);
return api.get('', phoneData).then(result => {
return getUserStatus(result);
}); // 所有数据返回一个 Promise,方便 Promise.all 调用
};
return this.get({
data: phoneData
}).then(result => {
return getUserStatus(result);
}); // 所有数据返回一个 Promise,方便 Promise.all 调用
}
/**
* 验证注册码进行注册并发券
*/
exports.registerAndSendCoupon = (data) => {
var defaultParam = {
/**
* 验证注册码进行注册并发券
*/
registerAndSendCoupon(data) {
let defaultParam = {
method: 'wap.order.registerAndSendCoupon'
},
};
// 处理完成后,发给后端
verifyData = Object.assign(defaultParam, data);
let verifyData = Object.assign(defaultParam, data);
return api.get('', verifyData).then(result => {
return getUserStatus(result);
}); // 所有数据返回一个 Promise,方便 Promise.all 调用
return this.get({
data: verifyData
}).then(result => {
return getUserStatus(result);
}); // 所有数据返回一个 Promise,方便 Promise.all 调用
}
};
... ...
... ... @@ -9,7 +9,6 @@ const utils = '../../../utils';
const _ = require('lodash');
const comment = require('./consult-comment');
const bundle = require('./bundle');
const api = global.yoho.API;
const helpers = global.yoho.helpers;
const productProcess = require(`${utils}/product-process`);
... ... @@ -149,7 +148,7 @@ module.exports = class extends global.yoho.BaseModel {
if (!brandId) {
return Promise.resolve([]);
}
return api.get({
return this.get({
data: {
method: 'app.shop.queryShopsByBrandId',
brand_id: _.toString(brandId)
... ...