// components/div-personal/index.js
const Nova = getApp().Nova;
const Parse = getApp().Parse;

Component({
  /**
   * 组件的属性列表
   */
  properties: {
    options: null,
  },

  /**
   * 组件的初始数据
   */
  data: {
    portrait:
      "//b.yzcdn.cn/showcase/membercenter/2018/08/06/default_avatar@2x.png",
      user: null
  },

  /**
   * 组件的方法列表
   */
   async created() {
   },
   async attached() {
    await this.getUser()
   },
  ready: function () {
    // 在组件布局完成后执行，确保options参数中有data信息
    this.loadData();
  },

  methods: {
    async loadData() {
      await Nova.checkComponentsDataProperties(this);
      // let list = await Nova.getBlockData(this.data.options.data);
      
      let { options } = this.data;
      console.log("个人页面组", options);
      let { style } = options;
      this.setData({
        style
      });
    },
    async getUser() {
        let cuid = Parse.User.current().id
        console.log(cuid)
        let User = new Parse.Query('User')
        if(cuid) {
            let user =await User.get(cuid)
            this.setData({
                user: user.toJSON()
            })
            console.log(user)
        }
    }
  },
});
