import $ from "./../../utils/Tool";
import {
  comfirmCodeLogin
} from "../../requests/api";
import router from "../../utils/router";
Page({

  /**
   * 页面的初始数据
   */
  data: {
    qrCodeId: "",
    macAddress: '',
    projectId: '',
    spaceId: ''
  },
  // 确认登录
  confirmLogin() {
    let param = {
      qrCodeId: this.data.qrCodeId,
      macAddress: this.data.macAddress,
      status: 2,  // 0-未扫码 1-已扫描 2-已确认 3-已经失效
      projectId: this.data.projectId,
      spaceId: this.data.spaceId
    }
    comfirmCodeLogin(param).then(res => {
      // if (res.result === 'success') {
      //   // Toast.success("已确认");
      // }
      router.pop();
    })
  },
  // 取消登录
  cancelLoginn() {
    router.pop();
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    options = JSON.parse(decodeURIComponent(JSON.stringify(options)))
    // debugger
    let { id, mac, spaceId } = options
    let projectId = $.store.get("projectId") || $.storage.get("projectId")
    this.setData({ qrCodeId: id, macAddress: mac, projectId: projectId, spaceId: spaceId })
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  }
})