mirror of
http://112.124.100.131/GFRS/ebiz-h5.git
synced 2025-12-23 06:26:44 +08:00
Merge branch 'feature/开门红' into dev
This commit is contained in:
@@ -48,27 +48,30 @@ export default {
|
||||
this.images = [this.$assetsUrl + pic.picUrl]
|
||||
},
|
||||
shareImg() {
|
||||
const img = this.getImageBase64()
|
||||
// eslint-disable-next-line no-undef
|
||||
EWebBridge.webCallAppInJs('bridge', {
|
||||
flag: 'share',
|
||||
extra: {
|
||||
shareType: '1',
|
||||
img
|
||||
}
|
||||
const img = this.toDataURL(this.images[0], function(base64) {
|
||||
console.log(base64)
|
||||
// eslint-disable-next-line no-undef
|
||||
EWebBridge.webCallAppInJs('bridge', {
|
||||
flag: 'share',
|
||||
extra: {
|
||||
shareType: '1',
|
||||
img
|
||||
}
|
||||
})
|
||||
})
|
||||
},
|
||||
getImageBase64() {
|
||||
const img = document.querySelector('#preview .van-image__img')
|
||||
img.setAttribute('crossOrigin', 'anonymous')
|
||||
var canvas = document.createElement('canvas')
|
||||
canvas.width = img.width
|
||||
canvas.height = img.height
|
||||
var ctx = canvas.getContext('2d')
|
||||
ctx.drawImage(img, 0, 0, img.width, img.height)
|
||||
var dataURL = canvas.toDataURL('image/png')
|
||||
canvas = null
|
||||
return dataURL
|
||||
toDataURL(url, callback) {
|
||||
var xhr = new XMLHttpRequest()
|
||||
xhr.onload = function() {
|
||||
var reader = new FileReader()
|
||||
reader.onloadend = function() {
|
||||
callback(reader.result)
|
||||
}
|
||||
reader.readAsDataURL(xhr.response)
|
||||
}
|
||||
xhr.open('GET', url)
|
||||
xhr.responseType = 'blob'
|
||||
xhr.send()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user