zoukankan      html  css  js  c++  java
  • JS面向对象写法

    <script type="text/javascript">
                visitNum = {
                    init: function() {
                        this.bindEvent();
                        this.getVisitNum('Current');
                    },
                    getVisitNum: function(type) {
                        $.ajax({
                            type: "get",
                            url: "http://app.ebda.cn:8003/app/api/download/getCount",
                            data: {
                                type: type
                            },
                            timeout: 3000,
                            async: true,
                            success: function(data) {
                                visitNum.initHtml(data);
                            },
                            error: function() {
                                alert('网络出现问题,稍后重试');
                            }
                        });
    
                    },
                    initHtml: function(data) {
                        for(var i = 0; i < data.data.length; i++) {
                            var item = data.data[i];
                            var _labelType = item.labelType;
                            if(_labelType == '5') {
                                $('#fastLoginNum').html(item.count);
                            }
                            if(_labelType == '6') {
                                $('#regUserNum').html(item.count);
                            }
                            if(_labelType == 'APKDownload') {
                                $('#androidNum').html(item.count);
                            }
                            if(_labelType == 'IOSDownload') {
                                $('#iosNum').html('-');
                            }
                            if(_labelType == 'Home') {
                                $('#homeNum').html(item.count);
                            }
                            if(_labelType == 'Information') {
                                $('#infoNum').html(item.count);
                            }
                            if(_labelType == 'Robot') {
                                $('#robotNum').html(item.count);
                            }
                        }
                    },
                    bindEvent: function() {
                        $('.nav-left').on('click', function() {
                            $('.nav-right').removeClass('nav-active');
                            $(this).addClass('nav-active');
                            visitNum.getVisitNum('Current');
                        });
                        $('.nav-right').on('click', function() {
                            $('.nav-left').removeClass('nav-active');
                            $(this).addClass('nav-active');
                            visitNum.getVisitNum('All');
                        });
                    }
                }
                visitNum.init();
            </script>
  • 相关阅读:
    让人难以想出的动态转移方程小集
    初识DP
    CSP复赛day2模拟题
    通知
    未完成作业
    2019年东莞特长生 散步
    营救
    农场主
    安全密码
    开发区规划
  • 原文地址:https://www.cnblogs.com/songjn/p/9489129.html
Copyright © 2011-2022 走看看