'use script' //开发环境建议开启严格模式 ; function getDefaultDateTime() { var now = new Date; now.setMinutes(now.getMinutes() - 60); return now.getFullYear + '-' + (now.getMonth() + 1) + '-' + now.getDate() + ' ' + now.getHours() + ':00:00'; } (function (window, mars3d) { //创建widget类,需要继承BaseWidget class MyWidget extends mars3d.widget.BaseWidget { //外部资源配置 get resources() { return ['view.css'] } //页面配置, append是添加DOM节点到html中的方式 get view() { return { type: "append", url: "view.html", parent: "body" }; } //初始化[仅执行1次] create() { // 初始化 参数 let request = haoutil.system.getRequest(); if (window.top) { request = $.extend(request, haoutil.system.getRequest(window.top)); } mars3d.globel_variables = {userid:request.userid || 2,queryDataType:'hour'}; mars3d.globel_variables.queryDataTStart = getDefaultDateTime(); mars3d.globel_variables.queryDataTEnd = getDefaultDateTime(); $('input[type=radio][name=datatype]').change(function() { mars3d.globel_variables.queryDataType = this.value ; console.log( mars3d.globel_variables.queryDataType); }); $('#current').val(mars3d.globel_variables.queryDataType=='hour'?'小时':'天'+mars3d.globel_variables.queryDataTStart); $('#current').val(mars3d.globel_variables.queryDataType=='hour'?'小时':'天'+mars3d.globel_variables.queryDataTStart); //$('#datatype_day').datepicker(); jeDate("#datatype_day",{ format:"YYYY-MM-DD", isTime:true, minDate:"2014-09-19 00:00:00" }) } //每个窗口创建完成后调用 winCreateOK(opt, result) { //此处可以绑定页面dom事件 } //激活插件 activate() { toastr.info('激活插件_example_append') } //释放插件 disable() { toastr.info('释放插件_example_append') } } //注册到widget管理器中。 mars3d.widget.bindClass(MyWidget) //每个widet之间都是直接引入到index.html中,会存在彼此命名冲突,所以闭包处理下。 })(window, mars3d)