// package_first/pages/ProtectionActivity/index.js
import { 
    api_getIsApply,
    api_TiktokAdd
} from  '../../../api/attention.js';
Page({

    /**
     * 页面的初始数据
     */
    data: {
        tikStatus:null,
        entersList:[
            {
                title:'关注抖音',
                iconPath:'../../../assets/img/attentionIcon.png',
                path: '/package_first/pages/AttentionMethod/index',
                isJoin: false,
                isShow: true
                // type: 'tiktok'
            },
            {
                title:'学习视频',
                iconPath:'../../../assets/img/video.png',
                path: '/package_first/pages/LearningVideo/index',
                isJoin: false,
                isShow: true
                // type: 'video'
            },
            {
                title:'志愿者活动',
                iconPath:'../../../assets/img/volunteer.png',
                path: '/package_first/pages/VolunteerActivity/index',
                isJoin: false,
                isShow: true
                // type: 'activity'
            }
        ]
    },

    /**
     * 生命周期函数--监听页面加载
     */
    onLoad(options) {

    },

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

    },

    /**
     * 生命周期函数--监听页面显示
     */
    onShow() {
        this.getIsApply()
    },

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

    },

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

    },

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

    },

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

    },

    /**
     * 用户点击右上角分享
     */
    onShareAppMessage() {
        
    },
    getIsApply(){
        const entersList = this.data.entersList
        const {tenantId} = wx.getStorageSync('tenant')
        const openid = wx.getStorageSync('openid')
        if(tenantId === null){
            entersList[0].isShow = false
            this.setData({ entersList })
        }else{
            const data = { openid }
            api_getIsApply(data).then(res=>{
                let tikStatus = res.data
                entersList[0].isJoin = res.data == 2 ? true:false
                this.setData({ entersList,tikStatus })
            })
        }

    },
    goPage(e){
        const { path } = e.currentTarget.dataset
        // if(path=='/package_first/pages/AttentionMethod/index'){
        //     wx.navigateTo({
        //         url: '/package_first/pages/AttentionMethod/index?status='+this.data.tikStatus
        //     })
        // }else{
        //     wx.navigateTo({
        //         url: path
        //     })
        // }
        wx.navigateTo({
        url: path
        })
    },
    homepage(e){
        wx.switchTab({
            url: `/pages/FirstPage/index`,
        })
    }
})