以文本方式查看主题

-  Foxtable(狐表)  (http://www.foxtable.com/bbs/index.asp)
--  专家坐堂  (http://www.foxtable.com/bbs/list.asp?boardid=2)
----  求助:通过微信扫码获取明细  (http://www.foxtable.com/bbs/dispbbs.asp?boardid=2&id=110626)

--  作者:xietan417
--  发布时间:2017/12/6 15:20:00
--  求助:通过微信扫码获取明细
wx.ready(function () {
    document.getElementById(\'scan\').onclick = function () {
        wx.scanQRCode({
            needResult: 1,
            scanType: [\'qrCode\',\'barCode\'],
            success: function (res) {
                var code = res.resultStr;
                  if(code.indexOf(",") >= 0){
                   code = code.split(",")[1];
                  }
                document.getElementById(\'number\').value = code;
                if(result){
                obj.number = code;
                result = submitAjaxFileds(\'getname.htm\',\'\',\'number\',false);
                        if(result){
                                 var vals=result.split("|");
                                 if(vals.length==2){
                                 document.getElementById("name").value=vals[0];
                                 document.getElementById("dp").value=vals[1];
       }        
    }
}
            }
        });
    };
});
wx.error(function (res) {
    //alert(res.errMsg);
});

JS这样写不行啊!


--  作者:有点甜
--  发布时间:2017/12/6 15:43:00
--  

1、最开始没修改的时候,扫码是否正常?

 

2、改一下

 

wx.ready(function () {
    document.getElementById(\'scan\').onclick = function () {
        wx.scanQRCode({
            needResult: 1,
            scanType: [\'qrCode\',\'barCode\'],
            success: function (res) {
                var code = res.resultStr;
alert(code)
                  if(code.indexOf(",") >= 0){
                   code = code.split(",")[1];
                  }
alert(code)
                document.getElementById(\'number\').value = code;
 
                var result = submitAjaxFileds(\'getname.htm\',\'\',\'number\',false);
alert(result)
                        if(result){
                                 var vals=result.split("|");
                                 if(vals.length==2){
                                     document.getElementById("name").value=vals[0];
                                     document.getElementById("dp").value=vals[1];
                                 }  
                        }      
            }
        });
    };
});
wx.error(function (res) {
    //alert(res.errMsg);
});

--  作者:xietan417
--  发布时间:2017/12/6 17:08:00
--  
这个是扫码的内部函数
Dim e As RequestEventArgs = args(0)
Dim wb As New weui
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 = "wxc47938dd3fd51234" \'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","EG盘点")
    .AddInput("product","盘点地点","text")
    With .AddInputCell("ic1")
        .AddLabel("lbh","编号",0)
        .AddInput("number","text",1)
        .AddVcodeButton("scan","扫码输入",2) \'增加二维码扫描按钮,2表示显示在右边 
        .AddLabel("mc","名称",0)       
        .AddInput("name","text",1)
        .AddLabel("bm","部门",0)       
        .AddInput("dp","text",1)
    End With
End With
With wb.AddButtonGroup("form1","btg1",True)
    .Add("btn1", "确定", "submit")
End With
e.WriteString(wb.Build) \'生成网页

这个是获取明细的内部函数

Dim e As RequestEventArgs = args(0)
MessageBox.Show(e.Values("number"))
Dim dr As DataRow = DataTables("固定资产").Find("资产编号=\'" & e.Values("number") & "\'")
        If dr IsNot Nothing Then
           e.WriteString(dr("资产名称") & "|" & dr("使用部门"))
        End If


还是不可以自动获取数据啊!


--  作者:有点甜
--  发布时间:2017/12/6 17:25:00
--  

1、本来能否扫描,扫描单个功能是否正常?

 

2、在1正常的前提下改成2楼代码,看弹出什么。

 

3、如果连扫描功能都不正常,下载一个工具测试 https://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1455784140

 

 

 


--  作者:xietan417
--  发布时间:2017/12/6 17:30:00
--  
描扫功能正常的!
--  作者:有点甜
--  发布时间:2017/12/6 17:31:00
--  
那2楼的代码,弹出什么数据?是否正常?
--  作者:xietan417
--  发布时间:2017/12/6 17:39:00
--  
就只有条码数据!
Dim e As RequestEventArgs = args(0)
MessageBox.Show(e.Values("number"))       但是这条就没有弹出来!
Dim dr As DataRow = DataTables("固定资产").Find("资产编号=\'" & e.Values("number") & "\'")
        If dr IsNot Nothing Then
           e.WriteString(dr("资产名称") & "|" & dr("使用部门"))
        End If

[此贴子已经被作者于2017/12/6 17:40:42编辑过]

--  作者:有点甜
--  发布时间:2017/12/6 17:46:00
--  

1、红色是否弹出?

 

2、你访问的是 getname.htm,在httprequest跟踪一下弹出 e.path 看看

 

wx.ready(function () {
    document.getElementById(\'scan\').onclick = function () {
        wx.scanQRCode({
            needResult: 1,
            scanType: [\'qrCode\',\'barCode\'],
            success: function (res) {
                var code = res.resultStr;
alert(code)
                  if(code.indexOf(",") >= 0){
                   code = code.split(",")[1];
                  }
alert(code)
                document.getElementById(\'number\').value = code;
 
                var result = submitAjaxFileds(\'getname.htm\',\'\',\'number\',false);
alert(result)
                        if(result){
                                 var vals=result.split("|");
                                 if(vals.length==2){
                                     document.getElementById("name").value=vals[0];
                                     document.getElementById("dp").value=vals[1];
                                 }  
                        }      
            }
        });
    };
});
wx.error(function (res) {
    //alert(res.errMsg);
});

--  作者:xietan417
--  发布时间:2017/12/7 14:25:00
--  
还是JS的问题啊!谢谢!可以了!
--  作者:xietan417
--  发布时间:2017/12/21 16:12:00
--  
甜版,这个功能只能通摄像头扫码后,才能自动填下明细,如果手动的话就不行了!有没有办法改进一下?