以文本方式查看主题 - Foxtable(狐表) (http://foxtable.com/bbs/index.asp) -- 专家坐堂 (http://foxtable.com/bbs/list.asp?boardid=2) ---- [求助]如何将这两个网页写在一起? (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=97299) |
|
-- 作者:xietan417 -- 发布时间:2017/3/9 14:53:00 -- [求助]如何将这两个网页写在一起? 这段代码是取得当前用户的userid If e.host = "qwe.ngrok.cc" 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("统计").Find("userid =\'" & UserId & "\'") \'根据openid找出对应的行 If UserId > "" AndAlso dr IsNot Nothing \'授权成功 Verified = True UserName = dr("姓名") 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=*************&redirect_uri=http%3a%2f%2fqwe.ngrok.cc&response_type=code&scope=snsapi_base&state=123#wechat_redirect" sb.Append("<meta http-equiv=\'Refresh\' c>") \'跳转到授权链接 e.WriteString(sb.ToString) Return End If If Verified = False Then sb.AppendLine("你无权访问本系统") Else sb.AppendLine("欢迎" & UserName & " , <a href=\'http://qwe.ngrok.cc\'>刷新页面</a>") End If e.WriteString(sb.ToString) End If 这段是通过UserId 来筛选考勤数据! Select Case e.Path Case "list.htm" Dim page As Integer = 0 \'默认page为0,显示第一页 Dim pageRows As Integer = 30 \'每页10行 If e.GetValues.ContainsKey("page") Then \'如果地址中有page参数 Integer.TryParse(e.GetValues("page"), page) \'提取page参数 End If Dim StartRow As Integer = page * pageRows \'此页第一行 Dim EndRow As Integer = (page + 1) * pageRows - 1 \'此页最后一行 Dim lst As List(of DataRow) = DataTables("统计").Select("userid =\'" & UserId & "\'","日期 Desc") \'按日期顺序显示 If StartRow > lst.Count -1 Then e.WriteString("已经是最后一页!") Return End If EndRow = Math.Min(EndRow, lst.Count - 1) \'这是必须的 Dim sb As New StringBuilder Dim nms() As String = {"姓名","日期","星期","t1","t2","t3","t4","t6"} sb.AppendLine("<Table border=\'1\'>") sb.AppendLine("<caption>考勤浏览<caption></br>") sb.Append("<tr>") For Each nm As String In nms sb.Append("<td>" & nm & "</td>") Next sb.AppendLine("</tr>") For r As Integer = StartRow To EndRow sb.Append("<tr>") For Each nm As String In nms sb.Append("<td>" & lst(r)(nm) & "</td>") Next sb.AppendLine("</tr>") Next sb.AppendLine("</Table></br></br>") If page > 0 Then sb.Append("<a href=\'list.htm?page=" & page - 1 & "\'>上一页</a> ") End If If EndRow < lst.Count -1 Then sb.Append("<a href=\'list.htm?page=" & page + 1 & "\'>下一页 </a>" ) End If e.WriteString(sb.ToString) End Select 要实现效果是通过企业号的微信id来查询每个员工自己的考勤数据!代码我已经分开测试成功!就是不知道怎么合在一起了!惭愧啊! [此贴子已经被作者于2017/3/9 14:53:59编辑过]
|
|
-- 作者:有点色 -- 发布时间:2017/3/9 15:02:00 -- 直接写在一起,再判断一下。
第一段 e.WriteString(sb.ToString)
改成
If e.path = "登陆验证页" OrElse Verified = False Then e.WriteString(sb.ToString) Return End If [此贴子已经被作者于2017/3/9 15:04:38编辑过]
|
|
-- 作者:xietan417 -- 发布时间:2017/3/9 15:10:00 -- 还是不太明白你的意思!在Else 后面加上第二段代码?
[此贴子已经被作者于2017/3/9 15:10:17编辑过]
|
|
-- 作者:有点色 -- 发布时间:2017/3/9 15:11:00 -- 直接写两段。然后改一下
If e.path = "登陆验证页" OrElse Verified = False Then e.WriteString(sb.ToString) Return End If |
|
-- 作者:xietan417 -- 发布时间:2017/3/9 15:26:00 -- 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=*************&redirect_uri=http%3a%2f%2fqwe.ngrok.cc&response_type=code&scope=snsapi_base&state=123#wechat_redirect" sb.Append("<meta http-equiv=\'Refresh\' c>") Select Case e.Path Case "list.htm" Dim page As Integer = 0 Dim pageRows As Integer = 30 If e.GetValues.ContainsKey("page") Then Integer.TryParse(e.GetValues("page"), page) End If Dim StartRow As Integer = page * pageRows Dim EndRow As Integer = (page + 1) * pageRows - 1 Dim lst As List(of DataRow) = DataTables("统计").Select("userid =\'" & UserId & "\'","日期 Desc") If StartRow > lst.Count -1 Then e.WriteString("已经是最后一页!") Return End If EndRow = Math.Min(EndRow, lst.Count - 1) \'这是必须的 Dim sb As New StringBuilder Dim nms() As String = {"姓名","日期","星期","t1","t2","t3","t4","t6"} sb.AppendLine("<Table border=\'1\'>") sb.AppendLine("<caption>考勤浏览<caption></br>") sb.Append("<tr>") For Each nm As String In nms sb.Append("<td>" & nm & "</td>") Next sb.AppendLine("</tr>") For r As Integer = StartRow To EndRow sb.Append("<tr>") For Each nm As String In nms sb.Append("<td>" & lst(r)(nm) & "</td>") Next sb.AppendLine("</tr>") Next sb.AppendLine("</Table></br></br>") If page > 0 Then sb.Append("<a href=\'list.htm?page=" & page - 1 & "\'>上一页</a> ") End If If EndRow < lst.Count -1 Then sb.Append("<a href=\'list.htm?page=" & page + 1 & "\'>下一页 </a>" ) End If e.WriteString(sb.ToString) End Select
|
|
-- 作者:xietan417 -- 发布时间:2017/3/9 15:27:00 -- 字节限制我把第一段前面的给删除了!这样改? |
|
-- 作者:有点色 -- 发布时间:2017/3/9 15:31:00 -- 第一段
If Verified = False Then
sb.AppendLine("你无权访问本系统")
Else
sb.AppendLine("欢迎" & UserName & " , <a href=\'http://qwe.ngrok.cc\'>刷新页面</a>")
End If
e.WriteString(sb.ToString)
End If
红色改成
If e.path = "登陆验证页" OrElse Verified = False Then e.WriteString(sb.ToString) Return End If |
|
-- 作者:xietan417 -- 发布时间:2017/3/9 16:07:00 -- 第二段代码应该放在哪里?刚刚试了一下不行呢! |
|
-- 作者:有点色 -- 发布时间:2017/3/9 16:48:00 -- 第二段代码放在下面。不可能不行。请加入msgbox调试你的代码。 |
|
-- 作者:xietan417 -- 发布时间:2017/3/10 11:05:00 -- 已经改好!谢谢你的指点! |