……
dr("ThumbMediaId") = xo("ThumbMediaId")
dr("PicUrl") = xo("PicUrl")
dr("Content") = xo("Content")
dr("Format") = xo("Format")
dr.save
End Select
End If
return
End Select
If e.host <> "$$$$$$$$.idcfengye.com" Then return '需要授权才能访问的域名
if e.path = "" then
Dim UserId As String
Dim UserName As String
Dim sb As New StringBuilder
sb.AppendLine("<meta name='viewport' c>")
If e.GetValues.ContainsKey("code") Then '如果通过授权链接跳转而来,就根据传递过来的code参数调用接口,获取用户的UserId
Dim ul As String = "https://qyapi.weixin.qq.com/cgi-bin/user/getuserinfo?access_token={0}&code={1}"
ul = CExp(ul,Functions.Execute("GetQYAccessToken"),e.GetValues("code"))
Dim hc As new HttpClient(ul)
Dim jo As JObject = JObject.Parse(hc.GetData)
If jo("UserId") IsNot Nothing Then
UserId = jo("UserId")
End If
Else
UserId = e.Cookies("userid") '否则从cookie中提取userid和username
End If
Dim Verified As Boolean
Dim dr As DataRow = DataTables("WXUsers").Find("userid ='" & UserId & "'") '根据openid找出对应的行
If UserId > "" AndAlso dr IsNot Nothing AndAlso dr("permit") = True '授权成功
Verified = True
UserName = dr("name")
e.AppendCookie("userid",UserId) '将userid和username存储在Cookie中
ElseIf e.GetValues.ContainsKey("code") = False Then '如果授权失败,且不是通过授权链接跳转而来,那么就跳转到授权链接
Dim ul As String = "https://open.weixin.qq.com/connect/oauth2/authorize?appid=$$$$$$$$$$$$8&redirect_uri=http%3a%2f%2fctterp.vipgz1.idcfengye.com&response_type=code&scope=snsapi_base&state=123#wechat_redirect"
sb.Append("<meta http-equiv='Refresh' content='0; url=" & ul & "'>") '跳转到授权链接
e.WriteString(sb.ToString)
Return
End If
If Verified = False Then
sb.AppendLine("你无权访问本系统")
Else
sb.Append("<meta http-equiv='Refresh' content='0; url= http://ctterp.vipgz1.idcfengye.com/default.htm'>")
End If
e.WriteString(sb.ToString)
return
end if
Select Case e.Path
Case "", "default.htm" '首页
wb.AddPageTitle("","pageheader","ERP")
wb.AddPageFooter("","pf1","Copyright @ 技术有限公司")
With wb.AddGrid("","g1")
.Add("c1","报告查询", "./images/notepad.png", "filter.htm")
……