dialog.js 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. function closedg(obj){
  2. $(obj).parents(".com-dialog").remove();
  3. }
  4. function cancel(obj){
  5. $(obj).parents(".com-dialog").remove();
  6. WKmsg.msg('您选择了取消本次操作!',2000);
  7. }
  8. //function yes(){
  9. // alert(300);
  10. //}
  11. var WKbody = document.getElementById('app');
  12. var WKtcon = '';
  13. var WKmsg = {
  14. msg: function (msg,time){
  15. WKtcon = '<div id="WKmsg" class="com-wkmsg"><span>' + msg + '</span></div>';
  16. WKbody.insertAdjacentHTML('beforeend',WKtcon);
  17. setTimeout(function(){
  18. document.getElementById("WKmsg").remove();
  19. },time);
  20. },
  21. confirmMsg: function (data){
  22. WKtcon = '<div class="com-dialog"><div class="dialog-close" onclick="closedg(this)"></div><div class="dialog-con">';
  23. if(!!data.title){
  24. WKtcon += '<div class="dialog-tit"><div>' + data.title + '</div><span onclick="closedg(this)" class="dialog-tit-btn mui-icon mui-icon-closeempty"></span></div>';
  25. }
  26. WKtcon += '<div class="dialog-intro">' + data.intro + '</div>';
  27. if(data.btn.length <= 1){
  28. WKtcon += '<div class="dialog-btn"><button onclick="data.yes" class="dialog-btn-1">' + data.btn[0] + '</button></div>';
  29. }else if(data.btn.length <= 2){
  30. WKtcon += '<div class="dialog-btn"><button class="dialog-btn-2 dialog-btn-gray" onclick="cancel(this)">' + data.btn[0] + '</button><button class="dialog-btn-2">' + data.btn[1] + '</button></div>';
  31. }
  32. WKtcon += '</div></div>';
  33. WKbody.insertAdjacentHTML('beforeend',WKtcon);
  34. if(data.title=="" || data.title==null){
  35. $(".dialog-con").height(110);
  36. }
  37. $(".dialog-btn-2").click(function(){
  38. if($(this).index()==1){
  39. data.yes();
  40. }
  41. });
  42. },
  43. inputMsg: function(data){
  44. WKtcon = '<div class="com-dialog"><div class="dialog-close" onclick="closedg(this)"></div><div class="dialog-con">';
  45. if(!!data.title){
  46. WKtcon += '<div class="dialog-tit"><div>' + data.title + '</div><span onclick="closedg(this)" class="dialog-tit-btn mui-icon mui-icon-closeempty"></span></div>';
  47. }
  48. WKtcon += '<div class="dialog-inp">' + data.inp + '</div>';
  49. if(data.btn.length <= 1){
  50. WKtcon += '<div class="dialog-btn"><button onclick="data.yes" class="dialog-btn-1">' + data.btn[0] + '</button></div>';
  51. }else if(data.btn.length <= 2){
  52. WKtcon += '<div class="dialog-btn"><button class="dialog-btn-2 dialog-btn-gray" onclick="cancel(this)">' + data.btn[0] + '</button><button class="dialog-btn-2">' + data.btn[1] + '</button></div>';
  53. }
  54. WKtcon += '</div></div>';
  55. WKbody.insertAdjacentHTML('beforeend',WKtcon);
  56. if(data.title=="" || data.title==null){
  57. $(".dialog-con").height(110);
  58. }
  59. $(".dialog-btn-2").click(function(){
  60. if($(this).index()==1){
  61. data.yes();
  62. }
  63. });
  64. },
  65. picMsg: function(data){
  66. WKtcon = '<div class="com-dialog"><div class="dialog-close" onclick="closedg(this)"></div><div class="dialog-con">';
  67. if(!!data.title){
  68. WKtcon += '<div class="dialog-tit"><div>' + data.title + '</div><span onclick="closedg(this)" class="dialog-tit-btn mui-icon mui-icon-closeempty"></span></div>';
  69. }
  70. WKtcon += '<div class="dialog-pic">' + data.pic + '</div>';
  71. WKtcon += '</div></div>';
  72. WKbody.insertAdjacentHTML('beforeend',WKtcon);
  73. $(".dialog-con").height(380);
  74. }
  75. }