dabory-contact-us.js 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. (function($) {
  2. $.fn.contactUs = async function(options) {
  3. const opts = $.extend({}, $.fn.contactUs.defaults, options)
  4. this.append(html.call(this, '', opts, ''))
  5. loadModule.call(this)
  6. };
  7. function html(contactUsList, opts, langJson) {
  8. return `<div class="dabory-contact-us-popup contact-us" style="top: ${opts['top']}px; left: ${opts['left']}px; width: ${opts['width']}px; display: none;">
  9. <button type="button" class="tab-close" data-widget="contact-us">
  10. <img src="/dabory/common/image/close-button.svg" alt="close-butto">
  11. </button>
  12. <div class="dabory-contact-us-box">
  13. <div class="dabory-contact-us-row">
  14. <div class="dabory-contact-us-col">
  15. <div class="dabory-contact-message">
  16. <ul>
  17. <li> <div>Adress : 경기도 광명시 하안로 60 광명SK테크노파크 B동 401호</div></li>
  18. <li> <div>Phone : 070-7781-0300</div></li>
  19. <li> <div>Fax : 02-2083-2880</div></li>
  20. <li> <div>E-mail : <a href="mailto:seco@secointerface.com">seco@secointerface.com</a></div></li>
  21. </ul>
  22. </div>
  23. </div>
  24. <div class="dabory-contact-us-col">
  25. <div class="dabory-contact-form">
  26. <h3>CONTACT US</h3>
  27. <p>
  28. <label>이메일 주소 *</label>
  29. <input type="email" class="pc5-txt" placeholder="이메일 주소 *" required>
  30. </p>
  31. <p>
  32. <label>모바일 번호</label>
  33. <input type="tel" class="pc4-txt" placeholder="모바일 번호">
  34. </p>
  35. <p>
  36. <label>제목 *</label>
  37. <input type="text" class="post-title-txt" placeholder="제목 *" required>
  38. </p>
  39. <div class="contact_textarea">
  40. <label>요청 내용 *</label>
  41. <textarea placeholder="요청 내용 *" class="post-contents-textarea" required></textarea>
  42. </div>
  43. <button type="button" class="send-btn">
  44. Send
  45. </button>
  46. <button type="button" class="close-btn">
  47. Close
  48. </button>
  49. </div>
  50. </div>
  51. </div>
  52. </div>
  53. </div>`
  54. }
  55. function getLangText(langJson, key) {
  56. if (! langJson) { return key }
  57. return langJson[key]
  58. }
  59. function actContactUsApi($btn) {
  60. $($btn).prop('disabled', true)
  61. const toMail = $(this).find('.dabory-contact-form .pc5-txt').val()
  62. $.fn.dataLinker.api23Js('post-act', {
  63. "Page": [
  64. {
  65. "Id": 0,
  66. "PostTitle": $(this).find('.dabory-contact-form .post-title-txt').val(),
  67. "PostContents": $(this).find('.dabory-contact-form .post-contents-textarea').val(),
  68. "Pc4": $(this).find('.dabory-contact-form .pc4-txt').val(),
  69. "Pc5": toMail,
  70. "PostTypeId": 7,
  71. "Status": "2",
  72. }
  73. ]
  74. }, function (response) {
  75. $($btn).prop('disabled', false)
  76. if (response.apiStatus) {
  77. return iziToast.error({ title: 'Error', message: 'API Error' });
  78. }
  79. $.fn.dataLinker.daboryApp('send-mail', {
  80. "Component": "views.emails.contact-us",
  81. "Data": "TEST",
  82. "ToMail": toMail,
  83. "Subject": "CONTACT TEST"
  84. }, function () { })
  85. return iziToast.success({ title: 'Success', message: 'Success' });
  86. })
  87. }
  88. function loadModule() {
  89. const self = this
  90. $(document).ready(function () {
  91. $(self).find('.dabory-contact-us-popup').draggable()
  92. $(self).find('.send-btn').on('click', async function() {
  93. actContactUsApi.call(self, this)
  94. });
  95. $(self).find('.close-btn').on('click', function() {
  96. $(self).find('.dabory-contact-us-popup').hide()
  97. $(self).closest('#dabory-widget-list').trigger('hide.widget', 'contact-us')
  98. });
  99. });
  100. }
  101. $.fn.contactUs.defaults = {
  102. top: 0,
  103. left: 0,
  104. width: 850,
  105. langType: 'ko',
  106. basePath: '/dabory/widget/contact-us',
  107. };
  108. }(jQuery));