From 4b37ce7620bc557b13cbd96202138ddbc9aa757b Mon Sep 17 00:00:00 2001 From: lh_wang Date: Sun, 9 Aug 2015 12:12:21 +0800 Subject: [PATCH] change canvas to dom --- meitu/css/main.css | 92 ++++++++++++++++++++++++++--------------- meitu/index.html | 15 ++++++- meitu/js/home/router.js | 73 ++++++++++++++++++-------------- 3 files changed, 115 insertions(+), 65 deletions(-) diff --git a/meitu/css/main.css b/meitu/css/main.css index cf8c0ac..4dec628 100644 --- a/meitu/css/main.css +++ b/meitu/css/main.css @@ -203,7 +203,7 @@ html body { z-index: 10012; background-color: #FFF; opacity: 0.9; - display:none; + display: none; } .speed_dash_container { width: 100px; @@ -220,36 +220,30 @@ html body { margin-left: auto; margin-right: auto; } - -.speed_lable{ - margin-top:-6px; - color:#999; +.speed_lable { + margin-top: -6px; + color: #999; } - -.speed_data{ +.speed_data { clear: both; - width:100%; - height:70px; - color:#999999; + width: 100%; + height: 70px; + color: #999999; } -.speed_data>div{ - height:20px; +.speed_data>div { + height: 20px; } - -.speed_title_strong{ - color:#0091FF; - font-size:13px; +.speed_title_strong { + color: #0091FF; + font-size: 13px; font-style: italic; } - -.speed_l{ +.speed_l { margin-left: 10px; } - -.speed_r{ +.speed_r { width: 100px; } - /*-----------------router----------------------------**/ .router { @@ -268,6 +262,41 @@ html body { -o-transform: translateZ(0); transform: translateZ(0); } +.router_line { + width: 2px; + height: 200px; + background-color: #E82D00; + margin-left: 33px; + margin-top: 10px; + FILTER: progid: DXImageTransform.Microsoft.Gradient(gradientType=0, startColorStr=#E82D00, endColorStr=#FFAE01); + /* IE 10 */ + background: -ms-linear-gradient(top, #E82D00, #FFAE01 ); + /*firefox*/ + background: -moz-linear-gradient(top, #E82D00, #FFAE01); + /*google*/ + background: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#E82D00), to(#FFAE01)); + /* Safari 4-5, Chrome 1-9*/ + background: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#E82D00), to(#FFAE01)); + /*Safari5.1 Chrome 10+*/ + background: -webkit-linear-gradient(top, #E82D00, #FFAE01); + /*Opera 11.10+*/ + background: -o-linear-gradient(top, #E82D00, #FFAE01); +} +.router_span{ + position:absolute; + top:10px; + margin-left:3px; +} + +.router_circle{ + width:10px; + height:10px; + background-color:#00C348; + border-radius:5px; + margin-left:2px; + margin-top:5px; +} + /*-----------------SN_info--------------------------------*/ .SN_info { @@ -338,17 +367,14 @@ html body { font-size: 17px; cursor: pointer; } - /*天气预报*/ -.tianqi_container{ - position:absolute; - min-width:100px; - min-height:100px; - left:50%; - margin-left:-60px; - bottom:140px; - z-index:10090; -} - - +.tianqi_container { + position: absolute; + min-width: 100px; + min-height: 100px; + left: 50%; + margin-left: -60px; + bottom: 140px; + z-index: 10090; +} \ No newline at end of file diff --git a/meitu/index.html b/meitu/index.html index 6516283..a81f95b 100644 --- a/meitu/index.html +++ b/meitu/index.html @@ -165,7 +165,20 @@ -->
- + +
+ +
diff --git a/meitu/js/home/router.js b/meitu/js/home/router.js index 0179c0e..1124503 100644 --- a/meitu/js/home/router.js +++ b/meitu/js/home/router.js @@ -3,39 +3,50 @@ define('home/router', function(require, exports, module) { var $ = require('lib/zepto'); var router = require('common/data').router[0]; - var canvas = $('#router_canvas')[0]; - var ctx = canvas.getContext('2d'); + var wrapper = $('#ROUTER_TPL'); + var tpl = $('#tpl_router').html(); + + var data = { + items: router + }; + + console.log(data.items); + var html = _.template(tpl)(data); + wrapper.html(html); - canvas.width = 45; - canvas.height = 220; - canvas.style.width = 45; - canvas.style.height = 220; - - //line - ctx.beginPath(); - var gradient = ctx.createLinearGradient(35, 5, 20, 215); - gradient.addColorStop(0, 'red'); - gradient.addColorStop(1, 'yellow'); - ctx.lineWidth = '2'; - ctx.strokeStyle = gradient; - ctx.moveTo(35, 5); - ctx.lineTo(35, 215); - ctx.closePath(); - ctx.stroke(); +// var canvas = $('#router_canvas')[0]; +// var ctx = canvas.getContext('2d'); +// +// canvas.width = 45; +// canvas.height = 220; +// canvas.style.width = 45; +// canvas.style.height = 220; +// +// //line +// ctx.beginPath(); +// var gradient = ctx.createLinearGradient(35, 5, 20, 215); +// gradient.addColorStop(0, 'red'); +// gradient.addColorStop(1, 'yellow'); +// ctx.lineWidth = '2'; +// ctx.strokeStyle = gradient; +// ctx.moveTo(35, 5); +// ctx.lineTo(35, 215); +// ctx.closePath(); +// ctx.stroke(); //circle - for(var i = 0; i < router.length; i++){ - ctx.beginPath(); - ctx.fillStyle = '#159AFE'; - ctx.arc(35, 25 + i * 25, 5, 0, Math.PI*2, true); - ctx.closePath(); - ctx.fill(); - - ctx.beginPath(); - ctx.fillStyle = '#000'; - ctx.fillText(router[i].content, 2, 25 + 3 + i * 25); - ctx.closePath(); - ctx.fill(); - } +// for(var i = 0; i < router.length; i++){ +// ctx.beginPath(); +// ctx.fillStyle = '#159AFE'; +// ctx.arc(35, 25 + i * 25, 5, 0, Math.PI*2, true); +// ctx.closePath(); +// ctx.fill(); +// +// ctx.beginPath(); +// ctx.fillStyle = '#000'; +// ctx.fillText(router[i].content, 2, 25 + 3 + i * 25); +// ctx.closePath(); +// ctx.fill(); +// } }); \ No newline at end of file