const APIBase = require("../../api.base");
const system = require("../../../system");
/**
 * 媒体聚合页项目-移动端调用相关接口
 */
class Mediaaggregation extends APIBase {
    constructor() {
        super();
        this.needinfoSve = system.getObject("service.media.needinfoSve");
        this.mediaaggregationSve = system.getObject("service.mediaaggregation.mediaaggregationSve");
    }
    /**
      * 接口跳转-POST请求
      * action_process  执行的流程
      * action_type     执行的类型
      * action_body     执行的参数
      */
    async springBoard(pobj, qobj, req) {
        if (!pobj.actionType) {
            return system.getResult(null, "actionType参数不能为空");
        }
        var result = await this.opActionProcess(pobj, pobj.actionType, req);
        return result;
    }
    async opActionProcess(pobj, action_type, req) {
        var opResult = null;
        var self = this;
        pobj.xctx = req.xctx;
        switch (action_type) {
            case "test"://测试
                opResult = system.getResultSuccess("测试接口");
                break;
            case "submitNeed"://提交需求/线索
                opResult = this.needinfoSve.submitNeed(pobj);
                break;
            default:
                opResult = system.getResult(null, "action_type参数错误");
                break;
        }
        return opResult;
    }


    /**
      * 接口跳转-POST请求
      * action_process  执行的流程
      * action_type     执行的类型
      * action_body     执行的参数
      */
    async mediAaggregationApi(pobj, qobj, req) {
        if (!pobj.actionType) {
            return system.getResult(null, "actionType参数不能为空");
        }
        var result = await this.mediAaggregationAction(pobj, pobj.actionType, req);
        return result;
    }

    async mediAaggregationAction(pobj, action_type, req) {
        var opResult = null;
        var self = this;
        pobj.xctx = req.xctx;
        switch (action_type) {
            case "test"://测试
                opResult = system.getResultSuccess("测试接口");
                break;
            case "productList"://首页产品列表
                opResult = await this.mediaaggregationSve.productList(pobj);
                break;
            case "rotationChartList"://首页轮播图
                opResult = await this.mediaaggregationSve.rotationChartList(pobj);
                break;
            case "needProductList"://留资表单产品
                opResult =await this.mediaaggregationSve.needProductList(pobj);
                break;
            case "popularRecommendationList"://热门推荐列表
                opResult = await this.mediaaggregationSve.popularRecommendationList(pobj);
                break;
            case "productTypeFirst"://产品分类列表
                opResult = await this.mediaaggregationSve.productTypeFirst(pobj);
                break;
            case "productTypeSecend"://产品分类列表
                opResult = await this.mediaaggregationSve.productTypeSecend(pobj);
                break;
            case "productDetail"://产品详情页
                opResult = await this.mediaaggregationSve.productDetail(pobj);
                break;
            // case "bottomMenuConfig"://吸底菜单
            //     opResult =await this.mediaaggregationSve.bottomMenuConfig(pobj);
            //     break;
            default:
                opResult = system.getResult(null, "action_type参数错误");
        }
        return opResult;
    }

}
module.exports = Mediaaggregation;
