You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

153 lines
6.5 KiB

2 years ago
  1. $(function () {
  2. 'use strict';
  3. var sLang = $('[http-equiv="content-language"]').attr('content') || 'zh-TW',
  4. bEn = sLang === 'en',
  5. eForm = $("#form_inquiry"),
  6. saOrderInfo = g_db.GetDic('OrderInfo'),
  7. oContactInfo = g_db.GetDic('ContactInfo'),
  8. sTotal = g_db.GetDic('Total'),
  9. sExpoName = g_db.GetDic('ExpoName'),
  10. /*
  11. * 目的 表單驗證初始化
  12. */
  13. fnSetForm_Rule = function () {
  14. eForm.validate({
  15. errorPlacement: function (error, element) {
  16. error.css({
  17. "border": "none",
  18. "color": "red"
  19. });
  20. var wrapper = $("<p></p>");
  21. error.appendTo(wrapper);
  22. $(element).parent().after(wrapper);
  23. },
  24. highlight: function (element, errorClass) {
  25. $(element).css({
  26. "border": "1px solid red"
  27. });
  28. },
  29. unhighlight: function (element, errorClass) {
  30. $(element).css({
  31. "border": ""
  32. });
  33. },
  34. rules: {
  35. },
  36. messages: {
  37. CompName: {
  38. required: bEn ? 'Please enter the company name' : '請輸入公司名稱'
  39. },
  40. Unicode: {
  41. required: bEn ? 'Please enter the VAT number' : '請輸入統編'
  42. },
  43. MuseumMumber: {
  44. required: bEn ? 'Please enter the booth number' : '請輸入攤位號碼'
  45. },
  46. AppointUser: {
  47. required: bEn ? 'Please enter the name of the reservation holder' : '請輸入預約者姓名'
  48. },
  49. AppointTel: {
  50. required: bEn ? 'Please enter the company tel number' : '請輸入公司電話'
  51. },
  52. AppointEmail: {
  53. email: bEn ? "The subscriber's Email format is wrong" : '請輸入預約者Email',
  54. required: bEn ? 'Please enter the subscriber Email' : '請輸入預約者Email'
  55. },
  56. Contactor: {
  57. required: bEn ? 'Please enter the field contact person' : '請輸入現場聯絡人'
  58. },
  59. ContactTel: {
  60. required: bEn ? 'Please enter the field contact phone' : '請輸入現場聯絡手機'
  61. },
  62. ApproachTime: {
  63. required: bEn ? 'Please choose the entry time' : '請選擇進場時間'
  64. },
  65. ExitTime: {
  66. required: bEn ? 'Please choose the exit time' : '請選擇退場時間'
  67. },
  68. validcode: {
  69. required: bEn ? 'Please enter the verification code' : '請輸入驗證碼'
  70. }
  71. }
  72. });
  73. },
  74. init = function () {
  75. var myHelpers = {
  76. setMoney: function (val, flag) {
  77. return (flag ? 'NT$' : '') + fMoney(val || 0, 0, 'NTD');
  78. },
  79. setExpoType: function (val) {
  80. var oExpoType = {
  81. 'zh-TW': { '01': '裸機', '02': '木箱', '03': '散貨', '04': '打板', '05': '其他' },
  82. 'en': { '01': 'Unwrapped', '02': 'Wooden Crate', '03': 'Bulk Cargo', '04': 'Pallet', '05': 'Other' }
  83. };
  84. return val ? oExpoType[sLang][val] : '';
  85. },
  86. setService: function (ExpoStack, ExpoSplit, ExpoPack, ExpoFeed, ExpoStorage, ExpoDays) {
  87. var oService = {
  88. 'zh-TW': ['堆高機服務', '拆箱', '裝箱', '空箱收送與儲存(展覽期間)'],
  89. 'en': ['Forklift', 'Unpacking', 'Packing', 'Empty Crate Transport And StorageEmpty Crate Transport and Storage During the Exhibition']
  90. },
  91. saText = [];
  92. if (ExpoStack) {
  93. saText.push(oService[sLang][0]);
  94. }
  95. if (ExpoSplit) {
  96. saText.push(oService[sLang][1]);
  97. }
  98. if (ExpoPack) {
  99. saText.push(oService[sLang][2]);
  100. }
  101. if (ExpoFeed) {
  102. saText.push(oService[sLang][3]);
  103. }
  104. return saText.join(',');
  105. }
  106. };
  107. $.views.helpers(myHelpers);
  108. fnSetForm_Rule();
  109. if (bEn) {
  110. $.datepicker.setDefaults($.datepicker.regional[""]);
  111. }
  112. $(".datepicker").datepicker({
  113. changeYear: true,
  114. changeMonth: true,
  115. dateFormat: 'yy/mm/dd'
  116. });
  117. //$('#change_validcode,.change_validcode').on('click', function () {
  118. // var url = $('#imgvalidcode').data('url') || $('#imgvalidcode').attr('src');
  119. // $('#imgvalidcode').attr('src', url + '&' + Math.random()).data('url', url);
  120. //});
  121. if (oContactInfo) {
  122. setFormVal($('#form_inquiry'), oContactInfo);
  123. }
  124. if (saOrderInfo) {
  125. var sHtml = $('#temp_service').render(saOrderInfo);
  126. $('#Servicebox').append(sHtml);
  127. $('#Total').text(fMoney(sTotal || 0, 0, 'NTD'));
  128. $(".confappoint").click(function () {
  129. if (!eForm.valid()) {
  130. return false;
  131. }
  132. var formdata = getFormSerialize(eForm);
  133. formdata.ExpoName = sExpoName;
  134. if(formdata.PaymentWay === "1"){
  135. formdata.PaymentWayDesc = "匯款";
  136. } else if (formdata.PaymentWay === "2"){
  137. formdata.PaymentWayDesc = "現場付現";
  138. }
  139. g_db.SetDic('ContactInfo', formdata);
  140. window.location.href = window.location.origin + '/TE/inquiryPreview' + (bEn ? '_en' : '') + '.html';
  141. });
  142. }
  143. else {
  144. window.location.href = window.location.origin + '/TE/inquiry' + (bEn ? '_en' : '') + '.html';
  145. }
  146. };
  147. init();
  148. });