| 1234567891011121314151617181920212223242526272829303132333435363738394041424344 |
- // pages/scan/scan.js
- const App = getApp();
- Page({
- /**
- * 页面的初始数据
- */
- data: {
- navTop:App.globalData.navTop,
- },
- isOnlyDigits(str) {
- const regex = /^[0-9]+$/; return regex.test(str);
- },
- scanQRCode() {
- wx.scanCode({
- success: (res) => {
- console.log(res,"二维码扫描结果"); // 输出扫描结果
- if(this.isOnlyDigits(res.result)){
- wx.setStorage({
- key: 'exhibition_id',
- data: res.result,
- })
- setTimeout(function () {
- wx.switchTab({
- url: '../index/index'
- })
- }, 400)
- }else{
- wx.showToast({
- title: '请扫描正确的二维码!',
- icon: 'none',
- duration: 2000
- });
- }
- },
- fail: (res) => {
- console.log(res);
- }
- });
- },
- onLoad(options) {
- },
- })
|