userinfo.php 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212
  1. <?php
  2. namespace WY\app\controller\member;
  3. error_reporting(0);
  4. use WY\app\libs\Controller;
  5. if (!defined('WY_ROOT')) {
  6. exit;
  7. }
  8. class userinfo extends CheckUser
  9. {
  10. public function index()
  11. {
  12. $where = array('fields' => 'id=?', 'values' => array($_SESSION['login_userid']));
  13. $users = $this->model()->select()->from('users')->where($where)->fetchRow();
  14. $where = array('fields' => 'userid=?', 'values' => array($_SESSION['login_userid']));
  15. $userinfo = $this->model()->select()->from('userinfo')->where($where)->fetchRow();
  16. $data = array('title' => '商户资料', 'userinfo' => $userinfo, 'users' => $users);
  17. $this->put('userinfo.php', $data);
  18. }
  19. public function editsave()
  20. {
  21. // if ($this->userData['is_state'] == '1') {
  22. // //add
  23. // if ($this->userData['is_verify_phone'] == '0') { //未认证
  24. // echo json_encode(array('status' => 0, 'msg' => '手机号码未验证,请先认证手机号码后修改资料'));
  25. // exit;
  26. // }
  27. // }
  28. $data = isset($_POST) ? $_POST : false;
  29. if (!$data) {
  30. echo json_encode(array('status' => 0, 'msg' => '选项填写不完整'));
  31. echo json_encode(array('status' => 0, 'msg' => $data));
  32. exit;
  33. }
  34. foreach ($data as $key => $val) {
  35. $data[$key] = $this->req->post($key);
  36. }
  37. // unset($data[verifycode]);
  38. //add
  39. $Code=$data['verifycode'];
  40. if ($this->userData['is_verify_phone'] == '1') { //是否认证
  41. if ($data['phone'] == '' ){
  42. $data['phone'] = $this->userInfo['phone'];
  43. }
  44. //echo $Code."|".$_SESSION["code"];
  45. //exit;
  46. if(strlen($Code)>1 and $Code!=$_SESSION["code"]){
  47. echo json_encode(array('status' => 0, 'msg' => '验证码不正确!'));
  48. exit;
  49. }else{
  50. unset($data[verifycode],$_SESSION['code']);
  51. }
  52. }
  53. if ($data['phone'] == '' || $data['qq'] == '' || $data['realname'] == '' || $data['idcard'] == '' || $data['batype'] == '' || $data['baname'] == '' || $data['baaddr'] == '' || $data['sitename'] == '' || $data['siteurl'] == '') {
  54. echo json_encode(array('status' => 0, 'msg' => '选项填写不完整'));
  55. exit;
  56. }
  57. if (!preg_match('/\\d{11}/', $data['phone'])) {
  58. echo json_encode(array('status' => 0, 'msg' => '手机号码格式错误'));
  59. exit;
  60. }
  61. if (!preg_match('/\\d{5,12}/', $data['qq'])) {
  62. echo json_encode(array('status' => 0, 'msg' => 'QQ号码格式错误'));
  63. exit;
  64. }
  65. if (!preg_match('/[0-9X]{18}/', $data['idcard'])) {
  66. echo json_encode(array('status' => 0, 'msg' => '身份证号码格式错误'));
  67. exit;
  68. }
  69. if (preg_match('/http[s]?:\\/\\/(.*)/', $data['siteurl'], $match)) {
  70. $data['siteurl'] = $match[1];
  71. }
  72. if ($this->model()->from('userinfo')->updateSet($data)->where(array('fields' => 'userid=?', 'values' => array($_SESSION['login_userid'])))->update()) {
  73. echo json_encode(array('status' => 1, 'msg' => '修改已保存'));
  74. exit;
  75. }
  76. echo json_encode(array('status' => 0, 'msg' => '保存失败或无更改'));
  77. exit;
  78. }
  79. public function addsms()
  80. {
  81. $where = array('fields' => 'id=?', 'values' => array($_SESSION['login_userid']));
  82. $users = $this->model()->select()->from('users')->where($where)->fetchRow();
  83. $where = array('fields' => 'userid=?', 'values' => array($_SESSION['login_userid']));
  84. $userinfo = $this->model()->select()->from('userinfo')->where($where)->fetchRow();
  85. $data = array('title' => '手机验证', 'userinfo' => $userinfo, 'users' => $users);
  86. $this->put('addsms.php', $data);
  87. }
  88. public function savesms()
  89. {
  90. $Code=$this->req->post('verifycode');
  91. if(strlen($Code)>1 and $Code==$_SESSION["code"]){
  92. $data = array('is_verify_phone' => 1);
  93. if ($this->model()->from('users')->updateSet($data)->where(array('fields' => 'id=?', 'values' => array($this->userData['id'])))->update()) {
  94. print( "<script>alert('验证成功');window.history.back();</script>");
  95. exit;
  96. }
  97. }else{
  98. print( "<script>alert('验证码不正确');window.history.back(); </script>");
  99. exit;
  100. }
  101. unset($_SESSION['code']);
  102. }
  103. public function addcfo()
  104. {
  105. $this->put('addcfo.php', array());
  106. }
  107. public function savecfo()
  108. {
  109. $bankname = $this->req->post('bankname');
  110. $provice = $this->req->post('provice');
  111. $city = $this->req->post('city');
  112. $branchname = $this->req->post('branchname');
  113. $accountname = $this->req->post('accountname');
  114. $cardno = $this->req->post('cardno');
  115. $sfz = $this->req->post('sfz');
  116. $shouji = $this->req->post('shouji');
  117. if ($bankname == '' || $provice == '' || $city == '' || $branchname == '' || $accountname == '' || $cardno == '' || $sfz == '' || $shouji == '') {
  118. echo json_encode(array('status' => 0));
  119. exit;
  120. }
  121. $data = array('userid' => $this->userData['id'], 'bankname' => $bankname, 'sfz' => $sfz, 'shouji' => $shouji, 'provice' => str_replace('省', '', $provice), 'city' => str_replace('市', '', $city), 'branchname' => $branchname, 'accountname' => $accountname, 'cardno' => $cardno, 'addtime' => time());
  122. if ($this->model()->from('cfo')->insertData($data)->insert()) {
  123. echo json_encode(array('status' => 1));
  124. exit;
  125. }
  126. echo json_encode(array('status' => 0));
  127. }
  128. public function editcfo()
  129. {
  130. $id = isset($this->action[3]) ? intval($this->action[3]) : 0;
  131. if ($id && ($cfo = $this->model()->select()->from('cfo')->where(array('fields' => 'userid=? and id=?', 'values' => array($this->userData['id'], $id)))->fetchRow())) {
  132. $this->put('editcfo.php', $cfo);
  133. exit;
  134. }
  135. $this->put('woodyapp.php', array('msg' => '出现错误'));
  136. }
  137. public function editsavecfo()
  138. {
  139. $id = isset($this->action[3]) ? intval($this->action[3]) : 0;
  140. $bankname = $this->req->post('bankname');
  141. $provice = $this->req->post('provice');
  142. $city = $this->req->post('city');
  143. $branchname = $this->req->post('branchname');
  144. $accountname = $this->req->post('accountname');
  145. $cardno = $this->req->post('cardno');
  146. $sfz = $this->req->post('sfz');
  147. $shouji = $this->req->post('shouji');
  148. if ($id == '' && $bankname == '' || $provice == '' || $city == '' || $branchname == '' || $accountname == '' || $cardno == '' || $sfz == '' || $shouji == '') {
  149. echo json_encode(array('status' => 0));
  150. exit;
  151. }
  152. $data = array('bankname' => $bankname, 'sfz' => $sfz, 'shouji' => $shouji, 'provice' => str_replace('省', '', $provice), 'city' => str_replace('市', '', $city), 'branchname' => $branchname, 'accountname' => $accountname, 'cardno' => $cardno);
  153. if ($this->model()->from('cfo')->updateSet($data)->where(array('fields' => 'userid=? and id=?', 'values' => array($this->userData['id'], $id)))->update()) {
  154. echo json_encode(array('status' => 1));
  155. exit;
  156. }
  157. echo json_encode(array('status' => 0));
  158. }
  159. public function delcfo()
  160. {
  161. $id = intval($this->req->post('id'));
  162. if ($id && $this->model()->from('cfo')->where(array('fields' => 'userid=? and id=?', 'values' => array($this->userData['id'], $id)))->delete()) {
  163. echo json_encode(array('status' => 1));
  164. exit;
  165. }
  166. echo json_encode(array('status' => 0));
  167. }
  168. public function getCfo()
  169. {
  170. $str = '';
  171. $cfo = $this->model()->select()->from('cfo')->where(array('fields' => 'userid=?', 'values' => array($this->userData['id'])))->fetchAll();
  172. if ($cfo) {
  173. foreach ($cfo as $key => $val) {
  174. $str .= '<p class="c' . $val['id'] . '"><label><input type="radio" name="cfoid" value="' . $val['id'] . '">&nbsp;' . $val['bankname'] . '/' . $val['cardno'] . '</label>&nbsp&nbsp;<a href="javascript:;" alt="编辑" onclick="showContent(\'编辑代收银行\',\'/member/userinfo/editcfo/' . $val['id'] . '\')" style="font-size:12px"><span class="fa fa-pencil-square-o"></span></a>&nbsp;<a href="javascript:;" alt="删除" onclick="del(' . $val['id'] . ')" style="font-size:12px"><span class="fa fa-trash"></span></a></p>';
  175. }
  176. }
  177. echo $str;
  178. }
  179. }