userinfo.ts 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. // pages/userinfo/userinfo.js
  2. import { getHwUserInfo, upLoadImage } from '../../utils/util'
  3. import api from '../../api/api'
  4. Page({
  5. /**
  6. * 页面的初始数据
  7. */
  8. data: {
  9. region: ['江苏省', '无锡市', '新吴区'],
  10. userInfo: {}
  11. },
  12. /**
  13. * 更换头像
  14. * @licenseFront 后台接取的字段
  15. */
  16. changeAvatar() {
  17. wx.chooseImage({
  18. success: (res) => {
  19. upLoadImage({
  20. files: res.tempFilePaths,
  21. name: 'licenseFront',
  22. url: api.hwUser.changeAvatar
  23. }).then((data) => {
  24. wx.setStorageSync('userInfo', data[0].hwUser);
  25. this.setData({
  26. userInfo: data[0].hwUser
  27. })
  28. }).catch(() => { })
  29. },
  30. })
  31. },
  32. /**
  33. * 生命周期函数--监听页面加载
  34. */
  35. onLoad: function () {
  36. },
  37. /**
  38. * 生命周期函数--监听页面初次渲染完成
  39. */
  40. onReady: function () {
  41. },
  42. /**
  43. * 生命周期函数--监听页面显示
  44. */
  45. onShow: async function () {
  46. // 获取个人信息
  47. await getHwUserInfo()
  48. this.setData({
  49. userInfo: wx.getStorageSync('userInfo'),
  50. })
  51. },
  52. /**
  53. * 生命周期函数--监听页面隐藏
  54. */
  55. onHide: function () {
  56. },
  57. /**
  58. * 生命周期函数--监听页面卸载
  59. */
  60. onUnload: function () {
  61. },
  62. /**
  63. * 页面相关事件处理函数--监听用户下拉动作
  64. */
  65. onPullDownRefresh: function () {
  66. },
  67. /**
  68. * 页面上拉触底事件的处理函数
  69. */
  70. onReachBottom: function () {
  71. }
  72. })