transfer.js 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. function setCookie(name, value, day, path, domain) {
  2. day = day || 30;
  3. path = path || '/';
  4. var str = name + '=' + value + '; ';
  5. if (day) str += 'expires=' + new Date(Date.now() + day * 24 * 3600 * 1000).toGMTString() + '; ';
  6. if (path) str += 'path=' + path + '; ';
  7. if (domain) str += 'domain=' + domain;
  8. document.cookie = str;
  9. }
  10. new Vue({
  11. el:'#transfer',
  12. data() {
  13. return {
  14. }
  15. },
  16. methods:{
  17. },
  18. mounted() {
  19. let zlb_token = '';
  20. if (location.search.includes('zlb_token')) {
  21. zlb_token = location.search.substring(11);
  22. const requestURL = 'https://tyyxopenapi.txhlwxx.com/openapi/oauth/zlb/checkticket.php';
  23. $.ajax({
  24. url: requestURL,
  25. async: false,
  26. type: "POST",
  27. timeout: 30000,
  28. dataType: 'json',
  29. data: {
  30. type: 'login',
  31. zlb_token: zlb_token,
  32. client:'h5'
  33. },
  34. success: (res) => {
  35. if (res.code === '1') {
  36. localStorage.setItem('userInfo', JSON.stringify(res.data));
  37. setCookie('token', res.data.token, 30, '/');
  38. setTimeout(() => {
  39. location.href = './index.html';
  40. }, 500)
  41. } else if(res.code === '501'){
  42. this.$message({
  43. message:res.msg,
  44. type: 'warning',
  45. showClose: true,
  46. duration: '1500',
  47. onClose:()=>{
  48. localStorage.setItem('userInfo', JSON.stringify(res.data));
  49. setCookie('token', res.data.token, 30, '/');
  50. setTimeout(() => {
  51. location.href = './index.html';
  52. }, 500)
  53. },
  54. });
  55. } else {
  56. this.$message({
  57. message: res.msg,
  58. type: 'error',
  59. showClose: true,
  60. duration: '1500'
  61. });
  62. }
  63. }
  64. });
  65. }
  66. }
  67. });