index.js 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. // components/div-personal/index.js
  2. const Nova = getApp().Nova;
  3. const Parse = getApp().Parse;
  4. Component({
  5. /**
  6. * 组件的属性列表
  7. */
  8. properties: {
  9. options: null,
  10. },
  11. /**
  12. * 组件的初始数据
  13. */
  14. data: {
  15. portrait:
  16. "//b.yzcdn.cn/showcase/membercenter/2018/08/06/default_avatar@2x.png",
  17. user: null
  18. },
  19. /**
  20. * 组件的方法列表
  21. */
  22. async created() {
  23. },
  24. async attached() {
  25. await this.getUser()
  26. },
  27. pageLifetimes: {
  28. show: async function () {
  29. await this.getUser()
  30. }
  31. },
  32. ready: function () {
  33. // 在组件布局完成后执行,确保options参数中有data信息
  34. this.loadData();
  35. },
  36. methods: {
  37. async loadData() {
  38. await Nova.checkComponentsDataProperties(this);
  39. // let list = await Nova.getBlockData(this.data.options.data);
  40. let { options } = this.data;
  41. console.log("个人页面组", options);
  42. let { style } = options;
  43. this.setData({
  44. style
  45. });
  46. },
  47. async getUser() {
  48. const current = Parse && Parse.User && typeof Parse.User.current === 'function' ? Parse.User.current() : null
  49. const cuid = current && current.id ? current.id : ''
  50. if (!cuid) return
  51. let User = new Parse.Query('_User')
  52. let user = await User.get(cuid)
  53. this.setData({
  54. user: user.toJSON()
  55. })
  56. }
  57. },
  58. });