index.js 909 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  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. this.setData({
  24. userList: getApp().globalData.account_list
  25. });
  26. }
  27. },
  28. /**
  29. * 组件的方法列表
  30. */
  31. methods: {
  32. /* 用户账号选择 */
  33. userChange(e) {
  34. // console.log(e)
  35. const {
  36. index
  37. } = e.currentTarget.dataset;
  38. this.triggerEvent('userChange',{userIndex:index})
  39. }
  40. }
  41. })