index.js 1.3 KB

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