Rss & SiteMap

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

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

标题:扫码带参数如何做

11楼
有点蓝 发表于:2024/6/11 11:17:00
设计一个窗口,放到按钮点击事件里。能不能扫测试一下不就知道了
12楼
xuzihang 发表于:2024/6/11 12:23:00
老师,手机能扫进去了,但是怎么提取推荐人的KHID存起来
13楼
有点蓝 发表于:2024/6/11 12:49:00
http://www.foxtable.com/mobilehelp/topics/0113.htm
14楼
xuzihang 发表于:2024/6/13 18:05:00
老师,不会写了,帮我写下,存在客户表里,推荐人的khid,姓名
15楼
有点蓝 发表于:2024/6/13 20:52:00
比如 :http://www.foxtable.com/mobilehelp/topics/0235.htm
大概
If e.host = "wexin.foxtable.com" Then '需要授权才能访问的域名
    Dim OpenID As String
    Dim sb As New StringBuilder
    sb.AppendLine("<meta name='viewport' c>")
    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","a5a3b06a790d4200a151e6b13c3dc263",e.GetValues("code"))
        Dim hc As new HttpClient(ul)
        Dim jo As JObject = JObject.Parse(hc.GetData)
        If jo("openid") IsNot Nothing Then
            OpenID = jo("openid")
        End If
    End If
    
    Dim Verified As Boolean
    If OpenId > "" andalso e.GetValues.ContainsKey("khid")
        Dim dr As DataRow = DataTables("客户表").Find("openid  ='" & OpenID & "'") '根据openid找出对应的行
        if  dr Is Nothing then
            dr = DataTables("客户表").addnew
            dr("openid") = OpenID 
        end if
        dr("khid") = e.GetValues("khid")
        dr.save
        Verified  = True
    ElseIf e.GetValues.ContainsKey("code") = False 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_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("Foxtable欢迎您, <a href='http://wexin.foxtable.com'>刷新页面</a>")
    End If
    e.WriteString(sb.ToString)
End If
16楼
xuzihang 发表于:2024/6/14 9:30:00
老师我把代码加在红字位置了,没加   Dim Verified As Boolean  在红字位置就不走不下去了


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")
            '            msgbox("获取openid", 64, "提示")
            Dim dr As DataRow = DataTables("客户").SQLFind("openid ='" & Openid & "'")
            If dr IsNot Nothing Then 
                UserName = dr("nickname")
                '                msgbox("昵称", 64, "提示")
            Else
                msgbox("要增行网页ul", 64, "提示")
                ul = "https://api.weixin.qq.com/sns/userinfo?access_token={0}&openid={1}&lang=zh_CN "
                '根据openid和accesstoken获取用户详情,注意这里这个accesstoken不是普通accesston,只能用于网页授权
                hc = New HttpClient(CExp(ul, jo("access_token"), OpenId))
                jo = jo.Parse(hc.GetData)
                msgbox("判断openid", 64, "提示")
                If jo("openid") IsNot Nothing Then 
                    UserName = jo("nickname")
                    msgbox("增行前", 64, "提示")
                    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, "提示")
                    If OpenId > "" AndAlso e.GetValues.ContainsKey("khid") Then     'e.GetValues.ContainsKey("khid")获取二维码推荐人的khid
                        msgbox("写入推荐人", 64, "提示")
                        dr("客户来源_KHID") = e.GetValues("khid")                      'e.GetValues.ContainsKey("khid")获取二维码推荐人的TJkhid ,保存khid
                        msgbox("保存", 64, "提示")
                        dr.Save
                    End If
                Else
                    e.WriteString(jo.ToString) '在用户浏览器显示错误信息
                    '                   msgbox("不能增行token里openid空", 64, "提示空")
                    Return
                End If
            End If
            e.AppendCookie("username", UserName) '用户名和openid存储在Cookie中
            e.AppendCookie("openid", OpenID)
            '            e.AppendCookie("KHID", KHID)
            
            '            msgbox("存缓存", 64, "提示")
        Else
            e.WriteString(jo.ToString) '在用户浏览器显示错误信息
            '            msgbox("openid空的", 64, "提示")
            Return
        End If
    Else
        UserName = e.Cookies("username") '从cookie获取用户名和openid
        OpenID = e.Cookies("openid")
        '        KHID = e.Cookies("KHID")
        '        msgbox("获取缓存", 64, "提示")
        Dim dr As DataRow = DataTables("客户").SQLFind("openid ='" & Openid & "'") '根据openid找出对应的行
        If dr Is Nothing OrElse UserName = "" OrElse OpenId = "" Then '空 
            '            msgbox("判断名 openid 行 空", 64, "提示")
            '        If userName = "" OrElse OpenID = "" Then
            Dim ul As String = "https://open.weixin.qq.com/connect/oauth2/authorize?appid=wx................&redirect_uri=http%3a%2f%2fwx.....cn&response_type=code&scope=snsapi_userinfo&state=123#wechat_redirect"
            sb.Append("<meta http-equiv='Refresh' c>") '跳转到授权链接
            e.WriteString(sb.ToString)
            '             msgbox("跳转授权链接", 64, "提示")
            Return
        End If
    End If
