const { disinfectSetOpenId } = require('../../../../utils/api/xiaosha'); Page({ /** * 页面的初始数据 */ data: { userInfo: wx.getStorageSync('userInfo'), wxCode: wx.getStorageSync('wxCode'), }, scanCode() { let data = { userId: this.data.userInfo.userId, code: this.data.wxCode } disinfectSetOpenId(data).then(res => { // 只允许从相机扫码 wx.scanCode({ onlyFromCamera: true, scanType: ['qrCode'], success(res) { console.log(res); if (res.result.indexOf("https://tx.hz-hanghui.com:8088/yx-fyzd?disinfectAreaId") != -1) { //是否有参数 let str = res.result.substr(1); let strs = str.split("="); wx.navigateTo({ url: '/pages/wx_airport/Xiaosha_registration/index?disinfectAreaId=' + strs[1], }) } else { wx.showToast({ title: '扫码失败,请重试!', icon: 'none' }) } } }) }) }, /** * 生命周期函数--监听页面加载 */ onLoad(options) { }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady() { }, /** * 生命周期函数--监听页面显示 */ onShow() { }, /** * 生命周期函数--监听页面隐藏 */ onHide() { }, /** * 生命周期函数--监听页面卸载 */ onUnload() { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh() { }, /** * 页面上拉触底事件的处理函数 */ onReachBottom() { }, /** * 用户点击右上角分享 */ onShareAppMessage() { } })