myactivity_active.js 2.3 KB
const app = getApp()
var util = require('../../../utils/util.js');
Page({

    /**
     * 页面的初始数据
     */
    data: {
        list: '',
        id: '',
        latitude: '',
        longitude: ''
    },

    onLoad: function (options) {
        // console.log(options)
        this.setData({
            id: options.id
        })
    },
    onReady: function () {

    },

    onShow: function () {
        let that = this;
        that.getList();
        // 获取经纬度
        wx.getLocation({
            success: function (res) {
                console.log(res);
                that.setData({
                    latitude: res.latitude,
                    longitude: res.longitude
                })
            },
        })

    

    },



    // 详情列表
    getList() {

        let that = this;
        let url = '/index/second/clockInfo';
        let head = {
            'XX-Token': wx.getStorageSync('token')
        }
        let d = {
            id: that.data.id

        }
        // console.log(d)
        app.post(url, d, head).then((res) => {
            // console.log(res)
            that.setData({
                list: res
            })

        }).catch((err) => {

        })
    },

    // 打卡
    getpunch() {

        let that = this;
        let url = '/index/second/startClock';
        let head = {
            'XX-Token': wx.getStorageSync('token')
        }
        let d = {
            id: that.data.id,
            long: that.data.latitude,
            lat: that.data.longitude

        }
        console.log(d)
        app.post(url, d, head).then((res) => {
            console.log(res)
            // that.setData({
            //     list: res
            // })

        }).catch((err) => {

        })

    },









    // 提示
    click: function (e) {
        this.setData({
            hiddenName: !this.data.hiddenName
        })
    },




    onHide: function () {

    },

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

    },

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

    },

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

    },

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

    }
})