headerOpr.js 3.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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. return {getCategoryList, addEventListener, banNavigatorContextMenu};
  78. })();
  79. CommonHeader.banNavigatorContextMenu();
  80. $(document).ready(function(){
  81. CommonHeader.addEventListener();
  82. });