Authored by 郝肖肖

'ctx'

Too many changes to show.

To preserve performance only 33 of 33+ files are displayed.

... ... @@ -4,7 +4,7 @@ const CloudModel = require('../models/ali-cloud');
const aliCloudbo = (req, res, next) => {
let contentCode = '5ad7e20546e0a2662d351864929a40ab';
CloudModel.cloud(contentCode).then((result) => {
req.ctx(CloudModel).cloud(contentCode).then((result) => {
res.render('ali-cloud/ali-bottom', {
module: 'activity',
width750: true,
... ... @@ -16,7 +16,7 @@ const aliCloudbo = (req, res, next) => {
const aliCloudri = (req, res, next) => {
let contentCode = 'ec057186abced9d3b390c413c2548bf6';
CloudModel.cloud(contentCode).then((result) => {
req.ctx(CloudModel).cloud(contentCode).then((result) => {
res.render('ali-cloud/ali-right', {
module: 'activity',
width750: true,
... ...
... ... @@ -19,7 +19,7 @@ const index = (req, res, next) => {
return;
}
annualAccountModel.getAccountData({
req.ctx(annualAccountModel).getAccountData({
uid: uid,
year: '2016'
}).then(result => {
... ... @@ -66,7 +66,7 @@ const index = (req, res, next) => {
// }
//
// if (parseInt(uid, 10)) {
// annualAccountModel.getAccountData({
// req.ctx(annualAccountModel).getAccountData({
// uid: uid,
// year: '2016'
// }).then(result => {
... ...
... ... @@ -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
});
... ...
... ... @@ -18,7 +18,7 @@ const secretKey = '5466ee572bcbc75830d044e66ab429bc';// 秘钥
判断邀请 好友 类型
*/
exports.checkType = function(req, res, next) {
inviteModel.checkType()
req.ctx(inviteModel).checkType()
.then(function(result) {
if (result.code === 200 && result.data) {
res.locals.isVipDay = true;
... ... @@ -40,7 +40,7 @@ exports.index = (req, res, next) => {
let uid = req.user.uid || req.query.uid || 0;
let renderPage = 'invite/list';
inviteModel.index({
req.ctx(inviteModel).index({
uid: uid,
activityId: actId
}).then((result) => {
... ... @@ -70,9 +70,9 @@ exports.share = (req, res, next) => {
let shareUid = req.params[0];
let actId = req.params[1];
let nums = req.params[2];
let shareUrl = inviteModel.createShareUrl(shareUid, actId, nums);
let shareUrl = req.ctx(inviteModel).createShareUrl(shareUid, actId, nums);
let callback = 'http://m.yohobuy.com/activity/invite/getwxinfo?url=' + shareUrl;
let url = inviteModel.getWxOauthUrl(callback);
let url = req.ctx(inviteModel).getWxOauthUrl(callback);
let wxUserInfo = req.cookies.wxUserInfo || {};
if (_.isEmpty(wxUserInfo) || _.isEmpty(wxUserInfo.unionid)) {
... ... @@ -80,7 +80,7 @@ exports.share = (req, res, next) => {
return false;
}
inviteModel.shareModel({
req.ctx(inviteModel).shareModel({
uid: shareUid,
activityId: actId,
nums: nums,
... ... @@ -122,7 +122,7 @@ exports.share = (req, res, next) => {
exports.sendRegCodeToMobile = (req, res, next) => {
let mobile = req.query.mobile || '';
inviteModel.sendRegCodeToMobile({
req.ctx(inviteModel).sendRegCodeToMobile({
area: 86,
mobile: mobile
}).then((result) => {
... ... @@ -135,7 +135,7 @@ exports.checkOldUserCoupon = (req, res, next) => {
let mobile = req.query.mobile || '';
let actId = req.query.actId || '';
inviteModel.checkOldUserCoupon({
req.ctx(inviteModel).checkOldUserCoupon({
mobile: mobile,
activityId: actId
}).then((result) => {
... ... @@ -148,7 +148,7 @@ exports.validRegCode = (req, res, next) => {
let mobile = req.query.mobile || '';
let code = req.query.code || '';
inviteModel.validRegCode({
req.ctx(inviteModel).validRegCode({
area: 86,
mobile: mobile,
code: code
... ... @@ -162,7 +162,7 @@ exports.register = (req, res, next) => {
let mobile = req.query.mobile || '';
let activityName = req.query.activityName || 'invite';
inviteModel.register({
req.ctx(inviteModel).register({
mobile: mobile,
activityName: activityName
}).then((result) => {
... ... @@ -178,7 +178,7 @@ exports.receiveCoupons = (req, res, next) => {
let shareUid = req.query.shareUid;
let openId = req.query.openId;
inviteModel.receiveCoupons({
req.ctx(inviteModel).receiveCoupons({
uid: uid,
activityId: actId,
nums: nums,
... ... @@ -209,7 +209,7 @@ exports.myCoupons = (req, res, next) => {
return false;
}
inviteModel.myCoupons({
req.ctx(inviteModel).myCoupons({
uid: uid,
shareUid: shareUid,
nums: nums,
... ... @@ -250,7 +250,7 @@ exports.getwxinfo = (req, res, next) => {
let url = req.query.url;
let code = req.query.code;
inviteModel.getWxUserInfo({
req.ctx(inviteModel).getWxUserInfo({
code: code
}).then((result) => {
if (result === false) {
... ...
/* eslint no-unused-vars: ["error", {"args": "none"}] */
'use strict';
const model = require('../models/live');
const liveModel = require('../models/live');
exports.index = (req, res, next) => {
liveModel.getAllList().then(result => {
req.ctx(liveModel).getAllList().then(result => {
res.render('live/entry', {
title: '直播列表',
module: 'activity',
... ... @@ -30,7 +29,7 @@ exports.main = (req, res, next) => {
res.locals.page = 'live-play';
res.locals.enableFoot = Number(req.query.no) !== 1;
model.fetchInfo(id, isReplay)
req.ctx(liveModel).fetchInfo(id, isReplay)
.then(result => {
if (!result.data) {
return next();
... ... @@ -44,7 +43,7 @@ exports.main = (req, res, next) => {
exports.barrage = (req, res, next) => {
const type = req.query.type;
model.getBarrageHost(type)
req.ctx(liveModel).getBarrageHost(type)
.then(result => {
if (result.code !== 200) {
next(result.message);
... ... @@ -61,7 +60,7 @@ exports.replayBarrage = (req, res, next) => {
const startTime = req.query.startTime;
const timeInterval = req.query.timeInterval;
model.getReplyBarrage(id, startTime, timeInterval)
req.ctx(liveModel).getReplyBarrage(id, startTime, timeInterval)
.then(result => {
res.json(result);
})
... ...
... ... @@ -8,10 +8,8 @@
const headerModel = require('../../../doraemon/models/header'); // 头部model
const indexModel = require('../models/promotion');
const api = global.yoho.API;
exports.index = (req, res, next) => {
let responseData = {
pageHeader: headerModel.setNav({
navTitle: '邀请同学认证送大礼',
... ... @@ -29,75 +27,54 @@ exports.index = (req, res, next) => {
shareUid: req.query.userUid
};
indexModel.index(params).then(result => {
req.ctx(indexModel).index(params).then(result => {
res.render('promotion', Object.assign(responseData, result));
}).catch(next);
};
// 获取学校省份列表
const getProvince = () => {
return api.get('', {
method: 'app.studentMarket.getAddressList'
}, {
cache: true
});
};
exports.province = (req, res, next) => {
getProvince().then((result) => {
req.ctx(indexModel).getProvince().then((result) => {
res.json(result);
}).catch(next);
};
// 获取学校列表
const getSchool = code => {
return api.get('', {
method: 'app.studentMarket.getSchoolInfoList',
areaCode: code
});
};
exports.school = (req, res, next) => {
let code = req.query.code;
getSchool(code).then((result) => {
req.ctx(indexModel).getSchool(code).then((result) => {
res.json(result);
}).catch(next);
};
exports.checkStudent = (req, res, next) => {
let params = {
uid: req.user.uid || req.query.uid,
};
indexModel.checkStudent(params).then((result) => {
req.ctx(indexModel).checkStudent(params).then((result) => {
res.json(result);
}).catch(next);
};
exports.schoolNum = (req, res, next) => {
let params = {
schoolName: req.query.college_name
};
indexModel.getSchoolNum(params).then(result => {
req.ctx(indexModel).getSchoolNum(params).then(result => {
res.json(result);
}).catch(next);
};
exports.addStudent = (req, res, next) => {
let params = {
uid: req.query.userUid,
shareUid: req.query.shareUid
};
indexModel.addStudent(params).then(result => {
req.ctx(indexModel).addStudent(params).then(result => {
res.json(result);
}).catch(next);
... ... @@ -111,7 +88,7 @@ exports.moreGoods = (req, res, next) => {
isApp: req.yoho.isApp
};
indexModel.moreGoods(params).then((result) => {
req.ctx(indexModel).moreGoods(params).then((result) => {
res.json(result);
}).catch(next);
};
... ...
... ... @@ -28,7 +28,7 @@ const shopIndex = (req, res) => {
}
}
shopModel.banner(contentCode).then((result) => {
req.ctx(shopModel).banner(contentCode).then((result) => {
res.render('shop-collect/index', Object.assign({
module: 'activity',
page: 'shop-collect',
... ... @@ -45,7 +45,7 @@ const shopIndex = (req, res) => {
const shopNav = (req, res, next) => {
let channelId = req.query.channelId || '';
shopModel.shopNav(channelId).then((result) => {
req.ctx(shopModel).shopNav(channelId).then((result) => {
res.json(result);
}).catch(next);
};
... ... @@ -56,7 +56,7 @@ const shopList = (req, res, next) => {
let tabName = req.query.tabName;
let channelId = req.query.channelId || '';
shopModel.shopList(uid, tabName, channelId).then((result) => {
req.ctx(shopModel).shopList(uid, tabName, channelId).then((result) => {
res.json(result);
}).catch(next);
};
... ... @@ -70,7 +70,7 @@ const shopFav = (req, res, next) => {
return;
}
shopModel.shopFav(uid, shopIds).then((result) => {
req.ctx(shopModel).shopFav(uid, shopIds).then((result) => {
res.json(result);
}).catch(next);
};
... ...
... ... @@ -38,8 +38,8 @@ const singleDay = (req, res) => {
const getSingleData = (req, res) => {
Promise.all([
singleDayModel.getResourceData(req.query.contCode),
singleDayModel.getTabData(req.query.channel_id)
req.ctx(singleDayModel).getResourceData(req.query.contCode),
req.ctx(singleDayModel).getTabData(req.query.channel_id)
]).then((result) => {
_.forEach(result[0], (item) => {
if (item.focus) {
... ... @@ -55,7 +55,7 @@ const getSingleData = (req, res) => {
const getProductData = (req, res) => {
let params = req.query || {};
singleDayModel.getProductData(params).then(result => {
req.ctx(singleDayModel).getProductData(params).then(result => {
res.json(result);
});
};
... ...
'use strict';
const serviceApi = global.yoho.ServiceAPI;
const api = global.yoho.API;
const helpers = global.yoho.helpers;
const crypto = global.yoho.crypto;
const Promise = require('bluebird');
const headerModel = require('../../../doraemon/models/header'); // 头部model
const _ = require('lodash');
const productProcess = require(`${global.utils}/product-process`);
const stdntMrktModel = require('../models/student-market');
const yasProcess = require(`${global.utils}/yas-process`);
const userAcquireStatus = (uid, couponIds) => {
if (couponIds !== '') {
return api.get('', {
method: 'app.coupons.userAcquireStatus',
uid: uid,
couponIds: couponIds
});
}
};
/**
* 查询商品
* @param id
* @returns {*}
*/
const _getRelatedData = (idList) => {
if (idList !== '') {
return api.get('', {
productSkn: idList,
method: 'h5.product.batch'
}).then((result) => {
let goods = [];
if (result && result.data && result.data.product_list && result.code === 200) {
_.forEach(result.data.product_list, function(val) {
if (!val.student_price) {
val.student_price = val.vip2_price;
}
});
goods = productProcess.processProductList(result.data.product_list);
return goods;
} else {
return {};
}
});
}
};
exports.index = (req, res, next) => {
let code = 'c9b9639ce2884b768cfbc5cf9e68a53f';
let uid = req.__USER__.uid;
... ... @@ -61,10 +15,7 @@ exports.index = (req, res, next) => {
'?openby:yohobuy={"action":"go.weblogin","params":{"jumpurl":{"url":"' +
req.__USER__.http + '//m.yohobuy.com/activity/student-market"}}}';
return serviceApi.get('operations/api/v5/resource/get', {
content_code: code,
platform: 'iphone'
}).then((result) => {
return req.ctx(stdntMrktModel).index(code).then(result => {
let coupons = {},
activities,
... ... @@ -133,8 +84,8 @@ exports.index = (req, res, next) => {
}
return Promise.all([
userAcquireStatus(uid, couponids.join(',')),
_getRelatedData(idList.join(','))])
req.ctx(stdntMrktModel).userAcquireStatus(uid, couponids.join(',')),
req.ctx(stdntMrktModel)._getRelatedData(idList.join(','))])
.then(datas => {
coupons.data = _.get(coupons, 'data', []).map((item)=>{
item.status = 1;
... ... @@ -196,7 +147,7 @@ exports.index = (req, res, next) => {
* 新版学生营销页面
*/
exports.newIndex = (req, res, next) => {
stdntMrktModel.getStudentGoods({
req.ctx(stdntMrktModel).getStudentGoods({
limit: req.query.limit || '60',
stocknumber: req.query.stocknumber || '1',
isApp: req.yoho.isApp
... ...
... ... @@ -2,94 +2,16 @@
const utils = '../../../utils';
const productNameProcess = require(`${utils}/product-name-process`);
const serviceApi = global.yoho.ServiceAPI;
const api = global.yoho.API;
const helpers = global.yoho.helpers;
const crypto = global.yoho.crypto;
const queryString = require('querystring');
const Promise = require('bluebird');
const co = Promise.coroutine;
const headerModel = require('../../../doraemon/models/header'); // 头部model
const studentModel = require('../models/student');
const _ = require('lodash');
const urlP = require('url');
const getResource = code => {
return serviceApi.get('operations/api/v5/resource/get', {
content_code: code,
platform: 'iphone'
});
};
const vip = (limit) => {
return api.get('', {
method: 'app.student.vip',
limit: limit || 60
});
};
const verifiedStudentTotal = () => {
return api.get('', {
method: 'app.student.verifiedStudentTotal'
});
};
const getProvince = () => {
return api.get('', {
method: 'app.studentMarket.getAddressList'
}, {
cache: true
});
};
const getSchool = code => {
return api.get('', {
method: 'app.studentMarket.getSchoolInfoList',
areaCode: code
});
};
const getEducationLevelList = () => {
return api.get('', {
method: 'app.studentMarket.getEducationLevelList'
});
};
const userAcquireStatus = (uid, couponIds) => {
return api.get('', {
method: 'app.coupons.userAcquireStatus',
uid: uid,
couponIds: couponIds
});
};
const verifyStudent = (uid, collegename, educationdegree, enrollmentyear) => {
return api.get('', {
method: 'app.student.verifyStudent',
uid: uid,
client_type: 'h5',
college_name: collegename,
enrollment_year: enrollmentyear,
education_degree: educationdegree
});
};
const verifyIdentity = (uid, certno, name, pageurl) => {
return api.get('', {
method: 'app.student.verifyIdentity',
uid: uid,
client_type: 'h5',
cert_no: certno,
name: name,
page_url: pageurl
});
};
const getUser = (uid) => {
if (!uid) {
return Promise.resolve({
code: 200,
data: {}
});
}
return api.get('', {
method: 'app.passport.profile',
uid: uid
}, {
cache: true
});
};
/* 获取用户或者环境相关数据*/
const getPlatForm = (req) => {
let userAgent = req.get('User-Agent');
... ... @@ -99,8 +21,6 @@ const getPlatForm = (req) => {
let isNewVersion = false;
const isProduction = process.env.NODE_ENV === 'production';
yoho.isiOS = /\(i[^;]+;( U;)? CPU.+Mac OS X/i.test(userAgent);
yoho.isAndroid = /Android/i.test(userAgent);
yoho.isApp = /YohoBuy/i.test(req.get('User-Agent')) || (req.query.app_version && req.query.client_type);
... ... @@ -111,17 +31,6 @@ const getPlatForm = (req) => {
yoho.app_version = _.toString(yoho.app_version);
arrs = yoho.app_version.split('.');
// if (arrs.length > 2) {
// if (arrs[0] && +arrs[0] < 4) {
// isNewVersion = false;
// } else if (arrs[1] && +arrs[1] < 9) {
// isNewVersion = false;
// } else if (arrs[2] && +arrs[2] <= 0) {
// isNewVersion = false;
// } else {
// isNewVersion = true;
// }
// }
if (arrs[0] >= 5) {
isNewVersion = true;
} else if (+arrs[0] === 4 && +arrs[1] === 9 && +arrs[2] > 0) {
... ... @@ -137,7 +46,7 @@ const getPlatForm = (req) => {
yoho.uid = req.user.uid || req.query.uid;
yoho.isLogin = yoho.uid ? true : false;
return co(function*() {
let data = yield getUser(yoho.uid);
let data = yield req.ctx(studentModel).getUser(yoho.uid);
yoho.isStudent = data && data.data && data.data.vip_info && data.data.vip_info.is_student ? true : false;
... ... @@ -156,9 +65,10 @@ exports.index = (req, res, next) => {
let options;
let noLoginUrl = helpers.urlFormat('/activity/student/register') + '?openby:yohobuy={"action":"go.weblogin","params":{"jumpurl":{"url":"' + req.__USER__.http + '//m.yohobuy.com/activity/student"}}}'; // eslint-disable-line
Promise.all([getResource(code), vip()]).then(datas => {
Promise.all([
req.ctx(studentModel).getResource(code),
req.ctx(studentModel).vip()
]).then(datas => {
let coupons,
activities,
banner,
... ... @@ -207,7 +117,7 @@ exports.index = (req, res, next) => {
});
}
return userAcquireStatus(uid, couponids.join(',')).then((cous) => {
return req.ctx(studentModel).userAcquireStatus(uid, couponids.join(',')).then((cous) => {
coupons.data = _.get(coupons, 'data', []).map((item)=>{
item.status = 1;
(cous.data || []).forEach((it) => {
... ... @@ -291,7 +201,7 @@ exports.index = (req, res, next) => {
exports.province = (req, res, next) => {
getProvince().then((result) => {
req.ctx(studentModel).getProvince().then((result) => {
res.json(result);
}).catch(next);
};
... ... @@ -303,7 +213,11 @@ exports.register = (req, res, next) => {
for (let i = 0; i < 8; i++) {
years.push((new Date()).getFullYear() - i);
}
Promise.all([verifiedStudentTotal(), getEducationLevelList()]).then((arr) => {
Promise.all([
req.ctx(studentModel).verifiedStudentTotal(),
req.ctx(studentModel).getEducationLevelList()
]).then((arr) => {
if (req.__USER__.isStudent) {
refer = '/activity/student?uid=' + req.__USER__.uid;// 所有认证过的,都跳转学生首页
... ... @@ -332,7 +246,7 @@ exports.register = (req, res, next) => {
exports.school = (req, res, next) => {
let code = req.query.code;
getSchool(code).then((result) => {
req.ctx(studentModel).getSchool(code).then((result) => {
res.json(result);
}).catch(next);
};
... ... @@ -365,20 +279,11 @@ exports.verifyidentity = (req, res, next) => {
}) + '&';
verifyIdentity(uid, params.cert_no, params.name, url).then((result) => {
req.ctx(studentModel).verifyIdentity(uid, params.cert_no, params.name, url).then((result) => {
res.json(result);
}).catch(next);
};
// 添加分享成功记录
const addStudent = (ownuid, shareId) => {
return api.get('', {
method: 'app.student.addShare',
uid: ownuid,
shareUid: shareId
});
};
exports.verifystudent = (req, res, next) => {
let params = req.query;
... ... @@ -389,73 +294,76 @@ exports.verifystudent = (req, res, next) => {
let shareId = req.query.shareId;
Promise.all([
verifiedStudentTotal(),
vip(),
verifyStudent(uid, params.college_name, params.education_degree, params.enrollment_year, params.token),
addStudent(ownuid, shareId)])
.then((datas) => {
let isverify = false,
prompt = '您的学校信息未通过审核';
if (datas[2].code === 200) {
if (datas[2].data.isStudent === 1) {
isverify = true;
prompt = datas[2].data.prompt;
// 添加分享成功记录
if (req.query.refer && req.query.shareId) {
let code = datas[3].code;
res.cookie('promotion', code, {
domain: 'yohobuy.com',
path: '/'
});
} else if (!req.query.shareId) {
res.cookie('promotion', 'own-succ', {
domain: 'yohobuy.com',
path: '/'
});
}
req.ctx(studentModel).verifiedStudentTotal(),
req.ctx(studentModel).vip(),
req.ctx(studentModel).verifyStudent(
uid, params.college_name, params.education_degree,
params.enrollment_year, params.token
),
req.ctx(studentModel).addStudent(ownuid, shareId)
]).then((datas) => {
let isverify = false,
prompt = '您的学校信息未通过审核';
if (datas[2].code === 200) {
if (datas[2].data.isStudent === 1) {
isverify = true;
prompt = datas[2].data.prompt;
// 添加分享成功记录
if (req.query.refer && req.query.shareId) {
let code = datas[3].code;
res.cookie('promotion', code, {
domain: 'yohobuy.com',
path: '/'
});
} else if (!req.query.shareId) {
res.cookie('promotion', 'own-succ', {
domain: 'yohobuy.com',
path: '/'
});
}
}
} else {
if (datas[2].code === 500) {
prompt = '请重新认证!';
} else {
if (datas[2].code === 500) {
prompt = '请重新认证!';
} else {
prompt = datas[2].message;
}
res.cookie('promotion', 'own-fail', {
domain: 'yohobuy.com',
path: '/'
});
prompt = datas[2].message;
}
datas[1].data.product_list = (datas[1].data.product_list || []).map(function(value) {
value.goodsId = value.goods_list[0].goods_id;
value.product_id = value.product_id;
res.cookie('promotion', 'own-fail', {
domain: 'yohobuy.com',
path: '/'
});
}
datas[1].data.product_list = (datas[1].data.product_list || []).map(function(value) {
value.goodsId = value.goods_list[0].goods_id;
value.product_id = value.product_id;
if (value.cn_alphabet) {
value.cn_alphabet = productNameProcess(value.cn_alphabet);
}
if (value.cn_alphabet) {
value.cn_alphabet = productNameProcess(value.cn_alphabet);
}
// 商品url改版
value.url = helpers.urlFormat(`/product/${value.product_skn}.html`) + `?openby:yohobuy={"action":"go.productDetail","params":{"product_skn":${value.product_skn}}}`; // eslint-disable-line
return value;
// 商品url改版
value.url = helpers.urlFormat(`/product/${value.product_skn}.html`) + `?openby:yohobuy={"action":"go.productDetail","params":{"product_skn":${value.product_skn}}}`; // eslint-disable-line
return value;
});
return req.ctx(studentModel).getUser(uid).then((user) => {
res.render('verify', {
isApp: req.__USER__.isApp,
count: datas[0].data,
goods: datas[1].data.product_list,
isverify: isverify,
prompt: prompt,
isLogin: user.data && user.data.vip_info && user.data.vip_info.is_student ? true : false,
title: '学生身份认证',
http: req.__USER__.http,
uid: req.__USER__.uid,
app_version: req.__USER__.app_version
});
return getUser(uid).then((user) => {
res.render('verify', {
isApp: req.__USER__.isApp,
count: datas[0].data,
goods: datas[1].data.product_list,
isverify: isverify,
prompt: prompt,
isLogin: user.data && user.data.vip_info && user.data.vip_info.is_student ? true : false,
title: '学生身份认证',
http: req.__USER__.http,
uid: req.__USER__.uid,
app_version: req.__USER__.app_version
});
}).catch(next);
}).catch(next);
}).catch(next);
};
exports.detail = (req, res) => {
... ...
... ... @@ -59,9 +59,8 @@ exports.index = (req, res, next) => {
}
vipDayModel.getGoods(cate)
req.ctx(vipDayModel).getGoods(cate)
.then(result => {
// console.log(result.data)
if (result.code !== 200) {
return Promise.reject('error');
}
... ... @@ -86,7 +85,7 @@ exports.crazyWheel = (req, res, next) => {
return res.redirect('/activity/vip-day');
}
vipDayModel.getJoinNum(1).then(result => {
req.ctx(vipDayModel).getJoinNum(1).then(result => {
let joins = result && result.data || 0;
res.render('vip-day/crazy-wheel', {
... ... @@ -107,8 +106,8 @@ exports.crazyLuck = (req, res, next) => {
res.locals.width750 = true;
co(function* () {
let coins = yield vipDayModel.getCoins(uid);
let joinNum = yield vipDayModel.getJoinNum(2);
let coins = yield req.ctx(vipDayModel).getCoins(uid);
let joinNum = yield req.ctx(vipDayModel).getJoinNum(2);
coins = (coins && coins.data && coins.data.total) || 0;
joinNum = (joinNum && joinNum.data) || 0;
... ... @@ -130,7 +129,7 @@ exports.crazyLuck = (req, res, next) => {
exports.signin = (req, res, next) => {
let uid = req.user.uid;
return vipDayModel.signin(uid)
return req.ctx(vipDayModel).signin(uid)
.then(function(result) {
res.json(result);
})
... ... @@ -148,7 +147,7 @@ exports.saveMsg = (req, res, next) => {
})
.then(nick_name => {
// 2. save message
return vipDayModel.saveMsg(uid, nick_name, content);
return req.ctx(vipDayModel).saveMsg(uid, nick_name, content);
})
.then(result => {
if (result.code === 200 && result.data === 1) {
... ... @@ -164,7 +163,7 @@ exports.saveMsg = (req, res, next) => {
exports.fetchMsg = (req, res, next) => {
let uid = req.user.uid || req.query.uid || 0;
vipDayModel.queryLeaveWordsList(uid).then(result => {
req.ctx(vipDayModel).queryLeaveWordsList(uid).then(result => {
return res.json(result);
}).catch(next);
};
... ... @@ -174,7 +173,7 @@ exports.wheelResult = (req, res, next) => {
let uid = req.user.uid;
let prize_type = 2;
return vipDayModel.addPrizeLog(uid, prize_type).then(result => {
return req.ctx(vipDayModel).addPrizeLog(uid, prize_type).then(result => {
return res.json(result);
}).catch(next);
... ... @@ -188,7 +187,7 @@ exports.luckResult = (req, res, next) => {
let handle = co(function* (uid) {
// 查询用户 有货币
let r1 = yield vipDayModel.getCoins(uid);
let r1 = yield req.ctx(vipDayModel).getCoins(uid);
if (r1.code !== 200) {
return {
... ... @@ -205,7 +204,7 @@ exports.luckResult = (req, res, next) => {
}
// 得出 中奖结果
let result = yield vipDayModel.addPrizeLog(uid, prize_type);
let result = yield req.ctx(vipDayModel).addPrizeLog(uid, prize_type);
if (result.code !== 200) {
return result;
... ... @@ -224,7 +223,7 @@ exports.luckResultCollect = (req, res, next) => {
let uid = req.user.uid;
let prize_type = 1;
return vipDayModel.queryPrizeLog(uid, prize_type).then(result => {
return req.ctx(vipDayModel).queryPrizeLog(uid, prize_type).then(result => {
if (result.code === 200 && result.data) {
result.data = result.data.filter(award => award.prizeValue);
}
... ...
... ... @@ -19,7 +19,7 @@ function humanNum_wan(num) {
exports.checkIsStudent = (req, res, next) => {
let uid = req.user.uid || req.query.uid;
vipDayModel.checkIsStudent(uid).then(result => {
req.ctx(vipDayModel).checkIsStudent(uid).then(result => {
res.json(result);
}).catch(next);
};
... ... @@ -73,13 +73,13 @@ exports.index = (req, res, next) => {
// 获取学生信息
if (uid) {
let result = yield vipDayModel.checkIsStudent(uid);
let result = yield req.ctx(vipDayModel).checkIsStudent(uid);
result.data && Number(result.data.isStudent) === 1 && (isStudent = true);
}
// 获取商品信息
let goodList = yield vipDayModel.getGoods(cate);
let goodList = yield req.ctx(vipDayModel).getGoods(cate);
res.render('vip-day/vip-day1028/index', {
title: '会员日活动',
... ... @@ -101,7 +101,7 @@ exports.crazyWheel = (req, res, next) => {
res.locals.page = 'vipday-wheel10';
res.locals.width750 = true;
vipDayModel.getJoinNum(1).then(result => {
req.ctx(vipDayModel).getJoinNum(1).then(result => {
let joins = result && result.data || 0;
res.render('vip-day/vip-day1028/crazy-wheel', {
... ... @@ -122,8 +122,8 @@ exports.crazyLuck = (req, res, next) => {
res.locals.width750 = true;
co(function*() {
let coins = yield vipDayModel.getCoins(uid);
let joinNum = yield vipDayModel.getJoinNum(2);
let coins = yield req.ctx(vipDayModel).getCoins(uid);
let joinNum = yield req.ctx(vipDayModel).getJoinNum(2);
coins = (coins && coins.data && coins.data.total) || 0;
joinNum = (joinNum && joinNum.data) || 0;
... ... @@ -145,7 +145,7 @@ exports.crazyLuck = (req, res, next) => {
exports.signin = (req, res, next) => {
let uid = req.user.uid;
return vipDayModel.signin(uid)
return req.ctx(vipDayModel).signin(uid)
.then(function(result) {
res.json(result);
})
... ... @@ -156,7 +156,7 @@ exports.wheelResult = (req, res, next) => {
let uid = req.user.uid || req.query.uid;
let prize_type = 3;
return vipDayModel.addPrizeLog(uid, prize_type).then(result => {
return req.ctx(vipDayModel).addPrizeLog(uid, prize_type).then(result => {
return res.json(result);
}).catch(next);
... ... @@ -170,7 +170,7 @@ exports.luckResult = (req, res, next) => {
let handle = co(function*(uid) {
// 查询用户 有货币
let r1 = yield vipDayModel.getCoins(uid);
let r1 = yield req.ctx(vipDayModel).getCoins(uid);
if (r1.code !== 200) {
return {
... ... @@ -187,7 +187,7 @@ exports.luckResult = (req, res, next) => {
}
// 得出 中奖结果
let result = yield vipDayModel.addPrizeLog(uid, prize_type);
let result = yield req.ctx(vipDayModel).addPrizeLog(uid, prize_type);
if (result.code !== 200) {
return result;
... ... @@ -206,7 +206,7 @@ exports.luckResultCollect = (req, res, next) => {
let uid = req.user.uid;
let prize_type = 3;
return vipDayModel.queryPrizeLog(uid, prize_type).then(result => {
return req.ctx(vipDayModel).queryPrizeLog(uid, prize_type).then(result => {
if (result.code === 200 && result.data) {
result.data = result.data.filter(award => award.prizeValue);
}
... ...
... ... @@ -4,7 +4,7 @@
* @date: 2016/12/5
*/
'use strict';
const service = global.yoho.ServiceAPI;
const serviceAPI = global.yoho.ServiceAPI;
const _cloudData = (list) => {
list = list || [];
... ... @@ -28,21 +28,27 @@ const _cloudData = (list) => {
return listData;
};
const cloud = (contentCode) => {
return service.get('operations/api/v5/resource/get', {
content_code: contentCode,
platform: 'iphone'
}, {
cache: true,
code: 200
}).then((result) => {
if (result && result.data && result.data[0] && result.data[0].data) {
return _cloudData(result.data[0].data);
}
});
};
module.exports = class extends global.yoho.BaseModel {
constructor(ctx) {
super(ctx);
}
module.exports = {
cloud
cloud(contentCode) {
return this.get({
api: serviceAPI,
url: 'operations/api/v5/resource/get',
data: {
content_code: contentCode,
platform: 'iphone'
},
param: {
cache: true,
code: 200
}
}).then((result) => {
if (result && result.data && result.data[0] && result.data[0].data) {
return _cloudData(result.data[0].data);
}
});
}
};
... ...
... ... @@ -6,10 +6,19 @@
'use strict';
const serviceAPI = global.yoho.ServiceAPI;
const getAccountData = (params) => {
return serviceAPI.get('/activity/YearMemberBillController/getBillByUid', params, {code: 200});
};
module.exports = class extends global.yoho.BaseModel {
constructor(ctx) {
super(ctx);
}
module.exports = {
getAccountData
getAccountData(params) {
return this.get({
api: serviceAPI,
url: '/activity/YearMemberBillController/getBillByUid',
data: params,
param: {
code: 200
}
});
}
};
... ...
... ... @@ -2,12 +2,16 @@
* 领取有货币
*/
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)
});
}
};
... ...
... ... @@ -2,7 +2,6 @@
'use strict';
const Promise = require('bluebird');
const api = global.yoho.API;
const _ = require('lodash');
const helpers = global.yoho.helpers;
const crypto = global.yoho.crypto;
... ... @@ -279,11 +278,15 @@ class couponFloor extends global.yoho.BaseModel {
}
floor(params, isApp, appVersion) {
let that = this;
return Promise.coroutine(function*() {
let result = {},
resource = yield api.get('', Object.assign(params, {
method: 'app.promotion.queryCouponCenter',
}));
resource = yield that.get({
data: Object.assign(params, {
method: 'app.promotion.queryCouponCenter',
})
});
if (resource && resource.code === 200) {
result = _getContent(resource.data, isApp);
... ... @@ -298,10 +301,14 @@ class couponFloor extends global.yoho.BaseModel {
}
status(params) {
let that = this;
return Promise.coroutine(function*() {
const resource = yield api.get('', Object.assign(params, {
method: 'app.promotion.couponStatus'
}));
const resource = yield that.get({
data: Object.assign(params, {
method: 'app.promotion.couponStatus'
})
});
const result = {
code: resource.code,
data: []
... ... @@ -332,10 +339,12 @@ class couponFloor extends global.yoho.BaseModel {
}
// 登录后调用领券接口
return api.get('', {
method: 'app.promotion.getCoupon',
couponId: receiveData.couponID,
uid: uid
return this.get({
data: {
method: 'app.promotion.getCoupon',
couponId: receiveData.couponID,
uid: uid
}
}).then(result => {
switch (result.code) {
case 200:
... ... @@ -394,8 +403,9 @@ class couponFloor extends global.yoho.BaseModel {
};
}
return api.get('', data).then(result => {
return this.get({
data: data
}).then(result => {
if (!result) {
result.code = 404;
result.message = '出错啦~';
... ...
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 调用
}
};
... ...
const api = global.yoho.API;
const _ = require('lodash');
const helpers = global.yoho.helpers;
const utils = '../../../utils';
const productProcess = require(`${utils}/product-process`);
const service = global.yoho.ServiceAPI;
const serviceAPI = global.yoho.ServiceAPI;
const co = require('bluebird').coroutine;
module.exports = class extends global.yoho.BaseModel {
... ... @@ -15,11 +14,14 @@ module.exports = class extends global.yoho.BaseModel {
* 我的邀请码页
*/
_getPromotionData(uid, isApp) {
return api.get('', {
method: 'app.invitecode.my',
uid: uid
}, {
code: 200
return this.get({
data: {
method: 'app.invitecode.my',
uid: uid
},
param: {
code: 200
}
}).then((result) => {
if (result && result.code === 200 && result.data) {
... ... @@ -39,11 +41,16 @@ module.exports = class extends global.yoho.BaseModel {
* 资源位
*/
_getTrendPop(contentCode) {
return service.get('operations/api/v5/resource/get', {
content_code: contentCode,
}, {
code: 200,
cache: true
return this.get({
api: serviceAPI,
url: 'operations/api/v5/resource/get',
data: {
content_code: contentCode,
},
param: {
code: 200,
cache: true
}
}).then(result => {
if (result && result.code === 200 && result.data) {
return result.data[0];
... ... @@ -54,7 +61,7 @@ module.exports = class extends global.yoho.BaseModel {
}
promotionData(uid, isApp, contentCode) {
return api.all([this._getPromotionData(uid, isApp), this._getTrendPop(contentCode)]).then(result => {
return Promise.all([this._getPromotionData(uid, isApp), this._getTrendPop(contentCode)]).then(result => {
let friendPromotionData = {};
friendPromotionData = Object.assign(friendPromotionData, result[0]);
... ... @@ -68,11 +75,13 @@ module.exports = class extends global.yoho.BaseModel {
* 奖励列表页
*/
rewardList(uid, page, limit, isApp) {
return api.get('', {
method: 'app.invitecode.history',
uid: uid,
page: page,
limit: limit
return this.get({
data: {
method: 'app.invitecode.history',
uid: uid,
page: page,
limit: limit
}
}).then((result) => {
if (result && result.code === 200 && result.data) {
... ... @@ -110,10 +119,12 @@ module.exports = class extends global.yoho.BaseModel {
* 奖励详情页
*/
rewardDeatil(uid, firstOrderUid) {
return api.get('', {
method: 'app.invitecode.detail',
uid: uid,
firstOrderUid: firstOrderUid
return this.get({
data: {
method: 'app.invitecode.detail',
uid: uid,
firstOrderUid: firstOrderUid
}
}).then((result) => {
if (result && result.code === 200) {
... ... @@ -130,13 +141,12 @@ module.exports = class extends global.yoho.BaseModel {
* 设置我的潮流口令
*/
setTrendWord(uid, trendWord) {
return api.get('', {
method: 'app.trendword.update',
uid: uid,
trendWord: trendWord
}).then((result) => {
return result;
return this.get({
data: {
method: 'app.trendword.update',
uid: uid,
trendWord: trendWord
}
});
}
... ... @@ -144,11 +154,13 @@ module.exports = class extends global.yoho.BaseModel {
* 好友邀请商品
*/
_hotGoods(yhChannel, limit, page) {
return api.get('', {
method: 'app.search.top',
yh_channel: yhChannel,
page: page,
limit: limit
return this.get({
data: {
method: 'app.search.top',
yh_channel: yhChannel,
page: page,
limit: limit
}
}).then((result) => {
if (result && result.code === 200) {
... ... @@ -163,19 +175,20 @@ module.exports = class extends global.yoho.BaseModel {
* 好友邀请信息
*/
inviteUserInfo(inviteCode) {
return api.get('', {
method: 'app.invitecode.userinfo',
inviteCode: inviteCode
}).then((result) => {
return result;
return this.get({
data: {
method: 'app.invitecode.userinfo',
inviteCode: inviteCode
}
});
}
_getProductList(skns) {
return api.get('', {
method: 'app.search.li',
query: skns
return this.get({
data: {
method: 'app.search.li',
query: skns
}
}).then((result) => {
if (result && result.code === 200) {
return result.data;
... ... @@ -199,9 +212,12 @@ module.exports = class extends global.yoho.BaseModel {
if (!token) {
return Promise.resolve({});
}
return api.get('', {
method: 'app.SpaceOrders.getProductList',
order_token: token
return this.get({
data: {
method: 'app.SpaceOrders.getProductList',
order_token: token
}
}).then((result) => {
let self = this;
... ... @@ -247,7 +263,7 @@ module.exports = class extends global.yoho.BaseModel {
* 好友邀请页
*/
friendInvite(inciteCode, yhChannel, limit, page, contentCode, token) {
return api.all([
return Promise.all([
this.inviteUserInfo(inciteCode),
this._hotGoods(yhChannel, limit, page),
this._getTrendPop(contentCode),
... ... @@ -272,11 +288,14 @@ module.exports = class extends global.yoho.BaseModel {
}
reloadQrcode(uid) {
return api.get('', {
method: 'app.invitecode.my',
uid: uid
}, {
code: 200
return this.get({
data: {
method: 'app.invitecode.my',
uid: uid
},
param: {
code: 200
}
}).then((result) => {
if (result && result.code === 200 && result.data) {
... ...
... ... @@ -4,71 +4,77 @@ const api = global.yoho.API;
const helpers = global.yoho.helpers;
const yasProcess = require('../../../utils/yas-process');
const _getProductBySkns = function(productObj, ctx) {
return api.get('', {
productSkn: productObj.defaultSkns,
method: 'h5.product.batch'
}, {
cache: true
}).then((result) => {
productObj.defaultPros = [];
if (result && result.data && result.data.product_list && result.code === 200) {
result.data.product_list.forEach(function(val) {
var obj = {
producturl: `//m.yohobuy.com/product/${val.product_skn}.html?openby:yohobuy={"action":"go.productDetail","params":{"product_skn":"${val.product_skn}","from_page_name":"${yasProcess.getPname(ctx.req)}","from_page_param":"${_.get(ctx,'req.url', '')}"}}`, // eslint-disable-line
productimg: helpers.image(val.default_images, 213, 284, 2, 60).replace('quality/80', 'quality/60'),
productname: val.product_name,
vipprice: val.vip_price,
saleprice: val.sales_price,
marketprice: val.sales_price === val.market_price ? '' : val.market_price,
brandname: val.brand_name,
product_skn: val.product_skn
};
if (val.shop_id) {
obj.brandurl = `//m.yohobuy.com/product/shop?domain=${val.brand_domain}&openby:yohobuy={"action":"go.shop","params":{"shop_id":${val.shop_id},"shop_template_type":${val.shop_template_type || "1"},"is_red_shop":${val.is_red_shop || 1}}}`; // eslint-disable-line
} else {
obj.brandurl = `//m.yohobuy.com/product/shop?domain=${val.brand_domain}&openby:yohobuy={"action":"go.brand","params":{"brand_id":${val.brand_id}}}`; // eslint-disable-line
}
productObj.defaultPros.push(obj);
});
}
});
};
/**
* 获取店铺组店铺数据
*/
const _getShopGroup = (shopRawData) => {
// 个性化店铺组,前端去查询
if (shopRawData.searchCondition) {
shopRawData.individuation = true;
return Promise.resolve();
class featureModel extends global.yoho.BaseModel {
constructor(ctx) {
super(ctx);
}
// 固定店铺组
return api.get('', {
method: 'app.shops.batchGetShops',
shop_ids: shopRawData.defaultShopIds
}).then(result => {
let renderData = _.get(result, 'data', []);
_.forEach(renderData, shop => {
let displayStyle = _.get(shopRawData, 'displayStyle', '0');
_getProductBySkns(productObj, ctx) {
return this.get({
data: {
productSkn: productObj.defaultSkns,
method: 'h5.product.batch'
},
param: {
cache: true
}
}).then((result) => {
productObj.defaultPros = [];
if (result && result.data && result.data.product_list && result.code === 200) {
result.data.product_list.forEach(function(val) {
var obj = {
producturl: `//m.yohobuy.com/product/${val.product_skn}.html?openby:yohobuy={"action":"go.productDetail","params":{"product_skn":"${val.product_skn}","from_page_name":"${yasProcess.getPname(ctx.req)}","from_page_param":"${_.get(ctx,'req.url', '')}"}}`, // eslint-disable-line
productimg: helpers.image(val.default_images, 213, 284, 2, 60).replace('quality/80', 'quality/60'), // eslint-disable-line
productname: val.product_name,
vipprice: val.vip_price,
saleprice: val.sales_price,
marketprice: val.sales_price === val.market_price ? '' : val.market_price,
brandname: val.brand_name,
product_skn: val.product_skn
};
if (val.shop_id) {
obj.brandurl = `//m.yohobuy.com/product/shop?domain=${val.brand_domain}&openby:yohobuy={"action":"go.shop","params":{"shop_id":${val.shop_id},"shop_template_type":${val.shop_template_type || "1"},"is_red_shop":${val.is_red_shop || 1}}}`; // eslint-disable-line
} else {
obj.brandurl = `//m.yohobuy.com/product/shop?domain=${val.brand_domain}&openby:yohobuy={"action":"go.brand","params":{"brand_id":${val.brand_id}}}`; // eslint-disable-line
}
shop.picture = displayStyle === '0' ? shop.pic_popular : shop.shop_logo;
shop.href = `//m.yohobuy.com/product/shop?domain=${shop.shop_domain}&openby:yohobuy={"action":"go.shop","params":{"shop_id":${shop.shops_id},"shop_template_type":${shop.shop_template_type || "1"},"is_red_shop":${shop.is_red_shop || 1}}}`; // eslint-disable-line
productObj.defaultPros.push(obj);
});
}
});
}
/**
* 获取店铺组店铺数据
*/
_getShopGroup(shopRawData) {
// 个性化店铺组,前端去查询
if (shopRawData.searchCondition) {
shopRawData.individuation = true;
return Promise.resolve();
}
shopRawData.renderData = renderData;
});
};
// 固定店铺组
return this.get({
data: {
method: 'app.shops.batchGetShops',
shop_ids: shopRawData.defaultShopIds
}
}).then(result => {
let renderData = _.get(result, 'data', []);
class featureModel extends global.yoho.BaseModel {
constructor(ctx) {
super(ctx);
_.forEach(renderData, shop => {
let displayStyle = _.get(shopRawData, 'displayStyle', '0');
shop.picture = displayStyle === '0' ? shop.pic_popular : shop.shop_logo;
shop.href = `//m.yohobuy.com/product/shop?domain=${shop.shop_domain}&openby:yohobuy={"action":"go.shop","params":{"shop_id":${shop.shops_id},"shop_template_type":${shop.shop_template_type || "1"},"is_red_shop":${shop.is_red_shop || 1}}}`; // eslint-disable-line
});
shopRawData.renderData = renderData;
});
}
index(params) {
const self = this;
... ... @@ -102,7 +108,7 @@ class featureModel extends global.yoho.BaseModel {
data.floors.forEach(f => {
if (f.component && f.component[0] &&
f.component[0].type === 'productGroup' && f.component[0].defaultSkns) {
sknsArr.push(_getProductBySkns(f.component[0], self.ctx));
sknsArr.push(self._getProductBySkns(f.component[0], self.ctx));
f.component[0].newStyle = _.get(f, 'component[0].newStyle') === '1';
}
... ... @@ -119,7 +125,7 @@ class featureModel extends global.yoho.BaseModel {
// 新增店铺组
if (_.get(f, 'component[0].type') === 'shopGroup') {
shopGroups.push(_getShopGroup(f.component[0]));
shopGroups.push(self._getShopGroup(f.component[0]));
}
if (_.get(f, 'type') === 'bottombar') {
... ...
const api = global.yoho.API;
const _ = require('lodash');
const moment = require('moment');
... ... @@ -11,9 +10,11 @@ module.exports = class extends global.yoho.BaseModel {
* 领取验证以及领券列表
*/
freeMail(uid, verify) {
return api.get('', {
method: 'app.coupons.queryFreePostCoupons',
uid: uid
return this.get({
data: {
method: 'app.coupons.queryFreePostCoupons',
uid: uid
}
}).then((result) => {
if (verify) {
return result;
... ... @@ -34,11 +35,11 @@ module.exports = class extends global.yoho.BaseModel {
}
receiveCoupon(uid) {
return api.get('', {
method: 'app.coupons.getFreePostCoupons',
uid: uid
}).then((result) => {
return result;
return this.get({
data: {
method: 'app.coupons.getFreePostCoupons',
uid: uid
}
});
}
};
... ...
'use strict';
const api = global.yoho.API;
const serviceAPI = global.yoho.ServiceAPI;
const _ = require('lodash');
const rp = require('request-promise');
... ... @@ -10,210 +9,227 @@ const wxCode = {
wxAppSecret: 'ce21ae4a3f93852279175a167e54509b'
};
/**
* 获取微信授权地址
* @param callback
* @returns {string}
*/
const getWxOauthUrl = (callback) => {
return 'https://open.weixin.qq.com/connect/oauth2/authorize?appid=' +
wxCode.wxAppId + '&redirect_uri=' + callback +
'&response_type=code&scope=snsapi_userinfo#wechat_redirect';
};
/**
* 生成分享url
* @param shareUid
* @param actId
* @param nums
* @returns {string}
*/
const createShareUrl = (shareUid, actId, nums) => {
return 'http://m.yohobuy.com/activity/invite/share_' + shareUid + '_' + actId + '_' + nums + '.html';
};
/**
* 根据第三方id,查询绑定信息
* @param {[string || array]} openIds 第三方id数组
* @return {[array]}
*/
const getBindLogByOpenId = (openIds) => {
openIds = _.isArray(openIds) ? openIds : [openIds];
return api.get('', {
method: 'wap.invite.getBindLogByOpenId',
openIds: openIds.join(',')
});
};
module.exports = class extends global.yoho.BaseModel {
constructor(ctx) {
super(ctx);
}
/**
* 获取微信授权地址
* @param callback
* @returns {string}
*/
getWxOauthUrl(callback) {
return 'https://open.weixin.qq.com/connect/oauth2/authorize?appid=' +
wxCode.wxAppId + '&redirect_uri=' + callback +
'&response_type=code&scope=snsapi_userinfo#wechat_redirect';
}
/**
* 生成分享url
* @param shareUid
* @param actId
* @param nums
* @returns {string}
*/
createShareUrl(shareUid, actId, nums) {
return 'http://m.yohobuy.com/activity/invite/share_' + shareUid + '_' + actId + '_' + nums + '.html';
}
/**
* 根据第三方id,查询绑定信息
* @param {[string || array]} openIds 第三方id数组
* @return {[array]}
*/
getBindLogByOpenId(openIds) {
openIds = _.isArray(openIds) ? openIds : [openIds];
return this.get({
data: {
method: 'wap.invite.getBindLogByOpenId',
openIds: openIds.join(',')
}
});
}
/**
* 合并第三方头像和昵称
* @param {[array]} data 邀请的用户列表,最主要的是openId字段
* @return {[array]}
*/
mergeBindLogDate(data) {
let openIds = [];
let photo = '//static.yohobuy.com/m/v1/activity/newyear/images/108.png';
// 取5条
data = _.slice(data, 0, 5);
_.forEach(data, (req) => {
openIds.push(req.openId);
});
/**
* 合并第三方头像和昵称
* @param {[array]} data 邀请的用户列表,最主要的是openId字段
* @return {[array]}
*/
const mergeBindLogDate = (data) => {
let openIds = [];
let photo = '//static.yohobuy.com/m/v1/activity/newyear/images/108.png';
// 取5条
data = _.slice(data, 0, 5);
_.forEach(data, (req) => {
openIds.push(req.openId);
});
return getBindLogByOpenId(openIds).then(result => {
if (!_.isEmpty(result.data)) {
_.forEach(data, (req, key) => {
data[key].img = photo;
_.forEach(result.data, (bind) => {
if (req.openId === bind.openId) {
data[key].img = _.isEmpty(bind.snsHeadimg) ?
photo : bind.snsHeadimg;
data[key].nick = bind.snsNick;
}
return this.getBindLogByOpenId(openIds).then(result => {
if (!_.isEmpty(result.data)) {
_.forEach(data, (req, key) => {
data[key].img = photo;
_.forEach(result.data, (bind) => {
if (req.openId === bind.openId) {
data[key].img = _.isEmpty(bind.snsHeadimg) ?
photo : bind.snsHeadimg;
data[key].nick = bind.snsNick;
}
});
});
});
}
return data;
});
};
}
return data;
});
}
/**
* 获取分享页面列表数据
* @param {[int]} uid 用户id
* @param {[int]} activityId 活动id
* @return {[array]}
*/
index(params) {
params = params || {};
return this.get({
data: Object.assign({
method: 'wap.invite.index'
}, params)
}).then((result) => {
let firstData = {
isNil: false,
isEmpty: false,
isFive: false,
isGo: false,
remainData: ['', '', '', '', ''],
data: []
};
switch (result.code) {
case 401:
// 没有分享记录
firstData.isNil = true;
break;
case 200:
return this.mergeBindLogDate(result.data).then(data => {
let len = data.length;
// 判断是否否5条分享
result.data = data;
if (len === 0) {
firstData.isEmpty = true;
} else if (len < 5) {
firstData.remainData =
_.slice(firstData.remainData, 0, 5 - len);
} else {
firstData.isFive = true;
firstData.remainData = [];
}
return Object.assign(firstData, result);
});
default:
// 活动状态不正确
firstData.isGo = true;
break;
}
/**
* 获取分享页面列表数据
* @param {[int]} uid 用户id
* @param {[int]} activityId 活动id
* @return {[array]}
*/
const index = (params) => {
params = params || {};
return api.get('', Object.assign({
method: 'wap.invite.index'
}, params
)).then((result) => {
return Object.assign(firstData, result);
});
}
/**
* 通过手机号发送验证码
* @param {[int]} area 区域,中国:86
* @param {[string]} mobile 手机号
* @return {[array]}
*/
sendRegCodeToMobile(params) {
return this.get({
data: Object.assign({
method: 'app.register.sendRegCodeToMobile'
}, params)
});
}
/**
* 发送已注册用户参与活动的优惠券
* @param {[string]} mobile 手机号
* @param {[int]} activityId 活动id
* @return {[array]}
*/
checkOldUserCoupon(params) {
return this.get({
data: Object.assign({
method: 'wap.invite.checkOldUserCoupon'
}, params)
});
}
/**
* 验证手机验证码是否正确
* @param {[int]} area 区域,中国:86
* @param {[string]} mobile 手机号
* @param {[int]} code 验证码
* @return {[array]}
*/
validRegCode(params) {
return this.get({
data: Object.assign({
method: 'app.register.validRegCode'
}, params)
});
}
/**
* 手机账号注册
* @param {[string]} mobile 手机号
* @param {[string]} activityName 活动名称
* @return {[array]}
*/
register(params) {
return this.get({
data: Object.assign({
method: 'wap.invite.register'
}, params)
});
}
/**
* 微信好友获取红包方法(即分享出去的地址)
* @param {[int]} uid 分享用户id
* @param {[int]} activityId 活动id
* @param {[int]} nums 发送优惠券的数量
* @param {[String]} openId 微信的union_id
* @param {[String]} nickName 微信昵称
* @param {[String]} headImgUrl 微信头像
* @returns {[array]}
*/
shareModel(params) {
let firstData = {
isNil: false,
isEmpty: false,
isFive: false,
isGo: false,
remainData: ['', '', '', '', ''],
data: []
};
switch (result.code) {
case 401:
// 没有分享记录
firstData.isNil = true;
break;
case 200:
return mergeBindLogDate(result.data).then(data => {
let len = data.length;
// 判断是否否5条分享
result.data = data;
if (len === 0) {
firstData.isEmpty = true;
} else if (len < 5) {
firstData.remainData =
_.slice(firstData.remainData, 0, 5 - len);
} else {
firstData.isFive = true;
firstData.remainData = [];
}
return Object.assign(firstData, result);
});
default:
// 活动状态不正确
firstData.isGo = true;
break;
}
return Object.assign(firstData, result);
});
};
/**
* 通过手机号发送验证码
* @param {[int]} area 区域,中国:86
* @param {[string]} mobile 手机号
* @return {[array]}
*/
const sendRegCodeToMobile = (params) => {
return api.get('', Object.assign({
method: 'app.register.sendRegCodeToMobile'
}, params));
};
/**
* 发送已注册用户参与活动的优惠券
* @param {[string]} mobile 手机号
* @param {[int]} activityId 活动id
* @return {[array]}
*/
const checkOldUserCoupon = (params) => {
return api.get('', Object.assign({
method: 'wap.invite.checkOldUserCoupon'
}, params));
};
/**
* 验证手机验证码是否正确
* @param {[int]} area 区域,中国:86
* @param {[string]} mobile 手机号
* @param {[int]} code 验证码
* @return {[array]}
*/
const validRegCode = (params) => {
return api.get('', Object.assign({
method: 'app.register.validRegCode'
}, params));
};
/**
* 手机账号注册
* @param {[string]} mobile 手机号
* @param {[string]} activityName 活动名称
* @return {[array]}
*/
const register = (params) => {
return api.get('', Object.assign({
method: 'wap.invite.register'
}, params));
};
/**
* 微信好友获取红包方法(即分享出去的地址)
* @param {[int]} uid 分享用户id
* @param {[int]} activityId 活动id
* @param {[int]} nums 发送优惠券的数量
* @param {[String]} openId 微信的union_id
* @param {[String]} nickName 微信昵称
* @param {[String]} headImgUrl 微信头像
* @returns {[array]}
*/
const shareModel = (params) => {
let firstData = {
isEmpty: false,
isFive: false,
isGo: false,
remainData: ['', '', '', '', ''],
data: []
};
let listData = [];
// 这里面的逻辑就是获取第三方用户的头像和昵称,然后插入数据和更新数据
return api.get('', Object.assign({
method: 'wap.invite.share'
}, params))
.then((result) => {
let listData = [];
// 这里面的逻辑就是获取第三方用户的头像和昵称,然后插入数据和更新数据
return this.get({
data: Object.assign({
method: 'wap.invite.share'
}, params)
}).then((result) => {
// list为空,说明不是分享者本人
if (result.code !== 200 || _.isEmpty(result.data.list)) {
return result;
}
return mergeBindLogDate(result.data.list).then(data => {
return this.mergeBindLogDate(result.data.list).then(data => {
let len = data.length;
// 判断是否满5条分享
... ... @@ -237,134 +253,125 @@ const shareModel = (params) => {
return result;
});
});
};
}
/**
* 邀请好友赢福利之后领取优惠券
* @param {[int]} uid 用户id
* @param {[int]} activityId 活动id
* @param {[int]} nums 发送优惠券的数量
* @param {[int]} shareUid 分享者的uid
* @param {[string]} openId 微信的union_id
* @returns {[array]}
*/
receiveCoupons(params) {
return this.get({
data: Object.assign({
method: 'wap.invite.receiveCoupons'
}, params)
});
}
/**
* 获取分享列表和用户信息
* @param {[int]} uid 用户id
* @param {[int]} shareUid 分享着uid
* @param {[int]} nums 发送优惠券的数量
* @param {[int]} amount 金额
* @param {[int]} activityId 活动id
* @return {[array]}
*/
myCoupons(params) {
let mobile;
let firstData = {
isEmpty: false,
isFive: false,
isGo: false,
remainData: ['', '', '', '', ''],
data: []
};
let listData = [];
/**
* 邀请好友赢福利之后领取优惠券
* @param {[int]} uid 用户id
* @param {[int]} activityId 活动id
* @param {[int]} nums 发送优惠券的数量
* @param {[int]} shareUid 分享者的uid
* @param {[string]} openId 微信的union_id
* @returns {[array]}
*/
const receiveCoupons = (params) => {
return api.get('', Object.assign({
method: 'wap.invite.receiveCoupons'
}, params));
};
return this.get({
data: Object.assign({
method: 'wap.invite.myCoupons'
}, params)
}).then((result) => {
/**
* 获取分享列表和用户信息
* @param {[int]} uid 用户id
* @param {[int]} shareUid 分享着uid
* @param {[int]} nums 发送优惠券的数量
* @param {[int]} amount 金额
* @param {[int]} activityId 活动id
* @return {[array]}
*/
const myCoupons = (params) => {
let mobile;
let firstData = {
isEmpty: false,
isFive: false,
isGo: false,
remainData: ['', '', '', '', ''],
data: []
};
let listData = [];
return api.get('', Object.assign({
method: 'wap.invite.myCoupons'
}, params)).then((result) => {
if (result.code !== 200) {
return result;
}
return mergeBindLogDate(result.data.list).then(data => {
listData = data;
if (listData.length < 5) {
firstData.remainData =
_.slice(firstData.remainData, 0, 5 - listData.length);
} else {
firstData.isFive = true;
firstData.remainData = [];
if (result.code !== 200) {
return result;
}
firstData.data = listData;
result.data.list = firstData;
return this.mergeBindLogDate(result.data.list).then(data => {
listData = data;
mobile = result.data.myProfile.mobile;
result.data.myProfile.encMobile = mobile.replace(mobile.substring(3, 7), '****');
if (listData.length < 5) {
firstData.remainData =
_.slice(firstData.remainData, 0, 5 - listData.length);
} else {
firstData.isFive = true;
firstData.remainData = [];
}
// 释放内存
listData = [];
return [result.data.list, result.data.myProfile];
});
});
};
firstData.data = listData;
result.data.list = firstData;
/**
* 授权后获取微信用户信息
* @return {[array]}
*/
const getWxUserInfo = (params) => {
let url1 = 'https://api.weixin.qq.com/sns/oauth2/access_token?appid=' +
wxCode.wxAppId + '&secret=' + wxCode.wxAppSecret + '&code=' +
params.code + '&grant_type=authorization_code';
let url2 = 'https://api.weixin.qq.com/sns/userinfo?lang=zh_CN';
return rp({
url: url1,
qs: {},
json: true,
gzip: true,
timeout: 3000
}).then((result) => {
if (_.isEmpty(result.openid)) {
return false;
}
url2 = url2 + '&access_token=' + result.access_token +
'&openid=' + result.openid;
mobile = result.data.myProfile.mobile;
result.data.myProfile.encMobile = mobile.replace(mobile.substring(3, 7), '****');
// 释放内存
listData = [];
return [result.data.list, result.data.myProfile];
});
});
}
/**
* 授权后获取微信用户信息
* @return {[array]}
*/
getWxUserInfo(params) {
let url1 = 'https://api.weixin.qq.com/sns/oauth2/access_token?appid=' +
wxCode.wxAppId + '&secret=' + wxCode.wxAppSecret + '&code=' +
params.code + '&grant_type=authorization_code';
let url2 = 'https://api.weixin.qq.com/sns/userinfo?lang=zh_CN';
return rp({
url: url2,
url: url1,
qs: {},
json: true,
gzip: true,
timeout: 3000
}).then((result2) => {
return result2;
});
});
};
/**
* 获取 邀请好友赢福利的类型:
* 1. 普通的要求好友赢福利
* 2. 会员日的邀请好友 赢福利
*/
const checkType = () => {
const url = '/activity/UserdaySigninController/isUserday';
return serviceAPI.get(url, {});
};
}).then((result) => {
if (_.isEmpty(result.openid)) {
return false;
}
module.exports = {
index,
checkType,
shareModel,
getBindLogByOpenId,
sendRegCodeToMobile,
checkOldUserCoupon,
validRegCode,
register,
receiveCoupons,
myCoupons,
createShareUrl,
getWxOauthUrl,
getWxUserInfo
url2 = url2 + '&access_token=' + result.access_token +
'&openid=' + result.openid;
return rp({
url: url2,
qs: {},
json: true,
gzip: true,
timeout: 3000
}).then((result2) => {
return result2;
});
});
}
/**
* 获取 邀请好友赢福利的类型:
* 1. 普通的要求好友赢福利
* 2. 会员日的邀请好友 赢福利
*/
checkType() {
return this.get({
api: serviceAPI,
url: '/activity/UserdaySigninController/isUserday',
data: {}
});
}
};
... ...
'use strict';
const moment = require('moment');
const service = global.yoho.ServiceAPI;
const serviceAPI = global.yoho.ServiceAPI;
const liveAPI = global.yoho.LiveAPI;
const contentCodeConfig = require('../../../config/content-code');
const resourcesProcess = require(`${global.utils}/resources-process`);
... ... @@ -47,102 +47,142 @@ const _getHumanDuration = (duration) => {
return `${duration[0]}:${duration[1]}:${duration[2]}`;
};
// 获取顶部bannel
let _getBannerData = () => {
return service.get('operations/api/v5/resource/get', {
content_code: contentCodeConfig.live.index,
platform: 'iphone'
}, {
code: 200,
cache: true
}).then((result) => {
return result && result.data ? resourcesProcess(result.data) : [];
});
};
module.exports = class extends global.yoho.BaseModel {
constructor(ctx) {
super(ctx);
}
// 获取精选视频
const _getBestList = () => {
return liveAPI.get('v1/living/best', {}, {
code: 200,
cache: false
}).then(result => {
let list = result && result.data || [];
// 获取顶部bannel
_getBannerData() {
return this.get({
api: serviceAPI,
url: 'operations/api/v5/resource/get',
data: {
content_code: contentCodeConfig.live.index,
platform: 'iphone'
},
param: {
code: 200,
cache: true
}
}).then((result) => {
return result && result.data ? resourcesProcess(result.data) : [];
});
}
if (result && result.data && result.data.length !== 2) {
result.data = [];
}
// 获取精选视频
_getBestList() {
return this.get({
api: liveAPI,
url: 'v1/living/best',
data: {},
param: {
code: 200,
cache: false
}
}).then(result => {
let list = result && result.data || [];
for (let item of list) {
switch (item.living) {
case 0:
item.pre_living = true;
break;
case 1:
default:
item.now_living = true;
break;
case 2:
// 直播结束不显示
result.data = [];
break;
if (result && result.data && result.data.length !== 2) {
result.data = [];
}
// 格式化时间
item.starting_time = _formatTime(item.starting_time * 1000, true);
}
for (let item of list) {
switch (item.living) {
case 0:
item.pre_living = true;
break;
case 1:
default:
item.now_living = true;
break;
case 2:
// 直播结束不显示
result.data = [];
break;
}
// 格式化时间
item.starting_time = _formatTime(item.starting_time * 1000, true);
}
return result && result.data || [];
});
};
return result && result.data || [];
});
}
// 获取直播中所有视频
const _getLivingList = () => {
return liveAPI.get('v1/living/listing', {}, {
code: 200,
cache: false
}).then(result => {
return result && result.data || [];
});
};
// 获取直播中所有视频
_getLivingList() {
return this.get({
api: liveAPI,
url: 'v1/living/listing',
data: {},
param: {
code: 200,
cache: false
}
}).then(result => {
return result && result.data || [];
});
}
// 获取直播预告列表
const _getPrelivingList = () => {
return liveAPI.get('v1/living/starting', {}, {
code: 200,
cache: false
}).then(result => {
let list = result && result.data || [];
// 获取直播预告列表
_getPrelivingList() {
return this.get({
api: liveAPI,
url: 'v1/living/starting',
data: {},
param: {
code: 200,
cache: false
}
}).then(result => {
let list = result && result.data || [];
for (let item of list) {
item.starting_time = _formatTime(item.starting_time * 1000);
}
return result && result.data || [];
});
};
for (let item of list) {
item.starting_time = _formatTime(item.starting_time * 1000);
}
return result && result.data || [];
});
}
// 获取回看列表
const _getRecordList = () => {
return liveAPI.get('v1/living/replaying', {}, {
code: 200,
cache: false
}).then(result => {
return result && result.data || [];
});
};
// 获取回看列表
_getRecordList() {
return this.get({
api: liveAPI,
url: 'v1/living/replaying',
data: {},
param: {
code: 200,
cache: false
}
}).then(result => {
return result && result.data || [];
});
}
// 返回所有数据
const getAllList = () => {
return Promise.all([_getBestList(), _getLivingList(), _getPrelivingList(), _getRecordList(), _getBannerData()]);
};
// 返回所有数据
getAllList() {
return Promise.all([
this._getBestList(),
this._getLivingList(),
this._getPrelivingList(),
this._getRecordList(),
this._getBannerData()
]);
}
// 获取 回放视屏 信息
const fetchReplayInfo = (videoID) => {
let url = 'v1/living/detail';
let data = { video_id: videoID };
let options = { cache: true };
// 获取 回放视屏 信息
fetchReplayInfo(videoID) {
let data = { video_id: videoID };
return liveAPI.get(url, data, options)
.then(result => {
return this.get({
api: liveAPI,
url: 'v1/living/detail',
data: data,
param: {
cache: true
}
}).then(result => {
if (result && result.data) {
let d = result.data;
... ... @@ -162,15 +202,17 @@ const fetchReplayInfo = (videoID) => {
return result || {};
});
};
}
// 获取 直播视屏 信息
const fetchLiveInfo = (roomID) => {
let url = 'v1/living/detail';
let data = { room_id: roomID };
// 获取 直播视屏 信息
fetchLiveInfo(roomID) {
let data = { room_id: roomID };
return liveAPI.get(url, data)
.then(result => {
return this.get({
api: liveAPI,
url: 'v1/living/detail',
data: data
}).then(result => {
if (result && result.data) {
let d = result.data;
... ... @@ -189,37 +231,39 @@ const fetchLiveInfo = (roomID) => {
return result || {};
});
};
const fetchInfo = (id, isReplay) => {
if (isReplay) {
return fetchReplayInfo(id);
} else {
return fetchLiveInfo(id);
}
};
// 获取 直播 弹幕 host
const getBarrageHost = (type) => {
return liveAPI.get('v1/system/gethosts', { type });
};
const getReplyBarrage = (videoID, startTime, timeInterval) => {
const url = 'v1/living/getreplaybarrage';
const data = {
startTime,
timeInterval,
video_id: videoID
};
const options = { cache: true };
fetchInfo(id, isReplay) {
if (isReplay) {
return this.fetchReplayInfo(id);
} else {
return this.fetchLiveInfo(id);
}
}
return liveAPI.get(url, data, options);
};
// 获取 直播 弹幕 host
getBarrageHost(type) {
return this.get({
api: liveAPI,
url: 'v1/system/gethosts',
data: { type }
});
}
// 处理直播时间
module.exports = {
getAllList,
fetchInfo,
getBarrageHost,
getReplyBarrage
getReplyBarrage(videoID, startTime, timeInterval) {
const data = {
startTime,
timeInterval,
video_id: videoID
};
return this.get({
api: liveAPI,
url: 'v1/living/getreplaybarrage',
data: data,
param: {
cache: true
}
});
}
};
... ...
... ... @@ -5,299 +5,344 @@
*/
'use strict';
const service = global.yoho.ServiceAPI;
const api = global.yoho.API;
const serviceAPI = global.yoho.ServiceAPI;
const _ = require('lodash');
const helpers = global.yoho.helpers;
const utils = '../../../utils';
const productProcess = require(`${utils}/product-process`);
module.exports = class extends global.yoho.BaseModel {
constructor(ctx) {
super(ctx);
}
// 获取学生个人信息
const _studentInfo = (params) => {
return api.get('', {
method: 'app.passport.getUserBase',
uid: params.shareUid
}, {code: 200});
};
// 获取学校省份列表
getProvince() {
return this.get({
data: {
method: 'app.studentMarket.getAddressList'
},
param: {
cache: true
}
});
}
// 判断哪个学校认证的
const _getCollege = (params) => {
return api.get('', {
method: 'app.student.getCollegeByUid',
uid: params.uid
}, {code: 200});
};
// 获取学校列表
getSchool(code) {
return this.get({
data: {
method: 'app.studentMarket.getSchoolInfoList',
areaCode: code
}
});
}
const checkStudent = (params) => {
return api.get('', {
method: 'app.student.checkIsStudent',
uid: params.uid
}).then(result => {
// 获取学生个人信息
_studentInfo(params) {
return this.get({
data: {
method: 'app.passport.getUserBase',
uid: params.shareUid
},
param: {
code: 200
}
});
}
let resu = {};
// 判断哪个学校认证的
_getCollege(params) {
return this.get({
data: {
method: 'app.student.getCollegeByUid',
uid: params.uid
},
param: {
code: 200
}
});
}
if (result && result.data) {
resu = result.data.isStudent;
}
checkStudent(params) {
return this.get({
data: {
method: 'app.student.checkIsStudent',
uid: params.uid
}
}).then(result => {
let resu = {};
return resu;
if (result && result.data) {
resu = result.data.isStudent;
}
});
};
return resu;
const moreGoods = (params) => {
let apiData = {
method: 'app.student.vip',
uid: params.uid,
limit: params.limit,
page: params.page
};
if (params.uid === 0) {
Object.assign(apiData, {
order: 's_n_desc'
});
}
return api.get('', apiData, {code: 200}).then(result => {
let resu = {
goods: []
moreGoods(params) {
let apiData = {
method: 'app.student.vip',
uid: params.uid,
limit: params.limit,
page: params.page
};
if (result && result.code === 200 && result.data.product_list) {
resu.goods = productProcess.processProductList(result.data.product_list, {isApp: params.isApp});
} else {
return '';
if (params.uid === 0) {
Object.assign(apiData, {
order: 's_n_desc'
});
}
return resu;
});
};
// 获取学生状态
const _studentState = (params) => {
let resu = {
studentState: {}
};
// 未登录状态
if (!params.uid) {
resu.studentState = {
unLogin: true
};
return resu;
} else if (params.shareUid !== 'undefined' && typeof params.shareUid !== 'undefined') {
// 已登录,为分享链接,验证是否已认证
return service.all([
_studentInfo(params),
checkStudent(params),
_getCollege(params)
]).then(result => {
if (result && result[1] === 1) {
resu.studentState = {
reg: true
};
if (result[2] && result[2].data) {
resu = Object.assign(resu, {schoolName: result[2].data.collegeName || '您认证时未选择学校'});
}
} else if (result && result[0] && result[0].data) {
resu.studentState = {
shareName: result[0].data.nickname || ''
};
return this.get({
data: apiData,
param: {
code: 200
}
}).then(result => {
let resu = {
goods: []
};
return resu;
});
} else {
// 已登录,为原链接,验证是否已认证
return service.all([
_getCollege(params),
checkStudent(params)
]).then(result => {
// 已认证
if (result && result[1] === 1) {
resu.studentState = {
reg: true
};
if (result[0] && result[0].data) {
resu = Object.assign(resu, {schoolName: result[0].data.collegeName || '您认证时未选择学校'});
}
if (result && result.code === 200 && result.data.product_list) {
resu.goods = productProcess.processProductList(result.data.product_list, {isApp: params.isApp});
} else {
// 未认证
resu.studentState = {
unReg: true
};
return '';
}
return resu;
});
}
};
// 获取学生认证总数
const _studentTotal = () => {
return api.get('', {
method: 'app.student.verifiedStudentTotal'
});
};
// 获取学生状态
_studentState(params) {
let resu = {
studentState: {}
};
// 获取学校认证总数
const _schoolTotal = () => {
return api.get('', {
method: 'app.student.getCollegeTotal'
});
};
// 未登录状态
if (!params.uid) {
resu.studentState = {
unLogin: true
};
return resu;
} else if (params.shareUid !== 'undefined' && typeof params.shareUid !== 'undefined') {
// 已登录,为分享链接,验证是否已认证
return Promise.all([
this._studentInfo(params),
this.checkStudent(params),
this._getCollege(params)
]).then(result => {
if (result && result[1] === 1) {
resu.studentState = {
reg: true
};
if (result[2] && result[2].data) {
resu = Object.assign(resu, {schoolName: result[2].data.collegeName || '您认证时未选择学校'});
}
} else if (result && result[0] && result[0].data) {
resu.studentState = {
shareName: result[0].data.nickname || ''
};
}
// 资源位
const _resource = () => {
return service.get('/operations/api/v5/resource/get', {
content_code: '1cff7f47ca7057ef6ac00cbf2efc37ad',
});
};
return resu;
});
} else {
// 已登录,为原链接,验证是否已认证
return Promise.all([
this._getCollege(params),
this.checkStudent(params)
]).then(result => {
// 已认证
if (result && result[1] === 1) {
resu.studentState = {
reg: true
};
if (result[0] && result[0].data) {
resu = Object.assign(resu, {schoolName: result[0].data.collegeName || '您认证时未选择学校'});
}
} else {
// 未认证
resu.studentState = {
unReg: true
};
}
return resu;
});
}
}
// 获取分享记录
const _shareLog = (params) => {
// 获取学生认证总数
_studentTotal() {
return this.get({
data: {
method: 'app.student.verifiedStudentTotal'
}
});
}
if (params.uid) {
return api.get('', {
method: 'app.student.getShareLog',
shareUid: params.uid
// 获取学校认证总数
_schoolTotal() {
return this.get({
data: {
method: 'app.student.getCollegeTotal'
}
});
} else {
let resu = '';
}
return Promise.resolve(resu);
// 资源位
_resource() {
return this.get({
api: serviceAPI,
url: '/operations/api/v5/resource/get',
data: {
content_code: '1cff7f47ca7057ef6ac00cbf2efc37ad',
}
});
}
};
// 获取分享记录
_shareLog(params) {
// 获取学校认证人数
const getSchoolNum = (params) => {
return api.get('', {
method: 'app.student.verifiedStudentTotalByCollege',
college_name: params.schoolName
}, {
cache: true,
code: 200
}).then(result => {
let obj = {
num: result.data,
name: params.schoolName
};
if (params.uid) {
return this.get({
data: {
method: 'app.student.getShareLog',
shareUid: params.uid
}
});
} else {
let resu = '';
result.data = obj;
return Promise.resolve(resu);
}
return result;
});
};
}
const index = (params) => {
return service.all([
_studentTotal(),
_schoolTotal(),
_shareLog(params),
_studentState(params),
_resource(),
]).then(result => {
// 获取学校认证人数
getSchoolNum(params) {
return this.get({
data: {
method: 'app.student.verifiedStudentTotalByCollege',
college_name: params.schoolName
},
param: {
cache: true,
code: 200
}
}).then(result => {
let obj = {
num: result.data,
name: params.schoolName
};
let resu = {
shareLog: [],
picList: [],
uid: params.uid
};
result.data = obj;
if (result && result[0] && result[0].data) {
return result;
});
}
let studentArr = result[0].data.toString().split('');
index(params) {
return Promise.all([
this._studentTotal(),
this._schoolTotal(),
this._shareLog(params),
this._studentState(params),
this._resource(),
]).then(result => {
let resu = {
shareLog: [],
picList: [],
uid: params.uid
};
resu = Object.assign(resu, {studentArr});
}
if (result && result[0] && result[0].data) {
if (result && result[1] && result[1].data) {
let studentArr = result[0].data.toString().split('');
resu = Object.assign(resu, {totalSchool: result[1].data});
}
resu = Object.assign(resu, {studentArr});
}
let obj = {};
if (result && result[1] && result[1].data) {
if (result && result[2] && result[2].data) {
resu = Object.assign(resu, {totalSchool: result[1].data});
}
_.forEach(result[2].data, function(val) {
let obj = {};
obj = {
reward: val.reward || '',
createTime: helpers.dateFormat('YYYY.MM.DD', val.create_time),
nickName: val.nickName
};
if (result && result[2] && result[2].data) {
resu.shareLog.push(obj);
_.forEach(result[2].data, function(val) {
});
obj = {
reward: val.reward || '',
createTime: helpers.dateFormat('YYYY.MM.DD', val.create_time),
nickName: val.nickName
};
}
resu.shareLog.push(obj);
if (result && result[3]) {
});
resu = Object.assign(resu, result[3]);
}
}
// 图片可配,调用资源位
if (result && result[4] && result[4].data && result[4].data[0] && result[4].data[0].data) {
let pList = result[4].data[0].data;
resu.picList = {
bannerPic: helpers.image(pList[0].src, 750, 701),
title1: helpers.image(pList[9].src, 750, 114),
title2: helpers.image(pList[12].src, 750, 114),
title3: helpers.image(pList[14].src, 750, 114),
title4: helpers.image(pList[15].src, 750, 114),
pri1: helpers.image(pList[1].src, 345, 154),
pri2: helpers.image(pList[3].src, 345, 154),
pri3: helpers.image(pList[5].src, 345, 154),
pri4: helpers.image(pList[7].src, 345, 154),
act1: {
src: helpers.image(pList[10].src, 375, 444),
url: pList[10].url
},
act2: {
src: helpers.image(pList[11].src, 375, 444),
url: pList[11].url
},
invite: helpers.image(pList[16].src, 750, 444),
dia1: {
src: helpers.image(pList[2].src, 560, 567),
url: pList[2].url
},
dia2: {
src: helpers.image(pList[4].src, 560, 567),
url: pList[4].url
},
dia3: {
src: helpers.image(pList[6].src, 560, 697),
url: pList[6].url
},
dia4: {
src: helpers.image(pList[8].src, 560, 488),
url: pList[8].url
},
dia5: {
src: helpers.image(pList[13].src, 560, 416),
url: pList[13].url
},
};
}
return resu;
});
if (result && result[3]) {
};
resu = Object.assign(resu, result[3]);
}
module.exports = {
index,
getSchoolNum,
checkStudent,
moreGoods
// 图片可配,调用资源位
if (result && result[4] && result[4].data && result[4].data[0] && result[4].data[0].data) {
let pList = result[4].data[0].data;
resu.picList = {
bannerPic: helpers.image(pList[0].src, 750, 701),
title1: helpers.image(pList[9].src, 750, 114),
title2: helpers.image(pList[12].src, 750, 114),
title3: helpers.image(pList[14].src, 750, 114),
title4: helpers.image(pList[15].src, 750, 114),
pri1: helpers.image(pList[1].src, 345, 154),
pri2: helpers.image(pList[3].src, 345, 154),
pri3: helpers.image(pList[5].src, 345, 154),
pri4: helpers.image(pList[7].src, 345, 154),
act1: {
src: helpers.image(pList[10].src, 375, 444),
url: pList[10].url
},
act2: {
src: helpers.image(pList[11].src, 375, 444),
url: pList[11].url
},
invite: helpers.image(pList[16].src, 750, 444),
dia1: {
src: helpers.image(pList[2].src, 560, 567),
url: pList[2].url
},
dia2: {
src: helpers.image(pList[4].src, 560, 567),
url: pList[4].url
},
dia3: {
src: helpers.image(pList[6].src, 560, 697),
url: pList[6].url
},
dia4: {
src: helpers.image(pList[8].src, 560, 488),
url: pList[8].url
},
dia5: {
src: helpers.image(pList[13].src, 560, 416),
url: pList[13].url
},
};
}
return resu;
});
}
};
... ...
const api = global.yoho.API;
const _ = require('lodash');
const helpers = global.yoho.helpers;
const service = global.yoho.ServiceAPI;
const serviceAPI = global.yoho.ServiceAPI;
module.exports = class extends global.yoho.BaseModel {
constructor(ctx) {
... ... @@ -13,7 +12,7 @@ module.exports = class extends global.yoho.BaseModel {
*/
shareIndex(activityId, isApp, uid) {
return api.all([this._CouponInfo(activityId, uid),
return Promise.all([this._CouponInfo(activityId, uid),
this._redeatList(),
this._banner()
]).then(result => {
... ... @@ -71,12 +70,17 @@ module.exports = class extends global.yoho.BaseModel {
* 首页资源位
*/
_banner() {
return service.get('operations/api/v5/resource/get', {
content_code: 'a4ceb2d742c55008ac7be30bca43e03f',
platform: 'iphone'
}, {
cache: true,
code: 200
return this.get({
api: serviceAPI,
url: 'operations/api/v5/resource/get',
data: {
content_code: 'a4ceb2d742c55008ac7be30bca43e03f',
platform: 'iphone'
},
param: {
cache: true,
code: 200
}
}).then((result) => {
if (result && result.data) {
... ... @@ -89,12 +93,15 @@ module.exports = class extends global.yoho.BaseModel {
* 首页获取优惠券信息
*/
_CouponInfo(activityId, uid) {
return api.get('', {
method: 'app.activity.getActivityCouponInfo',
activity_id: activityId,
uid: uid
}, {
code: 200
return this.get({
data: {
method: 'app.activity.getActivityCouponInfo',
activity_id: activityId,
uid: uid
},
param: {
code: 200
}
}).then((result) => {
if (result && result.code === 200 && result.data) {
return result;
... ... @@ -106,11 +113,14 @@ module.exports = class extends global.yoho.BaseModel {
* 首页获取返利记录
*/
_redeatList() {
return api.get('', {
method: 'app.yohocoinrebeat.lastedlist'
}, {
code: 200,
cache: true
return this.get({
data: {
method: 'app.yohocoinrebeat.lastedlist'
},
param: {
code: 200,
cache: true
}
}).then((result) => {
if (result && result.code === 200 && result.data) {
return result;
... ... @@ -122,12 +132,15 @@ module.exports = class extends global.yoho.BaseModel {
* 优惠劵详情数据
*/
shareDetail(param, isApp) {
return api.get('', {
method: 'app.activity.getActivityCouponDesc',
coupon_code: param.couponCode,
coupon_id: param.couponId
}, {
code: 200
return this.get({
data: {
method: 'app.activity.getActivityCouponDesc',
coupon_code: param.couponCode,
coupon_id: param.couponId
},
param: {
code: 200
}
}).then((result) => {
let moreUrl,
detailData,
... ... @@ -184,10 +197,12 @@ module.exports = class extends global.yoho.BaseModel {
* 获取分享码
*/
getCouponCode(uid, couponId, protocol) {
return api.get('', {
method: 'app.activity.getActivityCouponCode',
uid: uid,
coupon_id: couponId
return this.get({
data: {
method: 'app.activity.getActivityCouponCode',
uid: uid,
coupon_id: couponId
}
}).then(result => {
if (result && result.code === 200 && result.data) {
result.data.detailUrl = helpers.urlFormat('/activity/share-buy/detail', {
... ... @@ -205,11 +220,14 @@ module.exports = class extends global.yoho.BaseModel {
* 我的返利页数据
*/
myRebeat(uid, isApp) {
return api.get('', {
method: 'app.yohocoinrebeat.detail',
uid: uid
}, {
code: 200
return this.get({
data: {
method: 'app.yohocoinrebeat.detail',
uid: uid
},
param: {
code: 200
}
}).then((result) => {
let currencyUrl = helpers.urlFormat('/service/qaDetail', {
keyword: '%E6%9C%89%E8%B4%A7%E5%B8%81',
... ...
... ... @@ -4,122 +4,136 @@
* @date: 2016/10/17
*/
'use strict';
const api = global.yoho.API;
const _ = require('lodash');
const logger = global.yoho.logger;
const service = global.yoho.ServiceAPI;
const serviceAPI = global.yoho.ServiceAPI;
const shopList = (uid, tabName, channelId) => {
let params = {
method: 'app.shops.promote'
};
if (uid) {
params.uid = uid;
module.exports = class extends global.yoho.BaseModel {
constructor(ctx) {
super(ctx);
}
if (tabName) {
params.tab_name = tabName;
}
shopList(uid, tabName, channelId) {
let params = {
method: 'app.shops.promote'
};
if (channelId) {
params.channel_id = channelId;
}
if (uid) {
params.uid = uid;
}
return api.get('', params, {
code: 200
}).then((result) => {
if (result && result.code === 200) {
_.forEach(result.data, function(data) {
let href = '//m.yohobuy.com/product/shop?shop_id=' +
data.shopsId + '&openby:yohobuy={"action":"go.shop","params":{"shop_id":"' +
data.shopsId + '","shop_template_type":"' +
data.shopTemplateType + '","shop_name":"' + data.shopName + '"}}';
if (tabName) {
params.tab_name = tabName;
}
data.isFavorite = data.isFavorite === 'Y';
if (channelId) {
params.channel_id = channelId;
}
if (parseInt(data.collectionNum, 10) > 10000) {
data.collectionNum = (data.collectionNum / 10000).toFixed(1) + ' w';
}
return this.get({
data: params,
param: {
code: 200
}
}).then((result) => {
if (result && result.code === 200) {
_.forEach(result.data, function(data) {
let href = '//m.yohobuy.com/product/shop?shop_id=' +
data.shopsId + '&openby:yohobuy={"action":"go.shop","params":{"shop_id":"' +
data.shopsId + '","shop_template_type":"' +
data.shopTemplateType + '","shop_name":"' + data.shopName + '"}}';
data.href = href;
});
return result.data;
} else {
logger.error('shop list data return code is not 200');
return {};
}
});
};
data.isFavorite = data.isFavorite === 'Y';
const shopNav = (channelId) => {
let params = {
method: 'app.shops.promoteTabNameList'
};
if (parseInt(data.collectionNum, 10) > 10000) {
data.collectionNum = (data.collectionNum / 10000).toFixed(1) + ' w';
}
if (channelId) {
params.channel_id = channelId;
}
return api.get('', params, {
cache: true,
code: 200
}).then((result) => {
if (result.data) {
if (result.data.length === 0 || (result.data.length === 1 && result.data[0] === 'NULL')) {
return false;
} else {
data.href = href;
});
return result.data;
} else {
logger.error('shop list data return code is not 200');
return {};
}
}
});
};
});
}
const banner = (contentCode) => {
return service.get('operations/api/v5/resource/get', {
content_code: contentCode,
platform: 'iphone'
}, {
cache: true,
code: 200
}).then((result) => {
if (result && result.data) {
return result.data[0];
}
});
};
shopNav(channelId) {
let params = {
method: 'app.shops.promoteTabNameList'
};
const shopFav = (uid, shopIds) => {
return api.get('', {
method: 'app.shops.promoteFavorite',
shop_ids: shopIds,
uid: uid
}, {
code: 200
}).then((result) => {
if (result.data) {
return result.data;
if (channelId) {
params.channel_id = channelId;
}
});
};
/**
* 根据店铺ID调获取店铺数据
* 图片字段:pic_popular
order 传 pools_id_asc 或者 pools_id_desc
* @param {*} params
*/
const batchGetShops = (params) => {
return api.get('', {
method: 'app.shops.batchGetShops',
shop_ids: params.shop_ids,
order: params.order
});
};
return this.get({
data: params,
param: {
cache: true,
code: 200
}
}).then((result) => {
if (result.data) {
if (result.data.length === 0 || (result.data.length === 1 && result.data[0] === 'NULL')) {
return false;
} else {
return result.data;
}
}
});
}
banner(contentCode) {
return this.get({
api: serviceAPI,
url: 'operations/api/v5/resource/get',
data: {
content_code: contentCode,
platform: 'iphone'
},
param: {
cache: true,
code: 200
}
}).then((result) => {
if (result && result.data) {
return result.data[0];
}
});
}
module.exports = {
shopList,
shopNav,
banner,
shopFav,
batchGetShops
shopFav(uid, shopIds) {
return this.get({
data: {
method: 'app.shops.promoteFavorite',
shop_ids: shopIds,
uid: uid
},
param: {
code: 200
}
}).then((result) => {
if (result.data) {
return result.data;
}
});
}
/**
* 根据店铺ID调获取店铺数据
* 图片字段:pic_popular
order 传 pools_id_asc 或者 pools_id_desc
* @param {*} params
*/
batchGetShops(params) {
return this.get({
data: {
method: 'app.shops.batchGetShops',
shop_ids: params.shop_ids,
order: params.order
}
});
}
};
... ...
... ... @@ -7,80 +7,89 @@
const utils = '../../../utils';
const logger = global.yoho.logger;
const serviceAPI = global.yoho.ServiceAPI;
const api = global.yoho.API;
const helpers = global.yoho.helpers;
const _ = require('lodash');
const resourcesProcess = require(`${utils}/resources-process`);
const getResourceData = (contCode) => {
if (_.isEmpty(contCode)) {
return Promise.resolve([]);
module.exports = class extends global.yoho.BaseModel {
constructor(ctx) {
super(ctx);
}
return serviceAPI.get('operations/api/v5/resource/get', {
content_code: contCode,
platform: 'iphone'
}, {
cache: true
}).then((result) => {
if (result && result.code === 200) {
return resourcesProcess(result.data);
} else {
logger.error('resource code no 200');
return [];
getResourceData(contCode) {
if (_.isEmpty(contCode)) {
return Promise.resolve([]);
}
});
};
const getProductData = (params) => {
return api.get('', _.assign({
method: 'app.product.singleDay',
limit: '20'
}, params), {
cache: true
}).then((result) => {
if (result && result.code === 200) {
result.data = result.data || [];
if (result.data.length === 0) {
return '';
return this.get({
api: serviceAPI,
url: 'operations/api/v5/resource/get',
data: {
content_code: contCode,
platform: 'iphone'
},
param: {
cache: true
}
}).then((result) => {
if (result && result.code === 200) {
return resourcesProcess(result.data);
} else {
_.forEach(result.data, (item) => {
item.url = helpers.urlFormat(`/product/${item.productSkn}.html`); // 商品url改版 // eslint-disable-line
item.url = helpers.appUrlFormat(item.url, 'go.productDetail', {
product_skn: item.productSkn
});
});
return result.data;
logger.error('resource code no 200');
return [];
}
} else {
logger.error('get product data code no 200');
return [];
}
});
};
});
}
getProductData(params) {
return this.get({
data: _.assign({
method: 'app.product.singleDay',
limit: '20'
}, params),
param: {
cache: true
}
}).then((result) => {
if (result && result.code === 200) {
result.data = result.data || [];
// 获取活动tab标签
const getTabData = (channelId) => {
return api.get('', {
method: 'app.product.singleDayTabNameList',
channel_id: channelId
}, {
cache: true
}).then((result) => {
if (result && result.code === 200) {
return result.data || [];
} else {
logger.error('get tab data code no 200');
return [];
}
});
};
if (result.data.length === 0) {
return '';
} else {
_.forEach(result.data, (item) => {
item.url = helpers.urlFormat(`/product/${item.productSkn}.html`);
item.url = helpers.appUrlFormat(item.url, 'go.productDetail', {
product_skn: item.productSkn
});
});
return result.data;
}
} else {
logger.error('get product data code no 200');
return [];
}
});
}
module.exports = {
getResourceData,
getProductData,
getTabData
// 获取活动tab标签
getTabData(channelId) {
return this.get({
data: {
method: 'app.product.singleDayTabNameList',
channel_id: channelId
},
param: {
cache: true
}
}).then((result) => {
if (result && result.code === 200) {
return result.data || [];
} else {
logger.error('get tab data code no 200');
return [];
}
});
}
};
... ...
... ... @@ -10,19 +10,72 @@
const utils = '../../../utils';
const productProcess = require(`${utils}/product-process`);
const api = global.yoho.API;
const _ = require('lodash');
const serviceAPI = global.yoho.ServiceAPI;
const getStudentGoods = (params) => {
return api.get('', {
method: 'app.student.aggBrand',
limit: params.limit,
stocknumber: params.stocknumber,
}).then(result => {
return productProcess.processProductList(_.get(result, 'data.product_list', []), {isApp: params.isApp});
});
};
module.exports = class extends global.yoho.BaseModel {
constructor(ctx) {
super(ctx);
}
index(code) {
return this.get({
api: serviceAPI,
url: 'operations/api/v5/resource/get',
data: {
content_code: code,
platform: 'iphone'
}
});
}
getStudentGoods(params) {
return this.get({
data: {
method: 'app.student.aggBrand',
limit: params.limit,
stocknumber: params.stocknumber,
}
}).then(result => {
return productProcess.processProductList(_.get(result, 'data.product_list', []), {isApp: params.isApp});
});
}
userAcquireStatus(uid, couponIds) {
return this.get({
data: {
method: 'app.coupons.userAcquireStatus',
uid: uid,
couponIds: couponIds
}
});
}
/**
* 查询商品
* @param id
* @returns {*}
*/
_getRelatedData(idList) {
return this.get({
data: {
productSkn: idList,
method: 'h5.product.batch'
}
}).then(result => {
if (result && result.data && result.data.product_list && result.code === 200) {
_.forEach(result.data.product_list, function(val) {
if (!val.student_price) {
val.student_price = val.vip2_price;
}
});
module.exports = {
getStudentGoods
return productProcess.processProductList(result.data.product_list);
} else {
return {};
}
});
}
};
... ...
const serviceAPI = global.yoho.ServiceAPI;
module.exports = class extends global.yoho.BaseModel {
constructor(ctx) {
super(ctx);
}
getResource(code) {
return this.get({
api: serviceAPI,
url: 'operations/api/v5/resource/get',
data: {
content_code: code,
platform: 'iphone'
}
});
}
vip(limit) {
return this.get({
data: {
method: 'app.student.vip',
limit: limit || 60
}
});
}
verifiedStudentTotal() {
return this.get({
data: {
method: 'app.student.verifiedStudentTotal'
}
});
}
getProvince() {
return this.get({
data: {
method: 'app.studentMarket.getAddressList'
},
param: {
cache: true
}
});
}
getSchool(code) {
return this.get({
data: {
method: 'app.studentMarket.getSchoolInfoList',
areaCode: code
}
});
}
getEducationLevelList() {
return this.get({
data: {
method: 'app.studentMarket.getEducationLevelList'
}
});
}
userAcquireStatus(uid, couponIds) {
return this.get({
data: {
method: 'app.coupons.userAcquireStatus',
uid: uid,
couponIds: couponIds
}
});
}
verifyStudent(uid, collegename, educationdegree, enrollmentyear) {
return this.get({
data: {
method: 'app.student.verifyStudent',
uid: uid,
client_type: 'h5',
college_name: collegename,
enrollment_year: enrollmentyear,
education_degree: educationdegree
}
});
}
verifyIdentity(uid, certno, name, pageurl) {
return this.get({
data: {
method: 'app.student.verifyIdentity',
uid: uid,
client_type: 'h5',
cert_no: certno,
name: name,
page_url: pageurl
}
});
}
getUser(uid) {
if (!uid) {
return Promise.resolve({
code: 200,
data: {}
});
}
return this.get({
data: {
method: 'app.passport.profile',
uid: uid
},
param: {
cache: true
}
});
}
// 添加分享成功记录
addStudent(ownuid, shareId) {
return this.get({
data: {
method: 'app.student.addShare',
uid: ownuid,
shareUid: shareId
}
});
}
};
... ...
... ... @@ -2,129 +2,154 @@
'use strict';
const url = require('url');
const _ = require('lodash');
const API = global.yoho.API;
const serviceAPI = global.yoho.ServiceAPI;
const utils = require(global.utils + '/product-process');
const helpers = global.yoho.helpers;
// 签到
// doc: http://git.yoho.cn/yoho-documents/api-interfaces/blob/master/%E4%BC%9A%E5%91%98%E6%97%A5%E6%B4%BB%E5%8A%A8/%E4%BC%9A%E5%91%98%E6%97%A5%E7%AD%BE%E5%88%B0.md
exports.signin = (uid)=> {
return serviceAPI.post('/activity/UserdaySigninController/signin', {uid});
};
// 写留言
// doc: http://git.yoho.cn/yoho-documents/api-interfaces/blob/master/%E4%BC%9A%E5%91%98%E6%97%A5%E6%B4%BB%E5%8A%A8/%E4%BF%9D%E5%AD%98%E7%94%A8%E6%88%B7%E7%95%99%E8%A8%80.md
exports.saveMsg = (uid, nick_name, content) => {
return serviceAPI.post('/activity/UserdayLeaveWordsController/addLeaveWords', {
uid,
nick_name,
content
});
};
exports.queryLeaveWordsList = (uid) => {
module.exports = class extends global.yoho.BaseModel {
constructor(ctx) {
super(ctx);
}
// 签到
// doc: http://git.yoho.cn/yoho-documents/api-interfaces/blob/master/%E4%BC%9A%E5%91%98%E6%97%A5%E6%B4%BB%E5%8A%A8/%E4%BC%9A%E5%91%98%E6%97%A5%E7%AD%BE%E5%88%B0.md
signin(uid) {
return this.get({
api: serviceAPI,
url: '/activity/UserdaySigninController/signin',
data: {uid}
});
}
// 写留言
// doc: http://git.yoho.cn/yoho-documents/api-interfaces/blob/master/%E4%BC%9A%E5%91%98%E6%97%A5%E6%B4%BB%E5%8A%A8/%E4%BF%9D%E5%AD%98%E7%94%A8%E6%88%B7%E7%95%99%E8%A8%80.md
saveMsg(uid, nick_name, content) {
return this.get({
api: serviceAPI,
url: '/activity/UserdayLeaveWordsController/addLeaveWords',
data: {
uid,
nick_name,
content
}
});
}
queryLeaveWordsList(uid) {
return this.get({
api: serviceAPI,
url: '/activity/UserdayLeaveWordsController/queryLeaveWordsList',
data: {
uid
}
});
}
// 拼手气大转盘 抽奖
// doc: http://git.yoho.cn/yoho-documents/api-interfaces/blob/master/%E4%BC%9A%E5%91%98%E6%97%A5%E6%B4%BB%E5%8A%A8/%E6%8B%BC%E6%89%8B%E6%B0%94%E5%A4%A7%E8%BD%AC%E7%9B%98%E6%8A%BD%E5%A5%96.md
addPrizeLog(uid, prize_type) {
return this.get({
api: serviceAPI,
url: '/activity/UserdayPrizeLogController/addPrizeLog',
data: {
uid,
prize_type
}
});
}
// 查询 中奖纪录
queryPrizeLog(uid, prize_type) {
return this.get({
api: serviceAPI,
url: '/activity/UserdayPrizeLogController/queryPrizeLog',
data: {
uid,
prize_type
}
});
}
return serviceAPI.get('/activity/UserdayLeaveWordsController/queryLeaveWordsList', {uid});
};
// 获取用户的有货币
// doc: http://git.yoho.cn/yoho-documents/api-interfaces/tree/master/%E6%9C%89%E8%B4%A7%E5%B8%81
getCoins(uid) {
return this.get({
data: {
method: 'app.yohocoin.total',
uid
}
});
}
// 获取抽奖人数
// doc: http://git.yoho.cn/yoho-documents/api-interfaces/blob/master/%E4%BC%9A%E5%91%98%E6%97%A5%E6%B4%BB%E5%8A%A8/%E6%9F%A5%E8%AF%A2%E5%8F%82%E4%B8%8E%E6%8A%BD%E5%A5%96%E4%BA%BA%E6%95%B0.md
getJoinNum(prize_type) {
return this.get({
api: serviceAPI,
url: '/activity/UserdayPrizeLogController/queryPrizeLogNum',
data: {
prize_type
}
});
}
// 拼手气大转盘 抽奖
// doc: http://git.yoho.cn/yoho-documents/api-interfaces/blob/master/%E4%BC%9A%E5%91%98%E6%97%A5%E6%B4%BB%E5%8A%A8/%E6%8B%BC%E6%89%8B%E6%B0%94%E5%A4%A7%E8%BD%AC%E7%9B%98%E6%8A%BD%E5%A5%96.md
exports.addPrizeLog = (uid, prize_type) => {
/**
* cate [object Object]
*/
getGoods(cate) {
let skns = '';
let cates = Object.keys(cate);
return serviceAPI.post('/activity/UserdayPrizeLogController/addPrizeLog', {
uid,
prize_type
});
};
// 查询 中奖纪录
exports.queryPrizeLog = (uid, prize_type) => {
_.forEach(cate, function(val) {
skns = skns.concat(',').concat(val.join(','));
});
return serviceAPI.get('/activity/UserdayPrizeLogController/queryPrizeLog', {
uid,
prize_type
});
};
skns = skns.slice(1);
return this.get({
data: {
method: 'h5.product.batch',
productSkn: skns
}
}).then(result => {
if (result.code !== 200) {
return {
code: result.code,
message: result.message
};
}
let productList = utils.processProductList(result.data.product_list);
let data = {};
// 获取用户的有货币
// doc: http://git.yoho.cn/yoho-documents/api-interfaces/tree/master/%E6%9C%89%E8%B4%A7%E5%B8%81
exports.getCoins = uid => {
return API.get('', {
method: 'app.yohocoin.total',
uid
});
};
productList.forEach(product=> {
let skn = product.productSkn;
let imgSrc = url.parse(product.defaultImages || '');
// 获取抽奖人数
// doc: http://git.yoho.cn/yoho-documents/api-interfaces/blob/master/%E4%BC%9A%E5%91%98%E6%97%A5%E6%B4%BB%E5%8A%A8/%E6%9F%A5%E8%AF%A2%E5%8F%82%E4%B8%8E%E6%8A%BD%E5%A5%96%E4%BA%BA%E6%95%B0.md
exports.getJoinNum = prize_type => {
product.defaultImages = ['//', imgSrc.hostname, imgSrc.pathname].join('');
return serviceAPI.get('/activity/UserdayPrizeLogController/queryPrizeLogNum', {
prize_type,
});
};
product.url = helpers.appUrlFormat(product.url, 'go.productDetail', {
product_skn: skn
});
/**
* cate [object Object]
*/
exports.getGoods = cate => {
let skns = '';
let cates = Object.keys(cate);
for (let c of cates) {
let index = cate[c].indexOf(skn);
_.forEach(cate, function(val) {
skns = skns.concat(',').concat(val.join(','));
});
if (index !== -1) {
cate[c].splice(index, 1);
skns = skns.slice(1);
data[c] || (data[c] = []);
data[c].push(product);
break;
}
}
});
return API.get('', {
method: 'h5.product.batch',
productSkn: skns
}).then(result => {
if (result.code !== 200) {
return {
code: result.code,
message: result.message
code: 200,
data
};
}
let productList = utils.processProductList(result.data.product_list);
let data = {};
productList.forEach(product=> {
let skn = product.productSkn;
let imgSrc = url.parse(product.defaultImages || '');
product.defaultImages = ['//', imgSrc.hostname, imgSrc.pathname].join('');
product.url = helpers.appUrlFormat(product.url, 'go.productDetail', {
product_skn: skn
});
for (let c of cates) {
let index = cate[c].indexOf(skn);
if (index !== -1) {
cate[c].splice(index, 1);
data[c] || (data[c] = []);
data[c].push(product);
break;
}
}
});
// console.log(data.goods1.length)
// console.log(data.goods2.length)
// console.log(data.goods3.length)
return {
code: 200,
data
};
});
}
};
... ...
... ... @@ -2,126 +2,152 @@
'use strict';
const url = require('url');
const _ = require('lodash');
const API = global.yoho.API;
const serviceAPI = global.yoho.ServiceAPI;
const utils = require(global.utils + '/product-process');
const helpers = global.yoho.helpers;
// 签到
// doc: http://git.yoho.cn/yoho-documents/api-interfaces/blob/master/%E4%BC%9A%E5%91%98%E6%97%A5%E6%B4%BB%E5%8A%A8/%E4%BC%9A%E5%91%98%E6%97%A5%E7%AD%BE%E5%88%B0.md
exports.signin = (uid)=> {
return serviceAPI.post('/activity/UserdaySigninController/signin', {uid});
};
exports.queryLeaveWordsList = (uid) => {
return serviceAPI.get('/activity/UserdayLeaveWordsController/queryLeaveWordsList', {uid});
};
module.exports = class extends global.yoho.BaseModel {
constructor(ctx) {
super(ctx);
}
// 签到
// doc: http://git.yoho.cn/yoho-documents/api-interfaces/blob/master/%E4%BC%9A%E5%91%98%E6%97%A5%E6%B4%BB%E5%8A%A8/%E4%BC%9A%E5%91%98%E6%97%A5%E7%AD%BE%E5%88%B0.md
signin(uid) {
return this.get({
api: serviceAPI,
url: '/activity/UserdaySigninController/signin',
data: {
uid: uid
}
});
}
queryLeaveWordsList(uid) {
return this.get({
api: serviceAPI,
url: '/activity/UserdayLeaveWordsController/queryLeaveWordsList',
data: {
uid: uid
}
});
}
// 拼手气大转盘 抽奖
// doc: http://git.yoho.cn/yoho-documents/api-interfaces/blob/master/%E4%BC%9A%E5%91%98%E6%97%A5%E6%B4%BB%E5%8A%A8/%E6%8B%BC%E6%89%8B%E6%B0%94%E5%A4%A7%E8%BD%AC%E7%9B%98%E6%8A%BD%E5%A5%96.md
addPrizeLog(uid, prize_type) {
return this.get({
api: serviceAPI,
url: '/activity/UserdayPrizeLogController/addPrizeLog',
data: {
uid,
prize_type
}
});
}
// 查询 中奖纪录
queryPrizeLog(uid, prize_type) {
return this.get({
api: serviceAPI,
url: '/activity/UserdayPrizeLogController/queryPrizeLog',
data: {
uid,
prize_type
}
});
}
// 拼手气大转盘 抽奖
// doc: http://git.yoho.cn/yoho-documents/api-interfaces/blob/master/%E4%BC%9A%E5%91%98%E6%97%A5%E6%B4%BB%E5%8A%A8/%E6%8B%BC%E6%89%8B%E6%B0%94%E5%A4%A7%E8%BD%AC%E7%9B%98%E6%8A%BD%E5%A5%96.md
exports.addPrizeLog = (uid, prize_type) => {
// 获取用户的有货币
// doc: http://git.yoho.cn/yoho-documents/api-interfaces/tree/master/%E6%9C%89%E8%B4%A7%E5%B8%81
getCoins(uid) {
return this.get({
data: {
method: 'app.yohocoin.total',
uid
}
});
}
// 获取抽奖人数
// doc: http://git.yoho.cn/yoho-documents/api-interfaces/blob/master/%E4%BC%9A%E5%91%98%E6%97%A5%E6%B4%BB%E5%8A%A8/%E6%9F%A5%E8%AF%A2%E5%8F%82%E4%B8%8E%E6%8A%BD%E5%A5%96%E4%BA%BA%E6%95%B0.md
getJoinNum(prize_type) {
return this.get({
api: serviceAPI,
url: '/activity/UserdayPrizeLogController/queryPrizeLogNum',
data: {
prize_type
}
});
}
return serviceAPI.post('/activity/UserdayPrizeLogController/addPrizeLog', {
uid,
prize_type
});
};
/**
* cate [object Object]
*/
getGoods(cate) {
let skns = '';
let cates = Object.keys(cate);
// 查询 中奖纪录
exports.queryPrizeLog = (uid, prize_type) => {
_.forEach(cate, function(val) {
skns = skns.concat(',').concat(val.join(','));
});
return serviceAPI.get('/activity/UserdayPrizeLogController/queryPrizeLog', {
uid,
prize_type
});
};
skns = skns.slice(1);
return this.get({
data: {
method: 'h5.product.batch',
productSkn: skns
}
}).then(result => {
if (result.code !== 200) {
return {
code: result.code,
message: result.message
};
}
let productList = utils.processProductList(result.data.product_list);
let data = {};
// 获取用户的有货币
// doc: http://git.yoho.cn/yoho-documents/api-interfaces/tree/master/%E6%9C%89%E8%B4%A7%E5%B8%81
exports.getCoins = uid => {
return API.get('', {
method: 'app.yohocoin.total',
uid
});
};
productList.forEach(product=> {
let skn = product.product_skn;
let imgSrc = url.parse(product.default_images || '');
// 获取抽奖人数
// doc: http://git.yoho.cn/yoho-documents/api-interfaces/blob/master/%E4%BC%9A%E5%91%98%E6%97%A5%E6%B4%BB%E5%8A%A8/%E6%9F%A5%E8%AF%A2%E5%8F%82%E4%B8%8E%E6%8A%BD%E5%A5%96%E4%BA%BA%E6%95%B0.md
exports.getJoinNum = prize_type => {
product.default_images = ['//', imgSrc.hostname, imgSrc.pathname].join('');
return serviceAPI.get('/activity/UserdayPrizeLogController/queryPrizeLogNum', {
prize_type,
});
};
product.url = helpers.appUrlFormat(product.url, 'go.productDetail', {
product_skn: skn
});
/**
* cate [object Object]
*/
exports.getGoods = cate => {
let skns = '';
let cates = Object.keys(cate);
for (let c of cates) {
let index = cate[c].indexOf(skn);
_.forEach(cate, function(val) {
skns = skns.concat(',').concat(val.join(','));
});
if (index !== -1) {
cate[c].splice(index, 1);
skns = skns.slice(1);
data[c] || (data[c] = []);
data[c].push(product);
break;
}
}
});
return API.get('', {
method: 'h5.product.batch',
productSkn: skns
}).then(result => {
if (result.code !== 200) {
return {
code: result.code,
message: result.message
code: 200,
data
};
}
let productList = utils.processProductList(result.data.product_list);
let data = {};
productList.forEach(product=> {
let skn = product.product_skn;
let imgSrc = url.parse(product.default_images || '');
product.default_images = ['//', imgSrc.hostname, imgSrc.pathname].join('');
product.url = helpers.appUrlFormat(product.url, 'go.productDetail', {
product_skn: skn
});
for (let c of cates) {
let index = cate[c].indexOf(skn);
if (index !== -1) {
cate[c].splice(index, 1);
data[c] || (data[c] = []);
data[c].push(product);
break;
}
});
}
// 判断是否学生
checkIsStudent(uid) {
return this.get({
data: {
method: 'app.student.checkIsStudent',
uid: uid,
}
});
// console.log(data.goods1.length)
// console.log(data.goods2.length)
// console.log(data.goods3.length)
return {
code: 200,
data
};
});
};
// 判断是否学生
exports.checkIsStudent = uid => {
return API.get('', {
method: 'app.student.checkIsStudent',
uid: uid,
});
}
};
... ...
... ... @@ -38,7 +38,7 @@ const _repaymentList = (req, res, next, opt, params) => {
uid: req.user.uid
}, params);
installmentModel.getQueryAmtList(params).then((result) => {
req.ctx(installmentModel).getQueryAmtList(params).then((result) => {
res.render('installment/repayment-list', _.assign({
module: 'home',
page: 'repayment-list',
... ... @@ -59,8 +59,8 @@ const index = (req, res, next) => {
logger.info(`installment index info: client_type=${req.query.client_type},req.user.uid=${req.user.uid},req.query.uid=${req.query.uid},cookies=${JSON.stringify(req.cookies)}`); // eslint-disable-line
Promise.all([
installmentModel.getStauts(uid),
installmentModel.getSearchIntallment({
req.ctx(installmentModel).getStauts(uid),
req.ctx(installmentModel).getSearchIntallment({
uid: uid
})
]).then((result) => {
... ... @@ -88,7 +88,10 @@ const index = (req, res, next) => {
};
if (openStatus === '0') {
return Promise.all([installmentModel.getResources('openN'), installmentModel.getNotices()]).then(data => {
return Promise.all([
req.ctx(installmentModel).getResources('openN'),
req.ctx(installmentModel).getNotices()
]).then(data => {
_.forEach(data[0], (item) => {
if (item.singleOne) {
item.data[0].url = 'javascript:void(0)'; //eslint-disable-line
... ... @@ -104,10 +107,10 @@ const index = (req, res, next) => {
});
} else if (openStatus === '2') {
return Promise.all([
installmentModel.getQueryCreditInfo(uid),
installmentModel.getQueryAmtInfo(uid),
installmentModel.getResources('openY'),
installmentModel.getNotices()
req.ctx(installmentModel).getQueryCreditInfo(uid),
req.ctx(installmentModel).getQueryAmtInfo(uid),
req.ctx(installmentModel).getResources('openY'),
req.ctx(installmentModel).getNotices()
]).then((data) => {
let params = _.assign({
isOverdue: false,
... ... @@ -172,7 +175,7 @@ const getInstallmentGoods = (req, res, next) => {
uid: req.user.uid
};
installmentModel.getSearchIntallment(params).then((result) => {
req.ctx(installmentModel).getSearchIntallment(params).then((result) => {
if (result) {
res.render('installment/goods-template', {
layout: false,
... ... @@ -203,11 +206,11 @@ const review = (req, res, next) => {
if (openStatus === '2') {
Promise.all([
installmentModel.getSearchIntallment({
req.ctx(installmentModel).getSearchIntallment({
page: 1
}),
installmentModel.getQueryCreditInfo(uid),
installmentModel.getResources('advertisement')
req.ctx(installmentModel).getQueryCreditInfo(uid),
req.ctx(installmentModel).getResources('advertisement')
]).then((result) => {
let advertisement = false;
... ... @@ -325,7 +328,7 @@ const getRepayRecord = (req, res, next) => {
pageNo: req.query.page || 1
});
installmentModel.getQueryRePayList(params).then((result) => {
req.ctx(installmentModel).getQueryRePayList(params).then((result) => {
if (result) {
res.render('installment/record-template', {
layout: false,
... ... @@ -389,7 +392,7 @@ const postAccount = (req, res, next) => {
uid: req.user.uid
}, req.query);
installmentModel.postAccount(params).then((result) => {
req.ctx(installmentModel).postAccount(params).then((result) => {
res.json(result);
}).catch((err) => {
_serverCrash(res, {
... ... @@ -428,7 +431,7 @@ function getRealIP(req) {
const activateService = (req, res, next) => {
installmentModel.activateService({
req.ctx(installmentModel).activateService({
uid: req.user.uid,
userName: req.body.userName,
identityCardNo: req.body.identityCardNo,
... ... @@ -451,7 +454,7 @@ const activateService = (req, res, next) => {
};
const getBankInfo = (req, res, next) => {
installmentModel.getBankInfo({
req.ctx(installmentModel).getBankInfo({
cardNo: req.query.cardNo,
uid: req.user.uid
}).then((result)=> {
... ... @@ -464,7 +467,7 @@ const getBankInfo = (req, res, next) => {
};
const verifyCode = (req, res, next) => {
installmentModel.sendVerifyCode(req.user.uid || 1, req.query.mobile).then((result)=> {
req.ctx(installmentModel).sendVerifyCode(req.user.uid || 1, req.query.mobile).then((result)=> {
res.json(result);
}).catch((err) => {
_serverCrash(res, {
... ... @@ -492,7 +495,7 @@ const orderList = (req, res, next) => {
limit: req.query.limit || 10
};
installmentModel.getInstallmentOrders(params).then((result)=> {
req.ctx(installmentModel).getInstallmentOrders(params).then((result)=> {
res.render('installment/order-list', {
title: '我的分期订单',
orders: ((()=> {
... ... @@ -526,7 +529,7 @@ const orderDetail = (req, res, next) => {
orderCode: req.params.id
};
installmentModel.getInstallmentOrderDetail(params).then((result)=> {
req.ctx(installmentModel).getInstallmentOrderDetail(params).then((result)=> {
res.render('installment/order-detail', {
module: 'home',
page: 'installment.order-detail',
... ... @@ -621,7 +624,7 @@ const repayDetail = (req, res, next) => {
pageNo: 1
};
installmentModel.getQueryRePayList(params).then((result) => {
req.ctx(installmentModel).getQueryRePayList(params).then((result) => {
res.render('installment/repay-detail', _.assign({
title: '还款详情',
isInstallmentPage: true,
... ... @@ -639,7 +642,7 @@ const repayDetail = (req, res, next) => {
const help = (req, res, next) => {
let id = 263;
installmentModel.getHelpDetail(id).then((result) => {
req.ctx(installmentModel).getHelpDetail(id).then((result) => {
res.render('installment/help', {
title: '分期支付帮助中心',
helpdetail_list: result.helpdetail_list
... ... @@ -657,7 +660,7 @@ const agreement = (req, res) => {
// 计算金额
const totalAmount = (req, res, next) => {
installmentModel.totalAmount(req.query.prices).then((result) => {
req.ctx(installmentModel).totalAmount(req.query.prices).then((result) => {
res.json(result);
}).catch((err) => {
_serverCrash(res, {
... ... @@ -668,7 +671,7 @@ const totalAmount = (req, res, next) => {
// 检查验证码
const checkVerifyCode = (req, res, next) => {
installmentModel.checkVerifyCode(req.user.uid, req.query.mobile, req.query.code).then((result) => {
req.ctx(installmentModel).checkVerifyCode(req.user.uid, req.query.mobile, req.query.code).then((result) => {
res.json(result);
}).catch((err) => {
_serverCrash(res, {
... ... @@ -686,7 +689,7 @@ const serverCrash = (req, res) => {
const bankCard = (req, res, next) => {
let uid = req.user.uid;
installmentModel.getBankCards(uid).then((result) => {
req.ctx(installmentModel).getBankCards(uid).then((result) => {
let noBank = true;
_.forEach(result, (val) => {
... ... @@ -717,7 +720,7 @@ const cardDetail = (req, res, next) => {
let uid = req.user.uid;
let cardIdNo = req.query.cardIdNo;
installmentModel.getCardDetail(uid, cardIdNo).then((result) => {
req.ctx(installmentModel).getCardDetail(uid, cardIdNo).then((result) => {
res.render('installment/card-detail', {
module: 'home',
page: 'card-detail',
... ... @@ -741,7 +744,7 @@ const delBankCard = (req, res, next) => {
cardIdNo: req.query.cardIdNo
};
installmentModel.delBankCard(params).then((result) => {
req.ctx(installmentModel).delBankCard(params).then((result) => {
res.json(result);
}).catch((err) => {
_serverCrash(res, {
... ... @@ -758,7 +761,7 @@ const setMasterCard = (req, res, next) => {
cardIdNo: req.query.cardIdNo
};
installmentModel.setMasterCard(params).then((result) => {
req.ctx(installmentModel).setMasterCard(params).then((result) => {
res.json(result);
}).catch((err) => {
_serverCrash(res, {
... ...
... ... @@ -3,7 +3,7 @@
const _ = require('lodash');
const moment = require('moment');
const camelCase = global.yoho.camelCase;
const service = global.yoho.ServiceAPI;
const serviceAPI = global.yoho.ServiceAPI;
const resourcesProcess = require(`${global.utils}/resources-process`);
const helpers = global.yoho.helpers;
const crypto = global.yoho.crypto;
... ... @@ -63,14 +63,18 @@ class familyModel extends global.yoho.BaseModel {
* 资源位
*/
_getTrendPop(contentCode) {
return service.get('operations/api/v5/resource/get', {
content_code: contentCode,
}, {
code: 200,
cache: true
return this.get({
api: serviceAPI,
url: 'operations/api/v5/resource/get',
data: {
content_code: contentCode,
},
param: {
code: 200,
cache: true
}
}).then(result => {
if (result && result.code === 200 && result.data) {
return resourcesProcess(result.data);
} else {
return result;
... ... @@ -82,11 +86,16 @@ class familyModel extends global.yoho.BaseModel {
* 资源位
*/
_getdownPop(param) {
return service.get('operations/api/v5/resource/get', {
content_code: param.code,
}, {
code: 200,
cache: true
return this.get({
api: serviceAPI,
url: 'operations/api/v5/resource/get',
data: {
content_code: param.code,
},
param: {
code: 200,
cache: true
}
}).then(result => {
if (result && result.code === 200 && result.data) {
... ...