layui 禁用启用的确定提示弹窗

function enable(id, resState) {
        var context = null;
        if (1 == resState) {
            context = "该项目启用后即展现在商家平台,商家可提交资源申请,确定启用该项目?";


        } else if (0 == resState) {
            context = "该商品禁用后商家平台服务市场不可见,商家不可以再下单购买,确定禁用该商品?";
        }
        layer.confirm(context, {
            btnAlign: 'c' //按钮居中
            , btn: ['确定', '取消'], //按钮
            title: "提示"
        }, function () {
            $.ajax({
                type: "get",
                url: "/resource/enableResource",
                data: {id: id, resState: resState},
                //返回数据的格式
                datatype: "json",
                success: function (data) {
                    if (data) {
                        window.location.href = "/resource/getResourceList?resType=103";
                    } else {
                        console.log("禁用失败");
                    }


                },
                error: function () {
                    //请求出错处理
                    console.log("操作出错了");
                }
            });
        });


    }

猜你喜欢

转载自blog.csdn.net/qq_37121548/article/details/80896109