• 个人中心


    $( function() {
        var userStatus = function(){
            var $ajax = null;
            var $url = '';
            var $data = {};
            var $tip = $('#invest_list_tip') || {};
            var $name = $('#user_head_name .name') || {};
            //tip提示文字
            var textMap = {
                's1' : '一秒登录,踏上美好投资之旅!',
                's2' : '用户,快速身份认证,实名投资不怕啥',
                's3' : '用户,绑定银行卡,体验投资高收益',
                's4' : '用户,发现好项目,充值抢起来!',
                's5' : '用户,设置支付密码,任性投资更安全'
            };
            //tip提示的文字链接
            var urlMap = {
                'u1' : '/page/regist/login.jsp',
                'u2' : '/page/bindingcard/bind-verify.jsp',
                //'u3' : getCookieCardChannel(),
                'u4' : '/page/recharge/recharge.jsp',
                'u5' : '/page/bindingcard/setpayPwd.jsp'
            };
            //设置投资列表页Tip文字和链接
            var setTipValue = function(obj){
                $tip.attr({
                    'href': obj.href
                }).html( obj.text );
            };
            $ajax = MS.request( $url, $data, function( json ){
                var $cd = json.cd;
                var $ec = json.ec;
                //用户名称
                var $nickName = $cd.nickName;
                //用户账户余额
                var $cash = $cd.cash;
                //金币数量
                var $gold = $cd.gold_amount || 0;
                //是否实名认证
                var $isRealName = $cd.isRealName;
                //用户绑定的银行名称
                var $bankName = $cd.bankName;
                //用户绑定的银行卡号
                var $cardNo = $cd.cardNo;
                //用户当前状态
                var $status = $cd.status;
                // 用户手机
                var $mobile = $cd.mobile;
                var upLoadHref = function(){
                    var _cookie = MS.cookie.get('_cardChannel');
                    var _ajax = null;
                    var _url = '';
                    var _hrefOne = '/page/bindingcard/bind-penny.jsp?status=2';
                    var _hrefTwo = '/page/bindingcard/bind-shortcut.jsp';
                    var _goBindCard = $( '#go_bind_card a' );
                    if( _cookie ){
                        if( _cookie == 1 ){
                            _goBindCard.attr('href', _hrefOne);
                            setTipValue( {
                                'href' : _hrefOne,
                                'text' : '*' + $nickName + textMap.s3
                            } );
                        }else{
                            _goBindCard.attr('href', _hrefTwo);
                            setTipValue( {
                                'href' : _hrefTwo,
                                'text' : '*' + $nickName + textMap.s3
                            } );
                        }
                    }else{
                        _ajax = MS.request( _url, $data, function(json){
                            if( json.ec == 'M00000' ){
                                if( json.cd.verifyBankCardChannel == 1 ){
                                    _goBindCard.attr('href', _hrefOne);
                                    setTipValue( {
                                        'href' : _hrefOne,
                                        'text' : '*' + $nickName + textMap.s3
                                    } );
                                }else{
                                    _goBindCard.attr('href', _hrefTwo);
                                    setTipValue( {
                                        'href' : _hrefTwo,
                                        'text' : '*' + $nickName + textMap.s3
                                    } );
                                }
                            }else{
                                MS.messShow(json.em);
                            }
                        },{ isLoading : false } );
                    }
                };
                //用户未登录状态
                if( $ec == 'M00003' ){
                    $( '#go_login' ).removeClass('hidden');
                    $name.html('<a href="'+urlMap.u1+'">未登录</a>');
                    setTipValue( {
                        'href' : urlMap.u1,
                        'text' : '*' + textMap.s1
                    } );
                }
                //用户已登录状态
                if( $ec == 'M00000' ){
                    $( '#js_my_infos' ).removeClass( 'hidden' );
                    //显示用户的余额
                    $( '#js_my_infos .nums' ).html( $cash );
                    $( '#js_my_infos .g-nums' ).html( $gold );
                    //把用户名插入
                    $name.html( $nickName );
                    //以实名认证
                    if( $isRealName == true ){
                        //未绑卡
                        if( $status == 2 ){
                            $( '#go_bind_card' ).removeClass('hidden');
                            upLoadHref();
                        }else if( $status == 3 ){
                            $('#go_set_pwd').removeClass('hidden');
                            $( '#go_set_pwd a' ).attr('href', urlMap.u5);
                            setTipValue( {
                                'href' : urlMap.u5,
                                'text' : '*' + $nickName + textMap.s5
                            } );
                        }else{
                            //已完成认证用户
                            //账户余额为零提示充值
                            if ( parseInt( $cash, 10 ) <= 0 ){
                                setTipValue( {
                                    'href' : urlMap.u4,
                                    'text' : '*' + $nickName + textMap.s4
                                } );
                            }else{
                                //用户已完成验证隐藏tip
                                $tip.hide();
                            }
                            //展示所有菜单项
                            $( '#user_approved' ).removeClass('hidden');
                            //显示用户的余额
                            $( '#user_card_info' ).removeClass('hidden');
                            //显示用户的绑卡银行名称
                            $( '#user_card_info .card-name' ).html( $bankName );
                            //显示用户的绑卡银行卡号尾数
                            $( '#user_card_info .card-num' ).html( $cardNo );
                        }
                    }else{
                        //未实名认证
                        $( '#go_real_name' ).removeClass('hidden');
                        $( '#go_real_name a' ).attr('href', urlMap.u2);
                        setTipValue( {
                            'href' : urlMap.u2,
                            'text' : '*' + $nickName + textMap.s2
                        } );
                    }
                }
            }, { isLoading : false });
        };
        userStatus();
        /**
         * data-head-menu 侧边栏顶部的菜单图标
         * .m-sidebar 整个侧边栏
         * .page-title 页面顶部的title
         * .nav-title 导航里面的title
         */
        var __show = function(){
            var $pageTit = $( '.page-title' ).html(), $navTit = $( '.nav-title' );
            var $sidebar = $( '.m-sidebar' ), width = $sidebar.width(), speed = 200;
            var $shadow = MS.shadow.show( function() { $sidebar.animate( { left : -width }, speed ); } );
            $navTit.html( $pageTit );
            $sidebar.animate( { left : 0 }, speed );
        };
        var __hide = function(e){
            e.stopPropagation();
            e.preventDefault();
            var timer = 0;
            clearTimeout( timer );
            timer = setTimeout( function(){
                var $sidebar = $( '.m-sidebar' ), width = $sidebar.width(), speed = 200;
                var $shadow = MS.shadow.show( function() { $sidebar.animate( { left : -width }, speed ); } );
                $sidebar.animate( { left : -width }, speed );
                $shadow.hide();
            }, 500 );
            return false;
        };
        $( '[data-head-menu]' ).off( MS.EventCenter.CLICK, __show ).on( MS.EventCenter.CLICK, __show );
        $('.nav-i-menu').off( MS.EventCenter.CLICK, __hide ).on( MS.EventCenter.CLICK, __hide );
        $('.nav-l-invest').off( MS.EventCenter.CLICK, __hide ).on( MS.EventCenter.CLICK, __hide );
        //左侧导航滚动
        function scrollSidebar() {
            var myScroll = null;
            myScroll = new IScroll( '#_scroll', {
                scrollbars: false,//有滚动条
                probeType: 2,
                fadeScrollbars: true,//滚动时显示滚动条,默认影藏,并且是淡出淡入效果
                bounce: true,//边界反弹
                mouseWheel: true, click: true,
                interactiveScrollbars: true,//滚动条可以拖动
                shrinkScrollbars: 'scale',// 当滚动边界之外的滚动条是由少量的收缩。'clip' or 'scale'.
                momentum: true// 允许有惯性滑动
            } );
        }
        scrollSidebar();
        document.addEventListener('touchmove', function (e) { e.preventDefault(); }, false);
    } );

  • 相关阅读:
    网站设计中常见的几个错误
    C#的一个小函数来计算一个运算使用的时间和内存
    移动位置社交服务全球热潮日益高涨
    Opera CEO 专访:开源真的那么重要吗?
    N73和蓝牙GPS接收器LD3W----Route66 Mobile7中国版
    激励员工的首席执行官以及他们的秘诀
    2008年智能手机五大发展趋势
    J2EE初学者从这里入门
    Windows Mobile 5.0 开发学习
    手机开发平台指南、教程和资料介绍
  • 原文地址:https://www.cnblogs.com/sunhw360/p/4624125.html
Copyright © 2020-2023  润新知