js
/**
* 加载图片
*/
onLoadImage:function(){
var that = this;
wx.request({
url: that.data.httpUrl+'findImgDataByOne.do',
method:'GET',
responseType: 'arraybuffer',
success:function(res){
if(res.statusCode==200){
console.log("",res.data);
var imageData =res.data;
imageData = wx.arrayBufferToBase64(imageData);
that.setData({
//
proImage:'data:image/jpg;base64,'+imageData
});
console.log(that.data.proImage);
}
}
})
wxml
<image src="{{proImage?proImage:'../../../images/xc_img.png'}}"></image>
java后端:
@RequestMapping(value="/findImgDataByOne",method=RequestMethod.GET)
@ResponseBody
public byte[] findImgDataByOne(String barCode){
byte[] obj = wxOrderSerivice.findImgDataByOne(barCode);
return obj;
}