tide-command.js 1.35 KB
const api = global.yoho.API;
const service = global.yoho.ServiceAPI;
const _ = require('lodash');

module.exports = class extends global.yoho.BaseModel {
    constructor(ctx) {
        super(ctx);
    }

    // 文字说明
    invitionText(uid) {
        return api.get('', {
            method: 'app.invitecode.my',
            uid: uid
        }, {
            code: 200
        }).then((result) => {

            if (result && result.code === 200 && result.data) {

                return result.data;
            } else {
                return {};
            }
        });
    }

    // 资源位图
    resources(contentCode) {
        return service.get('operations/api/v5/resource/get', {
            content_code: contentCode
        }, {
            code: 200
        }).then((result) => {
            if (result && result.data) {

                return result.data[0];
            }
        });
    }

    invitionData(uid, contentCode, hideTips) {
        return api.all([this.invitionText(uid), this.resources(contentCode)]).then((result) => {
            let finaData = {};

            finaData = Object.assign(finaData, result[0]);
            finaData.imgSrc = _.get(result[1], 'data[0].src', '');
            finaData.resourcesUrl = _.get(result[1], 'data[0].url', '');
            finaData.hideTips = hideTips;

            return finaData;
        });
    }
};