fix
This commit is contained in:
26
resources/main/js/tg_app/Cookie.js
Normal file
26
resources/main/js/tg_app/Cookie.js
Normal file
@ -0,0 +1,26 @@
|
||||
class Cookie {
|
||||
setCookie(name,value,days) {
|
||||
var expires = "";
|
||||
if (days) {
|
||||
var date = new Date();
|
||||
date.setTime(date.getTime() + (days*24*60*60*1000));
|
||||
expires = "; expires=" + date.toUTCString();
|
||||
}
|
||||
document.cookie = name + "=" + (value || "") + expires + "; path=/";
|
||||
}
|
||||
getCookie(name) {
|
||||
var nameEQ = name + "=";
|
||||
var ca = document.cookie.split(';');
|
||||
for(var i=0;i < ca.length;i++) {
|
||||
var c = ca[i];
|
||||
while (c.charAt(0)===' ') c = c.substring(1,c.length);
|
||||
if (c.indexOf(nameEQ) === 0) return c.substring(nameEQ.length,c.length);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
eraseCookie(name) {
|
||||
document.cookie = name +'=; Path=/; Expires=Thu, 01 Jan 1970 00:00:01 GMT;';
|
||||
}
|
||||
}
|
||||
|
||||
export {Cookie}
|
33
resources/main/js/tg_app/SimpleRouter.js
Normal file
33
resources/main/js/tg_app/SimpleRouter.js
Normal file
@ -0,0 +1,33 @@
|
||||
class SimpleRouter {
|
||||
constructor(routes) {
|
||||
this.routes = routes;
|
||||
this.init();
|
||||
}
|
||||
|
||||
init() {
|
||||
// window.addEventListener('popstate', () => this.route());
|
||||
// document.addEventListener('DOMContentLoaded', () => this.route());
|
||||
// document.addEventListener('click', (e) => {
|
||||
// if (e.target.tagName === 'A') {
|
||||
// e.preventDefault();
|
||||
// this.navigate(e.target.href);
|
||||
// }
|
||||
// });
|
||||
this.route();
|
||||
}
|
||||
|
||||
navigate(path) {
|
||||
window.history.pushState({}, '', path);
|
||||
this.route();
|
||||
}
|
||||
|
||||
route() {
|
||||
const path = window.location.pathname;
|
||||
const route = this.routes[path] || this.routes['/404'];
|
||||
if (route) {
|
||||
route();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export {SimpleRouter}
|
@ -6,10 +6,9 @@ class TgApp {
|
||||
this.userId = userId;
|
||||
this.btnBox = this.createBox("btnBox");
|
||||
this.container.appendChild(this.btnBox);
|
||||
console.log(userId)
|
||||
}
|
||||
|
||||
actionMain(){
|
||||
actionMain() {
|
||||
this.createCardBox();
|
||||
|
||||
// this.createDefaultBox();
|
||||
@ -56,7 +55,7 @@ class TgApp {
|
||||
})
|
||||
}
|
||||
|
||||
getScanBtn(){
|
||||
getScanBtn() {
|
||||
fetch(config.config.apiUrl + `api/tg-bot/get-scan-btn/${this.userId}`, {
|
||||
method: 'GET', // Здесь так же могут быть GET, PUT, DELETE
|
||||
headers: {
|
||||
@ -71,15 +70,27 @@ class TgApp {
|
||||
})
|
||||
}
|
||||
|
||||
createBox(id){
|
||||
createBox(id) {
|
||||
let box = document.createElement("div");
|
||||
box.setAttribute("id", id);
|
||||
|
||||
return box;
|
||||
}
|
||||
|
||||
getAction(action){
|
||||
if (action === "actionMain"){
|
||||
// createScanner() {
|
||||
// let html5QrcodeScanner = new Html5QrcodeScanner(
|
||||
// "scanner_box",
|
||||
// {fps: 10, qrbox: {width: 250, height: 250}},
|
||||
// /* verbose= */ false);
|
||||
// html5QrcodeScanner.render(this.onScanSuccess);
|
||||
// }
|
||||
|
||||
onScanSuccess(decodedText, decodedResult) {
|
||||
console.log(`Code matched = ${decodedText}`, decodedResult);
|
||||
}
|
||||
|
||||
getAction(action) {
|
||||
if (action === "actionMain") {
|
||||
return this.actionMain;
|
||||
}
|
||||
|
||||
|
3
resources/main/js/tg_app/html5-qrcode.min.js
vendored
Normal file
3
resources/main/js/tg_app/html5-qrcode.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user