csrftoken.js 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. /**
  2. * Created by xiaofeng on 2017/8/9.
  3. */
  4. csrfToken = $('meta[name=csrf-token]').prop('content');
  5. function ReturnInfo(info) {
  6. if (info != null) {
  7. var strmsg = '';
  8. if (typeof info == 'string') {
  9. return info;
  10. }
  11. $.each(info, function (kk, vv) {
  12. strmsg += vv[0] + '<br>';
  13. })
  14. if (typeof strmsg == 'string') {
  15. return strmsg;
  16. }
  17. }
  18. }
  19. var objUrl = {}; //获取get参数
  20. var url = window.location.href;
  21. function getParams(url) {
  22. var theRequest = new Object();
  23. if (!url)
  24. url = location.href;
  25. if (url.indexOf("?") !== -1) {
  26. var str = url.substr(url.indexOf("?") + 1) + "&";
  27. var strs = str.split("&");
  28. for (var i = 0; i < strs.length - 1; i++) {
  29. var key = strs[i].substring(0, strs[i].indexOf("="));
  30. var val = strs[i].substring(strs[i].indexOf("=") + 1);
  31. theRequest[key] = val;
  32. }
  33. }
  34. return theRequest;
  35. }
  36. var params = getParams(url); //获取get请求的参数
  37. if (!$.isEmptyObject(params)) {
  38. $.each(params, function (key, val) {
  39. if (key == 'city') feng_cityTel = val;
  40. objUrl[key] = val;
  41. })
  42. }
  43. var feng_cityTel;
  44. $('.y_call').click(function () {
  45. var y_call = $('.lphomeV2_head_tel a').attr('href');
  46. if (typeof y_call === 'string' && y_call != '') {
  47. return window.location.href = y_call;
  48. }
  49. $.ajax({
  50. url: '/json/telrand',
  51. dataType: "json",
  52. type: 'POST',
  53. data: {city: feng_cityTel},
  54. success: function (data) {
  55. if (data.code == 200) {
  56. return window.location.href = 'tel:' + data.data.tel;
  57. }
  58. },
  59. error: function () {
  60. }
  61. });
  62. })
  63. $(function () {
  64. $('.y_lpleft').on('click', function () {
  65. history.back(-1);
  66. })
  67. })