review.php 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334
  1. <?php
  2. /**
  3. * FecShop file.
  4. *
  5. * @link http://www.fecshop.com/
  6. * @copyright Copyright (c) 2016 FecShop Software LLC
  7. * @license http://www.fecshop.com/license/
  8. */
  9. ?>
  10. <div class="main container one-column">
  11. <div class="col-main">
  12. <?= Yii::$service->page->widget->render('flashmessage'); ?>
  13. <form action="<?= Yii::$service->url->getCurrentUrl(); ?>" method="post" id="onestepcheckout-form">
  14. <?= \fec\helpers\CRequest::getCsrfInputHtml(); ?>
  15. <div style="margin: 0;" class="group-select">
  16. <p class="onestepcheckout-description"><?= Yii::$service->page->translate->__('Welcome to the checkout,Fill in the fields below to complete your purchase');?> !</p>
  17. <div class="onestepcheckout-threecolumns checkoutcontainer onestepcheckout-skin-generic onestepcheckout-enterprise">
  18. <div class="onestepcheckout-column-left">
  19. <?php # address 部门
  20. //echo $address_view_file;
  21. $addressView = [
  22. 'view' => 'payment/paypal/express/review/address.php',
  23. ];
  24. //var_dump($address_list);
  25. $addressParam = [
  26. 'cart_address_id' => $cart_address_id,
  27. 'address_list' => $address_list,
  28. 'customer_info' => $customer_info,
  29. 'country_select' => $country_select,
  30. 'state_html' => $state_html,
  31. 'cart_address' => $cart_address,
  32. //'payments' => $payments,
  33. //'current_payment_mothod' => $current_payment_mothod,
  34. ];
  35. ?>
  36. <?= Yii::$service->page->widget->render($addressView,$addressParam); ?>
  37. </div>
  38. <div class="onestepcheckout-column-middle">
  39. <div class="shipping_method_html">
  40. <?php # shipping部分
  41. $shippingView = [
  42. 'view' => 'payment/paypal/express/review/shipping.php'
  43. ];
  44. $shippingParam = [
  45. 'shippings' => $shippings,
  46. ];
  47. ?>
  48. <?= Yii::$service->page->widget->render($shippingView,$shippingParam); ?>
  49. </div>
  50. <div class="onestepcheckout-coupons">
  51. <div style="display: none;" id="coupon-notice"></div>
  52. <div class="op_block_title"><?= Yii::$service->page->translate->__('Coupon codes (optional)');?></div>
  53. <label for="id_couponcode"><?= Yii::$service->page->translate->__('Enter your coupon code if you have one.');?></label>
  54. <input type="hidden" class="couponType" value="<?= $cart_info['coupon_code'] ? 1 : 2 ; ?>" />
  55. <input style="color:#777;" class="input-text" id="id_couponcode" name="coupon_code" value="<?= $cart_info['coupon_code']; ?>">
  56. <br>
  57. <button style="" type="button" class="submitbutton add_coupon_submit" id="onestepcheckout-coupon-add"><?= Yii::$service->page->translate->__($cart_info['coupon_code'] ? 'Cancel Coupon' : 'Add Coupon') ; ?></button>
  58. <div class="clear"></div>
  59. <div class="coupon_add_log"></div>
  60. </div>
  61. <div class="onestepcheckout-coupons">
  62. <div class="op_block_title"><?= Yii::$service->page->translate->__('Order Remark (optional)');?></div>
  63. <label for="id_couponcode"><?= Yii::$service->page->translate->__('You can fill in the order remark information below');?></label>
  64. <textarea class="order_remark" name="order_remark" style="width:100%;height:100px;padding:10px;"></textarea>
  65. </div>
  66. </div>
  67. <div class="onestepcheckout-column-right">
  68. <div class="review_order_view">
  69. <?php # review order部分
  70. $reviewOrderView = [
  71. 'view' => 'payment/paypal/express/review/review_order.php'
  72. ];
  73. $reviewOrderParam = [
  74. 'cart_info' => $cart_info,
  75. 'currency_info' => $currency_info,
  76. ];
  77. ?>
  78. <?= Yii::$service->page->widget->render($reviewOrderView,$reviewOrderParam); ?>
  79. </div>
  80. <div class="onestepcheckout-place-order">
  81. <a class="large orange onestepcheckout-button" href="javascript:void(0)" id="onestepcheckout-place-order"><?= Yii::$service->page->translate->__('Place order now');?></a>
  82. <div class="onestepcheckout-place-order-loading"><img src="<?= Yii::$service->image->getImgUrl('images/opc-ajax-loader.gif'); ?>">&nbsp;&nbsp;<?= Yii::$service->page->translate->__('Please wait, processing your order...');?></div>
  83. </div>
  84. </div>
  85. <div style="clear: both;">&nbsp;</div>
  86. </div>
  87. </div>
  88. </form>
  89. </div>
  90. </div>
  91. <script>
  92. <?php $this->beginBlock('placeOrder') ?>
  93. function validateEmail(email) {
  94. var re = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
  95. return re.test(email);
  96. }
  97. // ajax
  98. function ajaxreflush(){
  99. shipping_method = $("input[name=shipping_method]:checked").val();
  100. //alert(shipping_method);
  101. country = $(".billing_country").val();
  102. address_id = $(".address_list").val();
  103. state = $(".address_state").val();
  104. //alert(state);
  105. if(country || address_id){
  106. $(".onestepcheckout-summary").html('<div style="text-align:center;min-height:40px;"><img src="<?= Yii::$service->image->getImgUrl('images/ajax-loader.gif'); ?>" /></div>');
  107. $(".onestepcheckout-shipping-method-block").html('<div style="text-align:center;min-height:40px;"><img src="<?= Yii::$service->image->getImgUrl('images/ajax-loader.gif'); ?>" /></div>');
  108. ajaxurl = "<?= Yii::$service->url->getUrl('checkout/onepage/ajaxupdateorder'); ?>";
  109. $.ajax({
  110. async:false,
  111. timeout: 8000,
  112. dataType: 'json',
  113. type:'get',
  114. data: {
  115. 'country':country,
  116. 'shipping_method':shipping_method,
  117. 'address_id':address_id,
  118. 'state':state,
  119. },
  120. url:ajaxurl,
  121. success:function(data, textStatus){
  122. status = data.status;
  123. if(status == 'success'){
  124. $(".review_order_view").html(data.reviewOrderHtml)
  125. $(".shipping_method_html").html(data.shippingHtml);
  126. }
  127. },
  128. error:function (XMLHttpRequest, textStatus, errorThrown){
  129. }
  130. });
  131. }
  132. }
  133. $(document).ready(function(){
  134. currentUrl = "<?= Yii::$service->url->getUrl('checkout/onepage') ?>"
  135. //优惠券
  136. $(".add_coupon_submit").click(function(){
  137. coupon_code = $("#id_couponcode").val();
  138. coupon_type = $(".couponType").val();
  139. coupon_url = "";
  140. $succ_coupon_type = 0;
  141. if(coupon_type == 2){
  142. coupon_url = "<?= Yii::$service->url->getUrl('checkout/cart/addcoupon'); ?>";
  143. $succ_coupon_type = 1;
  144. }else if(coupon_type == 1){
  145. coupon_url = "<?= Yii::$service->url->getUrl('checkout/cart/cancelcoupon'); ?>";
  146. $succ_coupon_type = 2;
  147. }
  148. //alert(coupon_type);
  149. if(!coupon_code){
  150. //alert("coupon can not empty!");
  151. }
  152. //coupon_url = $("#discount-coupon-form").attr("action");
  153. //alert(coupon_url);
  154. $.ajax({
  155. async:true,
  156. timeout: 6000,
  157. dataType: 'json',
  158. type:'post',
  159. data: {"coupon_code":coupon_code},
  160. url:coupon_url,
  161. success:function(data, textStatus){
  162. if(data.status == 'success'){
  163. $(".couponType").val($succ_coupon_type);
  164. hml = $('.add_coupon_submit').html();
  165. if(hml == 'Add Coupon'){
  166. $('.add_coupon_submit').html('<?= Yii::$service->page->translate->__('Cancel Coupon');?>');
  167. }else{
  168. $('.add_coupon_submit').html('<?= Yii::$service->page->translate->__('Add Coupon');?>');
  169. }
  170. $(".coupon_add_log").html("");
  171. ajaxreflush();
  172. }else if(data.content == 'nologin'){
  173. $(".coupon_add_log").html("<?= Yii::$service->page->translate->__('you must login your account before you use coupon');?>");
  174. }else{
  175. $(".coupon_add_log").html(data.content);
  176. }
  177. },
  178. error:function (XMLHttpRequest, textStatus, errorThrown){}
  179. });
  180. });
  181. // 对于非登录用户,可以填写密码,进行注册账户,这里进行信息的检查。
  182. $("#id_create_account").click(function(){
  183. if($(this).is(':checked')){
  184. email = $("input[name='billing[email]']").val();
  185. if(!email){
  186. $(this).prop('checked', false);
  187. $(".label_create_account").html(" <?= Yii::$service->page->translate->__('email address is empty, you must Fill in email');?>");
  188. }else{
  189. thischeckbox = this;
  190. if(!validateEmail(email)){
  191. $(this).prop('checked', false);
  192. $(".label_create_account").html(" <?= Yii::$service->page->translate->__('email address format is incorrect');?>");
  193. }else{
  194. // ajax get if email is register
  195. $.ajax({
  196. async:true,
  197. timeout: 6000,
  198. dataType: 'json',
  199. type:'get',
  200. data: {"email":email},
  201. url:"<?= Yii::$service->url->getUrl('customer/ajax/isregister'); ?>",
  202. success:function(data, textStatus){
  203. if(data.registered == 2){
  204. $(".label_create_account").html("");
  205. $("#onestepcheckout-li-password").show();
  206. $("#onestepcheckout-li-password input").addClass("required-entry");
  207. }else{
  208. $(thischeckbox).prop('checked', false);
  209. $(".label_create_account").html(" <?= Yii::$service->page->translate->__('This email is registered , you must fill in another email');?>");
  210. }
  211. },
  212. error:function (XMLHttpRequest, textStatus, errorThrown){}
  213. });
  214. }
  215. }
  216. }else{
  217. $(".label_create_account").html("");
  218. $("#onestepcheckout-li-password").hide();
  219. $("#onestepcheckout-li-password input").removeClass("required-entry");
  220. }
  221. });
  222. //###########################
  223. //下单(这个部分未完成。)
  224. $("#onestepcheckout-place-order").click(function(){
  225. $(".validation-advice").remove();
  226. i = 0;
  227. j = 0;
  228. address_list = $(".address_list").val();
  229. // shipping
  230. shipment_method = $(".onestepcheckout-shipping-method-block input[name='shipping_method']:checked").val();
  231. //alert(shipment_method);
  232. if(!shipment_method){
  233. $(".shipment-methods").after('<div style="" class="validation-advice"><?= Yii::$service->page->translate->__('This is a required field.');?></div>');
  234. j = 1;
  235. }
  236. $("#onestepcheckout-form .required-entry").each(function(){
  237. value = $(this).val();
  238. if(!value){
  239. i++;
  240. $(this).after('<div style="" class="validation-advice"><?= Yii::$service->page->translate->__('This is a required field.');?></div>');
  241. }
  242. });
  243. user_email = $("#billing_address .validate-email").val();
  244. if(user_email && !validateEmail(user_email)){
  245. $("#billing_address .validate-email").after('<div style="" class="validation-advice"><?= Yii::$service->page->translate->__('email address format is incorrect');?></div>');
  246. i++;
  247. }
  248. if(!i && !j){
  249. //alert(333);
  250. $(".onestepcheckout-place-order").addClass('visit');
  251. $("#onestepcheckout-form").submit();
  252. }
  253. });
  254. // 国家选择后,state需要清空,重新选择或者填写
  255. $(".billing_country").change(function(){
  256. country = $(this).val();
  257. //state = $(".address_state").val();
  258. //shipping_method = $("input[name=shipping_method]:checked").val();
  259. //alert(shipping_method);
  260. //$(".onestepcheckout-shipping-method-block").html('<div style="text-align:center;min-height:40px;"><img src="http://www.intosmile.com/skin/default/images/ajax-loader.gif" /></div>');
  261. //$(".onestepcheckout-summary").html('<div style="text-align:center;min-height:40px;"><img src="http://www.intosmile.com/skin/default/images/ajax-loader.gif" /></div>');
  262. ajaxurl = "<?= Yii::$service->url->getUrl('checkout/onepage/changecountry'); ?>";
  263. $.ajax({
  264. async:true,
  265. timeout: 8000,
  266. dataType: 'json',
  267. type:'get',
  268. data: {
  269. 'country':country,
  270. //'shipping_method':shipping_method,
  271. //'state':state
  272. },
  273. url:ajaxurl,
  274. success:function(data, textStatus){
  275. $(".state_html").html(data.state);
  276. },
  277. error:function (XMLHttpRequest, textStatus, errorThrown){
  278. }
  279. });
  280. ajaxreflush();
  281. });
  282. // state select 改变后的事件
  283. $(".input-state").off("change").on("change","select.address_state",function(){
  284. ajaxreflush();
  285. });
  286. // state input 改变后的事件
  287. $(".input-state").off("blur").on("blur","input.address_state",function(){
  288. ajaxreflush();
  289. });
  290. //改变shipping methos
  291. $(".onestepcheckout-column-middle").off("click").on("click","input[name=shipping_method]",function(){
  292. ajaxreflush();
  293. });
  294. });
  295. //ajaxreflush();
  296. <?php $this->endBlock(); ?>
  297. <?php $this->registerJs($this->blocks['placeOrder'],\yii\web\View::POS_END);//将编写的js代码注册到页面底部 ?>
  298. </script>