小程序与H5互通

This commit is contained in:
gongfuxiang 2019-06-29 23:55:47 +08:00
parent f107554ee0
commit 4315c44cc5
4 changed files with 7 additions and 10 deletions

View File

@ -42,16 +42,17 @@ class UserService
$user = null; $user = null;
if(APPLICATION == 'web') if(APPLICATION == 'web')
{ {
// web用户session
$user = session('user');
// token仅小程序浏览器环境和api接口环境中有效 // token仅小程序浏览器环境和api接口环境中有效
if(!empty($params['token']) && in_array(MiniAppEnv(), ['weixin', 'alipay', 'baidu'])) if(empty($user) && !empty($params['token']) && in_array(MiniAppEnv(), ['weixin', 'alipay', 'baidu']))
{ {
$user = cache(config('shopxo.cache_user_info').$params['token']); $user = cache(config('shopxo.cache_user_info').$params['token']);
if(isset($user['id'])) if(isset($user['id']))
{ {
self::UserLoginRecord($user['id']); self::UserLoginRecord($user['id']);
} }
} else {
$user = session('user');
} }
} else { } else {
if(!empty($params['token'])) if(!empty($params['token']))

View File

@ -20,8 +20,6 @@ Page({
} }
} }
this.setData({ this.setData({web_url: url});
web_url: url,
});
} }
}); });

View File

@ -61,7 +61,7 @@ App({
// 请求地址 // 请求地址
// request_url: "{{request_url}}", // request_url: "{{request_url}}",
request_url: 'http://tp5-dev.com/', request_url: 'http://tp5-dev.com/',
//request_url: 'https://test.shopxo.net/', request_url: 'https://test.shopxo.net/',
// 基础信息 // 基础信息
application_title: "{{application_title}}", application_title: "{{application_title}}",

View File

@ -20,8 +20,6 @@ Page({
} }
} }
this.setData({ this.setData({web_url: url});
web_url: url,
});
} }
}); });