var app = getApp();
var that;
import 'dingtalk-jsapi/entry/mobile';
import openLink from 'dingtalk-jsapi/api/biz/util/openLink';
Page({
  data: {
    userData:[],
    corpMessage:{},
    vipText:'立即开通',
    isShowNew:true,
    vipData:'',
  },
  onLoad(query) {
    that = this;
    dd.setNavigationBar({ title: "我的" });
    this.setData({userData:app.globalData.userData,corpMessage:app.globalData.corpMessage});
    this.getVip();
    // console.log("123")
  },
  getVip(){
    app.$get("api/order/goods/special").then((res) => {
        this.setData({
          vipData:res.data.data,
          vipText:res.data.data.status==2?'已开通':'立即开通'
        })
    })
  },
  openView2(){
    dd.navigateTo({
      url: '../buy/buy?code=' + this.data.vipData.goods_code
    })
  },
  onShow(){
    dd.getStorage({
      key: 'isShowNew',
      success: function (res) {
        if(res.data){
          that.setData({isShowNew:false});
        }
      }
    });
  },
  //跳转
  openView(e) {
    var index = e.target.dataset.index-1;
    if(index==5){
      openLink({
        url: `https://page.dingtalk.com/wow/dingtalk/act/serviceconversation?wh_biz=tm&showmenu=false&goodsCode=DT_GOODS_881607043109331&corpId=${app.globalData.corpId}&token=5784a3e6b5e025ee891517ea814180f4`
      })
      return;
    }
    var urls = [
      { url: '../addMoney/addMoney', query: '' },
      { url: '../organization/organization', query: '' },
      { url: '../integralRule/integralRule', query: '' },
      { url: '../setCheck/setCheck', query: '' },
      { url: '../upgrade/upgrade', query: '' },
      { url: '../buy/buy', query: '' },
      { url: '../buy/buy', query: '' },
    ];
    
    dd.navigateTo({
      url: urls[index].url+'?'+urls[index].query
    })
  },
});