17楼
xuzihang 发表于:2024/6/14 9:31:00
二维码我是这样设置的
Dim khid As String = "xxxx"
Dim Bar As New BarCodeBuilder
Bar.Symbology = Barpro.Symbology.QRCode
Bar.Code = "............/index.htm?tjr=" & khid 
Bar.QuietZoneWidth = 2
'Bar.SaveImage("二维码文件名")
Bar.SaveImage(projectpath & "Attachments\" & 1 & ".jpg")
18楼
有点蓝 发表于:2024/6/14 9:53: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")
        '            msgbox("获取openid", 64, "提示")
        Dim dr As DataRow = DataTables("客户").SQLFind("openid ='" & Openid & "'")
        If dr IsNot Nothing Then 
            UserName = dr("nickname")
            '                msgbox("昵称", 64, "提示")
        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, "提示")
            If e.GetValues.ContainsKey("tjr") Then 'e.GetValues.ContainsKey("khid")获取二维码推荐人的khid
                msgbox("写入推荐人", 64, "提示")
                dr("客户来源_KHID") = e.GetValues("tjr") 'e.GetValues.ContainsKey("khid")获取二维码推荐人的TJkhid ,保存khid
                msgbox("保存", 64, "提示")
                dr.Save
            End If
        End If
        e.AppendCookie("username", UserName) '用户名和openid存储在Cookie中
        e.AppendCookie("openid", OpenID)
        '            e.AppendCookie("KHID", KHID)
        
        '            msgbox("存缓存", 64, "提示")
    Else
        e.WriteString(jo.ToString) '在用户浏览器显示错误信息
        '            msgbox("openid空的", 64, "提示")
        Return
    End If
Else
    UserName = e.Cookies("username") '从cookie获取用户名和openid
    OpenID = e.Cookies("openid")
    '        KHID = e.Cookies("KHID")
    '        msgbox("获取缓存", 64, "提示")
    Dim dr As DataRow = DataTables("客户").SQLFind("openid ='" & Openid & "'") '根据openid找出对应的行
    If dr Is Nothing OrElse UserName = "" OrElse OpenId = "" Then '空 
        '            msgbox("判断名 openid 行 空", 64, "提示")
        '        If 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)
        '             msgbox("跳转授权链接", 64, "提示")
        Return
    End If
End If
19楼
xuzihang 发表于:2024/6/14 14:31:00
                    If e.GetValues.ContainsKey("tjr") Then 
                        dr("客户来源_KHID") = e.GetValues("tjr") 
                        dr.Save
                    End If


老师我改过来了,还是走不过去?哪里不对么?
20楼
有点蓝 发表于:2024/6/14 14:51:00
加调试代码,看哪些可以弹出,那些不能弹出
共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 .03125 s, 2 queries.