utils.js 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. function getQueryParams(name) {
  2. var url = window.location.href
  3. var parts = url.split('?')
  4. var query = parts[1]
  5. if (!query) return null
  6. var pairs = query.split('&')
  7. for (var i = 0; i < pairs.length; i++) {
  8. var pair = pairs[i].split('=')
  9. // 解码键和值
  10. var key = decodeURIComponent(pair[0])
  11. var value = decodeURIComponent(pair[1])
  12. if (key === name) {
  13. return value
  14. }
  15. }
  16. return null
  17. }
  18. function getOrgOptions(base, token) {
  19. $.ajax({
  20. url: base + '/client/c/mobileInfo/selection/selectionOrg',
  21. type: 'GET',
  22. headers: {
  23. 'token': token
  24. },
  25. success: function(response) {
  26. if (response.code === 200) {
  27. const dropdown = $('#orgSelect');
  28. response.data.forEach(item => {
  29. const option = $('<option></option>').val(item.orgId).text(item.orgName);
  30. dropdown.append(option);
  31. });
  32. } else {
  33. console.error('Error:', response);
  34. }
  35. },
  36. error: function(error) {
  37. console.error('Request failed:', error);
  38. }
  39. });
  40. }
  41. function getPlayUrl(base, token, orgId, cb) {
  42. $.ajax({
  43. url: base + '/client/c/mobileInfo/selection/selectionOrg',
  44. type: 'GET',
  45. headers: {
  46. 'token': token
  47. },
  48. success: function(response) {
  49. if (response.code === 200) {
  50. var data = response.data
  51. cb(data)
  52. } else {
  53. console.error('Error:', response);
  54. }
  55. },
  56. error: function(error) {
  57. console.error('Request failed:', error);
  58. }
  59. });
  60. }