wip coop/[id] page
This commit is contained in:
@@ -110,6 +110,7 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { mapState } from 'pinia'
|
||||
import DOMPurify from 'dompurify'
|
||||
import socialShare from '~/utils/socialShare'
|
||||
export default {
|
||||
@@ -138,7 +139,9 @@ export default {
|
||||
geolocation: null,
|
||||
}
|
||||
},
|
||||
|
||||
computed: {
|
||||
...mapState(useAuthStore, ['id', 'access']),
|
||||
},
|
||||
mounted() {
|
||||
this.productUrl = window.location.href
|
||||
this.sendLog('view')
|
||||
@@ -173,6 +176,7 @@ export default {
|
||||
})
|
||||
}
|
||||
},
|
||||
// TODO: implement buyIntent (review functionality)
|
||||
buyIntent() {
|
||||
this.sendLog('shop')
|
||||
return this.product.url
|
||||
@@ -208,10 +212,13 @@ export default {
|
||||
async sendLog(action) {
|
||||
const geo = await this.getPosition()
|
||||
try {
|
||||
const { data } = await this.$axios.get(
|
||||
'https://api.ipify.org?format=json'
|
||||
)
|
||||
const ip = data.ip
|
||||
const config = useRuntimeConfig()
|
||||
const accessToken = this.access
|
||||
const response = await $fetch('https://api.ipify.org?format=json', {
|
||||
baseURL: config.public.baseURL,
|
||||
method: 'GET'
|
||||
})
|
||||
const ip = response.ip
|
||||
const object = {
|
||||
action: action,
|
||||
action_object: {
|
||||
@@ -219,10 +226,21 @@ export default {
|
||||
id: this.product.id,
|
||||
},
|
||||
}
|
||||
console.log('Sending log OBJECT:', object)
|
||||
if (ip) object.ip = ip
|
||||
if (geo) object.geo = geo
|
||||
await this.$api.post(`/stats/me/`, object)
|
||||
} catch {}
|
||||
//TODO: review problems with 406 error backend
|
||||
await $fetch(`/stats/me/`, {
|
||||
baseURL: config.public.baseURL,
|
||||
method: 'POST',
|
||||
body: object,
|
||||
headers: {
|
||||
Authorization: `Bearer ${accessToken}`
|
||||
}
|
||||
})
|
||||
} catch (error) {
|
||||
console.error('Error sending log:', error)
|
||||
}
|
||||
},
|
||||
|
||||
shareFacebook() {
|
||||
|
||||
Reference in New Issue
Block a user