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

    /**
     * 页面的初始数据
     */
    data: {
        btnInfo: null,
        menuList: [
            {
                icon: '/image/my/youhuiquan.png',
                text: '优惠券',
                url:'/pages/my/coupon/coupon'
            },
            {
                icon: '/image/my/fenxianghaoyou.png',
                text: '分享好友'
            }, {
                icon: '/image/my/dizhiguanli.png',
                text: '地址管理',
                url:'/pages/my/address/address'

            }, {
                icon: '/image/my/fuwuliucheng.png',
                text: '服务流程'
            }, {
                icon: '/image/my/yonghuxieyi.png',
                text: '用户协议'
            }, {
                icon: '/image/my/lipeixize.png',
                text: '理赔细则'
            }, {
                icon: '/image/my/kefurexian.png',
                text: '客服热线'
            }
        ],
        active: false,
        userInfo:"",
        hasUserInfo:false,
        code:""
    },

    /**
     * 生命周期函数--监听页面加载
     */
    onLoad: function (options) {
        this.getBtnInfo()
        this.setData({
            code:wx.getStorageSync('phone'),
        })
        if (this.data.active == true) {
            this.data.menuList.shift()
            this.setData({
                code:wx.getStorageSync('phone'),
                menuList:this.data.menuList
            })

        }
    },

    getBtnInfo() {
        this.setData({
            btnInfo: app.globalData.btnInfo
        })
    },

    toUrl(e){
        let url = e.currentTarget.dataset.url
        wx.navigateTo({
          url,
        })
    },
    getUserProfile(e) {
        // 推荐使用wx.getUserProfile获取用户信息，开发者每次通过该接口获取用户个人信息均需用户确认
        // 开发者妥善保管用户快速填写的头像昵称，避免重复弹窗
        wx.getUserProfile({
          desc: '用于完善会员资料', // 声明获取用户个人信息后的用途，后续会展示在弹窗中，请谨慎填写
          success: (res) => {
            this.setData({
              userInfo: res.userInfo,
              hasUserInfo: true
            })
          }
        })
      },
      getPhoneNumber (e){
        console.log(e)
        this.setData({
            code: e.detail.code,
          })
      }

})