index.js 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. const setData = require('../../utils/processingData');
  2. Component({
  3. options: {
  4. addGlobalClass: true,
  5. },
  6. /**
  7. * 组件的属性列表
  8. */
  9. properties: {
  10. /* 选择用户列表下标 */
  11. userIndex: {
  12. type: Number,
  13. value: 0
  14. }
  15. },
  16. /**
  17. * 组件的初始数据
  18. */
  19. data: {
  20. userList: [], //用户列表
  21. },
  22. /* 组件的生命周期 */
  23. lifetimes: {
  24. attached: function () {
  25. // 在组件实例进入页面节点树时执行
  26. let list = wx.getStorageSync('account_list');
  27. const userList = setData.imageType(list, "headportrait"),
  28. userIndex = (wx.getStorageSync('userData').index) ? wx.getStorageSync('userData').index : 0;
  29. this.triggerEvent('userChange', {
  30. userIndex: userIndex
  31. });
  32. this.setData({
  33. userList,
  34. userIndex
  35. });
  36. }
  37. },
  38. /**
  39. * 组件的方法列表
  40. */
  41. methods: {
  42. /* 用户账号选择 */
  43. userChange(e) {
  44. // console.log(e)
  45. const {
  46. index
  47. } = e.currentTarget.dataset;
  48. this.triggerEvent('userChange', {
  49. userIndex: index
  50. })
  51. }
  52. }
  53. })