Login.php
6.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
<?php
namespace app\test\controller;
use think\Controller;
use think\Db;
use think\response\Json;
use think\Session;
use think\Cookie;
class Login extends Controller
{
public function login()
{
$ispost = I('ispost');
if ($ispost) {
session_start();
/*清理session,cookie*/
session_destroy();//删除所有的session
setcookie('user_id', null, null, '/');
Cookie::delete('user_id');
$user = null;
$mob = I('mob');
if (!empty($mob)) {
$user = M('users')->alias('a')->join('store b', ' a.store_id=b.store_id', 'left')->where('a.mobile', $mob)
->where('a.store_id', getMobileStoId())->field('a.*,b.ERPId')
->find();
session('user', $user);
setcookie('user_id', $user['user_id'], null, '/');
session('get_vip_base', get_vip_base());
setcookie('is_distribut', $user['is_distribut'], null, '/');
$cartLogic = new \app\home\logic\CartLogic();
$cartLogic->login_cart_handle($this->session_id, $user['user_id']); //用户登录后 需要对购物车 一些操作
$this->success('登录成功', U('Mobile/user/index', array('stoid' => getMobileStoId())));
} else {
$user_id = I('user_id');
$user = M('users')->alias('a')->join('store b', ' a.store_id=b.store_id', 'left')->where('a.user_id', $user_id)
->where('a.store_id', getMobileStoId())->field('a.*,b.ERPId')
->find();
session('user', $user);
setcookie('user_id', $user['user_id'], null, '/');
session('get_vip_base', get_vip_base());
setcookie('is_distribut', $user['is_distribut'], null, '/');
$cartLogic = new \app\home\logic\CartLogic();
$cartLogic->login_cart_handle($this->session_id, $user['user_id']); //用户登录后 需要对购物车
$this->success('登录成功', U('Mobile/index/index', array('stoid' => getMobileStoId())));
}
}
return $this->fetch('mylogin', getMobileStoId());
exit;
}
public function newqlogin()
{
$key = I('key');
if ($key) {
$where['store_name|ERPId'] = array('like', '%' . $key . '%');
}
$where['is_audit'] = 1;
$storelist = M('store')->where($where)->field('store_id,store_name,ERPId')->select();
$this->assign('storelist', $storelist);
$this->assign('key', $key);
return $this->fetch('');
}
public function go()
{
$storeid = I('storeid');
$loginpwd = I('loginpwd');
if ($loginpwd != "wxd.123.ylp" && $loginpwd != "yanyun") {
$return_arr = array(
'code' => -1,
'msg' => "登陆失败,密码有误",
'link' => ""
);
} else {
$res = M('store')->where('store_id', $storeid)->find();
//$res=tpCache('shop_info',$storeid);
if ($res) {
$fieldstr="";
$ERPUser=I("erpuser");
if ($res['ERPId'])
{
if(empty($ERPUser)){
$ERPUser="admin";
}
$fieldstr = "ERPId=" . $res['ERPId'] . "&ERPUser=".$ERPUser."";
}
else{
if(empty($ERPUser)){
$ERPUser=$res['reg_mobile'];
}
$fieldstr = "mobile=" . $res['reg_mobile'] . "&ERPUser=" . $ERPUser;
}
$gofieldstr = $fieldstr;
$fieldstr .= "&Key=" . getErpKey();
$fieldstr1 = strtolower($fieldstr);
$key = md5($fieldstr1);
$poststr = $gofieldstr . "&key=" . $key;
$poststr = urlencode($poststr);
$return_arr = array(
'code' => 0,
'msg' => "",
'link' => $poststr
);
} else {
$return_arr = array(
'code' => -1,
'msg' => "找不到商家信息",
'link' => ""
);
}
}
return \json($return_arr);
}
public function mlogin()
{
$storeid = I('storeid');
$mobile = I('mobile');
$loginpwd = I('loginpwd');
if (empty($storeid) || empty($loginpwd) || empty($mobile)) {
$return_arr = array(
'code' => -1,
'msg' => "参数有误",
'link' => ""
);
} else if ($loginpwd != "wxd.123.ylp") {
$return_arr = array(
'code' => -1,
'msg' => "登陆失败,密码有误",
'link' => ""
);
} else {
setcookie('user_id', null, null, '/');
Cookie::delete('user_id');
$user = null;
$user = M('users')->alias('a')->join('store b', ' a.store_id=b.store_id', 'left')
->where('a.mobile', $mobile)
->where('a.store_id', $storeid)->field('a.*,b.ERPId')
->find();
if ($user) {
session('user', $user);
setcookie('user_id', $user['user_id'], null, '/');
session('get_vip_base', get_vip_base());
setcookie('is_distribut', $user['is_distribut'], null, '/');
$cartLogic = new \app\home\logic\CartLogic();
$cartLogic->login_cart_handle($this->session_id, $user['user_id']); //用户登录后 需要对购物车 一些操作
$return_arr = array(
'code' => 0,
'msg' => ""
);
} else {
$return_arr = array(
'code' => -1,
'msg' => "登陆失败,找不到相关会员 ",
'link' => ""
);
}
}
return \json($return_arr);
}
}