MVC前台添加页面---正规的按商品属性来添加商品

就是正规的按商品属性来添加商品
 
@{
    ViewBag.Title = "Add";
}
<h2>添加优惠券</h2>
<table class="table" >
    <tr>
        <td class="text-right">优惠券名称</td>
        <td>
            <input type="text" id="mc" />
        </td>
    </tr>
    <tr>
        <td class="text-right">分类</td>
        <td>
            <select id="fenlei">
                <option>商城活动</option>
                <option>线下促销</option>
                <option>线上促销</option>
            </select>
        </td>
    </tr>
    <tr>
        <td class="text-right">使用条件</td>
        <td>
            <input type="text" id="sytj" />
        </td>
    </tr>
    <tr>
        <td class="text-right">使用时间限制</td>
        <td>
            <input type="radio" value="1" name="xz" checked/>
            获得后<input type="text" id="days" />天内有效
            <br />
            <input type="radio" value="2" name="xz" />
            在日期<input type="date" id="ksrq" />至<input type="date" id="jsrq"/>
            内有效
        </td>
    </tr>
    <tr>
        <td class="text-right">优惠方式</td>
        <td>
            <input type="radio" value="立减" name="yhfs" />立减
            <input type="radio" value="打折" name="yhfs" />打折
            <input type="radio" value="返利" name="yhfs" />返利
            <br />
            返<input type="text" id="yhfs1" />现金
            返<input type="text" id="yhfs2" />积分
            带#为.............
        </td>
    </tr>
    <tr>
        <td class="text-right">返利方式</td>
        <td>
            <input type="radio" value="1" name="flfs" />交易完成后
            <input type="radio" value="2" name="flfs" />订单完成后
            <input type="radio" value="3" name="flfs" />订单付款后
        </td>
    </tr>
    <tr>
        <td class="text-right">发放总数</td>
        <td>
            <input type="text" id="ffzs"/>
            <br/>
            优惠券总数量,没有不能领取......
        </td>
    </tr>
    <tr>
        <td></td>
        <td>
            <input type="button" value="提交" onclick="Add();" class="btn btn-success" />
            <input type="button" value="返回列表" class="btn btn-default" />
        </td>
    </tr>
</table>
@section scripts{
    <script>
        function Add() {
            var obj = {};
            obj.mc = $("#mc").val();
            obj.Fenlei = $("#fenlei").val();
            obj.sytj = $("#sytj").val();
            obj.sysjCheck = $("input[name='xz']:checked").val();
            obj.sysjAdd = $("#days").val();
            obj.ksrq = $("#ksrq").val();
            obj.jsrq = $("#jsrq").val();
            obj.yhfs = $("input[name='yhfs']:checked").val();
            obj.yhfs1 = $("#yhfs1").val();
            obj.yhfs2 = $("#yhfs2").val();
           
            obj.flfs = $("input[name='flfs']:checked").val();
            obj.ffzs = $("#ffzs").val();
            console.log(obj);
            $.ajax({
                url: "http://localhost:51807/api/shopping",
                type: "POST",
                data: obj,
                success: function (d) {
                    if (d == 1) {
                        alert('添加成功!');
                    } else {
                        alert('添加失败!');
                    }
                }
            });

        }

    </script>
   
    }
posted @ 2020-06-09 14:55  G蠢蠢  阅读(158)  评论(0编辑  收藏  举报