exchangeCoupon.js 1.98 KB
/**
 * Created by ty on 2016/6/23.
 * 发券管理
 */
var request = require('request');
var apiDomain = global.Register.domain;
module.exports={
    namespace:"exchangeCoupon",
    apis:{
        queryList:{
            title: "发券列表",
            url: '/activity/couponExchangeActivity/queryList',
            params: [
                {name: 'name', type: 'string'},//名称
                {name: 'page', type: 'Number'},
                {name: 'size', type: 'Number'}
            ]
        },
        add:{
            title: "添加",
            url: '/activity/couponExchangeActivity/add',
            params: [
                {name: 'name', type: 'string'},//名称
                {name: 'subName', type: 'string'}, // 副标题
                {name: 'sendCouponId', type: 'string'}, // 券Id
                {name: 'exchangeYohoCoinNum', type: 'Number'} // 使用有货币数量
            ]
        },
        update:{
            title: "更新",
            url: '/activity/couponExchangeActivity/update',
            params: [
                {name: 'name', type: 'string'},//名称
                {name: 'subName', type: 'string'}, // 副标题
                {name: 'sendCouponId', type: 'string'}, // 券Id
                {name: 'exchangeYohoCoinNum', type: 'Number'} // 使用有货币数量
            ]
        },
        delete: function(req, callback) {
            const params = []
            for(let key in req.body) {
                params.push(key+'='+encodeURI(req.body[key]))
            }
            const url = apiDomain + "/activity/couponExchangeActivity/delete?"+ params.join('&')
            request.get(url,function(err,res,body){
                if(err) {
                    return callback(null, err)
                }
                try{
                    body = JSON.parse(body)
                }catch{
                    return callback(null, {message: '删除失败'})
                }
                return callback(null, body);
            });
        },
    }
}