/* 微访客预约 - 前端公共 JS */ (function(){ window.App = { SITE_URL: "https:\/\/yuyue.zhenyaninfo.com" || '', toast: function(msg){ var t = document.querySelector('.toast'); if(!t){ t=document.createElement('div'); t.className='toast'; document.body.appendChild(t); } t.textContent = msg; t.classList.add('show'); clearTimeout(t._timer); t._timer = setTimeout(function(){ t.classList.remove('show'); }, 2200); }, request: function(url, data, method){ method = method || (data ? 'POST' : 'GET'); var opts = { method: method, headers: { 'Content-Type': 'application/json' } }; if(data){ opts.body = JSON.stringify(data); } return fetch(url, opts).then(function(r){ return r.json(); }); }, statusText: function(s){ return { pending:'待审批', approved:'已通过', rejected:'已拒绝', signed_in:'已签到', sign_out:'已签离', cancelled:'已取消' }[s] || s; }, tagClass: function(s){ return 'tag tag-' + s; } }; })();