pay_wx_old.blade.php 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202
  1. <!DOCTYPE html>
  2. <html class="bg-white">
  3. <head>
  4. <meta charset="utf-8">
  5. <!--此行代码为禁止苹果手机自动识别电话号码-->
  6. <meta name="format-detection" content="telephone=no">
  7. <meta name="viewport"
  8. content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,initial-scale=1.0,width=device-width"/>
  9. <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
  10. <title>{{$shop_info['shop_name']}}支付</title>
  11. <link rel="stylesheet" type="text/css" href="{{asset('wap/css/common.css')}}"/>
  12. <link rel="stylesheet" type="text/css" href="{{asset('wap/css/pay-page..css')}}"/>
  13. <script src="{{asset('wap/js/jquery-2.1.4.js')}}"></script>
  14. <script src="{{asset('wap/js/vue.js')}}?a=1"></script>
  15. <script src="{{asset('wap/js/jweixin-1.6.0.js')}}?a=1"></script>
  16. <script src="{{asset('wap/js/common.js')}}?a=1"></script>
  17. </head>
  18. <body>
  19. <div id="app">
  20. <div class="page">
  21. <div class="weui-form">
  22. <div class="weui-form__text-area">
  23. <h2 class="weui-form__title">门店支付</h2>
  24. <div class="weui-form__desc">{{$shop_info['shop_name']}}</div>
  25. </div>
  26. <div class="weui-form__control-area">
  27. <div class="weui-cells__group weui-cells__group_form">
  28. <div class="weui-cells weui-cells_form">
  29. <div class="weui-cell weui-cell_active">
  30. <div class="weui-cell__hd"><label class="weui-label">支付金额</label></div>
  31. <div class="weui-cell__bd">
  32. <input id="js_input" class="weui-input" placeholder="请输入支付金额" type="number"
  33. v-model="pay_money" mix="0.01" autofocus="autofocus"/>
  34. </div>
  35. </div>
  36. </div>
  37. </div>
  38. </div>
  39. <div class="weui-form__opr-area">
  40. <a v-show="is_pay" class="weui-btn weui-btn_primary " @click="creatWxPay" href="javascript:" id="showTooltips">确定</a>
  41. <a v-show="!is_pay" class="weui-btn weui-btn_primary weui-btn_disabled" href="javascript:" id="showTooltips">确定</a>
  42. </div>
  43. <!--BEGIN toast-->
  44. <div id="toast" style="display: none;">
  45. <div class="weui-mask_transparent"></div>
  46. <div class="weui-toast">
  47. <i class="weui-icon-success-no-circle weui-icon_toast"></i>
  48. <p class="weui-toast__content">@{{success_msg}}</p>
  49. </div>
  50. </div>
  51. <!--BEGIN toast-->
  52. <div id="textMoreToast" v-show="error_show">
  53. <div class="weui-mask_transparent"></div>
  54. <div class="weui-toast weui-toast_text-more">
  55. <i class="weui-icon-warn weui-icon_toast"></i>
  56. <p class="weui-toast__content">@{{error_msg}}</p>
  57. </div>
  58. </div>
  59. </div>
  60. </div>
  61. </div>
  62. <div id="app">
  63. <!-- 导航栏 -->
  64. <div class="nav-bar">
  65. <div>
  66. <img src="{{asset('wap/images/49@2x.png')}}" class="nav-img">
  67. </div>
  68. <div class="nav-title">湘西火锅-商家支付</div>
  69. <div>
  70. <img src="{{asset('wap/images/组 117@2x.png')}}" class="nav-img">
  71. </div>
  72. </div>
  73. <!-- 支付详情 -->
  74. <div class="pay-detail">
  75. <div class="pay-layout">
  76. <div class="spend-total">消费总额</div>
  77. <div class="input-money">
  78. <span>¥</span>
  79. <input type="text">
  80. </div>
  81. <div class="prompt">可询问工作人员应缴费用总额</div>
  82. </div>
  83. </div>
  84. <!-- button -->
  85. <div class="button-layout">
  86. <div class="button">
  87. <span>支付</span>
  88. </div>
  89. </div>
  90. </div>
  91. <script>
  92. $(function () {
  93. var vm = new Vue({
  94. el: '#app',
  95. data: {
  96. pay_money: '',
  97. success_msg: '',
  98. error_msg: '',
  99. error_show: false,
  100. success_show: false,
  101. is_pay: false,
  102. is_ajax: false,
  103. wx_config: {
  104. debug: true, // 开启调试模式,调用的所有api的返回值会在客户端alert出来,若要查看传入的参数,可以在pc端打开,参数信息会通过log打出,仅在pc端时才会打印。
  105. appId: "{{$wx_js['appid']}}", // 必填,公众号的唯一标识
  106. timestamp: {{$wx_js['timestamp']}}, // 必填,生成签名的时间戳
  107. nonceStr: "{{$wx_js['noncestr']}}", // 必填,生成签名的随机串
  108. signature: "{{$wx_js['signature']}}",// 必填,签名
  109. jsApiList: ['chooseWXPay'] // 必填,需要使用的JS接口列表
  110. }
  111. },
  112. methods: {
  113. 'errorMgs': function (error_msg) {
  114. this.error_msg = error_msg;
  115. this.error_show = true;
  116. setTimeout(function () {
  117. vm.error_show = false;
  118. }, 2000)
  119. },
  120. 'successMsg': function (success_msg) {
  121. this.success_msg = success_msg;
  122. this.success_show = true;
  123. setTimeout(function () {
  124. vm.success_show = false;
  125. }, 2000)
  126. },
  127. 'startWx': function () {
  128. wx.config(this.wx_config);
  129. wx.error(function (res) {
  130. // config信息验证失败会执行error函数,如签名过期导致验证失败,具体错误信息可以打开config的debug模式查看,也可以在返回的res参数中查看,对于SPA可以在这里更新签名。
  131. console.log(res);
  132. });
  133. },
  134. 'creatWxPay': function () {
  135. if (this.is_ajax) {
  136. return false;
  137. }
  138. // this.is_ajax = true;
  139. sendAjax('{{route('pay.wx_pay')}}', {'pay_money': this.pay_money,'shop_id':'{{$shop_info['id']}}'}, function (data) {
  140. if (data.code * 1 == 1) {
  141. console.log(data.data.appId);
  142. // return false;
  143. wx.chooseWXPay({
  144. timestamp: data.data.timeStamp, // 支付签名时间戳,注意微信jssdk中的所有使用timestamp字段均为小写。但最新版的支付后台生成签名使用的timeStamp字段名需大写其中的S字符
  145. nonceStr: data.data.nonceStr, // 支付签名随机串,不长于 32 位
  146. package: data.data.package, // 统一支付接口返回的prepay_id参数值,提交格式如:prepay_id=\*\*\*)
  147. signType: data.data.signType, // 微信支付V3的传入RSA,微信支付V2的传入格式与V2统一下单的签名格式保持一致
  148. paySign: data.data.paySign, // 支付签名
  149. success: function (res) {
  150. // 支付成功后的回调函数
  151. }
  152. });
  153. } else {
  154. vm.is_ajax = false;
  155. error_alert(data.msg);
  156. }
  157. })
  158. }
  159. },
  160. watch: {
  161. 'pay_money': function () {
  162. if (this.pay_money * 1 == 0) {
  163. this.is_pay = false;
  164. return false;
  165. }
  166. if (this.pay_money != '') {
  167. if (isNaN(this.pay_money) || this.pay_money * 1 < 0) {
  168. this.is_pay = false;
  169. this.pay_money = '';
  170. this.errorMgs('支付金额不合法');
  171. return false;
  172. }
  173. if (this.pay_money * 1 < 0.01) {
  174. this.is_pay = false;
  175. this.errorMgs('最低支付金额0.01元');
  176. return false;
  177. }
  178. }
  179. this.is_pay = true;
  180. }
  181. },
  182. created: function () {
  183. console.log('------------------')
  184. this.startWx();
  185. }
  186. });
  187. })
  188. </script>
  189. </body>
  190. </html>