pay.html 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. {include file="../application/h5/view/wx_book_dinner/header.html"}
  2. <title>微信支付</title>
  3. <script type="text/javascript">
  4. //调用微信JS api 支付
  5. var jasapi = {:json_decode($params["jsApiParameters"])};
  6. var oid = '{$params["orderid"]}';
  7. function jsApiCall()
  8. {
  9. WeixinJSBridge.invoke(
  10. 'getBrandWCPayRequest',
  11. jasapi,
  12. function(res){
  13. WeixinJSBridge.log(res.err_msg);
  14. //alert("支付完成");
  15. // $("#payButton").hide();
  16. // $("#payMessage").show();
  17. //alert(res.err_code+res.err_desc+res.err_msg);
  18. if(res.err_msg == "get_brand_wcpay_request:ok" ){
  19. // 使用以上方式判断前端返回,微信团队郑重提示:
  20. //res.err_msg将在用户支付成功后返回ok,但并不保证它绝对可靠。
  21. var url = 'payresult?id='+oid;
  22. window.location.href=url;
  23. }
  24. }
  25. );
  26. }
  27. function callpay()
  28. {
  29. if (typeof WeixinJSBridge == "undefined"){
  30. if( document.addEventListener ){
  31. document.addEventListener('WeixinJSBridgeReady', jsApiCall, false);
  32. }else if (document.attachEvent){
  33. document.attachEvent('WeixinJSBridgeReady', jsApiCall);
  34. document.attachEvent('onWeixinJSBridgeReady', jsApiCall);
  35. }
  36. }else{
  37. jsApiCall();
  38. }
  39. }
  40. </script>
  41. <script type="text/javascript">
  42. window.onload = function(){
  43. if (typeof WeixinJSBridge == "undefined"){
  44. if( document.addEventListener ){
  45. document.addEventListener('WeixinJSBridgeReady', editAddress, false);
  46. }else if (document.attachEvent){
  47. document.attachEvent('WeixinJSBridgeReady', editAddress);
  48. document.attachEvent('onWeixinJSBridgeReady', editAddress);
  49. }
  50. }else{
  51. editAddress();
  52. }
  53. };
  54. </script>
  55. </head>
  56. <body>
  57. <div class="weui-pay" id="payButton" >
  58. <h1 class="weui-payselect-title">订单金额</h1>
  59. <p class="weui-pay-num">{$params['localorder']['price']}</p>
  60. <div class="pay-div">
  61. <button class="weui_btn weui_btn_primary" id="pay" onclick="callpay()">立即支付</button>
  62. </div>
  63. </div>
  64. </body>
  65. </html>