Rss & SiteMap

Foxtable(狐表) http://www.foxtable.com

新一代数据库软件,完美融合Access、Foxpro、Excel、vb.net之优势,人人都能掌握的快速软件开发工具!
共62 条记录, 每页显示 10 条, 页签: [1][2] [3] [4][5][6][7]
[浏览完整版]

标题:扫码带参数如何做

21楼
xuzihang 发表于:2024/6/14 17:41:00
加了,还是到这一步  If e.GetValues.ContainsKey("tjr") Then 
[此贴子已经被作者于2024/6/14 17:41:23编辑过]
22楼
有点蓝 发表于:2024/6/17 8:47:00
怎么加的?哪些调试窗口可以弹出,哪些不可以?
23楼
xuzihang 发表于:2024/6/17 13:03:00
                         If e.GetValues.ContainsKey("tjr") Then     到这一步过不去,没到保存就跳过去了
                        dr("客户来源_KHID") = e.GetValues("tjr") 
                        dr.Save
                    End If


老师我改过来了,还是走不过去?哪里不对么?
24楼
有点蓝 发表于:2024/6/17 13:32:00
把加了调试代码的全部完整代码发上来
25楼
xuzihang 发表于:2024/6/17 14:28:00
Dim sb As New StringBuilder
sb
.AppendLine("<meta name='viewport' c>")
If
e.host = "wexin.foxtable.com" Then '授权测试
    Dim UserName As String   Dim OpenID As String
    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,"wx8acdb7df5beb68fd","dec0df8a469518df30e9bdef0758c678",e.GetValues("code"))
        Dim hc As new HttpClient(ul)
        Dim jo As JObject = JObject.Parse(hc.GetData)
        If jo("openid") IsNot Nothing Then '
如果获取openid成功(成功的话,还会同时返回一个accesstiken,用于获取用户详情)
            OpenID = jo("openid")
            Dim dr As DataRow = DataTables("WXUsers").Find("openid ='" & Openid & "'")
            If dr IsNot Nothing Then
                UserName = dr("nickname"Else   ul = "https://api.weixin.qq.com/sns/userinfo?access_token={0}&openid={1}&lang=zh_CN "
                '
根据openidaccesstoken获取用户详情,注意这里这个accesstoken不是普通accesston,只能用于网页授权
                hc = New HttpClient(CExp(ul, jo("access_token"), OpenId))
                jo = jo.Parse(hc.GetData)
                If jo("openid") IsNot Nothing Then
                    UserName = jo("nickname")
                    dr = DataTables("WXUsers").AddNew()
                    Dim nms() As String = {"openid","nickname","sex","city","country","province","headimgurl"} '""
                    For Each nm As String In nms
                        dr(nm) = jo(nm)
                    Next
                      If e.GetValues.ContainsKey("tjr") Then               卡在这里导致不保存,直接调在下面的  的 ("你无权访问本系统")
                                             dr("客户来源_KHID") = e.GetValues("tjr") 
                                             dr.Save
                                           End If
                Else
                    e.WriteString(jo.ToString) '
在用户浏览器显示错误信息
                    Return
                End If
            End If
            e.AppendCookie("username",UserName) '
用户名和openid存储在Cookie
            e.AppendCookie("openid",OpenID)
        Else
            e.WriteString(jo.ToString) '
在用户浏览器显示错误信息
            Return
        End If
    Else
        UserName = e.Cookies("username") '
cookie获取用户名和openid
        OpenID = e.Cookies("openid")
        If userName = "" OrElse OpenID = "" Then
            Dim ul As String  = "https://open.weixin.qq.com/connect/oauth2/authorize?appid=wx8acdb7df5beb68fd&redirect_uri=http%3a%2f%2fwexin.foxtable.com&response_type=code&scope=snsapi_userinfo&state=123#wechat_redirect"
            sb.Append("<meta http-equiv='Refresh' c>") '
跳转到授权链接
            e.WriteString(sb.ToString)
            Return
        End If
    End If
    If  OpenID > "" And UserName > "" Then
       
'这里可以做进一步的权限判断
        sb.AppendLine("欢迎" & UserName & "光临, <a href='http://wexin.foxtable.com'>刷新页面</a>")
    Else
        sb.AppendLine("你无权访问本系统")  上面过不去就直接跳转这里了
   
End If
End
If
e
.WriteString(sb.ToString)
26楼
有点蓝 发表于:2024/6/17 14:41:00
抄帮助的代码没有任何意义!!想解决问题麻烦发自己真实的代码!把敏感数据改改即可
27楼
xuzihang 发表于:2024/6/17 15:14:00
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, "w。。。。。。。。", "f...................", e.GetValues("code"))
    Dim hc As New HttpClient(ul)
    Dim jo As JObject = JObject.Parse(hc.GetData)
    If jo("openid") IsNot Nothing Then '如果获取openid成功(成功的话,还会同时返回一个accesstiken,用于获取用户详情)
        OpenID = jo("openid")
        Dim dr As DataRow = DataTables("客户").SQLFind("openid ='" & Openid & "'")
        If dr IsNot Nothing Then 
            UserName = dr("nickname")
        Else
            dr = DataTables("客户").AddNew()
            msgbox("增行后", 64, "提示")
            Dim nms() As String = {"openid", "nickname", "headimgurl", "性别"} '"", "客户住址_县市", "country", "客户住址_省市"} '""
            For Each nm As String In nms
                dr(nm) = jo(nm)      
                 msgbox("提取数据", 64, "提示")
            Next
            msgbox("判断tjkhid", 64, "提示")  ,这个提示后就不提示推荐人和 不保存,直接到下面的,else  sb.AppendLine("系统繁忙稍后访问本系统") 
            If e.GetValues.ContainsKey("tjr") Then      
                msgbox("写入推荐人", 64, "提示")
                dr("客户来源_KHID") = e.GetValues("tjr")  
                msgbox("保存", 64, "提示")
                dr.Save
            End If
        End If
       接下面代码....
