Dim e As RequestEventArgs = args(0)
Dim wb As New weui
wb.Title = "会议系统"
wb.AppendHTML("<script src='http://res.wx.qq.com/open/js/jweixin-1.2.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 = Functions.Execute("Get", "企业微信", 0) '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({beta: true, appId:'{0}',timestamp:{1},nonceStr:'{2}',signature:'{3}',jsApiList:['selectEnterpriseContact']});"
wb.AppendHTML("<script>" & CExp(cfg, appid, timestamp, noncestr, signature) & "</script>", True)
'开始正常生成网页内容
wb.AddForm("", "form1", "index.htm")
With wb.AddInputGroup("form1", "ipg1", "参会人员")
With .AddInputCell("ic1")
.AddLabel("lbh", "参会人员", 0)
.AddVcodeButton("ryxz", "打开通信录选择人员", 1) '增加人员选择按钮,2表示显示在右边
End With
.AddTextArea("chry", 5).Placeholder = "您也可以直接输入参会人员!"
End With
With wb.AddButtonGroup("form1", "btg1", True)
.Add("btn1", "确定", "submit")
End With
With wb.AddPageFooter("", "pf1", "Copyright © " & Date.Today.Year & " " & Functions.Execute("Get", "公司信息", 3).split(".")(Functions.Execute("Get", "公司信息", 3).split(".").Length - 2) & "." & Functions.Execute("Get", "公司信息", 3).split(".")(Functions.Execute("Get", "公司信息", 3).split(".").Length - 1))
.AddLink(Functions.Execute("Get", "公司信息", 0), Functions.Execute("Get", "公司信息", 3))
End With
e.WriteString(wb.Build) '生成网页
GetJsSignature代码:
Static CreateTime As Date '记录最近一次生成Ticket 的时间
Static Ticket As String '记录最近一次生成的Ticket
Dim tp As TimeSpan = Date.Now - CreateTime
Dim ul As String = "https://qyapi.weixin.qq.com/cgi-bin/get_jsapi_ticket?access_token={0}"
If tp.TotalSeconds > 3600 Then
Dim hc As New HttpClient(CExp(ul, Functions.Execute("GetQYAccessToken")))
Dim ret As String = hc.GetData()
If ret = "" Then '如果失败,再尝试一次
hc.GetData()
End If
CreateTime = Date.Now()
Dim jo As JObject = JObject.Parse(ret)
If jo("errcode") = "0" Then
Ticket = jo("ticket")
Else
Dim errmsg As String = "内部函数【GetJsSignature】反馈,获取jsapi_ticket失败的原因是:" & jo.ToString
Functions.Execute("ErrMsg", errmsg)
End If
End If
Dim signature As String = CExp("jsapi_ticket={0}&noncestr={1}×tamp={2}&url={3}", Ticket, args(0), args(1), args(2))
Return Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(signature, "SHA1").ToLower()
jssdk.js代码:
此主题相关图片如下:qq截图20241025095057.png
请老师帮忙看一下,究竟是哪里出错了!