no message
This commit is contained in:
parent
a2c78f4ca1
commit
61fccbfde1
58
index.html
58
index.html
@ -40,7 +40,7 @@
|
||||
</div>
|
||||
<div class="content offer-details">
|
||||
<div class="details-header flexacenter">
|
||||
<img class="icon" crossorigin="anonymous" :src="offerinfo?.school?.base64" />
|
||||
<img class="icon" ref="offerImage" crossorigin="anonymous" :src="offerinfo?.school?.base64 || offerinfo?.school?.image" @load="getBase64ImageFromURL('offer')" />
|
||||
<div class="school flex1 flexcolumn">
|
||||
<div class="name">{{ offerinfo?.school?.name }}</div>
|
||||
|
||||
@ -216,7 +216,7 @@
|
||||
<img class="semicircle-bj" crossorigin="anonymous" :src="semicircleicon" />
|
||||
</div>
|
||||
<div class="header flexacenter">
|
||||
<img class="schoolimg" crossorigin="anonymous" :src="item.base64" />
|
||||
<img :ref="'schoolimg' + index" @load="getBase64ImageFromURL('summary', index)" class="schoolimg" crossorigin="anonymous" :src="item.base64 || item.schoolimage" />
|
||||
<div class="schoolname">{{ item.schoolname }}</div>
|
||||
</div>
|
||||
<div class="summaryInclude-content flex1 flexcolumn">
|
||||
@ -410,6 +410,7 @@
|
||||
},
|
||||
mounted() {
|
||||
// axios.defaults.headers.common["Authorization"] = "813blr43ue2hhf2kjnlfibyy9swlxm2x"
|
||||
|
||||
this.base01 = base01
|
||||
this.base02 = base02
|
||||
this.base03 = base03
|
||||
@ -423,21 +424,48 @@
|
||||
this.arrowsgray = arrowsgray
|
||||
},
|
||||
methods: {
|
||||
getBase64ImageFromURL(url, type, index) {
|
||||
fetch(url)
|
||||
.then(response => response.blob())
|
||||
.then(blob => {
|
||||
const reader = new FileReader()
|
||||
reader.onloadend = () => {
|
||||
getBase64ImageFromURL(type, index) {
|
||||
if (type == "offer") {
|
||||
this.offerinfo.school["base64"] = reader.result
|
||||
const img = this.$refs.offerImage
|
||||
const canvas = document.createElement("canvas")
|
||||
canvas.width = img.naturalWidth
|
||||
canvas.height = img.naturalHeight
|
||||
|
||||
const ctx = canvas.getContext("2d")
|
||||
ctx.drawImage(img, 0, 0)
|
||||
|
||||
this.offerinfo.school["base64"] = canvas.toDataURL("image/jpeg")
|
||||
} else {
|
||||
this.offercollege[index]["base64"] = reader.result
|
||||
const img = this.$refs["schoolimg" + index][0]
|
||||
// console.log("img", img)
|
||||
const canvas = document.createElement("canvas")
|
||||
canvas.width = img.naturalWidth
|
||||
canvas.height = img.naturalHeight
|
||||
|
||||
const ctx = canvas.getContext("2d")
|
||||
ctx.drawImage(img, 0, 0)
|
||||
|
||||
// console.log("666", canvas.toDataURL("image/jpeg"))
|
||||
|
||||
this.offercollege[index]["base64"] = canvas.toDataURL("image/jpeg")
|
||||
this.$forceUpdate()
|
||||
}
|
||||
}
|
||||
reader.readAsDataURL(blob)
|
||||
})
|
||||
|
||||
// return
|
||||
// fetch(url)
|
||||
// .then(response => response.blob())
|
||||
// .then(blob => {
|
||||
// const reader = new FileReader()
|
||||
// reader.onloadend = () => {
|
||||
// if (type == "offer") {
|
||||
// this.offerinfo.school["base64"] = reader.result
|
||||
// } else {
|
||||
// this.offercollege[index]["base64"] = reader.result
|
||||
// this.$forceUpdate()
|
||||
// }
|
||||
// }
|
||||
// reader.readAsDataURL(blob)
|
||||
// })
|
||||
},
|
||||
|
||||
// 获取 offer 详情
|
||||
@ -458,7 +486,6 @@
|
||||
this.offerinfo = offerinfo
|
||||
this.moodmessage = data.moodmessage
|
||||
this.getPersonalBackground(data.backgroundid)
|
||||
this.getBase64ImageFromURL(offerinfo.school.image, "offer")
|
||||
})
|
||||
},
|
||||
|
||||
@ -477,9 +504,6 @@
|
||||
const data = res.data
|
||||
|
||||
const offercollege = data.offercollege || []
|
||||
offercollege.forEach((element, index) => {
|
||||
this.getBase64ImageFromURL(element.schoolimage, "summary", index)
|
||||
})
|
||||
|
||||
this.offercollege = offercollege
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user