以文本方式查看主题 - Foxtable(狐表) (http://foxtable.com/bbs/index.asp) -- 专家坐堂 (http://foxtable.com/bbs/list.asp?boardid=2) ---- 微信接入网页问题 (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=139491) |
||||
-- 作者:benwong2013 -- 发布时间:2019/8/14 8:42:00 -- 微信接入网页问题 根据教程及www.ngrok.cc申请了隧道域名,企业微信已经可以实现,在设置网页接口的时候只显示附图,但不知道如何跳转到此域名下的其它网页,请问如何处理? 授权链接是否就是首页而不是域名? 另外补充本地访问是可以打开的,127.0.0.1/default.htm 或test.htm
If e.host = "ctterp.vipgz1.idcfengye.com" 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("WXUsers").Find("userid =\'" & UserId & "\'") \'根据openid找出对应的行 If UserId > "" AndAlso dr IsNot Nothing AndAlso dr("permit") = True \'授权成功 Verified = True UserName = dr("name") 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%2fctterp.vipgz1.idcfengye.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("欢迎" & UserName & " , <a href=\'http://&&&&&.idcfengye.com\'>刷新页面</a>") End If e.WriteString(sb.ToString) End If Select Case e.Path Case "", "default.htm" \'首页 wb.AddPageTitle("","pageheader","%%%%ERP") wb.AddPageFooter("","pf1","Copyright @ %%%%%有限公司") With wb.AddGrid("","g1") .Add("c1","报告查询", "./images/notepad.png", "filter.htm") .Add("c12","FAQ管理", "./images/notepad.png", "faqfilter.htm") .Add("c21","照片上传", "./images/notepad.png", "fdphoto.htm") .Add("c22","退出", "./images/exit.png", "exit.htm") \'退出登录 End With e.WriteString(wb.Build) \'生成网页 Case "test.htm","" wb.AppendHTML("<script src=\'http://res.wx.qq.com/open/js/jweixin-1.0.0.js\'></script>",True) \'引入JS-SDK库 wb.AppendHTML("<script src=\'./lib/jssdk.js\'></script>") \'引入脚本文件 \'在页面注入权限验证配置 Dim st As New Date(1970,1,1,8,0,0) Dim appid As String = "wx9f8a&&&&&8" \'CorpID Dim timestamp As Integer = CInt((Date.Now - st).TotalSeconds()) \'时间戳 Dim noncestr As String = Rand.NextString(16) \'随机字符 Dim url As String = e.Request.URL.ToString \'当前页面地址 Dim signature As String = Functions.Execute("GetJsSignature", noncestr, timestamp, url) \'生成权限验证签名 Dim cfg As String = "wx.config({appId:\'{0}\',timestamp:{1},nonceStr:\'{2}\',signature:\'{3}\',jsApiList:[\'scanQRCode\']});" wb.AppendHTML("<script>" & CExp(cfg,appid,timestamp,noncestr,signature) & "</script>",True) \'开始正常生成网页内容 wb.AddForm("","form1","test.htm") With wb.AddInputGroup("form1","ipg1","产品输入") .AddInput("product","产品","text") With .AddInputCell("ic1") .AddLabel("lbh","编号",0) .AddInput("number","text",1) .AddVcodeButton("scan","扫码输入",2) \'增加二维码扫描按钮,2表示显示在右边 End With End With With wb.AddButtonGroup("form1","btg1",True) .Add("btn1", "确定", "submit") End With e.WriteString(wb.Build) \'生成网页 End Select [此贴子已经被作者于2019/8/14 8:55:56编辑过]
|
||||
-- 作者:浙江仔 -- 发布时间:2019/8/14 8:56:00 -- sb.AppendLine("欢迎" & UserName & " , <a href=\'http://&&&&&.idcfengye.com\'>刷新页面</a>") 可以取消欢迎页,直接跳转到业务网页 sb.Append("<meta http-equiv=\'Ref resh\' cont ent=\'0; u rl=/default.htm \'>") \'跳转到链接 或者欢迎页加按钮链接到业务网页 [此贴子已经被作者于2019/8/14 8:57:57编辑过]
|
||||
-- 作者:benwong2013 -- 发布时间:2019/8/14 9:28:00 -- 修改了之后打开是空白,我将整个代码上传,请帮忙看看是哪里的问题; 域名和授权的域名都是这个$$$$$$$$.idcfengye.com 请问在授权验证通过之后打开到默认的首页链接的时候,域名后面要不要加端口号的? 隧道域名: 自定义域名: - 隧道端口: - http验证用户名: - http验证密码: - 开通日期: 2019-08-12 18:35:50 FRP授权码: - 服务器地址: (请不要暴露此地址,避免服务器遭受攻击,谢谢) 服务器端口: 4443 QQ群: 289492085 (VIP一号群
|
||||
-- 作者:有点蓝 -- 发布时间:2019/8/14 9:40:00 -- …… dr("ThumbMediaId") = xo("ThumbMediaId") dr("PicUrl") = xo("PicUrl") dr("Content") = xo("Content") dr("Format") = xo("Format") dr.save End Select End If return End Select If e.host <> "$$$$$$$$.idcfengye.com" Then return \'需要授权才能访问的域名 if e.path = "" 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("WXUsers").Find("userid =\'" & UserId & "\'") \'根据openid找出对应的行 If UserId > "" AndAlso dr IsNot Nothing AndAlso dr("permit") = True \'授权成功 Verified = True UserName = dr("name") 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=$$$$$$$$$$$$8&redirect_uri=http%3a%2f%2fctterp.vipgz1.idcfengye.com&response_type=code&scope=snsapi_base&state=123#wechat_redirect" sb.Append("<meta http-equiv=\'Refresh\' content=\'0; url=" & ul & "\'>") \'跳转到授权链接 e.WriteString(sb.ToString) Return End If If Verified = False Then sb.AppendLine("你无权访问本系统") Else sb.Append("<meta http-equiv=\'Refresh\' content=\'0; url= http://ctterp.vipgz1.idcfengye.com/default.htm\'>") End If e.WriteString(sb.ToString) return end if Select Case e.Path Case "", "default.htm" \'首页 wb.AddPageTitle("","pageheader","ERP") wb.AddPageFooter("","pf1","Copyright @ 技术有限公司") With wb.AddGrid("","g1") .Add("c1","报告查询", "./images/notepad.png", "filter.htm") ……
|
||||
-- 作者:浙江仔 -- 发布时间:2019/8/14 9:46:00 -- 重定向的网页,最好用相对路径,这样你如果有端口,自动会带端口,除非本身是跨域链接 sb.Append("<meta http-equiv=\'Refresh\' content=\'0; url= http://ctterp.vipgz1.idcfengye.com/default.htm\'>") 改成 sb.Append("<meta http-equiv=\'Refresh\' content=\'0; url= /default.htm\'>")
[此贴子已经被作者于2019/8/14 9:46:01编辑过]
|
||||
-- 作者:benwong2013 -- 发布时间:2019/8/14 10:03:00 -- 还是空白,本地电脑或局域网用浏览器测试是没有问题 [此贴子已经被作者于2019/8/14 10:03:28编辑过]
|
||||
-- 作者:有点蓝 -- 发布时间:2019/8/14 10:22:00 -- 这个判断去掉 If e.host <> "$$$$$$$$.idcfengye.com" Then return
|
||||
-- 作者:浙江仔 -- 发布时间:2019/8/14 10:29:00 -- 我是这么处理的: 微信授权处理函数 Http_Get_MpOpenid2: Dim e As RequestEventArgs = Args(0) Dim Openid As String \'微信用户Openid Dim code As String \'微信授权码 Dim state As String \'开发者id Dim wb As weui =args(1) If e.Cookies.ContainsKey("openid") Then \'从cookie中获取微信用户id Openid = e.Cookies("openid") Else If e.host<> "127.0.0.1" Then If String.IsNullOrEmpty(code) OrElse (e.GetValues.ContainsKey("code") AndAlso code <> e.GetValues("code")) Then \'If e.GetValues.ContainsKey("state") Then state = e.GetValues("state") \'url的值,这里存储微信用户公众号开发者id,如果只维护一个公众号,可以忽略这个 If e.GetValues.ContainsKey("code") Then \'url的值 code = e.GetValues("code") openid =Functions.Execute("WeChat_GetOpenid_mp",code) ‘自己根据狐表帮助做 End If End If Else Openid ="测试id_XMw4V4s" End If End If If Openid >"" Then wb.Appendcookie("openid",openid ) Else Dim ul2 As String ul2 ="https://open.weixin.qq.com/connect/oauth2/authorize?appid={0}&redirect_uri="+ UrlEncode("http://" & e.host & "/" & e.path )+ "&response_type=code&scope=snsapi_base&state="+ mpCorpID +"#wechat_redirect" ul2=CExp(ul2,“你的id”) wb.InsertHTML("<meta http-equiv=\'Refresh\' c>") \'跳转到授权链接 End If Return openid Case "", "default.htm" \'首页 调用页面函数 Case "", "default.htm" e.AsyncExecute = True Functions.AsyncExecute("Http_wx_default",e) 页面函数:Http_wx_default Dim e As RequestEventArgs = Args(0) Dim Openid As String \'微信用户Openid Dim wb As New weui Openid = Functions.Execute("Http_Get_MpOpenid2",e,wb) \'调用函数统一处理授权 If openid="" Then e.WriteString(wb.Build) e.Handled = True Return "" End If wb.AddPageTitle("","pageheader","ERP") wb.AddPageFooter("","pf1","Copyright @ 技术有限公司") With wb.AddGrid("","g1") .Add("c1","报告查询", "./images/notepad.png", "filter.htm") .Add("c12","FAQ管理", "./images/notepad.png", "faqfilter.htm") .Add("c21","条码扫描", "./images/notepad.png", "test.htm") .Add("c22","退出", "./images/exit.png", "exit.htm") \'退出登录 End With e.WriteString(wb.Build) \'生成网页 e.Handled = True |
||||
-- 作者:benwong2013 -- 发布时间:2019/8/14 10:55:00 -- 好的,我试一下,谢谢两位 |