edit.js 1.9 KB

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