wx_bind.action.php 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467
  1. <?php
  2. class wx_bindModule
  3. {
  4. var $signPackage = '';
  5. var $user_info = '';
  6. var $wx_url = '';
  7. var $video_id = '';
  8. var $user_id = '';
  9. //提现首页
  10. public function index()
  11. {
  12. $call_back = SITE_DOMAIN.'/mapi/index.php?ctl=wx_bind';
  13. $from = strim($_REQUEST['from']);
  14. $this->check_user_info($call_back);
  15. //流程 wx_url 有值跳转,到微信绑定
  16. // user_info 有值已绑定
  17. //user_info 无值 ,没有账号,“用户未登陆方维主播,请先登录注册再绑定”
  18. /*if($this->user_info){
  19. $data['user_info'] = $this->user_info;
  20. if($from!='app'){
  21. $show_url = SITE_DOMAIN.'/index.php?c=money_carry_wx.php';
  22. app_redirect($show_url);
  23. }
  24. }else{
  25. $data['user_info'] = false;
  26. }
  27. $data['wx_url'] = $this->wx_url;
  28. $data['app_down'] = SITE_DOMAIN.'/mapi/index.php?ctl=app_download';
  29. header("Content-Type:text/html; charset=utf-8");
  30. echo(json_encode($data));
  31. exit;*/
  32. }
  33. //检查用户是否登陆
  34. public function check_user_info($back_url){
  35. if($_REQUEST['ttype']==1){
  36. return true;
  37. }
  38. $is_weixin=isWeixin();
  39. if(!$is_weixin){
  40. return false;
  41. }
  42. fanwe_require(APP_ROOT_PATH."system/utils/weixin.php");
  43. $m_config = load_auto_cache("m_config");//初始化手机端配置
  44. if($m_config['wx_gz_appid']==''||$m_config['wx_gz_secrit']==''){
  45. print_r("公众号未配置");exit;
  46. }else{
  47. $wx_appid = strim($m_config['wx_gz_appid']);
  48. $wx_secrit = strim($m_config['wx_gz_secrit']);
  49. }
  50. $wx_status = (($wx_appid&&$wx_secrit))?1:0;
  51. if($_REQUEST['code']&&$_REQUEST['state']==1&&$wx_status){
  52. $weixin=new weixin($wx_appid,$wx_secrit,$back_url);
  53. $wx_info=$weixin->scope_get_userinfo($_REQUEST['code']);
  54. $url1 = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=".$wx_appid."&secret=".$wx_secrit;
  55. $access_token_info=$weixin->https_request($url1);
  56. $access_token_info_str=json_decode($access_token_info['body'],1);
  57. $url2="https://api.weixin.qq.com/cgi-bin/user/info?access_token=".$access_token_info_str['access_token']."&openid=".$wx_info['openid']."&lang=zh_CN";
  58. $unionid_info=$weixin->https_request($url2);
  59. $unionid_info_str=json_decode($unionid_info['body'],1);
  60. $wx_info['subscribe']=$unionid_info_str['subscribe'];
  61. $wx_info['openid']=$unionid_info_str['openid'];
  62. $wx_info['unionid']=$unionid_info_str['unionid'];
  63. /*if($wx_info['errcode']>0){
  64. var_dump($wx_info);exit;
  65. }*/
  66. }else{
  67. if($is_weixin&&$wx_status){
  68. $weixin_2=new weixin($wx_appid,$wx_secrit,$back_url);
  69. $wx_url=$weixin_2->scope_get_code();
  70. app_redirect($wx_url);
  71. }else{
  72. $weixin_2=new weixin($wx_appid,$wx_secrit,$back_url);
  73. $wx_url=$weixin_2->scope_get_code();
  74. app_redirect($wx_url);
  75. }
  76. }
  77. if($wx_info['openid']!=''){
  78. if($wx_info['unionid']==''){
  79. echo '<!DOCTYPE html>
  80. <html>
  81. <head>
  82. <meta charset="utf-8">
  83. <meta http-equiv="X-UA-Compatible" content="IE=edge">
  84. <title></title>
  85. <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=2.0, user-scalable=0,minimum-scale=0.5">
  86. <link rel="shortcut icon" href="/favicon.ico">
  87. <meta name="apple-mobile-web-app-capable" content="yes">
  88. <meta name="apple-mobile-web-app-status-bar-style" content="black">
  89. </head>
  90. <body>
  91. <div style="padding:15px;margin-top:20px;font-size:16px;text-align:center;">公众号未绑定开放平台</div>
  92. </body>
  93. </html>
  94. ';exit;
  95. }
  96. $has_user = $GLOBALS['db']->getAll("select id,head_image,nick_name from ".DB_PREFIX."user where wx_unionid = '".$wx_info['unionid']."' ");
  97. $total = count($has_user);
  98. if(intval($total)==0){
  99. $this->wx_url = '';
  100. $this->user_info = false;
  101. $app_down = SITE_DOMAIN.'/mapi/index.php?ctl=app_download';
  102. echo '<!DOCTYPE html>
  103. <html>
  104. <head>
  105. <meta charset="utf-8">
  106. <meta http-equiv="X-UA-Compatible" content="IE=edge">
  107. <title></title>
  108. <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=2.0, user-scalable=0,minimum-scale=0.5">
  109. <link rel="shortcut icon" href="/favicon.ico">
  110. <meta name="apple-mobile-web-app-capable" content="yes">
  111. <meta name="apple-mobile-web-app-status-bar-style" content="black">
  112. </head>
  113. <body>
  114. <div style="padding:15px;margin-top:20px;font-size:16px;text-align:center;">您还未登陆'.$m_config['short_name'].',请先登录注册再绑定</div>
  115. <div style="padding:16px;">
  116. <a href="'.$app_down.'" style="display:block;width:100%;height:40px;line-height:40px;font-size:18px;color:#fff;background:#8ee2d3;border-radius:20px;text-align:center;text-decoration: none;">点击立即下载</a>
  117. </div>
  118. </body>
  119. </html>
  120. ';exit;
  121. }else{
  122. $data_info = array();
  123. if($has_user['gz_openid']!=$wx_info['openid']){
  124. $data_info['gz_openid'] = $wx_info['openid'];
  125. }
  126. if($has_user['subscribe']!=$wx_info['subscribe']){
  127. $data_info['subscribe'] = $wx_info['subscribe'];
  128. }
  129. $user = array();
  130. $html = '';
  131. foreach($has_user as $k=>$v){
  132. $arr[$k] =$v['id'];
  133. $user[$k]['head_image'] = get_spec_image($v['head_image']);
  134. $user[$k]['nick_name'] = $v['nick_name'];
  135. $user[$k]['id'] = $v['id'];
  136. fanwe_require(APP_ROOT_PATH.'mapi/lib/redis/BaseRedisService.php');
  137. fanwe_require(APP_ROOT_PATH.'mapi/lib/redis/UserRedisService.php');
  138. $user_redis = new UserRedisService();
  139. $fields = array("ticket","refund_ticket");
  140. $user_ticket_info = $user_redis->getRow_db($v['id'],$fields);
  141. $ticket_catty_ratio = $GLOBALS['db']->getOne("select alone_ticket_ratio from ".DB_PREFIX."user where id=".$v['id']);
  142. if($ticket_catty_ratio==''){
  143. $ticket_catty_ratio = $m_config['ticket_catty_ratio'];
  144. }
  145. $ticket = intval($user_ticket_info['ticket'])-intval($user_ticket_info['refund_ticket']);
  146. $money = number_format($ticket*$ticket_catty_ratio,2);
  147. $user[$k]['ticket'] =$ticket;
  148. $user[$k]['use_ticket'] =$money/$ticket_catty_ratio;
  149. $user[$k]['money'] = $money;
  150. $ready_refund_id =intval($GLOBALS['db']->getOne("select id from ".DB_PREFIX."user_refund where user_id = ".intval($v['id'])." and (is_pay =0 or is_pay=1)"));
  151. $submit = SITE_DOMAIN.'/mapi/index.php?ctl=user_center&act=submitrefundwx&&id='.$k;
  152. $html .='<div class="list-block media-list" style="margin:10px 0;font-size:14px;">
  153. <ul style="background: #fff;list-style: none;padding: 0;margin: 0;position: relative;font-size:14px;"><li v-for="user_info in user_info" style="border-bottom: 1px solid #e5e5e5;box-sizing: border-box; position: relative;">
  154. <a href="#" class="item-content" style="box-sizing:border-box;padding-left:15px;min-height:44px;display:-webkit-box;display:-webkit-flex;display:flex;-webkit-box-pack:justify;-webkit-justify-content:space-between;justify-content:space-between;-webkit-box-align:center;-webkit-align-items:center;align-items:center;text-decoration:none;color:#333;">
  155. <div class="item-media" style=" display:-webkit-box;display:-webkit-flex;display:flex;-webkit-flex-shrink:0;-ms-flex:0 0 auto;-webkit-flex-shrink:0;flex-shrink:0;-webkit-box-lines:single;-moz-box-lines:single;-webkit-flex-wrap:nowrap;flex-wrap:nowrap;box-sizing:border-box;-webkit-box-align:center;-webkit-align-items:center;align-items:center;padding-top:9px;padding-bottom:10px;">
  156. <img src="'.$user[$k]['head_image'].'" style="width:50px;height:50px;border-radius:50%;" />
  157. </div>
  158. <div class="item-inner" style="padding-right:15px;position:relative;width:100%;padding-top:10px;;padding-bottom:9px;;min-height:55px;overflow:hidden;box-sizing:border-box;display:-webkit-box;display:-webkit-flex;display:flex;-webkit-box-flex:1;-ms-flex:1;-webkit-box-pack:justify;-webkit-justify-content:space-between;justify-content:space-between;-webkit-box-align:center;-webkit-align-items:center;align-items:center;margin-left:15px;display:block;-webkit-align-self:stretch;align-self:stretch;">
  159. <div class="item-title-row" style="display:-webkit-box;display:-webkit-flex;display:flex;-webkit-box-pack:justify;-webkit-justify-content:space-between;justify-content:space-between;">
  160. <div class="item-title" style="-webkit-flex-shrink:1;-ms-flex:0 1 auto;-webkit-flex-shrink:1;flex-shrink:1;white-space:nowrap;position:relative;overflow:hidden;text-overflow:ellipsis;max-width:100%;font-weight:500;font-size:16px;">'.$v['nick_name'].'</div>
  161. </div>
  162. <div class="item-subtitle" style="height:initial;font-size:12px;position:relative;overflow:hidden;white-space:nowrap;max-width:100%;text-overflow:ellipsis;color:#333;">'.$v['id'].'</div>
  163. <div class="item-text" style="height:initial;font-size:12px;color:#333;line-height:21px;;position:relative;overflow:hidden;height:42px;text-overflow:ellipsis;-webkit-line-clamp:2;-webkit-box-orient:vertical;display:-webkit-box;">可领取'.$user[$k]['money'].'元</div>';
  164. if($ready_refund_id){
  165. $html.='<div class="item-text" style="color:red;">提现审核中</div>';
  166. }
  167. $html.='</div>
  168. </a>
  169. </li></ul>
  170. </div>
  171. <div class="content-block" style="margin:35px 0;padding:0 15px;color:#6d6d72;">
  172. <div class="row" style="overflow:hidden;margin-left:-4%;">
  173. <div class="col-100" style="width:96%;margin-left:4%;box-sizing:border-box;float:left;">
  174. <a href="'.$submit.'" class="button button-big button-fill button-round button-theme" style="border:1px solid #ff7552;color:#fff;text-decoration:none;text-align:center;display:block;height:44px;line-height:44px;;box-sizing:border-box;-webkit-appearance:none;-moz-appearance:none;-ms-appearance:none;appearance:none;background:0 0;padding:0 10px;margin:0;white-space:nowrap;position:relative;text-overflow:ellipsis;font-size:14px;font-family:inherit;cursor:pointer;-moz-border-radius:25px;-khtml-border-radius:25px;-webkit-border-radius:25px;border-radius:25px;background-color:#ff7552;border:none;font-size:17px;opacity:.9;">确定</a>
  175. </div>
  176. </div>
  177. </div>';
  178. $submit = '';
  179. }
  180. $arr_id =implode(',',$arr);
  181. $GLOBALS['db']->autoExecute(DB_PREFIX."user",$data_info,'UPDATE'," id in (".$arr_id.")");
  182. $user_info = $has_user;
  183. es_session::set("user_info_wx", $user);
  184. }
  185. $user_info['authorizer_access_token'] = $wx_info['authorizer_access_token'];
  186. $user_info['authorizer_appid'] = $wx_info['authorizer_appid'];
  187. echo '<!DOCTYPE html>
  188. <html>
  189. <head>
  190. <meta charset="utf-8">
  191. <meta http-equiv="X-UA-Compatible" content="IE=edge">
  192. <title>微信提现</title>
  193. <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=2.0, user-scalable=0,minimum-scale=0.5">
  194. <link rel="shortcut icon" href="/favicon.ico">
  195. <meta name="apple-mobile-web-app-capable" content="yes">
  196. <meta name="apple-mobile-web-app-status-bar-style" content="black">
  197. </head>
  198. <body style="background:#f0f7f6;">
  199. <div class="content-block-title" style="overflow:hidden;white-space: nowrap;text-overflow: ellipsis;font-size: 14px;text-transform: uppercase;line-height: 1;color: #6d6d72;margin: 35px 15px 10px;">请选择要领取红包的帐号</div>
  200. '.$html.'
  201. </body>
  202. </html>';
  203. }else{
  204. $weixin_2=new weixin($wx_appid,$wx_secrit,$back_url,'snsapi_base');
  205. $wx_url=$weixin_2->scope_get_code();
  206. app_redirect($wx_url);
  207. }
  208. }
  209. //充值页面
  210. public function recharge(){
  211. $refresh = SITE_DOMAIN.'/mapi/index.php?ctl=wx_bind&act=recharge';
  212. $tips = '<!DOCTYPE html>
  213. <html>
  214. <head>
  215. <meta charset="utf-8">
  216. <meta http-equiv="X-UA-Compatible" content="IE=edge">
  217. <title>微信充值</title>
  218. <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=2.0, user-scalable=0,minimum-scale=0.5">
  219. <meta http-equiv="refresh" content="1; url='.$refresh.'"><link rel="shortcut icon" href="/favicon.ico">
  220. <meta name="apple-mobile-web-app-capable" content="yes">
  221. <meta name="apple-mobile-web-app-status-bar-style" content="black">
  222. </head>
  223. <body style="background:#f0f7f6;">
  224. xxxx
  225. </body>
  226. </html>';
  227. $sql = "select id,name,class_name,logo from ".DB_PREFIX."payment where is_effect = 1 and class_name='Wwxjspay'";
  228. $pay = $GLOBALS['db']->getRow($sql,true,true);
  229. if(intval($pay['id'])==0){
  230. $error = "未开启微信充值.";
  231. echo str_replace('xxxx',$error,$tips);return;
  232. }
  233. array_unique($_REQUEST);
  234. $m_config = load_auto_cache("m_config");//初始化手机端配置
  235. $user_id = intval(strim($_REQUEST['user_id']));
  236. $is_pay = $_REQUEST['is_pay'];
  237. $rule_id = intval($_REQUEST['rule_id']);
  238. $rule_money = floatval($_REQUEST['rule_money']);
  239. if($is_pay!=''){
  240. $data['error_tip'] = '请输入'.$m_config['account_name'];
  241. $data['error_color'] = 'style="color:red"';
  242. if(strim($_REQUEST['user_id'])!=''){
  243. $user_info = $GLOBALS['db']->getOne("select id from ".DB_PREFIX."user where id =".$user_id);
  244. $data['error_tip'] = $m_config['account_name'].'不存在';
  245. $data['error_color'] = 'style="color:red"';
  246. if($user_info){
  247. if($is_pay==1){
  248. $data['error_tip'] = '';
  249. $data['error_color'] = 'style="color:red"';
  250. $data['rule_tip'] = "请选择充值金额";
  251. if($rule_id){
  252. $data['rule_tip'] = '';
  253. $sql = "select id,money,name,iap_money,product_id,(diamonds+gift_diamonds) as diamonds from ".DB_PREFIX."recharge_rule where is_effect = 1 and is_delete = 0 and id =".$rule_id;
  254. $rule = $GLOBALS['db']->getRow($sql,true,true);
  255. $payment_notice['create_time'] = NOW_TIME;
  256. $payment_notice['user_id'] = $user_id;
  257. $payment_notice['payment_id'] = $pay['id'];
  258. $payment_notice['money'] = $rule['money'];
  259. $payment_notice['diamonds'] = $rule['diamonds'];//充值时,获得的钻石数量
  260. $payment_notice['recharge_id'] = $rule['id'];
  261. $payment_notice['recharge_name'] = $rule['name'];
  262. $payment_notice['product_id'] = $rule['product_id'];
  263. $payment_notice['notice_sn'] = to_date(NOW_TIME,"YmdHis").rand(100,999);
  264. $GLOBALS['db']->autoExecute(DB_PREFIX."payment_notice",$payment_notice,"INSERT","","SILENT");
  265. $notice_id = $GLOBALS['db']->insert_id();
  266. $url = url_mapi("wx_bind#go_pay",array('id'=>$notice_id));
  267. app_redirect(get_domain().'/mapi'.$url);
  268. }
  269. }else{
  270. $data['error_tip'] = '验证通过';
  271. $data['error_color'] = 'style="color:green"';
  272. }
  273. }
  274. }
  275. }
  276. //print_r($data);exit;
  277. $rule_list = load_auto_cache("rule_list");
  278. $html = '<div class="content">
  279. <div class="m-top">
  280. <div class="m-user">
  281. <div class="user-img">
  282. <img src="'.get_spec_image($m_config['app_logo']).'"/>
  283. </div>
  284. <div class="user-name">
  285. <p class="name">'.$m_config['short_name'].'直播</p>
  286. </div>
  287. <div class="clear"></div>
  288. </div>
  289. <div class="clear"></div>
  290. </div>
  291. <form id="form_submit" action="'.$refresh.'" method="post">
  292. <div class="m-input">
  293. <span>'.$m_config['account_name'].'</span>
  294. <div class="input-content">
  295. <input type="text" name="user_id" value="'.strim($_REQUEST['user_id']).'" placeholder="请输入'.$m_config['account_name'].'" />
  296. <button class="button check" style="font-size:16px;">检测</button>
  297. </div>
  298. </div><div class="m-input" id="error_tip">';
  299. if($data['error_tip']){
  300. $html.='<span style="padding-left:60px;text-align:right;">&nbsp;</span><div class="input-content"><span '.$data['error_color'].'>'.$data['error_tip'].'</span></div>';
  301. }
  302. $html.='</div><div class="m-input">
  303. <span>充值金额</span>
  304. </div><div>';
  305. foreach($rule_list as $k=>$v){
  306. $html.='<div class="m-money">
  307. <div class="money-all" data-id="'.$v['id'].'" data-money="'.$v['money'].'" ';
  308. if($rule_id==$v['id']){
  309. $html.=' style="border:1px solid #ff5500;"';
  310. }
  311. $html.='>
  312. <p class="money">¥'.$v['money'].'</p><p class="title">购买'.$v['diamonds'].'钻石</p>
  313. </div></div>
  314. ';
  315. }
  316. $html.='</div><div class="clear"></div><div class="m-input">
  317. <span>应付金额</span>
  318. <div class="input-content">
  319. <span class="amount" style="color:#FF0000;">'.$rule_money.'</span><span>元</span>
  320. <span id="rule_tip" style="color:#FF0000;padding-left: 10px;">';
  321. if($data['rule_tip']){
  322. $html.=$data['rule_tip'];
  323. }
  324. $html.='</span>
  325. </div>
  326. </div>
  327. <input type="hidden" name="rule_id" value="'.$rule_id.'" class="rule_id"/>
  328. <input type="hidden" name="rule_money" value="'.$rule_money.'" class="rule_money"/>
  329. <input type="hidden" name="is_pay" class="is_pay" value=""/>
  330. <div class="button pay" style="width:30%;margin-left:25%;margin-top:10px;">确认支付
  331. </div></form></div>
  332. <script>
  333. $(function(){
  334. $(".money-all").click(function(){
  335. $(".rule_id").val($(this).attr("data-id"));
  336. $(".rule_money").val($(this).attr("data-money"));
  337. $(".money-all").css("border","1px solid #dedede");
  338. $(this).css("border","1px solid #ff5500");
  339. $(".amount").html($(this).attr("data-money"));
  340. $("#rule_tip").html("");
  341. });
  342. $(".check").click(function(){
  343. $(".is_pay").val(0);
  344. $("#form_submit").submit();
  345. });
  346. $(".pay").click(function(){
  347. $(".is_pay").val(1);
  348. $("#form_submit").submit();
  349. });});
  350. </script>';
  351. echo '<!DOCTYPE html><html><head>
  352. <meta charset="UTF-8">
  353. <meta http-equiv="X-UA-Compatible" content="IE=edge">
  354. <title>'.$m_config['short_name'].'充值</title>
  355. <meta name="viewport" content="initial-scale=1, maximum-scale=1">
  356. <meta name="apple-mobile-web-app-capable" content="yes">
  357. <meta name="apple-mobile-web-app-status-bar-style" content="black">
  358. <style type="text/css">
  359. *{margin: 0;padding: 0;}
  360. body{background: #eef7f4;font-size: 16px;}
  361. .clear {clear: both;visibility: hidden;font-size: 0;height: 0;line-height: 0;}
  362. .content{padding: 20px;background: #fff;}
  363. .m-user{display: -webkit-flex;display: flex;-webkit-align-items: center;align-items: center;margin-bottom: 15px;}
  364. .user-img{width: 50px;height: 50px;overflow: hidden;border-radius: 5px;float: left;margin-right: 10px;}
  365. .user-img img{width: 100%;}
  366. .user-name{float: left;}
  367. .user-name .name{font-size: 20px;line-height: 18px;margin-bottom: 5px;color:#ff5500;}
  368. .m-money{float:left;width: 48%;padding-right:2%;padding-bottom:5px;}
  369. .money-all{border: 1px solid #dedede;padding-top: 10px;padding-bottom:10px;box-sizing: border-box;text-align: center;}
  370. .money{font-size: 24px;color: #FF0000;font-family: arial;}
  371. .title{text-align:center;color: #666;line-height: 20px;font-size: 14px;}
  372. .button{border:none;text-align: center;background: #ff5500;height: 40px;line-height: 40px;color: #fff;padding: 0 30px;display: block;text-decoration: none;border-radius: 3px;}
  373. .m-input{display: -webkit-flex;display: flex;-webkit-align-items: center;align-items: center;margin-top: 15px;display:-webkit-box;-webkit-box-orient:horizontal;}
  374. .m-input .input-content{display:flex;-webkit-box-flex:1;-moz-box-flex:1;-webkit-box-align:center;}
  375. .m-input input{height: 36px;line-height: 36px;border: 1px solid #dedede;padding: 0 10px;margin: 0 10px;display: flex;font-size:14px;}
  376. .m-input span{font-size: 14px;line-height: 30px;color: #666;}
  377. </style>
  378. <script type="text/javascript" src="'.SITE_DOMAIN.'/wap/theme/default/dist/sui-mobile/zepto.min.js"></script>
  379. </head><body>
  380. '.$html.'
  381. </body></html>';
  382. }
  383. /*
  384. * 微信公众号充值
  385. */
  386. public function go_pay(){
  387. $refresh = SITE_DOMAIN.'/mapi/index.php?ctl=wx_bind&act=recharge';
  388. $notice_id = $_REQUEST['id'];
  389. $payment_notice = $GLOBALS['db']->getRow("select * from ".DB_PREFIX."payment_notice where id = ".$notice_id,true,true);
  390. $payment_info = $GLOBALS['db']->getRow("select id,class_name from ".DB_PREFIX."payment where id=".intval($payment_notice['payment_id']),true,true);
  391. $class_name = $payment_info['class_name']."_payment";
  392. fanwe_require(APP_ROOT_PATH."system/payment/".$class_name.".php");
  393. $o = new $class_name;
  394. $pay_info= $o->get_payment_code($notice_id);
  395. $html = '<html><head>
  396. <meta http-equiv="content-type" content="text/html;charset=utf-8"/>
  397. <meta name="viewport" content="width=device-width, initial-scale=1"/>
  398. <title>微信支付</title>
  399. <script type="text/javascript">
  400. //调用微信JS api 支付
  401. function jsApiCall(){
  402. WeixinJSBridge.invoke(
  403. "getBrandWCPayRequest",
  404. '.$pay_info.',
  405. function(res){
  406. WeixinJSBridge.log(res.err_msg);
  407. if(res.err_msg=="get_brand_wcpay_request:fail"){
  408. //alert(res.err_code+res.err_desc+res.err_msg);
  409. alert("支付失败");
  410. }
  411. if(res.err_msg=="get_brand_wcpay_request:cancel"){
  412. alert("支付取消");
  413. }
  414. if(res.err_msg=="get_brand_wcpay_request:ok"){
  415. alert("恭喜您支付成功");
  416. setTimeout(function(){
  417. location.href = "'.$refresh.'";
  418. },1000);
  419. }
  420. }
  421. );
  422. }
  423. function callpay(){
  424. if (typeof WeixinJSBridge == "undefined"){
  425. if( document.addEventListener ){
  426. document.addEventListener("WeixinJSBridgeReady", jsApiCall, false);
  427. }else if (document.attachEvent){
  428. document.attachEvent("WeixinJSBridgeReady", jsApiCall);
  429. document.attachEvent("onWeixinJSBridgeReady", jsApiCall);
  430. }
  431. }else{
  432. jsApiCall();
  433. }
  434. }
  435. </script>
  436. </head><body>
  437. <br/>
  438. <div style="text-align:center">
  439. <font color="#9ACD32"><b>支付金额为<span style="color:#f00;font-size:50px">'.$payment_notice['money'].'</span>元</b></font><br/><br/>
  440. </div>
  441. <div align="center">
  442. <button style="border:none;text-align: center;background: #ff5500;height: 40px;line-height: 40px;color: #fff;padding: 0 30px;display: block;text-decoration: none;border-radius: 3px;font-size:16px;" type="button" onclick="callpay()" >立即支付</button>
  443. </div>
  444. </body>
  445. </html>';
  446. echo $html;exit;
  447. }
  448. }
  449. ?>