//通过url获取图片
getRemoteImg: function (sp, avatarUrl) {
console.log("avatarUrl=", avatarUrl);
if (avatarUrl == undefined || avatarUrl == "") {
return;
}
if (cc.sys.platform === cc.sys.MOBILE_BROWSER || cc.sys.platform === cc.sys.DESKTOP_BROWSER) {
cc.loader.load({url: avatarUrl, type: 'jpg'}, function(err, texture) {
var frame = new cc.SpriteFrame(texture);
sp.spriteFrame = frame;
})
} else if (cc.sys.platform === cc.sys.WECHAT_GAME) {
wx.downloadFile({url:avatarUrl,
header:'image',
filePath:'',
success: function (res) {
var path = res.tempFilePath;
cc.loader.load(path, function(err, texture) {
var frame = new cc.SpriteFrame(texture);
sp.spriteFrame = frame;
})
},
fail: function (err) {
cc.log(err);
},
complete: function () {
}
})
}
}