用扫码枪时,输入后自带回车,方便实现在 扫码框 扫码输入信息-》提交-》清空扫码框等待下次在扫码 这样的连续操作,用企业微信扫一扫时,按帮助文档,值是扫到了扫码框,但没有实现自动提交,然后清空等待下次扫码输入这样的操作,需要自己手动点击提交按钮,浪费了时间,操作上也不够人性化了。多次测试终于实现了类似扫码枪回写的功能,现分享源码
原理就是增加了一个隐藏输入框,设置这个输入框值变更后,触发原扫码框相同的代码。
以下内容只有回复后才可以浏览
狐表 weui代码如下
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/ztd.js'></script>") '
'在页面注入权限验证配置
Dim st As New Date(1970,1,1,8,0,0)
Dim appid As String = "自己企业微信ID" '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:['scanQRCode']});"
wb.AppendHTML("<script>" & CExp(cfg,appid,timestamp,noncestr,signature) & "</script>",True)
wb.AddForm("","btt","ztd.htm").Attribute = "style='text-align:center;'"
With wb.AddInputGroup("btt","ipg1","装托单")
With .AddInputCell("ic1")
.AddVcodeButton("btqk","清 空",0).Attribute = "style='border-right: 1px solid #E5E5E5;border-left: none;' onc lick='rest art()'" '增加二维码扫描按钮,2表示显示在右边
.AddLabel("lbh","单号:",1).Attribute = "style='text-align:left;text-indent:5px;'"
.AddVcodeButton("btbc","保 存",2).Attribute = "onc lick='sa ve()'"
End With
With .AddInputCell("ic2") '通过InputCell增加输入框
.AddVcodeButton("smklb","扫码框",0).Attribute = "style='border-right: 1px solid #E5E5E5;border-left: none;' onc lick='mne nter()'"
'.AddLabel("smklb","扫码框",0).Attribute = "style='border-right: 1px solid #E5E5E5;'" '增加标签,0显示在左边
.AddInput("smk","text",1).Attribute = "style='text-align:left;text-indent:5px;'" '增加输入框,1表示显示在中间
.AddVcodeButton("wxsm","扫一扫",2) '增加获取验证码按钮,2表示显示在右边
End With
End With
With wb.AddInputGroup("btt","ipgy1")
For Each key As String In e.Cookies.Keys
.AddHiddenValue(key,e.Cookies(key))
Next
.AddInput("ztdh","单据内码:","text")
.AddInput("zt","状态:","text")
.AddInput("sc","是否首次:","text")
.AddInput("fz","扫码辅助:","text").Attribute = "oncha nge='sca nfz(this)'"
End With
With wb.AddButtonGroup("btt","btg2", False) '水平排列
.Add("tjan", "按钮","button").Attribute = "onc lick='setC odes()'"
End With
With wb.AddActionSheet("","menu") '设计菜单
.Add("mnuEdit", "编辑本条数据").Attribute ="onc lick='Editr ow()'"
.Add("mnuDelete", "删除本条数据").Attribute ="onc lick='Delr ow()'"
.Add("mnuCancel","取消","",True)
End With
wb.AppendHTML("<div id='p1' style='margin:0.5em'>表格</div>")
e.WriteString(wb.Build) '生成网页
[此贴子已经被作者于2021/12/1 11:10:27编辑过]