buy_payment.html 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208
  1. <div class="dsc-receipt-info" id="paymentCon">
  2. <div class="dsc-receipt-info-title">
  3. <h3>{$Think.lang.payment_method}</h3>
  4. {if !$deny_edit_payment}
  5. <a href="javascript:void(0)" ds_type="buy_edit" id="edit_payment">[{$Think.lang.modification}]</a>
  6. {/if}
  7. </div>
  8. <div class="dsc-candidate-items">
  9. <ul>
  10. <li>{$Think.lang.cart_step2_online_pay}</li>
  11. </ul>
  12. </div>
  13. <div id="payment_list" class="dsc-candidate-items" style="display:none">
  14. <ul>
  15. <li>
  16. <input type="radio" value="online" name="payment_type" id="payment_type_online">
  17. <label for="payment_type_online">{$Think.lang.cart_step2_online_pay}</label>
  18. </li>
  19. {notempty name="pay_goods_list.offline"}
  20. <li>
  21. <input type="radio" value="offline" name="payment_type" id="payment_type_offline">
  22. <label for="payment_type_offline">{$Think.lang.cart_step2_arrival_pay}</label>
  23. <a id="show_goods_list" style="display: none" class="dsc-payment-showgoods" href="javascript:void(0);">
  24. <i class="iconfont">&#xe6f1;</i>{$Think.lang.cart_step2_arrival_pay} (<span data-cod-nums="offline">{:count($pay_goods_list.offline)}</span>{$Think.lang.type_goods}) + <i class="iconfont">&#xe64f;</i>{$Think.lang.cart_step2_online_pay} {present name="pay_goods_list.online"}(<span data-cod-nums="online">{:count($pay_goods_list.online)}</span>{$Think.lang.type_goods}){/present}</a>
  25. </li>
  26. {/notempty}
  27. </ul>
  28. <div class="hr16"> <a href="javascript:void(0);" class="dsc-btn dsc-btn-red" id="hide_payment_list">{$Think.lang.save_payment_method}</a></div>
  29. </div>
  30. <div id="dsc-payment-showgoods-list" class="dsc-payment-showgoods-list">
  31. <dl>
  32. {notempty name="pay_goods_list.offline"}
  33. <dt data-hideshow="offline">{$Think.lang.cart_step2_arrival_pay}</dt>
  34. <dd data-hideshow="offline" data-cod2-type="offline">
  35. {foreach name="pay_goods_list.offline" item="value"}
  36. <div class="goods-thumb" data-cod2-store="{$value.store_id}"><span><img src="{:goods_thumb($value)}"></span></div>
  37. {/foreach}
  38. </dd>
  39. {/notempty}
  40. <dt data-hideshow="online">{$Think.lang.cart_step2_online_pay}</dt>
  41. <dd data-hideshow="online" data-cod2-type="online">
  42. {present name="pay_goods_list.online"}
  43. {foreach name="pay_goods_list.online" item="value"}
  44. <div class="goods-thumb" data-cod2-store="{$value.store_id}"><span><img src="{:goods_thumb($value)}"></span></div>
  45. {/foreach}
  46. {/present}
  47. </dd>
  48. </dl>
  49. </div>
  50. </div>
  51. <!-- 在线支付和货到付款组合时,显示弹出确认层内容 -->
  52. <div id="confirm_offpay_goods_list" style="display: none;">
  53. <dl class="dsc-offpay-list" data-hideshow="offline">
  54. <dt>{$Think.lang.following_commodity_support}<strong>{$Think.lang.cart_step2_arrival_pay}</strong></dt>
  55. <dd>
  56. {notempty name="pay_goods_list.offline"}
  57. <ul data-cod-type="offline">
  58. {foreach name="pay_goods_list.offline" item="value"}
  59. <li data-cod-store="{$value.store_id}"><span title="{$value.goods_name}"><img src="{:goods_thumb($value)}"></span></li>
  60. {/foreach}
  61. </ul>
  62. {/notempty}
  63. <label>
  64. <input type="radio" value="" checked="checked">
  65. {$Think.lang.cart_step2_arrival_pay}
  66. </label>
  67. </dd>
  68. </dl>
  69. <dl class="dsc-offpay-list" data-hideshow="online">
  70. <dt>{$Think.lang.following_commodity_support}<strong>{$Think.lang.cart_step2_online_pay}</strong></dt>
  71. <dd>
  72. <ul data-cod-type="online">
  73. {present name="pay_goods_list.online"}
  74. {foreach name="pay_goods_list.online" item="value"}
  75. <li data-cod-store="{$value.store_id}"><span title="{$value.goods_name}"><img src="{:goods_thumb($value)}"></span></li>
  76. {/foreach}
  77. {/present}
  78. </ul>
  79. <label>
  80. <input type="radio" value="" checked="checked">
  81. {$Think.lang.cart_step2_online_pay}
  82. </label>
  83. </dd>
  84. </dl>
  85. <div class="tc mt10 mb10"><a href="javascript:void(0);" class="dsc-btn dsc-btn-orange" id="close_confirm_button">{$Think.lang.confirm_payment_method}</a></div>
  86. </div>
  87. <script type="text/javascript">
  88. $(function(){
  89. var hybrid = {if $ifshow_offpay === true && isset($pay_goods_list['online'])}1{else/}0{/if};
  90. var failInPage = false;
  91. // 重新调整在线支付/到付的商品展示
  92. var setCodGoodsShow = function() {
  93. var j = $('#allow_offpay_batch').val();
  94. var arr = {};
  95. if (j) {
  96. $.each(j.split(';'), function(k, v) {
  97. vv = v.split(':');
  98. arr[vv[0]] = vv[1] == '1' ? true : false;
  99. });
  100. }
  101. $.each(arr, function(k, v) {
  102. //console.log(''+k+':'+v);
  103. if (v) {
  104. $("[data-cod-type='online'] [data-cod-store='"+k+"']").appendTo("[data-cod-type='offline']");
  105. $("[data-cod-type='online'] [data-cod-store='"+k+"']").remove();
  106. $("[data-cod2-type='online'] [data-cod2-store='"+k+"']").appendTo("[data-cod2-type='offline']");
  107. $("[data-cod2-type='online'] [data-cod2-store='"+k+"']").remove();
  108. } else {
  109. $("[data-cod-type='offline'] [data-cod-store='"+k+"']").appendTo("[data-cod-type='online']");
  110. $("[data-cod-type='offline'] [data-cod-store='"+k+"']").remove();
  111. $("[data-cod2-type='offline'] [data-cod2-store='"+k+"']").appendTo("[data-cod2-type='online']");
  112. $("[data-cod2-type='offline'] [data-cod2-store='"+k+"']").remove();
  113. }
  114. });
  115. var off = $("[data-cod2-type='offline'] [data-cod2-store]").length;
  116. var on = $("[data-cod2-type='online'] [data-cod2-store]").length;
  117. $("[data-hideshow='offline']")[off ? 'show' : 'hide']();
  118. $("[data-hideshow='online']")[on ? 'show' : 'hide']();
  119. $("span[data-cod-nums='offline']").html(off);
  120. $("span[data-cod-nums='online']").html(on);
  121. failInPage = ! off;
  122. hybrid = off && on;
  123. };
  124. //点击修改支付方式
  125. $('#edit_payment').on('click',function(){
  126. $('#edit_payment').parent().next().remove();
  127. $(this).hide();
  128. $('#paymentCon').addClass('current_box');
  129. $('#payment_list').show();
  130. disableOtherEdit('{$Think.lang.save_first_payment_method}');
  131. });
  132. //保存支付方式
  133. $('#hide_payment_list').on('click',function(){
  134. var payment_type = $('input[name="payment_type"]:checked').val();
  135. if ($('input[name="payment_type"]:checked').size() == 0) return;
  136. setCodGoodsShow();
  137. //判断该地区(县ID)是否能货到付款
  138. if (payment_type == 'offline' && ($('#allow_offpay').val() == '0' || failInPage)) {
  139. layer.alert('{$Think.lang.area_not_supported_delivery}');return;
  140. }
  141. $('#payment_list').hide();
  142. $('#edit_payment').show();
  143. $('.current_box').removeClass('current_box');
  144. var content = (payment_type == 'online' ? '{$Think.lang.cart_step2_online_pay}' : '{$Think.lang.cart_step2_arrival_pay}');
  145. $('#pay_name').val(payment_type);
  146. if (payment_type == 'offline'){
  147. //如果混合支付(在线+货到付款)
  148. if (hybrid) {
  149. content = $('#show_goods_list').clone().html();
  150. $('#edit_payment').parent().after('<div class="dsc-candidate-items"><ul><li>{$Think.lang.payment_options}<br/><a href="javsacript:void(0);" id="show_goods_list" class="dsc-payment-showgoods">'+content+'</a></li></ul></div>');
  151. $('#show_goods_list').hover(function(){showPayGoodsList(this)},function(){$('#dsc-payment-showgoods-list').fadeOut()});
  152. } else {
  153. $('#edit_payment').parent().after('<div class="dsc-candidate-items"><ul><li>'+content+'</li></ul></div>');
  154. $('#pd_panel').hide();
  155. }
  156. }else{
  157. $('#edit_payment').parent().after('<div class="dsc-candidate-items"><ul><li>'+content+'</li></ul></div>');
  158. $('#pd_panel').show();
  159. }
  160. ableOtherEdit();
  161. });
  162. $('#show_goods_list').hover(function(){showPayGoodsList(this)},function(){$('#dsc-payment-showgoods-list').fadeOut()});
  163. function showPayGoodsList(item){
  164. var pos = $(item).position();
  165. var pos_x = pos.left+0;
  166. var pos_y = pos.top+25;
  167. $("#dsc-payment-showgoods-list").css({'left' : pos_x, 'top' : pos_y,'position' : 'absolute','display' : 'block'});
  168. $('#dsc-payment-showgoods-list').addClass('dsc-payment-showgoods-list').fadeIn();
  169. }
  170. $('input[name="payment_type"]').on('change',function(){
  171. if ($(this).val() == 'online'){
  172. $('#show_goods_list').hide();
  173. } else {
  174. setCodGoodsShow();
  175. //判断该地区(县ID)是否能货到付款
  176. if (($('#allow_offpay').val() == '0') || failInPage) {
  177. $('#payment_type_online').prop('checked',true);
  178. layer.alert('{$Think.lang.area_not_supported_delivery}');return;
  179. }
  180. html_form('confirm_pay_type', '{$Think.lang.please_confirm_payment_method}', $('#confirm_offpay_goods_list').html(), 500,1);
  181. $('#show_goods_list').show();
  182. }
  183. });
  184. $('body').on('click','#close_confirm_button',function(){
  185. DialogManager.close('confirm_pay_type');
  186. });
  187. })
  188. </script>