reader_login.php 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * Member: tianyi
  5. * Date: 2018/4/11
  6. * Time: 17:42
  7. */
  8. try {
  9. $phone = safeCheck($_POST["phone"], 0);
  10. $wxopenid = safeCheck($_POST["wxopenid"], 0);
  11. $name = safeCheck($_POST["name"], 0);
  12. $sex = safeCheck($_POST["sex"], 0);
  13. $province = safeCheck($_POST["province"], 0);
  14. $city = safeCheck($_POST["city"], 0);
  15. $detailaddress = safeCheck($_POST["detailaddress"], 0);
  16. $hangye = safeCheck($_POST["hangye"], 0);
  17. $province = ($province > 0) ? $province : 0;
  18. $city = ($city > 0) ? $city : 0;
  19. $hangye = ($hangye > 0) ? $hangye : 0;
  20. //检查
  21. if (!ParamCheck::is_mobile($phone)) {
  22. echo action_msg('电话号码格式错误', 101);
  23. exit;
  24. }
  25. if (empty($name)) {
  26. echo action_msg('请填写姓名', 102);
  27. exit;
  28. }
  29. if (!in_array($sex, array(0, 1))) {
  30. echo action_msg('性别错误', 103);
  31. exit;
  32. }
  33. if (empty($wxopenid)) {
  34. echo action_msg('微信opeid不能为空', 104);
  35. exit;
  36. }
  37. if (empty($province)) {
  38. echo action_msg('请填写省份', 105);
  39. exit;
  40. }
  41. // if (empty($city)) {
  42. // echo action_msg('请填写城市', 106);
  43. // exit;
  44. // }
  45. if (empty($hangye)) {
  46. echo action_msg('请选择行业', 107);
  47. exit;
  48. }
  49. //添加不存在的客户
  50. $guest = Common_guest::getInfoByPhone($phone);
  51. if (empty($guest)) {
  52. //增加新用户
  53. $attr['phone'] = $phone;
  54. $attr['wxopenid'] = $wxopenid;
  55. $attr['name'] = $name;
  56. $attr['sex'] = $sex;
  57. $attr['province'] = $province;
  58. $attr['city'] = $city;
  59. $attr['detailaddress'] = $detailaddress;
  60. $attr['hangye_id'] = $hangye;
  61. $id = Common_guest::add($attr);
  62. if (empty($id)) {
  63. echo action_msg('新增普通客户失败', 103);
  64. exit;
  65. }
  66. } else {
  67. $id = $guest['id'];
  68. }
  69. $ret = Common_guest::getPassInfo($id);
  70. echo action_msg($ret, 200);
  71. } catch (MyException $e) {
  72. echo action_msg($e->getMessage(), $e->getCode());
  73. }
  74. ?>