// pages/signIn/siginIn.js const app=getApp() Page({ /** * 页面的初始数据 */ data: { checked: false, result:null, title:"" }, /** * 生命周期函数--监听页面加载 */ onLoad: function (options) { this.setData({ title:wx.getStorageSync('title') }) }, toHand(){ wx.navigateTo({ url: '/pages/signIn/hand/hand', }) }, toRecode(){ wx.navigateTo({ url: '/pages/signIn/recode/recode', }) }, onChange({ detail }) { // 需要手动对 checked 状态进行更新 this.setData({ checked: detail }); }, getScancode: function () { var _this = this; // 允许从相机和相册扫码 wx.scanCode({ onlyFromCamera: true, scanType:['barCode', 'qrCode','datamatrix','pdf417'], success: (res) => { console.log(res); var result = res.result; _this.sign(result); _this.setData({ result: result, }) }, fail:(err)=>{ console.log(err); } }) }, sign: function (seal_no) { var that=this; app.api.useApi(app.globalData.baseAppUrl + "api/admin/sorting/sign", { seal_no:seal_no }, "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(); var data=res.message.data wx.showLoading({ title: res.message.msg, }) setTimeout(function () { wx.hideLoading(); }, 1000); } }).catch(function (err) { console.log(222); }) }, })