update codefund

This commit is contained in:
Pan 2018-12-30 21:13:40 +08:00
parent e8e530de54
commit 92c25dacc6
1 changed files with 11 additions and 10 deletions

View File

@ -1,8 +1,9 @@
<template> <template>
<div id="codefund_ad"/> <div id="codefund"/>
</template> </template>
<script> <script>
import axios from 'axios'
export default { export default {
data() { data() {
return { return {
@ -12,24 +13,24 @@ export default {
watch: { watch: {
'$route.path': { '$route.path': {
handler: function(val, oldVal) { handler: function(val, oldVal) {
window._codefund && window._codefund.serve() this.getCodefund()
} }
} }
}, },
mounted() { mounted() {
this.addFundScript() this.getCodefund()
}, },
methods: { methods: {
addFundScript() { getCodefund() {
if (this.$isServer) return if (this.$isServer) return
const codefundId = this.isGitee() const codefundId = this.isGitee()
? '4d3a53de-d23e-4286-94c7-e5a57ad69d26' ? '111'
: '696d21c7-a78e-4437-b738-3967c5a57693' : '96'
const script = window.document.createElement('script')
const template = 'horizontal' const template = 'horizontal'
script.onerror = this.loadError axios.get(`https://api.codefund.app/properties/${codefundId}/funder.html?template=${template}`)
script.src = `https://codefund.io/scripts/${codefundId}/embed.js?template=${template}` .then(function(response) {
document.body.appendChild(script) document.getElementById('codefund').innerHTML = response.data
})
}, },
isGitee() { isGitee() {
const origin = window.location.origin const origin = window.location.origin