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.

145 lines
6.2 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. MuseumMumber: {
  41. required: bEn ? 'Please enter the booth number' : '請輸入攤位號碼'
  42. },
  43. AppointUser: {
  44. required: bEn ? 'Please enter the name of the reservation holder' : '請輸入預約者姓名'
  45. },
  46. AppointTel: {
  47. required: bEn ? 'Please enter the reservation number' : '請輸入預約者電話'
  48. },
  49. AppointEmail: {
  50. email: bEn ? "The subscriber's Email format is wrong" : '請輸入公司名稱',
  51. required: bEn ? 'Please enter the subscriber Email' : '請輸入公司名稱'
  52. },
  53. Contactor: {
  54. required: bEn ? 'Please enter the field contact person' : '請輸入現場聯絡人'
  55. },
  56. ContactTel: {
  57. required: bEn ? 'Please enter the field contact phone' : '請輸入現場聯絡手機'
  58. },
  59. ApproachTime: {
  60. required: bEn ? 'Please choose the entry time' : '請選擇進場時間'
  61. },
  62. ExitTime: {
  63. required: bEn ? 'Please choose the exit time' : '請選擇退場時間'
  64. },
  65. validcode: {
  66. required: bEn ? 'Please enter the verification code' : '請輸入驗證碼'
  67. }
  68. }
  69. });
  70. },
  71. init = function () {
  72. var myHelpers = {
  73. setMoney: function (val, flag) {
  74. return (flag ? 'NT$' : '') + fMoney(val || 0, 0, 'NTD');
  75. },
  76. setExpoType: function (val) {
  77. var oExpoType = {
  78. 'zh-TW': { '01': '裸機', '02': '木箱', '03': '散貨', '04': '打板', '05': '其他' },
  79. 'en': { '01': 'Unwrapped', '02': 'Wooden Crate', '03': 'Bulk Cargo', '04': 'Pallet', '05': 'Other' }
  80. };
  81. return val ? oExpoType[sLang][val] : '';
  82. },
  83. setService: function (ExpoStack, ExpoSplit, ExpoPack, ExpoFeed, ExpoStorage, ExpoDays) {
  84. var oService = {
  85. 'zh-TW': ['堆高機服務', '拆箱', '裝箱', '空箱收送與儲存(展覽期間)'],
  86. 'en': ['Forklift', 'Unpacking', 'Packing', 'Empty Crate Transport And StorageEmpty Crate Transport and Storage During the Exhibition']
  87. },
  88. saText = [];
  89. if (ExpoStack) {
  90. saText.push(oService[sLang][0]);
  91. }
  92. if (ExpoSplit) {
  93. saText.push(oService[sLang][1]);
  94. }
  95. if (ExpoPack) {
  96. saText.push(oService[sLang][2]);
  97. }
  98. if (ExpoFeed) {
  99. saText.push(oService[sLang][3]);
  100. }
  101. return saText.join(',');
  102. }
  103. };
  104. $.views.helpers(myHelpers);
  105. fnSetForm_Rule();
  106. if (bEn) {
  107. $.datepicker.setDefaults($.datepicker.regional[""]);
  108. }
  109. $(".datepicker").datepicker({
  110. changeYear: true,
  111. changeMonth: true,
  112. dateFormat: 'yy/mm/dd'
  113. });
  114. //$('#change_validcode,.change_validcode').on('click', function () {
  115. // var url = $('#imgvalidcode').data('url') || $('#imgvalidcode').attr('src');
  116. // $('#imgvalidcode').attr('src', url + '&' + Math.random()).data('url', url);
  117. //});
  118. if (oContactInfo) {
  119. setFormVal($('#form_inquiry'), oContactInfo);
  120. }
  121. //if (saOrderInfo) {
  122. // var sHtml = $('#temp_service').render(saOrderInfo);
  123. // $('#Servicebox').append(sHtml);
  124. // $('#Total').text(fMoney(sTotal || 0, 0, 'NTD'));
  125. // $(".confappoint").click(function () {
  126. // if (!eForm.valid()) {
  127. // return false;
  128. // }
  129. // var formdata = getFormSerialize(eForm);
  130. // formdata.ExpoName = sExpoName;
  131. // g_db.SetDic('ContactInfo', formdata);
  132. // window.location.href = window.location.origin + '/TG/page/inquiryPreview' + (bEn ? '_en' : '') + '.html';
  133. // });
  134. //}
  135. //else {
  136. // window.location.href = window.location.origin + '/TG/page/inquiry' + (bEn ? '_en' : '') + '.html';
  137. //}
  138. };
  139. init();
  140. });