index.js 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. // pages/mine/standing/index.js
  2. import {
  3. updateUserInfo
  4. } from '../../../utils/api/api'
  5. Page({
  6. /**
  7. * 页面的初始数据
  8. */
  9. data: {
  10. userInfo: wx.getStorageSync('userInfo')
  11. },
  12. getValue(e) {
  13. let type = e.currentTarget.dataset.type
  14. this.setData({
  15. [`userInfo.${type}`]: e.detail
  16. });
  17. },
  18. clearImg(e) {
  19. let type = e.currentTarget.dataset.type
  20. this.setData({
  21. [`userInfo.${type}`]: ''
  22. });
  23. },
  24. updateUserInfo() {
  25. updateUserInfo(this.data.userInfo).then(res => {
  26. wx.showToast({
  27. title: '修改成功',
  28. icon: 'none',
  29. duration: 800,
  30. mask: true,
  31. success: function () {
  32. setTimeout(function () {
  33. wx.switchTab({
  34. url: '/pages/mine/index/index',
  35. })
  36. }, 800)
  37. }
  38. })
  39. })
  40. },
  41. /**
  42. * 生命周期函数--监听页面加载
  43. */
  44. onLoad(options) {
  45. this.setData({
  46. userInfo: wx.getStorageSync('userInfo')
  47. })
  48. },
  49. /**
  50. * 生命周期函数--监听页面初次渲染完成
  51. */
  52. onReady() {
  53. },
  54. /**
  55. * 生命周期函数--监听页面显示
  56. */
  57. onShow() {
  58. },
  59. /**
  60. * 生命周期函数--监听页面隐藏
  61. */
  62. onHide() {
  63. },
  64. /**
  65. * 生命周期函数--监听页面卸载
  66. */
  67. onUnload() {
  68. },
  69. /**
  70. * 页面相关事件处理函数--监听用户下拉动作
  71. */
  72. onPullDownRefresh() {
  73. },
  74. /**
  75. * 页面上拉触底事件的处理函数
  76. */
  77. onReachBottom() {
  78. },
  79. /**
  80. * 用户点击右上角分享
  81. */
  82. onShareAppMessage() {
  83. }
  84. })