7***@qq.com
7***@qq.com
  • 发布:2016-08-09 17:57
  • 更新:2016-08-09 17:57
  • 阅读:2569

hbuilder 手机运行 ios requireJs

分类:HBuilder

hb 的app项目 ios 手机 运行

报错的问题是不是require引入的js没有生效的。 还有下面的config报错是不是config对象原因;
程序里面用到require方式引入的js就报错;

[ERROR] : TypeError: null is not a function (evaluating 'config.pagination(json.page_size, json.p, json.total_count, 10, function(p) {
request_count.p = p;
load_table();
})')
filename:file:///var/mobile/Containers/Data/Application/7CC6E2B8-4A08-4B1D-87E6-8B17E16A2EB5/Library/Pandora/apps/HBuilder/www/js/pages/manage/media/report/request_count.js
lineno:238
[LOG] : [object HTMLDivElement]
[ERROR] : TypeError: null is not a function (evaluating 'require('/template/release/manage/media/report/request_count_top.js')(json)')
file name:js/pages/manage/media/report/request_count.js
line no:219

下面是页面代码:

define(function(require, exports, module) {
"require:nomunge,exports:nomunge,module:nomunge";

require('../../../../util.js');  
var mui = require('../../../../mui.min.js');  
require('../../../../echarts.min.js');  
require('../../../../mui.picker.js');  
require('../../../../mui.poppicker.js');  
require("../../../../mui.picker.min.js");  

mui.init({  
    swipeBack: true //启用右滑关闭功能  
});  
if(config.pagination == undefined) {  
    config.pagination = require('/js/plugins/pagination/pagination.js');  
}  

var date1Picker = {};  
var date2Picker = {};  
var userListPicker = {};  

var request_count = {};  
var start_date = new Date();  
var end_date = new Date();  
request_count.media_id = 0,  
request_count.user_id = 0;  
request_count.is_first_change = true;  
start_date.setDate(start_date.getDate());  
end_date.setDate(end_date.getDate()-1);  
request_count.date1 = start_date.formatToString('yyyy-MM-dd');  //今天和昨天对比  
request_count.date2 = end_date.formatToString('yyyy-MM-dd');  
request_count.p = 1;  

mui.init({  
    swipeBack: true //启用右滑关闭功能  
});  

var startDate = $('#startDate')[0];  
var endDate = $('#endDate')[0];  
startDate.innerText = request_count.date1;  
endDate.innerText = request_count.date2;  

request_count.date1_init_flag = true;  
request_count.date2_init_flag = true;  

request_count.user_list_init_flag = true;  

load_data();  

function init_date1_cond(json){  
    (function($) {  
        var btns = $('#startDate');  
        var result = $('#startDate')[0];  
        btns.each(function(i, btn) {  
            btn.addEventListener('tap', function() {  
                if(request_count.date1_init_flag){  
                    date1Picker = new $.DtPicker({  
                        type: "date", //设置日历初始视图模式  
                            beginYear: "2000",  
                            endYear: "3000",  
                            value: request_count.date1,  
                    });  
                    request_count.date1_init_flag = false;  
                }  
                date1Picker.show(function(rs) {  
                    request_count.date1 = rs.value;  
                    result.innerText = rs.value;  
                    request_count.p = 1;  
                    load_data();  
                });  
            }, false);  
        });  

    })(mui);  
}  
function init_date2_cond(json){  
    (function($) {  
        var btns1 = $('#endDate');  
        var result1 = $('#endDate')[0];  
        btns1.each(function(i, btn) {  
                btn.addEventListener('tap', function() {  
                    if(request_count.date2_init_flag){  
                        date2Picker = new $.DtPicker({  
                            type: "date", //设置日历初始视图模式  
                            beginYear: "2000",  
                            endYear: "3000",  
                            value: request_count.date2,  
                        });  
                        request_count.date2_init_flag = false;  
                    }  
                    date2Picker.show(function(rs) {  
                        request_count.date2 = rs.value;  
                        result1.innerText = rs.value;  
                        request_count.p = 1;  
                        load_data();  
                    });  
                }, false);  
            });  
        })(mui);  
}  

function init_user_list_cond(json){  
    //加载媒体下拉列表  
    (function($, doc) {  
        var list = [{  
            'value': 0,  
            'text': '全部'  
        }];  
        if(json.media_list) {  
            for(var i = 0, length = json.media_list.length; i < length; i++) {  
                var temp = {};  
                temp.value = json.media_list[i].id,  
                    temp.text = json.media_list[i].media_name,  
                    list.push(temp);  
            }  
        }  
        if(request_count.user_list_init_flag){  
            userListPicker = new mui.PopPicker();  
            request_count.user_list_init_flag = false  
        }  

        userListPicker.setData(list);  
        var showUserPickerButton = doc.getElementById('showUserPicker');  
        var userResult = $('#showUserPicker')[0];  
        showUserPickerButton.addEventListener('tap', function(event) {  
            userListPicker.show(function(items) {  
                var str =JSON.stringify(items[0].text);  
                userResult.innerText = str.replace(/\"/g, "").replace(/\"/g, "");  
                //返回 false 可以阻止选择框的关闭  
                //return false;  
                request_count.media_id = JSON.stringify(items[0].value);  
                request_count.p = 1;  
                load_data();  
            });  
        }, false);  
    })(mui, document);  
}  
function init_search_cond(json){  

    init_date1_cond(json);  
    init_date2_cond(json);  
    init_user_list_cond(json);  

}  

function load_data(){  
    load_chart();  
    load_table();  
}  

//加载媒体流量报表  
function load_chart(){  
    getJSON(config.api_domain + '/manage/dsp/report/request_count?v=1&callback=?',{  
                media_id: request_count.media_id,  
                date1: request_count.date1,  
                date2: request_count.date2,  
                is_first_change:request_count.is_first_change,  
                user_id:request_count.user_id  
            },  
            function(json) {  
                if(!json.status) {  
                }  
                var myChart = echarts.init(document.getElementById('lineChart'));  
                myChart.setOption({  
                    tooltip: {  
                        trigger: 'axis'  
                    },  
                    legend: {  
                        data: [json.date1+'请求数', request_count.date2+'请求数'],  
                    },  
                    grid: {  
                        left: '3%',  
                        right: '4%',  
                        bottom: '3%',  
                        containLabel: true  
                    },  
                    xAxis: {  
                        type: 'category',  
                        boundaryGap: false,  
                        splitLine: {  
                            show: false  
                        },  
                        data: json.x_axis_data_list  
                    },  
                    yAxis: {  
                        type: 'value'  
                    },  
                    series: [{  
                        name: request_count.date1+'请求数',  
                        type: 'line',  
                        draggable: false,  
                        data: json.request_count_series_data1_list  
                    }, {  
                        name: request_count.date2+'请求数',  
                        type: 'line',  
                         draggable: false,  
                        data: json.request_count_series_data2_list  
                    }]  
                });  

                init_search_cond(json);  
                $('#top').html(require('/template/release/manage/media/report/request_count_top.js')(json));  
            }  
    );  
}  

//加载媒体流量报表table  
function load_table() {  
    getJSON(config.api_domain+ '/manage/dsp/report/get_request_count_pages?v=1&callback=?', {  
            media_id: request_count.media_id,  
            date1: request_count.date1,  
            date2: request_count.date2,  
            user_id:request_count.user_id,  
            p: request_count.p  
        },  
        function(json) {  

            $('#request_count_table_pagination').html(  
                config.pagination(json.page_size, json.p, json.total_count, 10, function(p) {  
                    request_count.p = p;  
                    load_table();  
                })  
            );  
            var table1 = require('/template/release/manage/media/report/request_count_table.js')(json);  
            var table2 = require('/template/release/manage/media/report/request_count_table2.js')(json);  

            $('#request_count_table_content1').html(table1)//默认今天的  
            $('#request_count_table_content2').html(table2);//默认昨天的  
        });  
}  

});

2016-08-09 17:57 1 条评论 负责人:无 分享
已邀请:

该问题目前已经被锁定, 无法添加新回复