**便签功能为拓展功能**
~~~javascript
$(function(){
function lg(a){
console.log(a);
}
var url = 'https://api.caiyunapp.com/v2/AMsGhlSnGoQJeTzt/120.883,32.05/forecast.jsonp';
var stickers = [];
apiData();
function apiData(){
$.ajax({
url:url,
type:'GET',
dataType:'JSONP',
success:function(data){
var washDesc = data.result.daily.carWashing[1].desc;
var tomorrow = data.result.daily.carWashing[1].datetime;
var sticker ={};
var sticker1 = {};
sticker.content = tomorrow+':'+washDesc+'洗车';
sticker1.content = '明天要带伞哦!';
stickers.push(sticker);
stickers.push(sticker1);
initStickers();
},
})
}
function initStickers(){
$('body').sticker({
color:'purple', //便签默认是黄色,可以选择pink,green,blue,purple
width:'200px', //便签的宽度
height:'300px', //便签的高度
saveStickerCallback: function(sticker){ //保存便签的回调方法,参数是sticker对象,包括便签的位置和内容信息
console.log('sticker info: left ' + sticker.left + ',top ' + sticker.top + ',content ' + sticker.content);
},
closeStickerCallback: function(stickerId){ //删除便签的回调方法,参数是便签的stickerId
console.log(stickerId);
}
},stickers);
}
})
~~~