userinfo.php 7.9 KB

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