index.js 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. const {
  2. disinfectSetOpenId
  3. } = require('../../../../utils/api/xiaosha');
  4. Page({
  5. /**
  6. * 页面的初始数据
  7. */
  8. data: {
  9. userInfo: wx.getStorageSync('userInfo'),
  10. wxCode: wx.getStorageSync('wxCode'),
  11. },
  12. scanCode() {
  13. let data = {
  14. userId: this.data.userInfo.userId,
  15. code: this.data.wxCode
  16. }
  17. disinfectSetOpenId(data).then(res => {
  18. // 只允许从相机扫码
  19. wx.scanCode({
  20. onlyFromCamera: true,
  21. scanType: ['qrCode'],
  22. success(res) {
  23. console.log(res);
  24. if (res.result.indexOf("https://tx.hz-hanghui.com:8088/yx-fyzd?disinfectAreaId") != -1) { //是否有参数
  25. let str = res.result.substr(1);
  26. let strs = str.split("=");
  27. wx.navigateTo({
  28. url: '/pages/wx_airport/Xiaosha_registration/index?disinfectAreaId=' + strs[1],
  29. })
  30. } else {
  31. wx.showToast({
  32. title: '扫码失败,请重试!',
  33. icon: 'none'
  34. })
  35. }
  36. }
  37. })
  38. })
  39. },
  40. /**
  41. * 生命周期函数--监听页面加载
  42. */
  43. onLoad(options) {
  44. },
  45. /**
  46. * 生命周期函数--监听页面初次渲染完成
  47. */
  48. onReady() {
  49. },
  50. /**
  51. * 生命周期函数--监听页面显示
  52. */
  53. onShow() {
  54. },
  55. /**
  56. * 生命周期函数--监听页面隐藏
  57. */
  58. onHide() {
  59. },
  60. /**
  61. * 生命周期函数--监听页面卸载
  62. */
  63. onUnload() {
  64. },
  65. /**
  66. * 页面相关事件处理函数--监听用户下拉动作
  67. */
  68. onPullDownRefresh() {
  69. },
  70. /**
  71. * 页面上拉触底事件的处理函数
  72. */
  73. onReachBottom() {
  74. },
  75. /**
  76. * 用户点击右上角分享
  77. */
  78. onShareAppMessage() {
  79. }
  80. })