myInfo.ts 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. // component/myInfo/myInfo.ts
  2. Component({
  3. /**
  4. * 组件的属性列表
  5. */
  6. properties: {
  7. },
  8. /**
  9. * 组件的初始数据
  10. */
  11. data: {
  12. region: ['北京市', '北京市', '海淀区'],
  13. schoolArray: ['中国', '美国', '巴西', '日本'],
  14. schoolIndex: 0,
  15. classArray: ['一年级一班', '一年级2班', '一年级3班', '一年级4班'],
  16. classIndex: 0,
  17. isShowPassWord: true,
  18. userName: "",
  19. userPwd: ""
  20. },
  21. /**
  22. * 组件的方法列表
  23. */
  24. methods: {
  25. bindRegionChange: function (event: any) {
  26. this.setData({
  27. region: event.detail.value
  28. })
  29. },
  30. bindSchoolPicker: function (event: any) {
  31. let newArray;
  32. switch (Number(event.detail.value)) {
  33. case 0:
  34. newArray = ["一", "二", "三"];
  35. this.setData({
  36. classArray: newArray,
  37. classIndex: 0
  38. })
  39. break;
  40. case 1:
  41. newArray = ["4", "5", "6"];
  42. this.setData({
  43. classArray: newArray,
  44. classIndex: 0
  45. })
  46. break;
  47. case 2:
  48. newArray = ["as", "ad", "af"];
  49. this.setData({
  50. classArray: newArray,
  51. classIndex: 0
  52. })
  53. break;
  54. case 3:
  55. newArray = ["b1", "b2", "b3"];
  56. this.setData({
  57. classArray: newArray,
  58. classIndex: 0
  59. })
  60. break;
  61. }
  62. this.setData({
  63. schoolIndex: event.detail.value
  64. })
  65. },
  66. bindClssPicker: function (event: any) {
  67. this.setData({
  68. classIndex: event.detail.value
  69. })
  70. },
  71. showPwdTab: function () {
  72. if (this.data.isShowPassWord) {
  73. this.setData({
  74. isShowPassWord: false
  75. })
  76. } else {
  77. this.setData({
  78. isShowPassWord: true
  79. })
  80. }
  81. },
  82. bindUserNameInput: function (event: any) {
  83. this.setData({
  84. userName: event.detail.value
  85. })
  86. },
  87. bindUserPwdInput: function (event: any) {
  88. this.setData({
  89. userPwd: event.detail.value
  90. })
  91. },
  92. submitMyInfo: function () {
  93. if (!this.data.userName) {
  94. wx.showToast({
  95. title: '请输入姓名',
  96. icon: 'none',
  97. duration: 1000
  98. })
  99. return;
  100. }
  101. if (!this.data.userPwd) {
  102. wx.showToast({
  103. title: '请输入密码',
  104. icon: 'none',
  105. duration: 1000
  106. })
  107. return;
  108. }
  109. let params = {
  110. name: this.data.userName,
  111. address: this.data.region[0] + "--" + this.data.region[1] + "--" + this.data.region[2],
  112. school: this.data.schoolArray[this.data.schoolIndex],
  113. class: this.data.classArray[this.data.classIndex],
  114. password: this.data.userPwd
  115. }
  116. console.log("params:", params)
  117. }
  118. }
  119. })