|
@@ -152,9 +152,17 @@ class LoginController extends BaseController |
|
@@ -152,9 +152,17 @@ class LoginController extends BaseController |
|
152
|
* @time :2023/8/23 18:46
|
152
|
* @time :2023/8/23 18:46
|
|
153
|
*/
|
153
|
*/
|
|
154
|
public function qrcode(){
|
154
|
public function qrcode(){
|
|
|
|
155
|
+ $this->request->validate([
|
|
|
|
156
|
+ 'type' => 'required',
|
|
|
|
157
|
+ ],[
|
|
|
|
158
|
+ 'type.required' => '请选择项目',
|
|
|
|
159
|
+ ]);
|
|
|
|
160
|
+ if(!isset($this->param['id'])){
|
|
|
|
161
|
+ $this->param['id'] = 0;
|
|
|
|
162
|
+ }
|
|
155
|
$wechat = new Wechat();
|
163
|
$wechat = new Wechat();
|
|
156
|
$accessToken = $wechat->getAccessToken();
|
164
|
$accessToken = $wechat->getAccessToken();
|
|
157
|
- $data = $wechat->setQrcode('global-v6',$accessToken);
|
165
|
+ $data = $wechat->setQrcode('global-v6_'.$this->param['type'].'_'.$this->param['id'],$accessToken);
|
|
158
|
if(!empty($data)){
|
166
|
if(!empty($data)){
|
|
159
|
$data['url'] = "https://mp.weixin.qq.com/cgi-bin/showqrcode?ticket=".$data['ticket'];
|
167
|
$data['url'] = "https://mp.weixin.qq.com/cgi-bin/showqrcode?ticket=".$data['ticket'];
|
|
160
|
}
|
168
|
}
|
|
@@ -173,25 +181,16 @@ class LoginController extends BaseController |
|
@@ -173,25 +181,16 @@ class LoginController extends BaseController |
|
173
|
$message = simplexml_load_string($message, 'SimpleXMLElement', LIBXML_NOCDATA | LIBXML_NOERROR);
|
181
|
$message = simplexml_load_string($message, 'SimpleXMLElement', LIBXML_NOCDATA | LIBXML_NOERROR);
|
|
174
|
$jsonData = json_encode($message);
|
182
|
$jsonData = json_encode($message);
|
|
175
|
$arrayData = json_decode($jsonData, true);
|
183
|
$arrayData = json_decode($jsonData, true);
|
|
176
|
- $data = $this->wechatLogin($arrayData['ToUserName']);
|
|
|
|
177
|
- @file_put_contents(storage_path('logs/lyh_error.log'), var_export($data, true) . PHP_EOL, FILE_APPEND);
|
|
|
|
178
|
- if($data['code'] == 0){//登录失败,请先绑定
|
|
|
|
179
|
- $resMessage = $data['message'];
|
|
|
|
180
|
- }else{
|
|
|
|
181
|
- $resMessage = $data['message'];
|
|
|
|
182
|
- $info = $data['data'];
|
|
|
|
183
|
- Cache::add($arrayData['Ticket'],$info,300);
|
|
|
|
184
|
- }
|
|
|
|
185
|
- @file_put_contents(storage_path('logs/lyh_error.log'), var_export($resMessage, true) . PHP_EOL, FILE_APPEND);
|
|
|
|
186
|
-// $arr = [
|
|
|
|
187
|
-// 'ToUserName' => 'gh_27174ac5c9d8',
|
|
|
|
188
|
-// 'FromUserName' => 'oMbcI6gRzvfrU8ssGsEyvzXOO94w',
|
|
|
|
189
|
-// 'CreateTime' => '1693385898',
|
|
|
|
190
|
-// 'MsgType' => 'event',
|
|
|
|
191
|
-// 'Event' => 'subscribe',
|
|
|
|
192
|
-// 'EventKey' => 'qrscene_global-v6_v6',
|
|
|
|
193
|
-// 'Ticket' => 'gQF27zwAAAAAAAAAAS5odHRwOi8vd2VpeGluLnFxLmNvbS9xLzAyWnppdHhWTlRjOEcxTlBpTE5BY2IAAgRjBO9kAwQQDgAA',
|
|
|
|
194
|
-// ];
|
184
|
+// $data = $this->setWechat($arrayData['ToUserName'],$arrayData['EventKey']);
|
|
|
|
185
|
+// if($data['code'] == 0){//登录失败,请先绑定
|
|
|
|
186
|
+// $resMessage = $data['message'];
|
|
|
|
187
|
+// }elseif($data['code'] == 1){
|
|
|
|
188
|
+// $resMessage = $data['message'];
|
|
|
|
189
|
+// $info = $data['data'];
|
|
|
|
190
|
+// Cache::add($arrayData['Ticket'],$info,300);
|
|
|
|
191
|
+// }else{
|
|
|
|
192
|
+// $resMessage = $data['message'];
|
|
|
|
193
|
+// }
|
|
195
|
return "<xml>
|
194
|
return "<xml>
|
|
196
|
<ToUserName><![CDATA[$message->FromUserName]]></ToUserName>
|
195
|
<ToUserName><![CDATA[$message->FromUserName]]></ToUserName>
|
|
197
|
<FromUserName><![CDATA[$message->ToUserName]]></FromUserName>
|
196
|
<FromUserName><![CDATA[$message->ToUserName]]></FromUserName>
|
|
@@ -246,93 +245,17 @@ class LoginController extends BaseController |
|
@@ -246,93 +245,17 @@ class LoginController extends BaseController |
|
246
|
* @method :post
|
245
|
* @method :post
|
|
247
|
* @time :2023/8/31 9:13
|
246
|
* @time :2023/8/31 9:13
|
|
248
|
*/
|
247
|
*/
|
|
249
|
- public function wechatLogin($wechat){
|
|
|
|
250
|
- //查看当前账户是否绑定
|
|
|
|
251
|
- $userModel = new UserModel();
|
|
|
|
252
|
- $info = $userModel->read(['wechat'=>$wechat]);
|
|
|
|
253
|
- if($info === false){
|
|
|
|
254
|
- $data = [
|
|
|
|
255
|
- 'code'=>0,
|
|
|
|
256
|
- 'message'=>'当前用户未绑定账户,请绑定后登录',
|
|
|
|
257
|
- ];
|
|
|
|
258
|
- }else {
|
|
|
|
259
|
- //获取项目详情
|
|
|
|
260
|
- $info = $this->assembleParam($info['mobile'],$info['project_id']);
|
|
|
|
261
|
- if(isset($info['token']) && !empty($info['token'])){
|
|
|
|
262
|
- //清除上一次用户缓存
|
|
|
|
263
|
- Cache::pull($info['token']);
|
|
|
|
264
|
- }
|
|
|
|
265
|
- //生成新token
|
|
|
|
266
|
- $token = md5(uniqid().$info['id']);
|
|
|
|
267
|
- //存储缓存
|
|
|
|
268
|
- $info['token'] = $token;
|
|
|
|
269
|
- Cache::add($token,$info,3600);
|
|
|
|
270
|
- //更新用户信息
|
|
|
|
271
|
- $this->model->edit(['token'=>$token],['id'=>$info['id']]);
|
|
|
|
272
|
- $data = [
|
|
|
|
273
|
- 'code'=>1,
|
|
|
|
274
|
- 'message'=>'登陆成功',
|
|
|
|
275
|
- 'data'=>$info
|
|
|
|
276
|
- ];
|
248
|
+ public function setWechat($wechat,$eventKey){
|
|
|
|
249
|
+ $userLoginLogic = new UserLoginLogic();
|
|
|
|
250
|
+ $key = explode("_",$eventKey);
|
|
|
|
251
|
+ if($key[1] == 'login'){
|
|
|
|
252
|
+ $data = $userLoginLogic->wechatLogin($wechat);
|
|
|
|
253
|
+ }else{
|
|
|
|
254
|
+ $data = $userLoginLogic->wechatBind($wechat,$key[2]);
|
|
277
|
}
|
255
|
}
|
|
278
|
return $data;
|
256
|
return $data;
|
|
279
|
}
|
257
|
}
|
|
280
|
|
258
|
|
|
281
|
|
259
|
|
|
282
|
- public function ceshi(){
|
|
|
|
283
|
- $templateModel = new Template();
|
|
|
|
284
|
- $list = $templateModel->list();
|
|
|
|
285
|
- foreach ($list as $k => $v){
|
|
|
|
286
|
- preg_match_all('/\(https:\/\/admin.item.globalso.site\/a\/image\/(.*?)\)/', $v['html'], $matches);
|
|
|
|
287
|
- if (!empty($matches[1])) {
|
|
|
|
288
|
- $srcValues = $matches[1];
|
|
|
|
289
|
- $imageModel = new Image();
|
|
|
|
290
|
- $html = $v['html'];
|
|
|
|
291
|
- foreach ($srcValues as $srcValue) {
|
|
|
|
292
|
- $image_info = $imageModel->read(['hash' => $srcValue]);
|
|
|
|
293
|
- if ($image_info !== false) {
|
|
|
|
294
|
- $path = $image_info['path'];
|
|
|
|
295
|
- $html = $this->re($html, '/a/image/'.$srcValue, $path);
|
|
|
|
296
|
- }
|
|
|
|
297
|
- }
|
|
|
|
298
|
- $templateModel->edit(['html'=>$html],['id'=>$v['id']]);
|
|
|
|
299
|
- }
|
|
|
|
300
|
- }
|
|
|
|
301
|
- return 1;
|
|
|
|
302
|
- }
|
|
|
|
303
|
-
|
|
|
|
304
|
- public function re(&$html,$srcValue,$path){
|
|
|
|
305
|
- $html = str_replace(
|
|
|
|
306
|
- $srcValue,
|
|
|
|
307
|
- $path,
|
|
|
|
308
|
- $html
|
|
|
|
309
|
- );
|
|
|
|
310
|
- return $html;
|
|
|
|
311
|
- }
|
|
|
|
312
|
|
260
|
|
|
313
|
- public function updateHtml(){
|
|
|
|
314
|
- $html = $this->re($v['html'],'develop.globalso.com','ecdn6.globalso.com');
|
|
|
|
315
|
- $html = $this->re($v['html'],'develop.globalso.com','ecdn6.globalso.com');
|
|
|
|
316
|
- }
|
|
|
|
317
|
-
|
|
|
|
318
|
- public function updateCe(){
|
|
|
|
319
|
- $templateModel = new TemplateModule();
|
|
|
|
320
|
- $list = [];
|
|
|
|
321
|
- foreach ($list as $k => $v){
|
|
|
|
322
|
- preg_match_all('/\"https:\/\/develop.globalso.com\/a\/image\/(.*?)\"/', $v['html'], $matches);
|
|
|
|
323
|
- if (!empty($matches[1])) {
|
|
|
|
324
|
- $srcValues = $matches[1];
|
|
|
|
325
|
- $imageModel = new Image();
|
|
|
|
326
|
- $html = $v['html'];
|
|
|
|
327
|
- foreach ($srcValues as $srcValue) {
|
|
|
|
328
|
- $image_info = $imageModel->read(['hash' => $srcValue]);
|
|
|
|
329
|
- if ($image_info !== false) {
|
|
|
|
330
|
- $path = basename($image_info['path']);
|
|
|
|
331
|
- $html = $this->re($html, $srcValue, $path);
|
|
|
|
332
|
- }
|
|
|
|
333
|
- }
|
|
|
|
334
|
- }
|
|
|
|
335
|
- $templateModel->edit(['html'=>$html],['id'=>$v['id']]);
|
|
|
|
336
|
- }
|
|
|
|
337
|
- }
|
|
|
|
338
|
} |
261
|
} |