index.js 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. const api = require('../../utils/api.js');
  2. // const app = getApp(),
  3. // {
  4. // globalData: {
  5. // util: {
  6. // regeneratorRuntime,
  7. // goLogin,
  8. // navigate_auth_native,
  9. // getUserInfo
  10. // }
  11. // }
  12. // } = app;
  13. Page({
  14. onLoad() {
  15. this.setData({
  16. list: [
  17. {
  18. title: '个人信息',
  19. icon: 'user-icon',
  20. url: '/pages/student/user/user',
  21. },
  22. {
  23. title: '我的投诉建议',
  24. icon: 'user-icon',
  25. url: '/pages/student/proposalList/proposalList',
  26. },
  27. {
  28. title: '我的设置',
  29. icon: 'shezhi',
  30. url: 'setting/index',
  31. }
  32. ]
  33. })
  34. },
  35. onShow() {
  36. let userInfo = wx.getStorageSync('user')
  37. this.setData({
  38. photo: userInfo.headImage ? api.total.split('.if')[0]+userInfo.headImage :'/images/default-urser.png',
  39. viewName: userInfo.userName
  40. })
  41. // if (!userInfo){
  42. // let { viewName = '', photo = '' } = await getUserInfo()
  43. // this.setData({
  44. // photo,
  45. // viewName
  46. // })
  47. // }else{
  48. // this.setData({
  49. // photo: userInfo.avatarUrl,
  50. // viewName: userInfo.nickName
  51. // })
  52. // }
  53. },
  54. navigate_auth:function(e){
  55. wx.navigateTo({
  56. url: e.currentTarget.dataset.url,
  57. })
  58. },
  59. updateimage:function(){
  60. let that=this
  61. wx.chooseImage({
  62. count:1,
  63. success: function(res) {
  64. wx.showLoading({
  65. title: '正在上传',
  66. })
  67. wx.uploadFile({
  68. url: api.updateimage,
  69. filePath: res.tempFilePaths[0],
  70. header: { 'content-type': 'application/x-www-form-urlencoded;charset=utf-8', },
  71. name: 'file',
  72. formData: {
  73. 'fileType': 'image',
  74. 'loginId': wx.getStorageSync('loginId')
  75. },
  76. success(res) {
  77. wx.hideLoading()
  78. if (JSON.parse(res.data).status == true) {
  79. let user = wx.getStorageSync('user')
  80. user.headImage = JSON.parse(res.data).headImage
  81. wx.setStorageSync('user', user)
  82. that.setData({
  83. photo: api.total.split('.if')[0]+user.headImage
  84. })
  85. wx.showToast({
  86. title: '修改成功',
  87. icon:'none'
  88. })
  89. }
  90. }
  91. })
  92. },
  93. })
  94. },
  95. // goLogin,
  96. // navigate_auth_native
  97. })