Dim e As RequestEventArgs = args(0)
Dim wb As New WeUI '定义一个基于weui框架的网页生成器
Dim ds As Row = Tables("网页表").Current
Tables("网页表").current("访问次数") = Tables("网页表").current("访问次数")+1
'MessageBox.Show(ds("网页"))
加上黄色部分就显示网页不存在 去掉就正常
Select Case e.Path
Case ds("网页")
Dim bm As String
Dim gw As String
Dim name As String
Dim userid = Functions.Execute("验证函数",e,ds("网页"))
If userid > "" Then
wb.AppendCookie("userid",userid) '将用户名和密码写入cookie
Dim wxdr As DataRow = DataTables("users").SQLFind("userid='" & userid & "'")
If wxdr IsNot Nothing Then
gw = wxdr("position")
name = wxdr("name")
Dim wxdr1 As DataRow = DataTables("departments").SQLFind("id='" & wxdr("department") & "'")
If wxdr1 IsNot Nothing Then
bm= wxdr1("name")
End If
e.WriteString(name & userid & "USERID获取成功" & gw & bm)
''------------------------------------------------------------------------------------------------------------------------------
wb.AddPageTitle("","pageheader",ds("二级分类"),ds("网页名称"))
With wb.AddTable("","Table1")
.RowHead = 1 '左边第一列作为行头
.Alternate = 3
Dim nms() As String = {"用户姓名","客户等级","客户地址","用户手机","互动" ,"状态"}
.Head.AddRow(nms)
For Each r As DataRow In DataTables("终端客户").sqlSelect("[业务经理] = '" & User.Name & "'", "", "日期 Desc")
With .Body.AddRow(r("用户姓名"),r("客户等级"),r("楼盘") & r("单元房号"),"<a href='tel:" & r("用户手机") & "' >>" & r("用户手机") & "</a>",r("互动次数"),r("状态"))
'.AddCell(Format(r("日期"),"MM月dd日"))
End With
Next
End With
e.WriteString(wb.Build)
'-----------------------------------------------------------------------------------
End If
End If
End Select
验证函数
Dim e As RequestEventArgs = args(0)
Dim url As String = args(1)
Dim UserId As String
Dim sb As New StringBuilder
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")
End If
If UserId > "" then'授权成功
e.AppendCookie("userid",UserId) '将userid和username存储在Cookie中
Return UserId
ElseIf e.GetValues.ContainsKey("code") = False Then '如果授权失败,且不是通过授权链接跳转而来,那么就跳转到授权链接
Dim ul1 As String = "https://open.weixin.qq.com/connect/oauth2/authorize?appid={0}&redirect_uri={1}&response_type=code&scope=SCOPE&agentid=AGENTID&state=STATE#wechat_redirect"
Dim CorpID As String
Dim kxym As String
CorpID= Tables("基础资料表").Current("CorpID") '企业号的CorpID
kxym = Tables("基础资料表").Current("可信域名")
Dim ul2 As String
ul2= UrlEncode("http://" & kxym & "/" & url)
ul1 = CExp(ul1,CorpID,ul2)
sb.Append("<meta http-equiv='Refresh' c>") '跳转到授权链接
e.WriteString(sb.ToString)
Return ""
End If
[此贴子已经被作者于2021/8/31 23:36:12编辑过]