|
|
'use strict';
|
|
|
|
|
|
const helpers = global.yoho.helpers;
|
|
|
const _ = require('lodash');
|
|
|
|
|
|
module.exports = class extends global.yoho.BaseModel {
|
|
|
constructor(ctx) {
|
|
|
super(ctx);
|
|
|
}
|
|
|
|
|
|
index(params) {
|
|
|
return Promise.resolve(params);
|
|
|
}
|
|
|
return Promise.all([
|
|
|
this.invitecode(params),
|
|
|
this.checkApply(params)
|
|
|
]).then(res => {
|
|
|
let checkStatus = _.get(res[1], 'data.status', 0);
|
|
|
let checkUrl = helpers.urlFormat('/activity/have-gain/apply', {}); // 未申请
|
|
|
|
|
|
submitApply(params) {
|
|
|
let options = {
|
|
|
data: {
|
|
|
method: 'app.promotion.validateGetBirthCoupon',
|
|
|
uid: params.uid
|
|
|
if (checkStatus === 1) { // 审核中
|
|
|
checkUrl = helpers.urlFormat('/activity/have-gain/verify', {});
|
|
|
} else if (checkStatus === 2) { // 审核成功
|
|
|
checkUrl = 'https://activity.yoho.cn/feature/2213.html?title=说明详情&openby:yohobuy={"action":"go.h5","params":{"title": "说明详情", url":"https://activity.yoho.cn/feature/2213.html"}}'; // eslint-disable-line
|
|
|
}
|
|
|
};
|
|
|
|
|
|
return this.get(options);
|
|
|
let share = (_.get(res[0], 'data.context', '')).match(/(\d+)/g);
|
|
|
let gainList = [
|
|
|
{
|
|
|
url: _.get(res[0], 'data.url', ''),
|
|
|
img: '//img10.static.yhbimg.com/article/2017/06/20/12/01a50a1f45b97365e758d6890858998310.jpg?imageView2/{mode}/w/{width}/h/{height}', // eslint-disable-line
|
|
|
totalUser: _.get(share, '[0]', 0),
|
|
|
totalCouponNum: _.get(share, '[1]', 0),
|
|
|
isShow: true
|
|
|
}, {
|
|
|
url: checkUrl,
|
|
|
img: '//img10.static.yhbimg.com/article/2017/06/20/12/01a50a1f45b97365e758d6890858998310.jpg?imageView2/{mode}/w/{width}/h/{height}', // eslint-disable-line
|
|
|
isShow: false
|
|
|
}
|
|
|
];
|
|
|
|
|
|
return gainList;
|
|
|
}).catch(() => {
|
|
|
return [];
|
|
|
});
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* [查询参与邀请好友数量]
|
|
|
* @param {[type]} params [{uid:''}]
|
|
|
* @return {[type]} [{}]
|
|
|
*/
|
|
|
invitecode(params) {
|
|
|
return this.get({
|
|
|
data: Object.assign({
|
|
|
method: 'app.invitecode.total'
|
|
|
}, params)
|
|
|
});
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* [检查是否申请]
|
|
|
* @param {[type]} params [{uid: 0}]
|
|
|
* @return {[type]} [{}]
|
|
|
*/
|
|
|
checkApply(params) {
|
|
|
return this.get({
|
|
|
data: Object.assign({
|
|
|
method: 'app.union.shareOrder.checkApply'
|
|
|
}, params)
|
|
|
});
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* [提交-申请]
|
|
|
* @param {[type]} params [{uid:'',name:'',mobile:'',socialMediaList:[{type:'',account:'',fans:200}]}]
|
|
|
* @return {[type]} [{}]
|
|
|
*/
|
|
|
submitApply(params) {
|
|
|
return this.get({
|
|
|
data: Object.assign({
|
|
|
method: 'app.union.shareOrder.userApply'
|
|
|
}, params)
|
|
|
});
|
|
|
}
|
|
|
}; |
...
|
...
|
|