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.

127 lines
5.8 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. sExpo = g_db.GetDic('Expo'),
  6. saOrderInfo = g_db.GetDic('OrderInfo'),
  7. oContactInfo = g_db.GetDic('ContactInfo'),
  8. sTotal = g_db.GetDic('Total'),
  9. /**
  10. * 目的 獲取展覽報價規則
  11. */
  12. fnGetServiceInstruction = function () {
  13. if (sExpo) {
  14. return g_api.ConnectLite(Service.apiwebcom, 'GetExhibitionRules', {
  15. Id: sExpo
  16. }, function (res) {
  17. if (res.RESULT) {
  18. var oRes = res.DATA.rel;
  19. $('#ServiceInstruction').html(bEn ? oRes.ServiceInstruction_EN || '' : oRes.ServiceInstruction || '');
  20. }
  21. });
  22. }
  23. else {
  24. $('#CostInstruction').html('');
  25. return $.Deferred().resolve().promise();
  26. }
  27. },
  28. /*
  29. * 目的 寄送郵件
  30. */
  31. fnAppoint = function (confbtn) {
  32. var data = oContactInfo;
  33. data.ExhibitionNO = sExpo;
  34. data.PackingInfo = JSON.stringify(saOrderInfo || '[]');
  35. data.Total = sTotal;
  36. $(confbtn).val(bEn ? 'Appointment processing...' : '預約處理中...').prop('disabled', true);
  37. return g_api.ConnectLite(Service.apitg, 'Appoint', data, function (res) {
  38. if (res.RESULT) {
  39. if (res.DATA.rel) {
  40. $.fancybox.close();
  41. g_db.RemoveItem('Expo');
  42. g_db.RemoveItem('ExpoName');
  43. g_db.RemoveItem('OrderInfo');
  44. g_db.RemoveItem('ContactInfo');
  45. g_db.RemoveItem('Total');
  46. window.location.href = window.location.origin + '/TG/page/inquiryResult' + (bEn ? '_en' : '') + '.html?AppointNO=' + res.DATA.AppointNO;
  47. }
  48. else {
  49. showMsg(bEn ? 'Make an appointment to failure' : '預約失敗', 'error'); // 預約失敗
  50. $(confbtn).val(bEn ? 'Determine the transfer' : '確定傳送').prop('disabled', false);
  51. }
  52. }
  53. else {
  54. showMsg(bEn ? 'Make an appointment to failure' : '預約失敗', 'error'); // 預約失敗
  55. $(confbtn).val(bEn ? 'Determine the transfer' : '確定傳送').prop('disabled', false);
  56. }
  57. }, function () {
  58. showMsg(bEn ? 'Make an appointment to failure' : '預約失敗', 'error'); // 預約失敗
  59. $(confbtn).val(bEn ? 'Determine the transfer' : '確定傳送').prop('disabled', false);
  60. });
  61. },
  62. init = function () {
  63. var myHelpers = {
  64. setMoney: function (val, flag) {
  65. return (flag ? 'NT$' : '') + fMoney(val || 0, 0, 'NTD');
  66. },
  67. setExpoType: function (val) {
  68. var oExpoType = {
  69. 'zh-TW': { '01': '裸機', '02': '木箱', '03': '散貨', '04': '打板', '05': '其他' },
  70. 'en': { '01': 'Unwrapped', '02': 'Wooden Crate', '03': 'Bulk Cargo', '04': 'Pallet', '05': 'Other' }
  71. };
  72. return val ? oExpoType[sLang][val] : '';
  73. },
  74. setService: function (ExpoStack, ExpoSplit, ExpoPack, ExpoFeed, ExpoStorage, ExpoDays) {
  75. var oService = {
  76. 'zh-TW': ['堆高機服務', '拆箱(含空箱收送與儲存)', '裝箱', '空箱收送', '空箱儲存', '天'],
  77. 'en': ['Forklift', 'Unpacking (including empty crate transport & storage)', 'Packing', 'Empty Crate Transport', 'Empty Crate Storage', 'Days']
  78. },
  79. saText = [];
  80. if (ExpoStack) {
  81. saText.push(oService[sLang][0]);
  82. }
  83. if (ExpoSplit) {
  84. saText.push(oService[sLang][1]);
  85. }
  86. if (ExpoPack) {
  87. saText.push(oService[sLang][2]);
  88. }
  89. if (ExpoFeed) {
  90. saText.push(oService[sLang][3]);
  91. }
  92. if (ExpoStorage) {
  93. saText.push(oService[sLang][4] + ExpoDays + oService[sLang][5]);
  94. }
  95. return saText.join(',');
  96. }
  97. };
  98. $.views.helpers(myHelpers);
  99. if (oContactInfo) {
  100. var sHtml = $('#temp_contact').render(oContactInfo);
  101. $('#contactInfo').append(sHtml);
  102. }
  103. //if (saOrderInfo) {
  104. // var sHtml = $('#temp_service').render(saOrderInfo);
  105. // $('#Servicebox').append(sHtml);
  106. // $('#Total').text(fMoney(sTotal || 0, 0, 'NTD'));
  107. // fnGetServiceInstruction();
  108. // $(".confappoint").click(function () {
  109. // $.fancybox.open($('.conf-content'), { zoomOpacity: false });
  110. // });
  111. // $("#comfirmBtn").click(function () {
  112. // if (!saOrderInfo) {
  113. // alert(bEn ? 'The webpage data has been invalid, please fill in the data again!!' : '網頁數據已失效,請重新填寫資料!!');
  114. // }
  115. // else {
  116. // fnAppoint(this);
  117. // }
  118. // });
  119. //}
  120. //else {
  121. // window.location.href = window.location.origin + '/TG/page/inquiry' + (bEn ? '_en' : '') + '.html';
  122. //}
  123. };
  124. init();
  125. });