体验版小程序识别小程序码

由于小程序码只能生成已经上线的小程序,但是使用B方案时,测试要测试,直接跳转到线上明显不合适
利用wx.scanCode({})
scene参数的时候,记得利用encodeURIComponent对参数进行编码

小程序码B方法

<button bindtap="onCode">识别二维码</button>
onCode () {
    wx.scanCode({
      success (res) {
      	// 识别成功,路径跳转,方案b跳转
        wx.navigateTo({
          url: "/" + res.path,
        })
      },
      fail (error) {
        console.log('失败')
        console.log(error)
      }
    })
  }

如果是用scene参数的(通用型)

onCode () {
    wx.scanCode({
      success (res) {
        // 如果是用scene参数的,记得对参数 encodeURIComponent,同样适用方案b
        let arr = res.path.split("scene=")
        wx.navigateTo({
          // encodeURIComponent(arr[1])  对参数进行编码,否则真机安卓机无法出来
          url: "/" + arr[0] + "scene=" + encodeURIComponent(arr[1])
        })
      },
      fail (error) {
        console.log('失败')
        console.log(error)
      }
    })
  }
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
http://blog.csdn.net/xiaoxiao108/article/details/7226120 前些天,12306这个网站挺火的,看到网上出现了各种各样的登陆、订票插件跟程序。虽然没经历过春运,看到网上各种各样的插件跟工具挺有意思的,下载了几个看了看,都挺不错的。印象中有个java本的订票程序里面有个验证码识别功能,用tesseract-ocr来识别验证码的,如果验证码不是很复杂识别效果还可以。 开发环境 vs2008 开发语言C# 使用方法很简单 1.下载tesseract 的.net 类库tessnet2_32.dll ,添加引用。 http://www.pixel-technology.com/freeware/tessnet2/ 2.下载tesseract 相对应的语言包。 http://code.google.com/p/tesseract-ocr/downloads/list 3.调用tesseract 的方法进行识别。 具体代码 1.读取网上的验证码到pictureBox中 //string url = "https://dynamic.12306.cn/otsweb/passCodeAction.do?rand=lrand"; string url = "http://static.baixing.net/pages/mobile.php?c=bcqsFelX+vKQcrnIbhyDYQ==/2.jpg"; HttpWebRequest request = WebRequest.Create(url) as HttpWebRequest; HttpWebResponse response = request.GetResponse() as HttpWebResponse; System.IO.Stream responseStream = response.GetResponseStream(); this.pictureBox1.Image = Image.FromStream(responseStream); 2.OCR类 public class Ocr { public void DumpResult(List result) { foreach (tessnet2.Word word in result) //Console.WriteLine("{0} : {1}", word.Confidence, word.Text); MessageBox.Show(string.Format("{0} : {1}", word.Confidence, word.Text)); } public List DoOCRNormal(Bitmap image, string lang) { tessnet2.Tesseract ocr = new tessnet2.Tesseract(); ocr.Init(null, lang, false); List result = ocr.DoOCR(image, Rectangle.Empty); DumpResult(result); return result; } System.Threading.ManualResetEvent m_event; public void DoOCRMultiThred(Bitmap image, string lang) { tessnet2.Tesseract ocr = new tessnet2.Tesseract(); ocr.Init(null, lang, false); // If the Oc

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值