便条首页
搜索:
全文搜
搜标签
关注的
显 示
搜索标签
登陆后可以记录私有便条!
8602
图片
admin
分数: 0 (0 次)
创建: 2015-08-28 16:23:22
更新: 2021-02-14 13:54:43
上海
//天气组件 version 0.3 //标题为城市参数 function Shape_$ID(options) { this.brushTypeOnly = 'stroke'; Base.call(this, options); } Shape_$ID.prototype = { type : 'auid', city : '$Name', redraw_time_count: 0, redraw_time: 3600, weather : '...', temperature : '...', Read : function (ctx,style){ this.ReadCount=1; var my=this; var city2=encodeURIComponent(this.city); var url="/funnyscript/fs_remote_funnyscript.php?id=1441¶m_count=1¶m0="+city2; $.ajax({ type: "GET", url: url, success: function (msg) { var index=msg.indexOf("{"); msg=msg.substr(index); var json=JSON.parse(msg); my.weather=json.results[0].weather_data[0].weather; my.temperature=json.results[0].weather_data[0].temperature; my.buildPath(ctx,style); } }); }, ReadCount:0, buildPath : function(ctx, style) { if (this.ReadCount<1) this.Read(ctx,style); var x = style.x; var y = style.y; ctx.beginPath(); //重新绘制一条全新的路径了,之前画的东西无关 //ctx.rect(x-5,y-25,390,38); ctx.clearRect(x-5,y-25,390,38); ctx.font="26px '宋体',Arial,Times"; ctx.fillStyle = 'rgba(0, 0, 255,1)'; ctx.fillText(this.city+":"+this.weather+" 气温:"+this.temperature, x,y); ctx.stroke(); return; }, /** * 返回矩形区域,用于局部刷新和文字定位 * @param {Object} style */ getRect : function(style) { return { x : style.x-5, y : style.y-25, width : 360, height : 50 }; }, isCover : function(x, y) { var originPos = this.getTansform(x, y); x = originPos[0]; y = originPos[1]; if (x >= (this.style.x - 5) && x <= (this.style.x + 390) && y >= this.style.y - 25 && y <= (this.style.y + 13) ) { return true; } return false; } } require('zrender/tool/util').inherits(Shape_$ID, Base);