老师,您好。
1、员工接收到模板信息,点击“详情”登录,"详情"链接如下所示:
jo("url") = "http://abc.cn/abc.htm?key=" & PrimaryKey & "&page=" & PageNumber & "&from=2" '数据详细页面
2、员工若当天第1次登录,需要先获取openid,会登录到首页:http://abc.cn
需要关闭次页面,再点击“详情”,才能到达目标页面(即要登录2次):http://abc.cn/abc.htm
当天后续的登录,因为openid已经存在,所以都会到达目标页面。
咨询:授权登录页面要如何修改?
If e.host = "abc.cn" Then '需要授权才能访问的域名.
Dim OpenID As String
Dim sb As New StringBuilder
sb.AppendLine("<meta name='viewport' c>")
If e.GetValues.ContainsKey("code") Then '如果通过授权链接跳转而来,就根据传递过来的code参数调用接口,获取用户的OpenID
Dim ul As String = "https://api.weixin.qq.com/sns/oauth2/access_token?appid={0}&secret={1}&code={2}&grant_type=authorization_code"
ul = CExp(ul,"wxd123***","333***",e.GetValues("code"))
Dim hc As new HttpClient(ul)
Dim jo As JObject = JObject.Parse(hc.GetData)
If jo("openid") IsNot Nothing Then
OpenID = jo("openid")
e.AppendCookie("openid",OpenID) '将openid存储在Cookie中,后续使用此openid
End If
Else
OpenId = e.Cookies("openid") '否则从cookie中提取openid
End If
Dim Verified As Boolean
Dim dr As DataRow = DataTables("Users").SQLFind("openid ='" & OpenID & "'") '从登录用户表中,根据openid找出对应的行
If OpenId > "" AndAlso dr IsNot Nothing AndAlso dr("离职") = 0 Then '存在需要访问者的openid,而且未离职.
Verified = True
ElseIf e.GetValues.ContainsKey("code") = False Then '如果授权失败,且不是通过授权链接跳转而来,那么就跳转到授权链接
Dim ul As String = "https://open.weixin.qq.com/connect/oauth2/authorize?appid=wxd***&redirect_uri=http%3a%2f%2fabc.cn&response_type=code&scope=snsapi_base&state=123#wechat_redirect"
sb.Append("<meta h t t p-equiv='Refresh' c o ntent='0; u r l=" & ul & "'>") '跳转到授权链接
e.WriteString(sb.ToString)
Return '必须的
End If
Dim wb As New weui
If Verified = False Then
wb.InsertHTML("<meta h t t p-equiv='Refresh' c o ntent='0; url=/***.htm'>") '直接跳转到登录页,显示无登录权限.
e.WriteString(wb.Build) '生成网页
Return '必须的
ElseIf e.path = "" Then '从登录页访问
wb.InsertHTML("<meta h t t p-equiv='Refresh' c o ntent='0; url=/d efault.htm'>") '直接跳转到首页
e.WriteString(wb.Build) '生成网页
Return '必须的
End If
End If
Select Case e.path
Case "abc.htm"
Functions.Execute("abc",e)
End Select
[此贴子已经被作者于2019/3/13 17:18:39编辑过]