// pages/my/my.js
const app = getApp()
Page({

    /**
     * 页面的初始数据
     */
    data: {
        id: '', //分享用
        nickname: '', // 用户名称
        img: '', //用户头像
        qian: '', //钱包金额
        code0num: '', //号码牌数量
        order0num: '', // 订单数量
        pic: '',
        show: ''
    },


    /**
     * 生命周期函数--监听页面加载
     */
    onLoad: function (options) {
        let t = this;
        let u = 'index/shareImg';
        app.post(u, '').then(r => {
            t.setData({
                pic: r.data.img
            })
        })
    },
    onShow: function () {
        this.getMy()
        this.setData({
            show:wx.getStorageSync('token') == "" ? 'as' : 'share'
        })
    },

    getMy() {
        let t = this;
        let u = 'index/myInfo';
        app.post(u, '').then(r => {
            console.log(r)
            t.setData({
                id: r.data.id,
                nickname: r.data.nickname,
                img: r.data.img,
                qian: r.data.money,
                code0num: r.data.code0num,
                order0num: r.data.order0num
            })
        })
    },

    onReady: function () {

    },
    // 我的信息
    mymessage() {
        let token = wx.getStorageSync('token')
        if (token == '') {
            wx.navigateTo({
                url: "/pages/logs/logs",
            })
            console.log(this.data.id)
        } else {
            wx.navigateTo({
                url: '/pages/mymessage/mymessage',
            })
        }

    },
    //订单
    getOrder() {
        let token = wx.getStorageSync('token')
        if (token == '') {
            wx.navigateTo({
                url: "/pages/logs/logs",
            })
        } else {
            wx.navigateTo({
                url: '/pages/order/order'
            })

        }

    },
    //钱包
    getWallet() {
        let token = wx.getStorageSync('token')
        if (token == '') {
            wx.navigateTo({
                url: "/pages/logs/logs",
            })
        } else {
            wx.navigateTo({
                url: '/pages/wallet/wallet'
            })

        }

    },
    //挪车码
    getMove_code() {
        let token = wx.getStorageSync('token')
        if (token == '') {
            wx.navigateTo({
                url: "/pages/logs/logs",
            })
        } else {
            wx.navigateTo({
                url: '/pages/move_code/move_code'
            })

        }

    },
    // 分销
    getShareIt() {
        if (this.data.show == 'share') {


        } else {
            wx.navigateTo({
                url: "/pages/logs/logs"
            })
        }

    },
    //常见问题
    getProblem() {
        wx.navigateTo({
            url: '/pages/problem/problem'
        })
    },
    //使用说明
    getLegend() {
        wx.navigateTo({
            url: '/pages/legend/legend'
        })
    },
    //加盟代理
    getJoin() {
        let token = wx.getStorageSync('token')
        if (token == '') {
            wx.navigateTo({
                url: "/pages/logs/logs",
            })
        } else {
            wx.navigateTo({
                url: '/pages/Join/Join'
            })

        }

    },



    onHide: function () {

    },

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

    },

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

    },

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

    },

    /**
     * 用户点击右上角分享
     */
    onShareAppMessage: function () {
        var pic = this.data.pic
        return {
            imageUrl: pic, // 图片 URL
            path: '/pages/index/index',
        }
    }
})