<%@ Page Title="" Language="C#" MasterPageFile="~/Master/UserMaster.master" CodeBehind="BaseInfo.aspx.cs" Inherits="WAP2P.Web.PC.User.Info.BaseInfo" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="content" runat="server">
    <div class="m-userbox">
        <dl class="ui-tab">
            <dt><a href="/User/Info/BaseInfo<% =PageBase.PageExt %>" <%= string.IsNullOrEmpty(callCode) ? " class=\"on\"" : string.Empty %>>基本信息</a></dt>
            <asp:Repeater runat="server" ID="rptMenuModuledt" ItemType="WAP2P.Sys.FormSetting">
                <ItemTemplate>
                    <dt><a href="<%# Item.CallCode == callCode ? "javascript:void(0);" : "?type="+Item.CallCode %>" <%# Item.CallCode == callCode ? " class=\"on\"" : string.Empty %>><%# InfoIsValid(Item.CallCode) ? "<i class=\"iconfont fcgreen-2\">&#xe62a;</i>" : string.Empty %> <%# Item.Name %></a></dt>
                </ItemTemplate>
            </asp:Repeater>
            <dd>
                <div class="form-big">
                    <form class="js-auto js-vtip g-ohide" method="post" action="<% =Request.RawUrl.UrlEncodeParam() %>">
                        <ruson:Space runat="server" ID="siteData" Visible="false">
                            <div class="t-uploadheader userheader-box g-ohide js-tip">
                                <div class="uploadheader-photo">
                                    <img src="<%= CurrentUser.GetFace() %>" id="faceImg" alt="" />
                                </div>
                                <div class="g-left mt10 mb10" style="padding-left:378px;">
                                    <input type="file" class="btn-nobordbig c-normal" id="btnFace" value="头像上传" style="display: none;" />
                                    <input type="hidden" name="face" id="face" value="<% =CurrentUser.Face.HtmlEncode() %>" />
                                </div>
                            </div>
                            <div class="input-big js-tip ml150">
                                <label class="leftfont">昵称</label>
                                <% =CurrentUser.GetNickname() %> <% =string.IsNullOrWhiteSpace(CurrentUser.Nickname) ? string.Format("<a href=\"../InitInfo{0}\">现在设置</a>", PageExt) : string.Empty %>
                            </div>
                            <div class="input-big js-tip ml150">
                                <label class="leftfont">所在地区</label>
                                <span id="area" class="m-area"></span>
                                <input type="text" class="text w218 mt10 g-block ml99" name="address" value="<% =CurrentUser.Address.HtmlEncode() %>" placeholder="请输入您的详细地址" />
                            </div>
                            <div class="input-big js-tip ml150 g-ohide">
                                <label class="leftfont g-left">个性签名</label>
                                <textarea rows="5" class="w230 g-left ml5" name="signature" placeholder="请输入您的个性签名"><% =CurrentUser.Signature.HtmlEncode() %></textarea>
                            </div>
                        </ruson:Space>

                        <ruson:Space runat="server" ID="basicData" Visible="false">
                            <table width="100%" class="m-jsonfrom mt20">
                                <asp:Repeater runat="server" ID="rptInfoFields" ItemType="WAP2P.Sys.FormField">
                                    <ItemTemplate>
                                        <%# Item.BuildHtml("<tr><th>{%=Name%}</th><td class='js-tip'>{%=Value%}</td></tr>", !isValided, callCode + "_") %>
                                    </ItemTemplate>
                                </asp:Repeater>
                            </table>
                        </ruson:Space>
                        <div class="btn-submits mt10 ml249">
                            <% =isValided ? string.Empty : "<input type=\"submit\" value=\"保 存\" class=\"btn-bbord c-normal w252 fs16\" data-success-text=\"保存成功\" />" %>                        
                            <div class="w252"><em class="m-sumtip js-vsum"></em></div>
                        </div>
                    </form>
                </div>
            </dd>
        </dl>

    </div>

