layui type2 通过url给iframe子页面传值

A页面 调用layui.layer.open

                layui.use(["layer"], function () {
                    layui.layer.open({
                        type: 2,
                        title: "管理角色拥有的部门",
                        btn: ["确定修改", "关闭"],
                        content: '@Url.Content("~/Role/UserRoleView?rid=")'+a[0].ID + '&uid=' + a[0].UID,//这里指向office
                        btn1: function (index, layero) {
                            //获取子页面数据
                            var body = layer.getChildFrame('body', index);
                            var addData = body.find("#listFalse li");
                            console.log(addData);
                            var delData = body.find("#listTrue li")
                            console.log(delData);
                            if (addData.length==0&&delData.length==0) {
                                layui.layer.closeAll();
                                layui.layer.msg("没有做任何修改!");
                                return false;
                            } else {
                                var url = '@Url.Content("~/Role/AddRemoveUsers2Role")';
                                if ($(addData).find("span").length != 0) {
                                    var data = getListData(addData);
                                    $.ajax({
                                        type: "post",
                                        url: url,
                                        data: { "rid": a[0].ID, "uids": data },
                                        success: function (rst) {
                                            layui.layer.closeAll();
                                            layui.layer.msg("添加用户成功,其用户名分别为:" + data.toString());

                                        }
                                    })
                                };
                                if ($(delData).find("span").length != 0) {
                                    var data = getListData(delData);
                                    $.ajax({
                                        type: "post",
                                        url: url,
                                        data: { "rid": a[0].ID, "uids": data ,"Add":"false"},
                                        success: function (rst) {
                                            layui.layer.closeAll();
                                            layui.layer.msg("删除用户成功,其用户名分别为:" + data.toString());
                                        }
                                    })
                                }
                            }
                        },
                        btn2: function () {
                            layui.layer.closeAll();
                        }

                    })
                })


B页面获取解析为Object

   //页面初始化

    $(function () {
       var oid = args().oid;//获取父页面oid
    })
    //获取index传参rid args为传递过来的所有参数,类型为OBJDECT,调用为args();
        var args = function(params){
            var a = {};
            params = params || location.search;
            if(!params) return {};
            params = decodeURI(params);
            params.replace(/(?:^\?|&)([^=&]+)(?:\=)([^=&]+)(?=&|$)/g,function(m,k,v){  a[k] = v; });
            return a;
        };



你可能感兴趣的:(layui type2 通过url给iframe子页面传值)