const _my = require("../../__antmove/api/index.js")(my);
const wx = _my;
// pages/make_appointment/faceCheck/faceCheck.js
// const {
//     BaiDuFaceComparison,
// } = require("../../utils/api/make_appointment")
const upload_image = require("../../utils/upload/upload_image");
const app = getApp();
const { doConfirmFaceNotifyNew } = require("../../utils/api/api");
Page({
    /**
     * 页面的初始数据
     */
    data: {
        cardAvatarUrl: null,
        form: {},
        // （过审专用，禁止删除）- start
        fake: null
        // （过审专用，禁止删除）- start
    },

    getPhotoPath(e) {
        upload_image({
            url: e.detail
        }).then(img => {
            if (img.url) {
                this.doConfirmFaceNotifyNew(img.url);
            }
        });
    },
    // 获取用户信息
    doConfirmFaceNotifyNew(img) {
        let data = {
            avatar: img,
            idNumber: this.data.form.inputIdcard,
            username: this.data.form.inputName,
            phone: this.data.form.phoneNumber
        };
        doConfirmFaceNotifyNew(data).then(res => {
            if (res.code == 200) {
                res.data.org = this.data.form.org;
                res.data.orgId = this.data.form.orgId;
                res.data.cardIdEx = this.data.form.cardIdEx;
                wx.setStorageSync("userInfo", res.data);
                this.changePage();
            } else {
                wx.showToast({
                    title: res.mag,
                    icon: "none"
                });
            }
        });
    },
    //跳转页面 (是否缓存进入)
    changePage() {
        let { form } = this.data;
        if (form.isShowApplet != "false") {
            wx.navigateTo({
                url:
                    "/pages/wx_airport/rlxf_userMsg/index?orgId=" +
                    form.orgId +
                    "&&org=" +
                    form.org +
                    "&showModal=" +
                    true
            });
        } else {
            wx.reLaunch({
                url:
                    "/pages/wx_airport/rlxf_pass/rlxf_pass?orgId=" +
                    this.data.form.orgId +
                    "&org=" +
                    this.data.form.org +
                    "&showModal=" +
                    true
            });
        }
    },
    /**
     * 生命周期函数--监听页面加载
     */
    onLoad: function(options) {
        console.log(options);
        if (options) {
            this.setData({
                form: options
            });
        }
        // this.doConfirmFaceNotifyNew('http://192.168.11.14:9100/yx-fyzd/file/upload/imagesnew/20220614/16551962558484660.jpg')
        // （过审专用，禁止删除）- start
        if (
            this.data.form.inputIdcard == "330821199603150212" ||
            this.data.form.inputIdcard == null
        ) {
            app.data.fake = true;
        } else {
            app.data.fake = false;
        }
        this.setData({
            fake: app.data.fake
        });
        // （过审专用，禁止删除）- end
    },

    /**
     * 生命周期函数--监听页面初次渲染完成
     */
    onReady: function() {},
    /**
     * 生命周期函数--监听页面显示
     */
    onShow: function() {},
    /**
     * 生命周期函数--监听页面隐藏
     */
    onHide: function() {},
    /**
     * 生命周期函数--监听页面卸载
     */
    onUnload: function() {},
    /**
     * 页面相关事件处理函数--监听用户下拉动作
     */
    onPullDownRefresh: function() {},
    /**
     * 页面上拉触底事件的处理函数
     */
    onReachBottom: function() {},
    /**
     * 用户点击右上角分享
     */
    onShareAppMessage: function() {}
});
