Main.php 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. <?php
  2. namespace Mshop\Src;
  3. use Dever;
  4. class Main
  5. {
  6. public function config()
  7. {
  8. $config = Dever::db('main/manage_config')->find();
  9. $this->data['config'] = $config;
  10. return $this->data;
  11. }
  12. # 登录
  13. public function login()
  14. {
  15. $where['mobile'] = Dever::load('passport/reg')->checkMobileExists(false, -1, 'shop/member');
  16. $user = Dever::db('shop/member')->select($where);
  17. if ($user) {
  18. $this->data['uid'] = $user[0]['id'];
  19. $this->data['signature'] = Dever::login($this->data['uid']);
  20. $this->data['shop'] = array();
  21. $this->data['shop_id'] = false;
  22. foreach ($user as $k => $v) {
  23. $shop = Dever::db('shop/info')->getOne($v['shop_id']);
  24. if ($shop) {
  25. $this->data['shop'][] = $shop;
  26. $this->data['shop_id'] = $v['shop_id'];
  27. }
  28. }
  29. $this->data['shop_num'] = count($this->data['shop']);
  30. return $this->data;
  31. } else {
  32. Dever::alert('登录失败,手机号不存在');
  33. }
  34. }
  35. # 获取验证码
  36. public function mcode()
  37. {
  38. $mobile = Dever::load('passport/reg')->checkMobileExists(1, true, 'shop/member');
  39. $msg = Dever::load('passport/reg')->getMcode_action($mobile);
  40. return $msg;
  41. }
  42. # 申请合作
  43. public function apply()
  44. {
  45. $data['name'] = Dever::input('name');
  46. $data['mobile'] = Dever::input('mobile');
  47. $data['city'] = Dever::input('city');
  48. if (!$data['name']) {
  49. Dever::alert('请输入姓名');
  50. }
  51. if (!$data['mobile']) {
  52. Dever::alert('请输入手机号');
  53. }
  54. if (!$data['city']) {
  55. Dever::alert('请选择城市');
  56. }
  57. $info = Dever::db('shop/apply')->find($data);
  58. $data['truename'] = $data['name'];
  59. # 根据城市查找省份
  60. $county = Dever::db('area/county')->find($data['city']);
  61. if ($county) {
  62. $data['city'] = $county['city_id'];
  63. }
  64. $city = Dever::db('area/city')->find($data['city']);
  65. $data['province'] = $city['province_id'];
  66. $data['area'] = $data['province'] . ',' . $data['city'];
  67. if ($county) {
  68. $data['area'] .= ',' . $county['id'];
  69. }
  70. # 获取经纬度
  71. list($data['lng'], $data['lat'], $data['map']) = Dever::load('shop/lib/info')->geo($data['city'], $city['name']);
  72. $data['status'] = 1;
  73. if (!$info) {
  74. Dever::db('shop/apply')->insert($data);
  75. } else {
  76. $data['where_id'] = $info['id'];
  77. Dever::db('shop/apply')->insert($data);
  78. }
  79. $this->data['msg'] = '提交成功,我们会在3个工作日内与您联系,感谢您的信任。';
  80. return $this->data;
  81. }
  82. }