info.js 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. // pages/contest/contest.js
  2. import {
  3. imine
  4. } from '../../../api/api.js'
  5. Page({
  6. /**
  7. * 页面的初始数据
  8. */
  9. data: {
  10. sexList: [{label:'男',value:1},{label:'女',value:2}],
  11. form: {},
  12. areaList: [],
  13. school: []
  14. },
  15. changeInput (e) {
  16. const id = e.currentTarget.id;
  17. const value = e.detail.value;
  18. this.setData({
  19. ['form.'+id]: value
  20. })
  21. },
  22. bindAddrChange (e) {
  23. const id = e.currentTarget.id;
  24. const value = e.detail.value
  25. this.setData({
  26. ['form.'+id]: value.join(' ')
  27. })
  28. },
  29. bindPickerSex (e) {
  30. const id = e.currentTarget.id;
  31. const value = e.detail.value
  32. this.setData({
  33. ['form.'+id]: this.data.sexList[value].value
  34. })
  35. },
  36. bindPickerSchool (e) {
  37. const id = e.currentTarget.id;
  38. const value = e.detail.value
  39. this.setData({
  40. ['form.'+id]: this.data.areaList[value].id,
  41. ['form.schoolName']: this.data.schoolList[value].schoolName
  42. })
  43. },
  44. bindPickerChange(e) {
  45. const id = e.currentTarget.id;
  46. const value = e.detail.value
  47. this.setData({
  48. ['form.'+id]: this.data.areaList[value].id,
  49. ['form.areaName']: this.data.areaList[value].areaName
  50. }, () => {
  51. imine.querySchoolByAreaId({reqdata:{
  52. id: this.data.form[id]
  53. }},r => {
  54. this.setData({
  55. schoolList: r.list
  56. })
  57. })
  58. })
  59. },
  60. submit (e) {
  61. let {actualName,age,area,grade,other,school} = this.data.form
  62. let id = wx.getStorageSync('id')
  63. imine.updateUser({reqdata:{actualName,age,area,grade,other,school,id}},r => {
  64. this.loadMyinformation()
  65. wx.navigateTo({
  66. url: '/pages/contest/answer/answer'
  67. })
  68. })
  69. },
  70. queryAllArea () {
  71. imine.queryAllArea({},r => {
  72. this.setData({
  73. areaList: r.list
  74. })
  75. })
  76. },
  77. loadMyinformation() {
  78. let id = wx.getStorageSync('id')
  79. imine.loadMyinformation({reqdata: {id}},r => {
  80. wx.setStorage({
  81. key: 'user',
  82. data: r.object
  83. })
  84. })
  85. },
  86. /**
  87. * 生命周期函数--监听页面加载
  88. */
  89. onLoad: function (options) {
  90. this.queryAllArea()
  91. },
  92. /**
  93. * 生命周期函数--监听页面初次渲染完成
  94. */
  95. onReady: function () {
  96. },
  97. /**
  98. * 生命周期函数--监听页面显示
  99. */
  100. onShow: function () {
  101. },
  102. /**
  103. * 生命周期函数--监听页面隐藏
  104. */
  105. onHide: function () {
  106. },
  107. /**
  108. * 生命周期函数--监听页面卸载
  109. */
  110. onUnload: function () {
  111. },
  112. /**
  113. * 页面相关事件处理函数--监听用户下拉动作
  114. */
  115. onPullDownRefresh: function () {
  116. },
  117. /**
  118. * 页面上拉触底事件的处理函数
  119. */
  120. onReachBottom: function () {
  121. },
  122. /**
  123. * 用户点击右上角分享
  124. */
  125. onShareAppMessage: function () {
  126. }
  127. })