...
|
...
|
@@ -2,6 +2,7 @@ |
|
|
|
|
|
const _ = require('lodash');
|
|
|
const api = global.yoho.API;
|
|
|
const co = Promise.coroutine;
|
|
|
|
|
|
class newQrcode extends global.yoho.BaseModel {
|
|
|
constructor(ctx) {
|
...
|
...
|
@@ -44,24 +45,26 @@ class newQrcode extends global.yoho.BaseModel { |
|
|
}
|
|
|
|
|
|
index(params) {
|
|
|
return api.all([
|
|
|
this.userInfo(params),
|
|
|
this.getCode(params),
|
|
|
this.getToken(params)
|
|
|
]).then(result => {
|
|
|
let resu = {};
|
|
|
let self = this;
|
|
|
|
|
|
if (_.get(result, '[0]data')) {
|
|
|
resu = result[0].data;
|
|
|
}
|
|
|
if (_.get(result, '[1]data')) {
|
|
|
resu.trendWord = result[1].data.trendWord || result[1].data.inviteCode;
|
|
|
}
|
|
|
if (_.get(result, '[2]')) {
|
|
|
resu.token = result[2];
|
|
|
return co(function* () {
|
|
|
let userInfo = yield self.userInfo(params);
|
|
|
|
|
|
if (!_.get(userInfo, 'data') || userInfo.code !== 200) {
|
|
|
return {};
|
|
|
}
|
|
|
return resu;
|
|
|
});
|
|
|
|
|
|
let [getCodeData, getTokenData] = yield Promise.all([
|
|
|
self.getCode(params),
|
|
|
self.getToken(params)
|
|
|
]);
|
|
|
let getCode = _.get(getCodeData, 'data.trendWord') || _.get(getCodeData, 'data.inviteCode');
|
|
|
|
|
|
return {
|
|
|
trendWord: getCode,
|
|
|
token: getTokenData
|
|
|
};
|
|
|
})();
|
|
|
}
|
|
|
}
|
|
|
|
...
|
...
|
|