edit.js 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. import {
  2. imine,
  3. ihome
  4. } from '../../../../api/api.js'
  5. Page({
  6. data: {
  7. user: {},
  8. modalKeys: {
  9. realname: '姓名',
  10. mobile: '联系方式',
  11. birthday: '出生年月',
  12. gender: '性别',
  13. brief_intro: '自我介绍'
  14. },
  15. placeholder: {
  16. realname: '请填写姓名',
  17. mobile: '请填写手机号',
  18. birthday: '请填写出生年月',
  19. brief_intro: '请填写自我介绍'
  20. }
  21. },
  22. changeBirthday(e) {
  23. this.data.user['birthday'] = e.detail.value
  24. imine.loadEditMyinformation(this.data.user, r => {
  25. this.loadMyinformation()
  26. })
  27. },
  28. clickConfirm() {
  29. this.data.user[this.data.modalKey] = this.data.inputInfo
  30. imine.loadEditMyinformation(this.data.user, r => {
  31. this.setData({
  32. inputInfo: '',
  33. modalKey: ''
  34. })
  35. this.loadMyinformation()
  36. })
  37. },
  38. clickRadio(e) {
  39. this.setData({
  40. inputInfo: e.currentTarget.dataset.v
  41. })
  42. },
  43. inputInfo(e) {
  44. console.log(e)
  45. this.setData({
  46. inputInfo: e.detail.value
  47. })
  48. },
  49. hideModal() {
  50. this.setData({
  51. modalKey: ''
  52. })
  53. },
  54. clickInfo(e) {
  55. let k = e.currentTarget.dataset.key
  56. this.setData({
  57. modalKey: k,
  58. inputText: this.data.user[k],
  59. inputInfo: this.data.user[k]
  60. })
  61. },
  62. loadMyinformation() {
  63. imine.loadMyinformation({reqdata:{id:1}},r => {
  64. this.setData({
  65. user: Object.assign(this.data.user, r.userinfo)
  66. })
  67. wx.setStorage({
  68. key: 'user',
  69. data: this.data.user
  70. })
  71. })
  72. },
  73. onLoad(args) {
  74. wx.getStorage({
  75. key: 'user',
  76. success: r => {
  77. this.setData({
  78. user: Object.assign(this.data.user, r.data)
  79. })
  80. },
  81. })
  82. this.loadMyinformation()
  83. this.setData({
  84. endDate: new Date().format('yyyy-MM-dd'),
  85. })
  86. },
  87. })