order-detail.js 5.2 KB
// pages/index/confirm-appointment-info/confirm-appointment-info.js
const app = getApp();
Page({

    /**
     * 页面的初始数据
     */
    data: {
        show: false,
        modal_data: {
            is_showModal: false,
            currentBtn: null,
        },
        state_data: {
            is_showSuccessModal: false,
        },
        student_list: [{id:1,name:'张三',checked: false},
            {id:2,name:'李思思', checked: false},
            {id:3,name:'王五', checked: false},
            {id:4,name:'赵柳', checked: false},
            {id:5,name:'迪丽热巴-迪力木拉提',checked: false}],
        is_choose: false,
        num_arr: [],
        session_info: {},
        student_num: 5,
    },
    formSubmit(e) {
        console.log(e.detail);
        this.setData({'modal_data.is_showModal': true})
        // if(this.data.student_list.length === 0) {
        //     wx.showToast({title: '请添加学员!',icon:'none'})
        // }else {
        //     // this.setData({'modal_data.is_showModal': true})
        //     let url = '/portal/Experiment/confirm_session_submit';
        //     let header = {
        //         "XX-token": wx.getStorageSync('token')
        //     };
        //     let params = {
        //         _type: 2,
        //         formId: e.detail.formId,
        //         experiment_id: this.data.experiment_id,
        //         session_id: this.data.session_id,
        //         reservation_id: this.data.reservation_id,
        //         students: this.data.student_id,
        //     };
        //     app.post(url,params,header).then((res) => {
        //         console.log('提交预约信息',res);
        //     })
        // }
    },
    chooseNo(e) {
        this.setData({
            'modal_data.currentBtn': e.currentTarget.dataset.index,
            'modal_data.is_showModal': false
        });
        // wx.switchTab({url: '/pages/index/index'})
        wx.navigateBack({delta: 1})
    },
    chooseYes(e) {
        this.setData({
            'modal_data.currentBtn': e.currentTarget.dataset.index,
            'modal_data.is_showModal': false,
            'state_data.is_showSuccessModal': true
        });
        wx.navigateTo({url: '/pages/my/buyCard/buyCard'})
    },
    modalConfirm() {
        this.setData({'state_data.is_showSuccessModal': false})
    },
    disableScroll() {},
    addStudent() {
        wx.navigateTo({url: './add-student/add-student?is_back=' + true})
    },
    //获取预约信息
    getAppointmentInfo() {
        let url = '/portal/Experiment/confirm_session';
        let header = {
            "XX-token": wx.getStorageSync('token')
        };
        let params = {
            experiment_id: this.data.experiment_id,
            session_id: this.data.session_id,
            reservation_id: this.data.reservation_id,
        };
        app.post(url,params,header).then((res) => {
            console.log('预约信息',res);
            var arr = [];
            for (let i in res.list) {
                arr.push(res.list[i]); //属性
                //arr.push(obj[i]); //值
            }//对象转数组
            console.log('arr',arr);
            var new_arr = [];
            arr.forEach((item) => {
                new_arr.push({ ...item, checked: false })
            });//给每一项添加checked属性
            console.log(new_arr);
            this.setData({
                student_list: new_arr,
                new_arr:new_arr,
                session_info: res.session_info,
            })
            console.log('student_list', this.data.student_list);
        })
    },
    //获取学员列表
    // getStudentList() {
    //     let url = '/user/Student/student_list';
    //     let header = {
    //         "XX-token": wx.getStorageSync('token')
    //     };
    //     let params = {
    //         page: 1,
    //     };
    //     app.post(url,params,header).then((res) => {
    //         console.log('学员列表',res);
    //         this.setData({student_list: res.list})
    //     })
    // },
    /**
     * 生命周期函数--监听页面加载
     */
    onLoad: function (options) {
        const self =this;
        console.log('load');
        console.log(options);
        self.setData({
            currentTab: +options.currentTab?+options.currentTab:'',
        });
    },

    /**
     * 生命周期函数--监听页面初次渲染完成
     */
    onReady: function() {

    },

    /**
     * 生命周期函数--监听页面显示
     */
    onShow: function() {
        console.log('show');
        const self = this;
        // self.getStudentList();
        self.getAppointmentInfo();

        setTimeout(function() {
            self.setData({
                show: true
            })
        }, 500)
    },

    /**
     * 生命周期函数--监听页面隐藏
     */
    onHide: function() {

    },

    /**
     * 生命周期函数--监听页面卸载
     */
    onUnload: function() {

    },

    /**
     * 页面相关事件处理函数--监听用户下拉动作
     */
    onPullDownRefresh: function() {

    },

    /**
     * 页面上拉触底事件的处理函数
     */
    onReachBottom: function() {

    },

    /**
     * 用户点击右上角分享
     */
    onShareAppMessage: function() {

    }
})