index.js 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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.setData({
  30. userList,
  31. userIndex
  32. });
  33. }
  34. },
  35. /**
  36. * 组件的方法列表
  37. */
  38. methods: {
  39. /* 用户账号选择 */
  40. userChange(e) {
  41. // console.log(e)
  42. const {
  43. index
  44. } = e.currentTarget.dataset;
  45. this.triggerEvent('userChange', {
  46. userIndex: index
  47. })
  48. }
  49. }
  50. })