28楼
xuzihang 发表于:2024/6/17 15:14:00
        接上面代码
        e.AppendCookie("username", UserName) '用户名和openid存储在Cookie中
        e.AppendCookie("openid", OpenID)
       msgbox("存缓存", 64, "提示")
    Else
        e.WriteString(jo.ToString) '在用户浏览器显示错误信息
             msgbox("openid空的", 64, "提示")
        Return
    End If
Else
    UserName = e.Cookies("username") '从cookie获取用户名和openid
    OpenID = e.Cookies("openid")
    Dim dr As DataRow = DataTables("客户").SQLFind("openid ='" & Openid & "'") '根据openid找出对应的行
    If dr Is Nothing OrElse UserName = "" OrElse OpenId = "" Then '空 
        Dim url As String = e.Request.URL.ToString
        MsgBox(url)
        Dim ul As String = "https://open.weixin.qq.com/connect/oauth2/authorize?appid=wx................&redirect_uri=" & UrlEncode(url) &         "&response_type=code&scope=snsapi_userinfo&state=123#wechat_redirect"
        sb.Append("<meta http-equiv='Refresh' c>") '跳转到授权链接
        e.WriteString(sb.ToString)
        Return
    End If
End If
      msgbox("授权成功", 64, "提示")
    Dim Verified As Boolean
    Dim dr1 As DataRow = DataTables("客户").SQLFind("openid ='" & Openid & "'") '根据openid找出对应的行
    If OpenId > "" AndAlso dr1 IsNot Nothing AndAlso dr1("permit") = False Then'授权成功  
              msgbox("openid>0", 64, "提示")
        Verified = True
        sb.AppendLine("欢迎" & UserName & "光临!,用一天。 <a href='default.htm'>刷新页面</a>")   
        End Select 
        e.WriteString(wb.Build) '生成网页
    Else
         sb.AppendLine("系统繁忙稍后访问本系统")   上面不保存,直接跳转这里了
    End if
Else
    sb.AppendLine("你无权访问本系统")
End If
e.WriteString(sb.ToString)
[此贴子已经被作者于2024/6/17 17:05:52编辑过]
29楼
有点蓝 发表于:2024/6/17 15:31:00
调试这个位置,下面红色能不能弹出,弹出什么内容?

……
Else
    UserName = e.Cookies("username") '从cookie获取用户名和openid
    OpenID = e.Cookies("openid")
MsgBox("OpenID=" & OpenID & ",UserName=" & UserName
    Dim dr As DataRow = DataTables("客户").SQLFind("openid ='" & Openid & "'") '根据openid找出对应的行
MsgBox("dr = " & (dr Is Nothing)
    If dr Is Nothing OrElse UserName = "" OrElse OpenId = "" Then '空 
        Dim url As String = e.Request.URL.ToString
        MsgBox(url)
        Dim ul As String = "https://open.weixin.qq.com/connect/oauth2/authorize?appid=wx................&redirect_uri=" & UrlEncode(url) & "&response_type=code&scope=snsapi_userinfo&state=123#wechat_redirect"
        sb.Append("<meta http-equiv='Refresh' c>") '跳转到授权链接
        e.WriteString(sb.ToString)
        Return
    End If
End If
……
30楼
xuzihang 发表于:2024/6/17 16:43:00
       MsgBox(url)  
图片点击可在新窗口打开查看此主题相关图片如下:11111111111111111.png
图片点击可在新窗口打开查看
共62 条记录, 每页显示 10 条, 页签: [1][2] [3] [4][5][6][7]

Copyright © 2000 - 2018 foxtable.com Tel: 4000-810-820 粤ICP备11091905号

Powered By Dvbbs Version 8.3.0
Processed in .02734 s, 2 queries.