以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.net/bbs/index.asp)
--  专家坐堂  (http://foxtable.net/bbs/list.asp?boardid=2)
----  e.Cookies("userid")怎么不见了  (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=159142)

--  作者:aidimeng
--  发布时间:2020/12/15 15:14:00
--  e.Cookies("userid")怎么不见了
Dim fl As String = "c:\\web\\" & e.Path
If filesys.FileExists(fl)
    Dim idx As Integer = fl.LastIndexOf(".")
    Dim ext As String  = fl.SubString(idx)
    Select Case ext
        Case ".jpg",".gif",".png",".bmp",".wmf",".js",".css" ,".html",".htm",".zip",".rar"
            e.WriteFile(fl)
            Return \'这里必须返回
    End Select
End If
Dim wb As New weui
Dim Verified As Boolean
Dim UserId As String
Dim UserName As String

Select Case e.path
    Case "Remuneration"  \'工资信息
        \'       Dim e As RequestEventArgs = args(0)
        
        Dim sb As New StringBuilder
        sb.AppendLine("<meta name=\'viewport\' c>")
        If e.GetValues.ContainsKey("code") Then \'如果通过授权链接跳转而来,就根据传递过来的code参数调用接口,获取用户的UserId
            \'MessageBox.Show("通过授权链接进入")
            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")
                \'MessageBox.Show("通过授权链接包含信息:" & userid)
            End If
        Else
            UserId = e.Cookies("userid") \'否则从cookie中提取userid
            Vars("userid")= e.Cookies("userid")
            \'MessageBox.Show("通过cookies获取:" & userid)
        End If
        
        Dim drc As DataRow = DataTables("员工花名册").Find("企业微信号ID =\'" & UserId & "\'") \'根据openid找出对应的行
        If UserId  <> "" AndAlso drc IsNot Nothing  AndAlso drc("微信权限") = 1 \'授权成功
            Verified  = True
            UserName = drc("姓名")
            wb.AppendCookie("userid",UserId) \'将userid和username存储在Cookie中
            e.AppendCookie("userid",UserId)
            
        ElseIf e.GetValues.ContainsKey("code") = False Then \'如果授权失败,且不是通过授权链接跳转而来,那么就跳转到授权链接
            \'MessageBox.Show("跳转授权链接" & userid)
            Dim ul As String = "https://open.weixin.qq.com/connect/oauth2/authorize?appid={0}&redirect_uri={1}&response_type=code&scope=snsapi_base&agentid={2}&state=STATE#wechat_redirect"
            Dim ul2 As String = UrlEncode(Vars("yyzy"))
            ul = CExp(ul,Vars("qyid"),ul2,Vars("yyid"))
            \'Dim ul As String = "https://open.weixin.qq.com/connect/oauth2/authorize?appid=ww8bbc1c6c7bd8a2e7&redirect_uri=http%3a%2f%2fgz.crucg.top%3a8090%2fRemuneration&response_type=code&scope=snsapi_base&agentid=1000002&state=STATE#wechat_redirect"
            sb.Append("<meta http-equiv=\'Refresh\' c>") \'跳转到授权链接%3a8090
            wb.InsertHTML(sb.ToString)
            e.WriteString(wb.Build)
            Return
        End If
        If Verified = False Then
            \'MessageBox.Show("授权不通过:" & userid)
            sb.AppendLine("你无权访问本系统")
        Else
            \'MessageBox.Show("通过,进入主页")
            wb.InsertHTML ("<meta http-equiv=\'Refresh\' c>")
            e.WriteString(wb.Build)
            \'    sb.AppendLine("欢迎" & UserName & "同志使用本系统,授权成功!请" & " , <a href=\'http://www.crucg.top/Remuneration2\'>刷新页面后进去</a>")
        End If
        
        wb.InsertHTML(sb.ToString)
        e.WriteString(wb.Build)
        wb.AppendCookie("userid",UserId)
    Case "Remuneration2"
        
        
        If e.Cookies.ContainsKey("userid") =False Then
            
            e.WriteString("非法访问")
            Return
        End If
        e.AsyncExecute = True
        Functions.AsyncExecute("Remuneration2",e)
        MessageBox.Show("Remuneration2:" & e.Cookies("userid") )  这里 e.Cookies("userid") 还有值, 下面 在访问
    Case "mx"
        
        If e.Cookies.ContainsKey("userid") =False Then
            e.WriteString("非法访问")
            Return
        End If
        e.AsyncExecute = True
        Functions.AsyncExecute("mx",e)
        
        MessageBox.Show("mx:" & e.Cookies("userid") )
    Case "order.xls"
        If e.Cookies.ContainsKey("userid") =False Then
            e.WriteString("非法访问")
            Return
        End If
        e.AsyncExecute = True
        Functions.AsyncExecute("CreateXLS",e)
    Case "tongji"
        MessageBox.Show("6:" & e.Cookies("userid") )  这里 e.Cookies("userid") 就没有值了,访问到这里 提示 非法访问
        
        If e.Cookies.ContainsKey("userid") =False Then
            e.WriteString("非法访问")
            Return
            
        End If
        e.AsyncExecute = True
        Functions.AsyncExecute("tongji",e)
        MessageBox.Show("7:" & e.Cookies("userid") )
        
    Case "tongjit"
        If e.Cookies.ContainsKey("userid") =False Then
            e.WriteString("非法访问")
            Return
        End If
        e.AsyncExecute = True
        Functions.AsyncExecute("tongjit",e)
End Select

--  作者:有点蓝
--  发布时间:2020/12/15 15:22:00
--  
tongji页面是从哪里进来的?如果是直接访问的肯定没有,只有通过Remuneration页面打开并且切换跳转的才会有
--  作者:aidimeng
--  发布时间:2020/12/15 15:25:00
--  
Dim e As RequestEventArgs = args(0)
Dim drg As new List(of DataRow)
Dim userid As String = e.Cookies("userid")
\'Return("Remuneration2中的 cook" & e.Cookies("userid"))
Dim dr As DataRow = DataTables("员工花名册").SQLFind("企业微信号ID = \'"& userid &"\'")
drg = DataTables("职工工资发放明细表").SQLSelect("身份证号 = \'"& dr("身份证号") &"\'and 公布 = 1 ",24,"月份 desc")
Dim wb As New weui
wb.AddPageTitle("","pageheader","员工工资条",Vars("dwmc"))
wb.AddForm("","form1","Remuneration.htm")
If drg IsNot Nothing Then
    With wb.AddListGroup("", "lsg1", dr("姓名") & "同志,以下是您近2年的薪酬信息")
        For Each dg As DataRow In drg
            .Add("lsg" & dg("_Identify"),dg("月份") & "工资", "实发工资:" & dg("实发工资"), Vars("fwqip") & "mx?zhujian=" & dg("_Identify") )
        Next
    End With
End If

With wb.AddTabBar("", "tb1", 1)
    .AddButton("bt1","当年全年薪酬收入情况","./images/tongji.png",Vars("fwqip") & "tongji")
    .AddButton("bt2","往年全年薪酬收入情况","./images/tongji2.png",Vars("fwqip") & "/tongjit")
End With
e.WriteString(wb.Build)
e.Handled = True

内部函数 Remuneration2 ,这里怎么修改啊

--  作者:有点蓝
--  发布时间:2020/12/15 15:40:00
--  
.AddButton("bt1","当年全年薪酬收入情况","./images/tongji.png","./tongji")