|
@@ -22,6 +22,7 @@ class User extends Api |
|
@@ -22,6 +22,7 @@ class User extends Api |
22
|
public function _initialize()
|
22
|
public function _initialize()
|
23
|
{
|
23
|
{
|
24
|
parent::_initialize();
|
24
|
parent::_initialize();
|
|
|
25
|
+ $this->model = model('app\common\model\User');
|
25
|
$this->user = $this->auth->getUser();
|
26
|
$this->user = $this->auth->getUser();
|
26
|
}
|
27
|
}
|
27
|
|
28
|
|
|
@@ -40,7 +41,7 @@ class User extends Api |
|
@@ -40,7 +41,7 @@ class User extends Api |
40
|
public function index()
|
41
|
public function index()
|
41
|
{
|
42
|
{
|
42
|
// 当前用户信息
|
43
|
// 当前用户信息
|
43
|
- $user = $this->auth->getUser();
|
44
|
+ $user = $this->user;
|
44
|
$coupon_count = \app\common\model\UserCoupon::alias('uc')
|
45
|
$coupon_count = \app\common\model\UserCoupon::alias('uc')
|
45
|
->join('coupon c','c.id = uc.coupon_id')
|
46
|
->join('coupon c','c.id = uc.coupon_id')
|
46
|
->where('uc.user_id',$this->user['id'])
|
47
|
->where('uc.user_id',$this->user['id'])
|
|
@@ -73,8 +74,8 @@ class User extends Api |
|
@@ -73,8 +74,8 @@ class User extends Api |
73
|
// $session = Wechat::miniProgram()->auth->session($code);
|
74
|
// $session = Wechat::miniProgram()->auth->session($code);
|
74
|
// // 自动注册用户
|
75
|
// // 自动注册用户
|
75
|
// $userInfo = json_decode(htmlspecialchars_decode($user_info), true);
|
76
|
// $userInfo = json_decode(htmlspecialchars_decode($user_info), true);
|
76
|
- // if (!$user = UserModel::get(['openid' => $session['openid']])) {
|
|
|
77
|
- // $user = new UserModel;
|
77
|
+ // if (!$user = $this->model->get(['openid' => $session['openid']])) {
|
|
|
78
|
+ // $user = $this->model;
|
78
|
// $userInfo['openid'] = $session['openid'];
|
79
|
// $userInfo['openid'] = $session['openid'];
|
79
|
// }
|
80
|
// }
|
80
|
// $userInfo['nickname'] = preg_replace('/[\xf0-\xf7].{3}/', '', $userInfo['nickname']);
|
81
|
// $userInfo['nickname'] = preg_replace('/[\xf0-\xf7].{3}/', '', $userInfo['nickname']);
|
|
@@ -84,7 +85,7 @@ class User extends Api |
|
@@ -84,7 +85,7 @@ class User extends Api |
84
|
$session = [
|
85
|
$session = [
|
85
|
'openid' => $testopenid ?: 'test',
|
86
|
'openid' => $testopenid ?: 'test',
|
86
|
];
|
87
|
];
|
87
|
- $user = UserModel::get(['openid' => $session['openid']]);
|
88
|
+ $user = $this->model->get(['openid' => $session['openid']]);
|
88
|
// 生成token (session3rd)
|
89
|
// 生成token (session3rd)
|
89
|
$guid = guidv4();// 生成一个不会重复的随机字符串
|
90
|
$guid = guidv4();// 生成一个不会重复的随机字符串
|
90
|
$timeStamp = microtime(true);// 当前时间戳 (精确到毫秒)
|
91
|
$timeStamp = microtime(true);// 当前时间戳 (精确到毫秒)
|
|
@@ -143,7 +144,7 @@ class User extends Api |
|
@@ -143,7 +144,7 @@ class User extends Api |
143
|
if (!Validate::regex($mobile, "^1\d{10}$")) {
|
144
|
if (!Validate::regex($mobile, "^1\d{10}$")) {
|
144
|
$this->error(__('Mobile is incorrect'));
|
145
|
$this->error(__('Mobile is incorrect'));
|
145
|
}
|
146
|
}
|
146
|
- if (UserModel::where('mobile', $mobile)->where('id', '<>', $this->user['id'])->find()) {
|
147
|
+ if ($this->model->where('mobile', $mobile)->where('id', '<>', $this->user['id'])->find()) {
|
147
|
$this->error(__('Mobile already exists'));
|
148
|
$this->error(__('Mobile already exists'));
|
148
|
}
|
149
|
}
|
149
|
// $result = Sms::check($mobile, $captcha, 'changemobile');
|
150
|
// $result = Sms::check($mobile, $captcha, 'changemobile');
|
|
@@ -176,7 +177,7 @@ class User extends Api |
|
@@ -176,7 +177,7 @@ class User extends Api |
176
|
*/
|
177
|
*/
|
177
|
public function scoreLog(){
|
178
|
public function scoreLog(){
|
178
|
$page = $this->request->request('page');
|
179
|
$page = $this->request->request('page');
|
179
|
- $list = UserModel::scoreLog($this->user['id'],$page);
|
180
|
+ $list = $this->model->scoreLog($this->user['id'],$page);
|
180
|
$this->success(__('成功'),compact('list'));
|
181
|
$this->success(__('成功'),compact('list'));
|
181
|
}
|
182
|
}
|
182
|
|
183
|
|