let cu_url = "";
let live24_app;
let timet1;
let timet1_cnt = 0;
let vkds_sttimer = null;
(function (CAFE24API) {
console.log("LIVE24", "player in script init. v4.1");
let vm = new Vue({
el: "#live24_app",
template:
'
\n' +
"\n" +
'
\n" +
"\n" +
'
\n' +
'
\n' +
" \n" +
' \n' +
"
\n" +
" \n" +
"\n" +
'
\n' +
' \n' +
"
\n" +
"
\n" +
"\n" +
"
",
data() {
return {
clp_user_no: "1c6ae315a8120fdf707362a4e6aabb59",
api_url: "https://live24.app",
src_url: "",
mode: "to_player",
login_info: [],
user_key: "",
user_no: "",
userid: "",
tr_no: "",
post_no: "",
sf_no: "",
content_no: "",
type: "",
ui: "",
init_load: false,
privew: "",
test_mode: "",
refferrer: "",
go_page: false,
isstudio: "",
nox: "",
cover: "",
};
},
watch: {
userid(to) {
if (to) {
this.set_live24_url(1);
console.log("set_user_id", to);
}
},
},
computed: {
live24_url() {
let urls =
`https://go.live24.app` +
"/shop/go_to_v2/" +
this.clp_user_no +
"/" +
this.tr_no +
"?key=" +
this.user_key +
"&privew=" +
this.privew +
"&mode=" +
this.test_mode +
"&userid=" +
this.userid +
"&refferrer=" +
this.refferrer +
"&post_no=" +
this.post_no +
"&sf_no=" +
this.sf_no +
"&content_no=" +
this.content_no +
"&ui=" +
this.ui +
"&nox=" +
this.nox +
"&cover=" +
this.cover +
"&type=" +
this.type +
"&isstudio=" +
this.isstudio;
if (this.user_key == "") {
this.user_key = "nouser";
return urls.replace("/#", "");
} else {
return urls.replace("/#", "");
}
},
},
methods: {
active_float_player() {
this.mode = "float_player";
},
go_link(url) {
this.go_page = true;
if (url != this.src_url && url) {
this.src_url = url;
}
},
get_query() {
var url = document.location.href;
var qs = url.substring(url.indexOf("?") + 1).split("&");
for (var i = 0, result = {}; i < qs.length; i++) {
qs[i] = qs[i].split("=");
result[qs[i][0]] = decodeURIComponent(qs[i][1]);
}
return result;
},
set_live24_url(idx) {
$("#live24_ifr").attr("src", this.live24_url);
setTimeout(() => {
this.init_load = true;
}, 300);
},
async c24_login_sync() {
var customer = await CAFE24API.getCustomerInfo((err, res) => {
if (err) {
sessionStorage.removeItem("USER_KEY");
sessionStorage.removeItem("USER_MEMBER_ID");
sessionStorage.removeItem("USER_MEMBER_GROUP_ID");
sessionStorage.removeItem("USER_MEMBER_GROUP_NAME");
this.init_load = true;
} else {
if (res.customer.member_id) {
sessionStorage.setItem("USER_MEMBER_ID", res.customer.member_id);
this.userid = res.customer.member_id;
}
this.live24_auth_sync(CAFE24API, res).then(() => {
console.log("live24_auth_sync", this.live24_url);
//로그인 정지 현상 조치
if (!this.init_load && !sessionStorage.getItem("USER_MEMBER_ID")) {
setTimeout(() => {
location.reload();
}, 5000);
}
});
}
});
},
async live24_auth_sync(CAFE24API, res) {
await $.ajax({
type: "POST",
url: this.api_url + "/cafe24/mall_user_sync",
data: {
mall_id: CAFE24API.MALL_ID,
shop_no: CAFE24API.SHOP_NO,
member_id: sessionStorage.getItem("USER_MEMBER_ID"),
},
dataType: "json",
success(res_sub, status) {
if (res_sub.code == 200) {
sessionStorage.setItem("USER_KEY", res_sub.result.user_key);
vm.user_key = res_sub.result.user_key;
//로그인 되었는데 ID 못받아올때
if (!sessionStorage.getItem("USER_MEMBER_ID")) {
setInterval(() => {
if (sessionStorage.getItem("USER_MEMBER_ID")) {
location.reload();
}
}, 500);
}
} else {
console.log(res.message);
}
},
error: function (request, status, error) {
console.log(request.responseText);
},
});
},
},
async created() {
var ta = this.get_query();
if (ta) {
if (ta.tr_no) {
this.tr_no = ta.tr_no;
}
if (ta.post_no) {
this.post_no = ta.post_no;
}
if (ta.sf_no) {
this.sf_no = ta.sf_no;
}
if (ta.content_no) {
this.content_no = ta.content_no;
}
if (ta.type) {
this.type = ta.type;
}
if (ta.ui) {
this.ui = ta.ui;
}
if (ta.privew) {
this.privew = ta.privew;
}
if (ta.mode) {
this.test_mode = ta.mode;
}
if (ta.refferrer) {
this.refferrer = ta.refferrer;
}
if (ta.isstudio) {
this.isstudio = ta.isstudio;
}
if (ta.nox) {
this.nox = ta.nox;
}
if (ta.cover) {
this.cover = ta.cover;
}
if (ta.dev_test_mode) {
this.api_url = "https://dev.live24.app";
}
if (ta.reset) {
let re_urls =
"/live24_player.html?tr_no=" +
this.tr_no +
"&privew=" +
this.privew +
"&mode=" +
this.mode +
"&refferrer=" +
this.refferrer +
"&content_no=" +
this.content_no +
"&ui=" +
this.ui +
"&cover=" +
this.cover +
"&nox=" +
this.nox +
"&type=" +
this.type;
//console.log('re_urls', re_urls);
top.location.href = re_urls;
return false;
}
}
this.userid = sessionStorage.getItem("USER_MEMBER_ID") || "";
setInterval(() => {
if (sessionStorage.getItem("USER_KEY")) {
this.user_key = sessionStorage.getItem("USER_KEY");
} else {
this.user_key = "nouser";
}
}, 100);
},
async mounted() {
await this.c24_login_sync();
$("body,html").css("overflow", "hidden");
$(document).ready(function () {
$(".autoheight").height($(window).height());
});
$(window).resize(function () {
$(".autoheight").height($(window).height());
});
setTimeout(() => {
try {
document.querySelector("#ch-plugin").remove();
} catch (e) {}
}, 5000);
window.addEventListener("message", function (e) {
if (e.data.action === "go_c24_href") {
vm.go_page = true;
vm.mode = "float_player";
vm.go_link(e.data.go_url);
}
if (e.data.action === "go_c24_href_nch") {
vm.go_page = true;
vm.go_link(e.data.go_url);
}
if (e.data.action === "go_c24_href_top") {
top.location.href = e.data.go_url;
}
if (e.data.action === "to_mode") {
vm.mode = e.data.set_mode;
}
if (e.data.action === "getSessionStorage") {
var value = `${e.data.key}`.split(/, ?/).map((key) => sessionStorage.getItem(key));
document
.querySelector("#live24_ifr")
.contentWindow.postMessage({ type: "sessionStorageData", value: value }, "*");
}
});
},
updated() {
$(".autoheight").height($(window).height());
},
});
})(
CAFE24API.init({
client_id: "QFf0CgssYa4YTLAyyi7hJC", // 사용할 앱의 App Key를 설정해 주세요.
version: "2022-06-01", // 적용할 버전을 설정해 주세요.
})
);