Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
starsw001
ShopXO
提交
a11b758d
ShopXO
项目概览
starsw001
/
ShopXO
与 Fork 源项目一致
Fork自
纵之格 / ShopXO
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
ShopXO
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
a11b758d
编写于
1月 17, 2019
作者:
G
gongfuxiang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
wechat mini login
上级
b8b33d51
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
44 addition
and
47 deletion
+44
-47
application/api/controller/User.php
application/api/controller/User.php
+1
-1
public/appmini/old/weixin/app.js
public/appmini/old/weixin/app.js
+38
-43
public/appmini/old/weixin/pages/login/login.js
public/appmini/old/weixin/pages/login/login.js
+5
-3
未找到文件。
application/api/controller/User.php
浏览文件 @
a11b758d
...
...
@@ -142,7 +142,7 @@ class User extends Common
$result
[
'referrer'
]
=
isset
(
$this
->
data_post
[
'referrer'
])
?
intval
(
$this
->
data_post
[
'referrer'
])
:
0
;
return
UserService
::
AuthUserProgram
(
$result
,
'weixin_openid'
);
}
return
DataReturn
(
'获取用户信息失败'
,
-
100
);
return
DataReturn
(
empty
(
$result
)
?
'获取用户信息失败'
:
$result
,
-
100
);
}
/**
...
...
public/appmini/old/weixin/app.js
浏览文件 @
a11b758d
...
...
@@ -60,7 +60,7 @@ App({
// 请求地址
request_url
:
"
{{request_url}}
"
,
//
request_url: 'https://test.shopxo.net/',
request_url
:
'
https://test.shopxo.net/
'
,
// 基础信息
application_title
:
"
{{application_title}}
"
,
...
...
@@ -192,8 +192,9 @@ App({
* 用户登录
* object 回调操作对象
* method 回调操作对象的函数
* auth_data 授权数据
*/
user_auth_login
(
object
,
method
)
{
user_auth_login
(
object
,
method
,
auth_data
)
{
wx
.
showLoading
({
title
:
"
授权中...
"
});
var
$this
=
this
;
wx
.
checkSession
({
...
...
@@ -201,9 +202,9 @@ App({
var
openid
=
wx
.
getStorageSync
(
$this
.
data
.
cache_user_login_key
);
if
((
openid
||
null
)
==
null
)
{
$this
.
user_login
(
object
,
method
);
$this
.
user_login
(
object
,
method
,
auth_data
);
}
else
{
$this
.
get_user_login_info
(
object
,
method
,
openid
);
$this
.
get_user_login_info
(
object
,
method
,
openid
,
auth_data
);
}
},
fail
:
function
()
{
...
...
@@ -216,8 +217,9 @@ App({
* 用户登录
* object 回调操作对象
* method 回调操作对象的函数
* auth_data 授权数据
*/
user_login
(
object
,
method
)
{
user_login
(
object
,
method
,
auth_data
)
{
var
$this
=
this
;
wx
.
login
({
success
:
(
res
)
=>
{
...
...
@@ -234,7 +236,7 @@ App({
key
:
$this
.
data
.
cache_user_login_key
,
data
:
res
.
data
.
data
});
$this
.
get_user_login_info
(
object
,
method
,
res
.
data
.
data
);
$this
.
get_user_login_info
(
object
,
method
,
res
.
data
.
data
,
auth_data
);
}
else
{
wx
.
hideLoading
();
$this
.
showToast
(
res
.
data
.
msg
);
...
...
@@ -259,48 +261,41 @@ App({
* object 回调操作对象
* method 回调操作对象的函数
* openid 用户openid
* auth_data 授权数据
*/
get_user_login_info
(
object
,
method
,
openid
)
{
get_user_login_info
(
object
,
method
,
openid
,
auth_data
)
{
var
$this
=
this
;
wx
.
getUserInfo
({
withCredentials
:
true
,
success
:
function
(
res
)
{
// 远程解密数据
wx
.
request
({
url
:
$this
.
get_request_url
(
'
WechatUserInfo
'
,
'
user
'
),
method
:
'
POST
'
,
data
:
{
encrypted_data
:
res
.
encryptedData
,
iv
:
res
.
iv
,
openid
:
openid
},
dataType
:
'
json
'
,
header
:
{
'
content-type
'
:
'
application/x-www-form-urlencoded
'
},
success
:
(
res
)
=>
{
wx
.
hideLoading
();
if
(
res
.
data
.
code
==
0
)
{
wx
.
setStorage
({
key
:
$this
.
data
.
cache_user_info_key
,
data
:
res
.
data
.
data
,
success
:
(
res
)
=>
{
if
(
typeof
object
===
'
object
'
&&
(
method
||
null
)
!=
null
)
{
object
[
method
]();
}
},
fail
:
()
=>
{
$this
.
showToast
(
'
用户信息缓存失败
'
);
}
});
}
else
{
$this
.
showToast
(
res
.
data
.
msg
);
// 远程解密数据
wx
.
request
({
url
:
$this
.
get_request_url
(
'
WechatUserInfo
'
,
'
user
'
),
method
:
'
POST
'
,
data
:
{
encrypted_data
:
auth_data
.
encryptedData
,
iv
:
auth_data
.
iv
,
openid
:
openid
},
dataType
:
'
json
'
,
header
:
{
'
content-type
'
:
'
application/x-www-form-urlencoded
'
},
success
:
(
res
)
=>
{
wx
.
hideLoading
();
if
(
res
.
data
.
code
==
0
)
{
wx
.
setStorage
({
key
:
$this
.
data
.
cache_user_info_key
,
data
:
res
.
data
.
data
,
success
:
(
res
)
=>
{
if
(
typeof
object
===
'
object
'
&&
(
method
||
null
)
!=
null
)
{
object
[
method
]();
}
},
fail
:
()
=>
{
$this
.
showToast
(
'
用户信息缓存失败
'
);
}
},
fail
:
()
=>
{
wx
.
hideLoading
();
$this
.
showToast
(
'
服务器请求出错
'
);
},
});
});
}
else
{
$this
.
showToast
(
res
.
data
.
msg
);
}
},
fail
:
(
e
)
=>
{
fail
:
()
=>
{
wx
.
hideLoading
();
$this
.
showToast
(
'
获取用户信息失败
'
);
}
$this
.
showToast
(
'
服务器请求出错
'
);
}
,
});
},
...
...
public/appmini/old/weixin/pages/login/login.js
浏览文件 @
a11b758d
...
...
@@ -30,15 +30,17 @@ Page({
* 登录授权事件
*/
get_user_info_event
(
e
)
{
this
.
user_auth_code
();
console
.
log
(
e
);
this
.
user_auth_code
(
null
,
null
,
e
.
detail
);
},
/**
* 用户授权
* object 回调操作对象
* method 回调操作对象的函数
* auth_data 授权数据
*/
user_auth_code
(
object
,
method
)
{
user_auth_code
(
object
,
method
,
auth_data
)
{
// 请求授权接口
var
$this
=
this
;
wx
.
getSetting
({
...
...
@@ -46,7 +48,7 @@ Page({
if
(
!
res
.
authSetting
[
'
scope.userInfo
'
])
{
$this
.
setData
({
user
:
null
});
}
else
{
app
.
user_auth_login
(
$this
,
'
user_auth_back_event
'
);
app
.
user_auth_login
(
$this
,
'
user_auth_back_event
'
,
auth_data
);
}
},
fail
:
(
e
)
=>
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录