12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758 |
- <?php
-
-
- namespace app\api\model\v1;
-
- use think\Db;
- use think\Cache;
-
-
- class UserBase extends Base
- {
- public $users_id;
- public $session;
-
-
- protected function initialize()
- {
-
- parent::initialize();
-
- $token = input('param.token/s');
- if (!empty($token)) {
- $tokenDecode = mchStrCode($token, 'DECODE', '#!@diyminipro#!$');
- if (preg_match_all('/^([0-9a-zA-Z]{8})eyoucms(\d{1,})eyoucms(.+)eyoucms([a-z]{8})eyoucms(.+)eyoucms_token_salt$/i', $tokenDecode, $matches)) {
- $this->users_id = !empty($matches[2][0]) ? intval($matches[2][0]) : 0;
- $openid = !empty($matches[3][0]) ? $matches[3][0] : '';
- $session_key = !empty($matches[5][0]) ? $matches[5][0] : '';
-
- $this->session = [
- 'openid' => $openid,
- 'session_key' => $session_key,
- 'users_id' => $this->users_id,
- ];
- Cache::set($token, $this->session, 86400 * 7);
- }
- }
-
-
- if (!empty($this->users_id)) {
-
-
-
- model('OrderPreHandle')->eyou_shopOrderPreHandle($this->users_id);
- }
- }
- }
|