headerOpr.js 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. 'use strict';
  2. /**
  3. *
  4. *
  5. * @author Zhong
  6. * @date 2018/11/30
  7. * @version
  8. */
  9. //header相关的公共操作接口
  10. const CommonHeader = (function () {
  11. //帮助-联系客服
  12. const csDom = $('#customerService');
  13. //获取办事处客服列表
  14. //@param {Number}category @return {void}
  15. function getCategoryList(category = -1, titile = '') {
  16. if (titile) {
  17. $('#upgrade-title').text(titile);
  18. }
  19. $.ajax({
  20. type: 'get',
  21. url: '/cld/getCategoryStaff?category=' + category,
  22. dataType: 'json',
  23. timeout: 5000,
  24. success: function (response) {
  25. if (response.error !== 0) {
  26. alert('获取CLD人员信息失败!');
  27. } else {
  28. let staffList = response.data;
  29. let staffhtml = '';
  30. $.each(staffList, function (key, staff) {
  31. staffhtml += '<div class="col-4 mb-4"> ' +
  32. '<div class="card"> ' +
  33. '<div class="card-body"> ' +
  34. '<h4 class="card-title">' + staff.username + '</h4> ' +
  35. '<h6 class="card-subtitle mb-2 text-muted">' + staff.category + '</h6> ' +
  36. '</div> ' +
  37. '<ul class="list-group list-group-flush"> ' +
  38. '<li class="list-group-item" data-toggle="tooltip" data-placement="bottom" title="" data-original-title="腾讯QQ"><i class="fa fa-qq"></i> ' + staff.qq + '</li> ' +
  39. '<li class="list-group-item" data-toggle="tooltip" data-placement="bottom" title="" data-original-title="手机号码"><i class="fa fa-tablet"></i> ' + staff.telephone + '</li> ' +
  40. '<li class="list-group-item" data-toggle="tooltip" data-placement="bottom" title="" data-original-title="固定电话"><i class="fa fa-phone"></i> ' + staff.phone + '</li> ' +
  41. '</ul> </div> </div>';
  42. });
  43. $('#staffList').html(staffhtml);
  44. $('#activ').modal('show');
  45. }
  46. },
  47. error: function () {
  48. console.log('请求超时');
  49. }
  50. })
  51. }
  52. //绑定事件
  53. //@return {void}
  54. function addEventListener(){
  55. csDom.click(function () {
  56. getCategoryList(-1, '联系客服');
  57. });
  58. }
  59. //取消浏览器自带右键
  60. //@return {void}
  61. function banNavigatorContextMenu() {
  62. document.oncontextmenu = function(event) {
  63. if (window.event) {
  64. event = window.event;
  65. }
  66. try {
  67. var the = event.srcElement;
  68. if (!((the.tagName == "INPUT" && the.type.toLowerCase() == "text") || the.tagName == "TEXTAREA")) {
  69. return false;
  70. }
  71. return true;
  72. } catch (e) {
  73. return false;
  74. }
  75. }
  76. }
  77. // 验证版本后进行的操作(针对一些没有通过后端的操作)
  78. async function doAfterValidateVersion(proFunc, freeFunc) {
  79. try {
  80. const { isFree } = await ajaxPost('/user/isFree');
  81. if (isFree && freeFunc) {
  82. freeFunc();
  83. } else if (!isFree && proFunc) {
  84. proFunc();
  85. }
  86. } catch (err) {
  87. console.log(err);
  88. }
  89. }
  90. return {
  91. getCategoryList,
  92. addEventListener,
  93. banNavigatorContextMenu,
  94. doAfterValidateVersion
  95. };
  96. })();
  97. CommonHeader.banNavigatorContextMenu();
  98. $(document).ready(function(){
  99. CommonHeader.addEventListener();
  100. });