人人商城

wechat.html 22KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648
  1. {php $newUI = true;}
  2. {template 'common/header'}
  3. <!--收银台-->
  4. <style>
  5. .check-stand .row > div{text-align:center; vertical-align:middle; min-width:300px;}
  6. .check-stand .row form{margin-top:100px;}
  7. .check-stand .row h6{font-weight:700;}
  8. .check-stand .row .qr-area{border:1px dashed #666; width:216px; height:216px; text-align:center; line-height:214px; margin: 5px auto;}
  9. .check-stand .row .qr-area .qr-img{width:200px; height:200px;}
  10. .check-stand .row .qr-area canvas{vertical-align:middle}
  11. .check-stand .row .down-load a{display:block; text-align:center; padding:10px 0;}
  12. .table-center td, .table-center th{text-align:center}
  13. .table img{cursor:pointer}
  14. .table-none-border>tbody>tr>td{border-top:none;}
  15. </style>
  16. <ul class="nav nav-tabs">
  17. <li {if $do == 'index'}class="active"{/if}><a href="{php echo url('paycenter/wechat/index')}">二维码收款</a></li>
  18. <li {if $do == 'qrcode'}class="active"{/if}><a href="{php echo url('paycenter/wechat/qrcode')}">二维码记录</a></li>
  19. <li {if $do == 'pay'}class="active"{/if}><a href="{php echo url('paycenter/wechat/pay');}">收款记录</a></li>
  20. <li {if $do == 'micro'}class="active"{/if}><a href="{php echo url('paycenter/wechat/micro');}">刷卡收款</a></li>
  21. <li {if $action == 'stat' && $do == 'index'}class="active"{/if}><a href="{php echo url('paycenter/stat/index');}">数据统计</a></li>
  22. </ul>
  23. {if $do == 'index'}
  24. <div class="clearfix">
  25. <div class="panel panel-default check-stand">
  26. <div class="panel-heading">指定金额收款</div>
  27. <div class="panel-body row">
  28. <div class="col-sm-3">
  29. <form action="" method="post" id="form1">
  30. <div class="form-group">
  31. <input type="text" class="form-control" name="body" placeholder="收款商品名称"/>
  32. </div>
  33. <div class="form-group">
  34. <div class="input-group">
  35. <input type="text" class="form-control" name="fee" placeholder="输入金额(至少0.01元)" />
  36. <span class="input-group-btn"><button class="btn btn-success btn-submit">生成二维码</button></span>
  37. </div>
  38. </div>
  39. </form>
  40. </div>
  41. <div class="col-sm-3">
  42. <h6>立刻支付二维码</h6>
  43. <div class="qr-area" id="rightNow-qrcode">
  44. 二维码区域
  45. </div>
  46. <div>收款:<span id="rightNow-fee">-</span>元</div>
  47. </div>
  48. <div class="col-sm-3">
  49. <h6>永久支付二维码</h6>
  50. <div class="qr-area" id="forever-qrcode">
  51. 二维码区域
  52. </div>
  53. <div>收款:<span id="forever-fee">-</span>元</div>
  54. <div class="down-load"><a href="javascript:;" class="forever-qrcode download" data-name="forever">下载二维码</a></div>
  55. </div>
  56. <div class="col-sm-3">
  57. <h6>自助付款</h6>
  58. <div class="qr-area" id="code">
  59. <img src="" alt="" class="qr-img"/>
  60. </div>
  61. <div>买家可自助输入付款金额</div>
  62. <div class="down-load"><a href="javascript:;" class="init-qrcode download">下载二维码</a></div>
  63. </div>
  64. </div>
  65. </div>
  66. <div class="panel panel-default">
  67. <div class="panel-heading">近期收款情况</div>
  68. <div class="panel-body">
  69. <table class="table table-hover table-responsive table-center">
  70. <thead>
  71. <tr>
  72. <th>编号</th>
  73. <th>付款人</th>
  74. <th>付款时间</th>
  75. <th>付款金额</th>
  76. <th>退款情况</th>
  77. <th>操作</th>
  78. </tr>
  79. </thead>
  80. {if !empty($orders)}
  81. {loop $orders $order}
  82. <tr>
  83. <td>{$order['id']}</td>
  84. <td>{$order['openid']}</td>
  85. <td>{php echo date('Y-m-d H:i:s', $order['paytime']);}</td>
  86. <td>{$order['fee']}</td>
  87. <td><span class="{$status[$order['status']]['class']}">{$status[$order['status']]['text']}</span></td>
  88. <td>
  89. <a href="javascript:;" class="btn btn-success btn-sm pay-info" data-id="{$order['id']}">支付详情</a>
  90. </td>
  91. </tr>
  92. {/loop}
  93. {/if}
  94. </table>
  95. </div>
  96. </div>
  97. </div>
  98. {/if}
  99. {if $do == 'qrcode'}
  100. <div class="clearfix">
  101. <div class="panel panel-default">
  102. <div class="panel-body">
  103. <table class="table table-hover table-center table-responsive">
  104. <thead>
  105. <tr>
  106. <th style="text-align:left">编号</th>
  107. <th>二维码</th>
  108. <th>付款金额(元)</th>
  109. <th>生成时间</th>
  110. <th>支付状态</th>
  111. <th>付款理由</th>
  112. <th>操作</th>
  113. </tr>
  114. </thead>
  115. {if !empty($orders)}
  116. {loop $orders $order}
  117. <tr>
  118. <td style="text-align:left">{$order['id']}</td>
  119. <td><img src="http://cashier.b0.upaiyun.com/pigcms_static/images/qrcode.png" width="90" class="url-modal" data-pid="{$order['pid']}"></td>
  120. <td>{$order['fee']}</td>
  121. <td>{php echo date('Y-m-d H:i:s', $order['createtime']);}</td>
  122. <td><span class="{$status[$order['status']]['class']}">{$status[$order['status']]['text']}</span></td>
  123. <td>{$order['body']}</td>
  124. <td>
  125. <a href="javascript:;" class="btn btn-success btn-sm pay-info" data-id="{$order['id']}">支付详情</a>
  126. </td>
  127. </tr>
  128. {/loop}
  129. {/if}
  130. </table>
  131. </div>
  132. </div>
  133. {$pager}
  134. </div>
  135. {/if}
  136. {if $do == 'pay'}
  137. <div class="clearfix">
  138. <div class="panel panel-default">
  139. <div class="panel-body">
  140. <table class="table table-hover table-center table-responsive">
  141. <thead>
  142. <tr>
  143. <th style="text-align:left">编号</th>
  144. <th>付款人</th>
  145. <th>付款时间</th>
  146. <th>付款理由</th>
  147. <th>付款金额(元)</th>
  148. <th>退款情况</th>
  149. <th>操作</th>
  150. </tr>
  151. </thead>
  152. {if !empty($orders)}
  153. {loop $orders $order}
  154. <tr>
  155. <td style="text-align:left">{$order['id']}</td>
  156. <td>{$order['openid']}</td>
  157. <td>{php echo date('Y-m-d H:i:s', $order['paytime']);}</td>
  158. <td>{$order['body']}</td>
  159. <td>{$order['fee']}</td>
  160. <td><span class="{$status[$order['status']]['class']}">{$status[$order['status']]['text']}</span></td>
  161. <td>
  162. <a href="javascript:;" class="btn btn-success btn-sm pay-info" data-id="{$order['id']}">支付详情</a>
  163. </td>
  164. </tr>
  165. {/loop}
  166. {/if}
  167. </table>
  168. </div>
  169. </div>
  170. {$pager}
  171. </div>
  172. {/if}
  173. {if $do == 'micro'}
  174. <div class="clearfix" ng-controller="microPay" id="microPay">
  175. <div class="panel panel-default">
  176. <div class="panel-heading">刷卡收款</div>
  177. <div class="panel-body">
  178. <div class="col-lg-5">
  179. <form action="" class="form" method="post" id="form1">
  180. <div class="form-group">
  181. <label>商品描述</label>
  182. <input type="text" name="body" class="form-control" ng-model="micro.config.body" placeholder="商品名称">
  183. </div>
  184. <div class="form-group">
  185. <label>支付金额</label>
  186. <input type="text" name="fee" class="form-control" ng-model="micro.config.fee" ng-init="micro.config.fee" placeholder="支付金额(至少0.01元)">
  187. </div>
  188. {if !empty($card_set)}
  189. <div ng-show="micro.config.body && micro.config.fee">
  190. <div class="form-group">
  191. <label>会员卡卡号</label>
  192. <div class="input-group">
  193. <input type="text" name="cardsn" class="form-control" ng-model="micro.config.cardsn" placeholder="输入会员卡卡号">
  194. <span class="input-group-btn"><span class="btn btn-success" ng-click="micro.checkCard()">校 验</span></span>
  195. </div>
  196. </div>
  197. </div>
  198. <table class="table table-hover table-bordered" ng-show="micro.config.member.uid > 0">
  199. <tr>
  200. <td colspan="4" style="text-align:center"><h4>{{micro.config.cardsn}}</h4></td>
  201. </tr>
  202. <tr>
  203. <th width="100">姓名</th>
  204. <td>{{micro.config.member.realname}}</td>
  205. <th>手机号</th>
  206. <td>{{micro.config.member.mobile}}</td>
  207. </tr>
  208. <tr>
  209. <th>积分</th>
  210. <td>{{micro.config.member.credit1}}</td>
  211. <th>余额</th>
  212. <td>{{micro.config.member.credit2}}</td>
  213. </tr>
  214. <tr>
  215. <th>会员等级</th>
  216. <td>{{micro.config.member.groupname}}</td>
  217. <th>优惠信息</th>
  218. <td>{{micro.config.member.discount_cn}}</td>
  219. </tr>
  220. </table>
  221. <div class="form-group" ng-show="micro.config.member.uid > 0">
  222. <label>实际支付金额</label>
  223. <input type="text" name="fact_fee" class="form-control" ng-model="micro.fact_fee" readonly>
  224. </div>
  225. <div ng-if="micro.fact_fee > 0">
  226. <div class="form-group">
  227. <label>支付方式</label>
  228. <table class="table table-hover table-bordered">
  229. <tr>
  230. <td>
  231. <label class="checkbox-inline"><input type="checkbox" value="1" ng-model="micro.is_credit1_pay" ng-click="micro.checkCredit1()"/> 积分抵现</label>
  232. <div class="input-group">
  233. <input type="text" class="form-control" value="" ng-model="micro.config.credit1" ng-disabled="!micro.is_credit1_pay"/>
  234. <span class="input-group-addon">积分 抵消</span>
  235. <input type="text" class="form-control" value="" ng-model="micro.config.offset_money" ng-disabled="!micro.is_credit1_pay"/>
  236. <span class="input-group-addon">元</span>
  237. </div>
  238. </td>
  239. </tr>
  240. <tr>
  241. <td>
  242. <label class="checkbox-inline"><input type="checkbox" value="1" ng-model="micro.is_credit2_pay" ng-click="micro.checkCredit2()"/> 余额支付</label>
  243. <div class="input-group">
  244. <input type="text" class="form-control" value="" ng-model="micro.config.credit2" ng-disabled="!micro.is_credit2_pay"/>
  245. <span class="input-group-addon">元</span>
  246. </div>
  247. </td>
  248. </tr>
  249. <tr>
  250. <td>
  251. <label class="checkbox-inline"><input type="checkbox" value="1" ng-model="micro.is_cash_pay" ng-click="micro.checkCash()"/> 现金支付</label>
  252. <div class="input-group">
  253. <input type="text" class="form-control" value="" ng-model="micro.config.cash" ng-disabled="!micro.is_cash_pay"/>
  254. <span class="input-group-addon">元</span>
  255. </div>
  256. </td>
  257. </tr>
  258. </table>
  259. </div>
  260. </div>
  261. {/if}
  262. <div class="form-group">
  263. <label>刷卡授权码</label>
  264. <input type="text" name="code" class="form-control" ng-model="micro.code" placeholder="微信刷卡支付授权码(请链接扫码枪扫码)">
  265. </div>
  266. <div class="form-group text-right">
  267. <a class="btn btn-primary" id="micro-submit" ng-click="micro.submit()">确认收款</a>
  268. <a class="btn btn-success" style="display:none" id="micro-query">查询支付情况</a>
  269. </div>
  270. </form>
  271. </div>
  272. <div class="col-lg-2">
  273. </div>
  274. <div class="col-lg-5">
  275. <table class="table table-hover table-bordered">
  276. <tr>
  277. <th colspan="3" style="text-align:center"><h4>会员卡信息</h4></th>
  278. </tr>
  279. <tr>
  280. <th style="width:150px">付款返积分比率: </th>
  281. <td colspan="2">每消费 1 元赠送 {$card_set['grant_rate']} 积分</td>
  282. </tr>
  283. <tr>
  284. <th width="150">积分抵现金比率: </th>
  285. <td colspan="2">{$card_set['offset_rate']} 积分抵 1 元, 单次最多可抵现 {$card_set['offset_max']} 元</td>
  286. </tr>
  287. {if $card_set['discount_type'] > 0 && !empty($card_set['discount'])}
  288. {loop $card_set['discount'] $key $row}
  289. <tr>
  290. <th width="150">{$_W['account']['groups'][$key]['title']}: </th>
  291. {if $card_set['discount_type'] == 1}
  292. <td colspan="2">满 {$row['condition']} 元减 {$row['discount']} 元</td>
  293. {else}
  294. <td colspan="2">满 {$row['condition']} 元打 {php echo $row['discount'] * 10} 折</td>
  295. {/if}
  296. </tr>
  297. {/loop}
  298. {/if}
  299. </table>
  300. </div>
  301. </div>
  302. </div>
  303. </div>
  304. {/if}
  305. <div class="modal fade" id="qrcode-modal">
  306. <div class="modal-dialog">
  307. <div class="modal-content">
  308. <div class="modal-header">
  309. <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
  310. <h3 class="modal-title">支付二维码</h3>
  311. </div>
  312. <div class="modal-body">
  313. <div class="qrcode" style="text-align:center; margin:20px 0"></div>
  314. </div>
  315. <div class="modal-footer">
  316. <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
  317. </div>
  318. </div>
  319. </div>
  320. </div>
  321. <div class="modal fade" id="payinfo-modal">
  322. <div class="modal-dialog">
  323. <div class="modal-content">
  324. <div class="modal-header">
  325. <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
  326. <h3 class="modal-title">支付详情</h3>
  327. </div>
  328. <div class="modal-body"></div>
  329. <div class="modal-footer">
  330. <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
  331. </div>
  332. </div>
  333. </div>
  334. </div>
  335. <script>
  336. angular.module('app', []).controller('microPay', function($scope, $http){
  337. var card_set_str = '{$card_set_str}';
  338. var card = $.parseJSON(card_set_str);
  339. $scope.micro = {
  340. config: {
  341. body: '测试商品',
  342. fee: '10',
  343. cardsn: '18635132526',
  344. card: card,
  345. credit1: 0,
  346. credit2: 0,
  347. offset_money: 0,
  348. cash: 0,
  349. member: {
  350. uid: 0
  351. }
  352. }
  353. };
  354. $scope.micro.checkBasic = function() {
  355. var body = $.trim($scope.micro.config.body);
  356. if(!body) {
  357. util.message('商品名称不能为空');
  358. return false;
  359. }
  360. var reg = /^(([1-9]{1}\d*)|([0]{1}))(\.(\d){1,2})?$/;
  361. var fee = $.trim($scope.micro.config.fee);
  362. if(!reg.test(fee)) {
  363. util.message('支付金额不能少于0.01元');
  364. return false;
  365. }
  366. };
  367. $scope.micro.checkCard = function() {
  368. $scope.micro.checkBasic();
  369. var cardsn = $.trim($scope.micro.config.cardsn);
  370. if(!cardsn) {
  371. util.message('卡号不能为空');
  372. return false;
  373. }
  374. $http.post("{php echo url('paycenter/card/check');}", {cardsn: cardsn}).success(function(dat){
  375. if(dat.message.errno == -1) {
  376. util.message(dat.message.message, '', 'error');
  377. } else{
  378. $scope.micro.config.member = dat.message.message;
  379. $scope.micro.fact_fee = $scope.micro.config.fee;
  380. if($scope.micro.config.member.discount_type > 0 && $scope.micro.config.member.discount && ($scope.micro.config.fee >= $scope.micro.config.member.discount.condition)) {
  381. if($scope.micro.config.member.discount_type == 1) {
  382. $scope.micro.fact_fee = $scope.micro.config.fee - $scope.micro.config.member.discount.discount;
  383. } else {
  384. $scope.micro.fact_fee = $scope.micro.config.fee * $scope.micro.config.member.discount.discount;
  385. }
  386. if($scope.micro.fact_fee < 0) {
  387. $scope.micro.fact_fee = 0;
  388. }
  389. }
  390. $scope.micro.last_money = $scope.micro.fact_fee;
  391. return false;
  392. }
  393. });
  394. };
  395. $scope.micro.checkCredit1 = function() {
  396. $scope.micro.checkLast_money();
  397. if(!$scope.micro.is_credit1_pay) {
  398. $scope.micro.config.credit1 = 0;
  399. $scope.micro.config.offset_money = 0;
  400. } else {
  401. if($scope.micro.last_money <= 0) {
  402. $scope.micro.is_credit1_pay = false;
  403. return false;
  404. }
  405. if($scope.micro.config.card['offset_rate'] > 0 && $scope.micro.config.card['offset_max'] > 0) {
  406. var min = Math.min.apply(null, [$scope.micro.config.member.credit1, $scope.micro.config.card.offset_rate * $scope.micro.config.card.offset_max, $scope.micro.config.card.offset_rate * $scope.micro.last_money]);
  407. $scope.micro.config.credit1 = min;
  408. $scope.micro.config.offset_money = min/$scope.micro.config.card.offset_rate;
  409. }
  410. }
  411. $scope.micro.checkLast_money();
  412. }
  413. $scope.micro.checkCredit2 = function() {
  414. $scope.micro.checkLast_money();
  415. if(!$scope.micro.is_credit2_pay) {
  416. $scope.micro.config.credit2 = 0;
  417. } else {
  418. if($scope.micro.last_money <= 0) {
  419. $scope.micro.is_credit2_pay = false;
  420. return false;
  421. }
  422. $scope.micro.config.credit2 = Math.min.apply(null, [$scope.micro.config.member.credit2, $scope.micro.last_money]);
  423. }
  424. $scope.micro.checkLast_money();
  425. }
  426. $scope.micro.checkCash = function() {
  427. $scope.micro.checkLast_money();
  428. if(!$scope.micro.is_cash_pay) {
  429. $scope.micro.config.cash = 0;
  430. } else {
  431. if($scope.micro.last_money <= 0) {
  432. $scope.micro.is_cash_pay = false;
  433. return false;
  434. }
  435. $scope.micro.config.cash = $scope.micro.last_money;
  436. }
  437. }
  438. $scope.micro.checkLast_money = function() {
  439. $scope.micro.last_money = $scope.micro.fact_fee - $scope.micro.config.credit2 - $scope.micro.config.offset_money - $scope.micro.config.cash;
  440. }
  441. $scope.micro.submit = function() {
  442. if($scope.micro.config.member.uid > 0) {
  443. $scope.micro.checkLast_money();
  444. if($scope.micro.last_money != 0) {
  445. util.message('支付金额有误', '', 'error');
  446. return false;
  447. }
  448. }
  449. if(!$.trim($scope.micro.code)) {
  450. util.message('支付授权码不能为空', '', 'error');
  451. return false;
  452. }
  453. $http.post("{php echo url('paycenter/wechat/micro');}", $scope.micro.config).success(function(dat){
  454. var data = $.parseJSON(data);
  455. if(data.message.errno == 0) {
  456. util.message('支付成功', '', 'success');
  457. $('#form1 :text[name="code"]').val('');
  458. } else if(data.message.errno == -1) {
  459. util.message('支付失败:' + data.message.message, '', 'error');
  460. $('#form1 :text[name="code"]').val('');
  461. } else if(data.message.errno == -10) {
  462. util.message('支付失败:' + data.message.message + '<br>请点击"查询支付情况"来查询订单支付状态', '', 'error');
  463. uniontid = data.message.uniontid;
  464. //$('#micro-submit').hide();
  465. $('#micro-query').data('uniontid', uniontid);
  466. $('#micro-query').show();
  467. }
  468. return false;
  469. });
  470. }
  471. });
  472. angular.bootstrap($('#microPay')[0], ['app']);
  473. require(['jquery.qrcode'], function(){
  474. $('.card-submit').click(function(){
  475. var cardsn = $.trim($(':text[name="cardsn"]').val());
  476. if(!cardsn) {
  477. util.message('卡号不能为空');
  478. return false;
  479. }
  480. $.post("{php echo url('paycenter/card');}", {cardsn: cardsn}, function(data){
  481. var data = $.parseJSON(data);
  482. });
  483. });
  484. //刷卡支付
  485. $('#micro-submitd').click(function(){
  486. var uniontid = '';
  487. $('#micro-query').data('uniontid', '');
  488. var body = $.trim($('#form1 :text[name="body"]').val());
  489. if(!body) {
  490. util.message('商品名称不能为空');
  491. return false;
  492. }
  493. var reg = /^(([1-9]{1}\d*)|([0]{1}))(\.(\d){1,2})?$/;
  494. var fee = $.trim($('#form1 :text[name="fee"]').val());
  495. if(!reg.test(fee)) {
  496. util.message('支付金额不能少于0.01元');
  497. return false;
  498. }
  499. var code = $.trim($('#form1 :text[name="code"]').val());
  500. if(!code) {
  501. util.message('微信刷卡支付授权码不能为空');
  502. return false;
  503. }
  504. $.post("{php echo url('paycenter/wechat/micro');}", {body: body, fee: fee, code: code}, function(data){
  505. var data = $.parseJSON(data);
  506. if(data.message.errno == 0) {
  507. util.message('支付成功', '', 'success');
  508. $('#form1 :text[name="code"]').val('');
  509. } else if(data.message.errno == -1) {
  510. util.message('支付失败:' + data.message.message, '', 'error');
  511. $('#form1 :text[name="code"]').val('');
  512. } else if(data.message.errno == -10) {
  513. util.message('支付失败:' + data.message.message + '<br>请点击"查询支付情况"来查询订单支付状态', '', 'error');
  514. uniontid = data.message.uniontid;
  515. //$('#micro-submit').hide();
  516. $('#micro-query').data('uniontid', uniontid);
  517. $('#micro-query').show();
  518. }
  519. return false;
  520. });
  521. });
  522. $('#micro-query').click(function(){
  523. var uniontid = $(this).data('uniontid');
  524. if(!uniontid) {
  525. util.message('订单号错误', '', 'error');
  526. return false;
  527. }
  528. $.post("{php echo url('paycenter/wechat/query');}", {uniontid : uniontid}, function(data){
  529. var data = $.parseJSON(data);
  530. if(data.message.errno != 0) {
  531. util.message(data.message.message);
  532. return false;
  533. } else {
  534. util.message('支付成功', '', 'success');
  535. $('#form1 :text[name="code"]').val('');
  536. return false;
  537. }
  538. });
  539. });
  540. //扫码支付
  541. $('.btn-submit').click(function(){
  542. var body = $.trim($('#form1 :text[name="body"]').val());
  543. if(!body) {
  544. util.message('付款理由不能为空');
  545. return false;
  546. }
  547. var reg = /^(([1-9]{1}\d*)|([0]{1}))(\.(\d){1,2})?$/;
  548. var fee = $.trim($('#form1 :text[name="fee"]').val());
  549. if(!reg.test(fee)) {
  550. util.message('支付金额不能少于0.01元');
  551. return false;
  552. }
  553. $.post("{php echo url('paycenter/wechat/index');}", {body: body, fee: fee}, function(data){
  554. var data = $.parseJSON(data);
  555. if(data.message.errno != 0) {
  556. util.message(data.message.message);
  557. return false;
  558. } else {
  559. var option = {
  560. render: 'canvas',
  561. width: 200,
  562. height: 200
  563. }
  564. option.text = data.message.rightNow
  565. $('#rightNow-qrcode').html('').qrcode(option);
  566. option.text = data.message.forever;
  567. $('#forever-qrcode').html('').qrcode(option);
  568. $('.forever-qrcode').data('text', data.message.forever);
  569. $('.forever-qrcode').data('name', 'forever-pay-' + fee);
  570. $('#rightNow-fee, #forever-fee').html(fee);
  571. }
  572. });
  573. return false;
  574. });
  575. $('.download').click(function(){
  576. var text = $(this).data('text');
  577. if(!text) {
  578. util.message('参数错误 ', '', 'error');
  579. return;
  580. }
  581. var name = $(this).data('name');
  582. var url = "{php echo url('paycenter/wechat/download');}";
  583. text = encodeURIComponent(text);
  584. location.href = url + '&text=' + text + '&name=' + name;
  585. });
  586. $('.url-modal').click(function(){
  587. var pid = $(this).data('pid');
  588. if(!pid) {
  589. util.message('商品编号pid错误', '', 'error');
  590. return false;
  591. }
  592. $.post("{php echo url('paycenter/wechat/url');}", {pid: pid}, function(data) {
  593. var data = $.parseJSON(data);
  594. if(data.message.errno == -1) {
  595. util.message(data.message.message, '', 'error');
  596. return false;
  597. } else {
  598. $('#qrcode-modal .qrcode').html('').qrcode({
  599. render: 'canvas',
  600. width: 350,
  601. height: 350,
  602. text: data.message.message
  603. });
  604. $('#qrcode-modal').modal('show');
  605. return false;
  606. }
  607. });
  608. });
  609. $('.pay-info').click(function(){
  610. var id = $(this).data('id');
  611. if(!id) {
  612. util.message('订单编号错误', '', 'error');
  613. return false;
  614. }
  615. $.post("{php echo url('paycenter/wechat/info');}", {id: id}, function(data) {
  616. var data = $.parseJSON(data);
  617. if(data.message.errno == -1) {
  618. util.message(data.message.message, '', 'error');
  619. return false;
  620. } else {
  621. $('#payinfo-modal .modal-body').html(data.message.message);
  622. $('#payinfo-modal').modal('show');
  623. return false;
  624. }
  625. });
  626. });
  627. });
  628. </script>
  629. {template 'common/footer'}