// pages/tabber/news/index.js const app=getApp(); Page({ /** * 页面的初始数据 */ data: { selectInfo: {}, id:0 }, /** * 生命周期函数--监听页面加载 */ onLoad: function (options) { this.setData({ id:options.id, }) }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady: function () { }, saoma:function(e){ var that=this; wx.scanCode({ onlyFromCamera: true, success (res) { console.log(res) var reg = new RegExp('(^|&|/?)orde_num=([^&|/?]*)(&|/?|$)', 'i'); var r = res.result.substr(1).match(reg); var order_num=r[2]; that.settask(order_num); } }) }, settask(order_num){ var that=this app.api.useApi(app.globalData.baseAppUrl + "api/admin/bindQr", { device_id:this.data.id, order_num:order_num, }, "post").then(function (res) { console.log(res); if (res.code != 200) { wx.showLoading({ title: res.message.msg, }) setTimeout(function () { wx.hideLoading(); }, 1000); } else { wx.hideLoading(); wx.showModal({ title: '提示', content: res.message.msg, showCancel:false, success (res) { if (res.confirm) { console.log('用户点击确定') wx.navigateBack() } else if (res.cancel) { console.log('用户点击取消') } } }) } }).catch(function (err) { console.log(err); }) } })