virtualEdit.html 7.74 KB
<!DOCTYPE html>
<div id="tt" class="easyui-layout" fit="true" style="overflow-y: scroll">
    <form name="topicForm" id="topicForm" method="post">
        <div style="margin-top: 20px;margin-left: 30px">
            <table border="0" style="width:95%;margin-top:5px;line-height:30px;" id="tab">
                <tr style="height: 60px">
                    <td>
                        <span style="color:red">*</span><label>UID</label> <br>
                        <input id="uid" name="uid" class="easyui-textbox" style="width: 380px;"/>
                        <a id="userBotton" class="btn btn-small" style="font-size: 18px;">确认</a>
                        <div id="userInfo">
                        </div>
                    </td>
                </tr>

                <tr style="height: 60px">
                    <td>
                        <span style="color:red">*</span><label>达人昵称</label> <br>
                        <input id="nickName" name="nickName" class="easyui-textbox" style="width: 380px;"/>
                    </td>
                </tr>

                <tr style="height: 60px">
                    <td>
                        <span style="color:red">*</span><label>头像</label> <br>
                        <div id="imageUpload">
                        </div>
                        <!-- <span style=" margin-left: 10px; color: red"> 图片宽高(186x170)</span>-->
                    </td>
                </tr>

                <tr style="height: 60px">
                    <td>
                        <label>签名</label> <br>
                        <textarea id="signature" name="signature" style="width: 380px;" rows="6" placeholder=""
                                  required="true" maxlength="500"></textarea>
                    </td>
                </tr>

                <tr style="height: 60px">
                    <td>
                        <span style="color:red">*</span><label>用户身份</label><br>

                        <input class="easyui-combobox" id="groupId" name="groupId">
                        </input>
                        <!-- <span style=" margin-left: 10px; color: red"> 图片宽高(186x170)</span>-->
                    </td>
                </tr>

                <tr style="height: 60px">
                    <td>
                        <span style="color:red"></span><label>擅长领域</label> <br>
                        <textarea id="skillsDesc" name="skillsDesc" style="width: 380px;" rows="6" placeholder=""
                                   maxlength="500"></textarea>
                        <br>
                        <label>100字以内,案例:美食生活、数码电子、时尚穿搭</label>
                    </td>
                </tr>

                <tr style="height: 60px">
                    <td>
                        <input value="1" type="radio" name="authStatus">认证</input>
                        <input value="0" type="radio" name="authStatus" required="true">取消认证</input>
                    </td>
                </tr>
            </table>
        </div>
    </form>
</div>

<script>
    $(function () {

        $("#userBotton").linkbutton({
            iconCls: "icon-search",
            onClick: function () {
                //发送请求
                $.ajax({
                    type: "POST",
                    url: serverContextPath + "/grassArticle/getUserInfo",     //提交到后端的url
                    dataType: 'json',
                    data: {
                        uid: $("#uid").textbox("getValue")
                    },
                    success: function (result) {
                        if (result.code == 200) {
                            if (result.data != null && result.data != '') {
                                debugger
                                var headIco = result.data.headIco.substring(0, result.data.headIco.indexOf("?"));
                                var nickName = result.data.nickName;
                                $("#nickName").textbox("setValue", nickName);
                                $("#imageUpload").imageUpload('setValue', headIco);
                                $("#userInfo").html("");
                                //图片不可更改
                                $("#imageUpload .file-close").hide();

                            } else {
                                var html = '<span style="color:red;font-size: 15px;">获取用户信息失败,请检查uid输入是否正确</span>';
                                $("#userInfo").html(html);
                                $("#nickName").textbox("setValue", "");
                                $("#imageUpload").imageUpload("setValue", "");
                            }
                        }
                        else {
                            var html = '<span style="color:red;font-size: 15px;">获取用户信息失败,请稍后重试</span>';
                            $("#userInfo").html(html);
                            $("#nickName").textbox("setValue", "");
                            $("#imageUpload").imageUpload("setValue", "");

                        }

                    }
                });
            }
        });


        $("#nickName").textbox({
            required: true,
            missingMessage: "昵称不能为空",
            prompt: "请输入昵称"
        });

        $("#groupId").combobox({
            valueField: "id",
            textField: "groupName",
            required: true,
            prompt: "身份类型",
            url: serverContextPath + "/grassUserManage/getAllVirtualGroup",
            loadFilter: function (data) {
                var data = defaultLoadFilter(data);
//                data.unshift({'id': '', 'groupName': '--用户身份类型--'});
                return data;
            }
        });


        $("#imageUpload").imageUpload({
            width: 171,
            height: 120,
            realInputName: "headIcon",
            url: serverContextPath + '/fileupload/uploadFile',
            queryParams: {
                bucket: "yhb-img01"
            },
            onBeforeSubmit: function () {
                $.messager.progress({
                    title: "正在执行",
                    msg: "正在执行,请稍后...",
                    interval: 500,
                    text: ""
                });
            },
            filterFileName: function (data) {
                debugger;
                if (!data || data.code != 200) {
                    $.messager.progress("close");
                    $.messager.alert("错误", data.message);
                    return "";
                }
                return data.data.url;
            },
            onLoadSuccess: function (data) {
                $.messager.progress("close");
                return false;
            }
        });


        //加载数据
        var data = paramObject.mkData;
        if (data) {
            $("#userBotton").css("display", "none");
            $("#uid").textbox('textbox').attr('readonly', true);
            $("#uid").textbox("setValue", data.uid);
            $("#nickName").textbox("setValue", data.nickName);
            //图片
            $("#imageUpload").imageUpload('setValue', data.headIcon);
            $("#signature").html(data.signature);
            $("#skillsDesc").html(data.skillsDesc== null ? "":data.skillsDesc);
            //所属分组
            $("#groupId").combobox('setValue', data.groupId);
            $("input[name='authStatus'][value='" + data.authStatus + "']").attr("checked", "checked").parent().addClass('checked');
        } else {
            debugger
            //新增
            $("#nickName").textbox('textbox').attr('readonly', true);
            $("#imageUpload").imageUpload("readonly", true);
        }


    });


</script>

</html>