</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="script" runat="server">
    <script src="<% =this.ImportJsCss("~/res/uploadify/jquery.uploadify.min.js") %>"></script>
    <script src="<% =this.ImportJsCss("/res/core/scripts/areadata.js") %>"></script>
    <script>
        $('#area').cascade({ data: areadata, names: ['provinceId', 'cityId', 'areaId'], values: ['<% =CurrentUser.ProvinceId %>', '<% =CurrentUser.CityId %>', '<% =CurrentUser.AreaId %>'], emptyTip: '请选择', ismust: true });

        setTimeout(function () {
            $('#btnFace').uploadify({
                width: 132,
                height: 36,
                multi: false,
                removeTimeout: 0,
                swf: '/res/uploadify/uploadify.swf?v=<% =CryptoHelper.Random(100000,999999) %>',
                uploader: '/res/uploadify/SwfUpload<% =PageExt %>?type=image&width=118&height=118',
                buttonClass:'btn-nobordbig c-normal',
                buttonText: '上传头像',
                fileTypeExts: '<% =WAP2P.Web.PC.Res.uploadify.SwfUpload.AllowImages %>',
                formData: {
                    <% =WAP2P.Web.User.Membership.CookieName %> : '<% =Request.Cookies[WAP2P.Web.User.Membership.CookieName].Value %>'
                },
                onUploadSuccess: function(res, data) {
                    eval('var d = ' + data);
                    if (d.Success) {
                        $('#face').val(d.Message).trigger('change');
                        $('#faceImg').attr('src', d.Message);
                    } else {
                        alert(d.Message);
                    }
                }
            });
        }, 10);

        //配合后端的表单编辑的js
        var formService = {
            initJs: function() {
                $('script.js-script').each(function (i, n) {
                    eval(n.innerHTML);
                });
            },
            initUpload: function(id, multi, isfile) {
                setTimeout(function () {     
                    var fileobj = $('#' + id + 'File');
                    fileobj.uploadify({
                        width: 120,
                        height: 36,
                        multi: multi ? true : false,
                        removeTimeout: 0,
                        swf: '/res/uploadify/uploadify.swf?v=<% =CryptoHelper.Random(100000,999999) %>',
                        uploader: '/res/uploadify/SwfUpload.aspx?type=' + (isfile ? 'file' : 'image'),
                        buttonClass:'btn c-normal',
                        buttonText: fileobj.val() !='' ?fileobj.val() : ('上传' + (isfile ? '文件' : '图片')),
                        fileTypeExts: isfile ? '<% =WAP2P.Web.PC.Res.uploadify.SwfUpload.AllowFiles %>' : '<% =WAP2P.Web.PC.Res.uploadify.SwfUpload.AllowImages %>',
                        formData: {
                            <% =WAP2P.Web.User.Membership.CookieName %> : '<% =Request.Cookies[WAP2P.Web.User.Membership.CookieName].Value %>'
                        },
                        onUploadSuccess: function(res, data) {
                            eval('var d = ' + data);
                            if (d.Success) {
                                var showHtml = isfile ? '<a href="' + d.Message + '" target="_blank"><span class="iconfont fs24">&#xe631;</span> 下载查看</a>' : '<a href="' + d.Message + '" target="_blank"><img width="150" src="' + d.Message + '" alt="" /></a>';
                                if (multi) {
                                    var vals = $('#' + id + 'Input');
                                    vals.append('<input type="hidden" name="' + id + '" value="' + d.Message + '" />');
                                    vals.find('.js-uploadMustInput').val(d.Message).trigger('change');
                                    $('#' + id + 'Result').append(showHtml);
                                } else {
                                    $('#' + id).val(d.Message).trigger('change');
                                    $('#' + id + 'Result').html(showHtml);
                                }
                            } else {
                                $.jError(d.Message);
                            }
                        }
                    });
                }, 10);
            },
            init: function() {
                formService.initJs();                

                $('input.js-imageUpload').each(function(i, n) {
                    n = $(n);
                    formService.initUpload(n.attr('data-id'), false, false);
                });
                $('input.js-imageMultiUpload').each(function(i, n) {
                    n = $(n);
                    formService.initUpload(n.attr('data-id'), true, false);
                });
                $('input.js-fileUpload').each(function(i, n) {
                    n = $(n);
                    formService.initUpload(n.attr('data-id'), false, true);
                });
                $('input.js-fileMultiUpload').each(function(i, n) {
                    n = $(n);
                    formService.initUpload(n.attr('data-id'), true, true);
                });

                //自定义表单多图片或文件上传处理
                $('.ui-imageuploadmulti, .ui-fileuploadmulti').on('mouseenter', 'a', function () {                    
                    $(this).append($('<i class="iconfont fs16 iconsDelete" title="删除">&#xe605;</i>').click(function() {
                        var a = $(this).closest('a'), src = a.attr('href');
                        var inputs = a.closest('div').next();
                        inputs.find('[value="' + src + '"]').not('.js-uploadMustInput').remove();
                        if (inputs.find('input').length == 1) inputs.find('.js-uploadMustInput').val('');
                        a.remove();
                        return false;
                    }));
                }).on('mouseleave', 'a', function () {
                    $(this).find('i').remove();
                });
            }
        }; 
        formService.init();
        var imgObj=$('.ui-customuploads').before('<div class="customuploads-new"><div class="customuploads-col"></div><div class="customuploads-col"></div><div class="customuploads-col"></div></div>').find('img').each(function(){
            var me=$(this),
                myparent=me.parent(),
                newImgList=myparent.prev(),
                imgUrl=me.attr('src'),
                indexNum=me.index()+1;           
            if(indexNum%3==0){
                indexNum=2;
            }else if(indexNum%3==1){
                indexNum=0;
            }else{
                indexNum=1;
            };
            var tempH=0;
            newImgList.find('.customuploads-col').each(function(i,n){
                if(tempH>=$(this).outerHeight()){
                    tempH=$(this).outerHeight();
                    indexNum=i;
                }
            })
            newImgList.find('.customuploads-col').eq(indexNum).append('<a target="_blank" href="'+ imgUrl +'"><img src="'+ imgUrl +'" width="'+newImgList.find('.customuploads-col').width()+'" /></a>');
            if(myparent.find('img').length==newImgList.find('img').length){
                myparent.remove();
            }
        });
        $('.m-jsonfrom').imageWidthReset({'pWidth':210});
    </script>
</asp:Content>
