vue-socials
Version:
Social media share buttons and counts for Vue.js
55 lines (48 loc) • 1.32 kB
JavaScript
import { defineComponent } from 'vue';
import HTTP from '../../utils/http.js';
import getSerialisedParams from '../../utils/getSerialisedParams.js';
import BaseCount from '../../mixins/BaseCount/BaseCount.js';
/**
* Hey!
*
* SOdnoklassnikiCount component used for Odnoklassniki (English: "Classmates") social network
* @link https://ok.ru/
*/
/**
* Share parameters for link
* @link https://apiok.ru/en/ext/like
*/
var SOdnoklassnikiCount = /* #__PURE__ */defineComponent({
name: 'SOdnoklassnikiCount',
mixins: [BaseCount('Odnoklassniki')],
methods: {
handleOKResponse: function handleOKResponse(count) {
this.handleResult({
count: count
});
this.handleCount(count);
}
},
mounted: function mounted() {
var _this = this;
var shareOptions = this.shareOptions;
var ref = shareOptions.ref;
var BASE_URL = 'https://connect.ok.ru/dk';
var finalURL = "".concat(BASE_URL).concat(getSerialisedParams({
'st.cmd': 'extLike',
tp: 'json',
ref: ref
}));
this.handleLoading(true);
HTTP(finalURL, function (err, data) {
_this.handleLoading(false);
if (err) {
_this.handleError(err);
}
if (data) {
_this.handleOKResponse(data.count);
}
});
}
});
export default SOdnoklassnikiCount;