index.js 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  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. studenturl: '/pages/student/user/user',
  21. teacherurl:'/pages/student/user/user'
  22. },
  23. {
  24. title: '我的投诉建议',
  25. icon: 'tousu',
  26. studenturl: '/pages/student/proposalList/proposalList',
  27. teacherurl:''
  28. },
  29. {
  30. title: '我的设置',
  31. icon: 'shezhi',
  32. studenturl: 'setting/index',
  33. teacherurl:'setting/index'
  34. }
  35. ]
  36. })
  37. },
  38. onShow() {
  39. let userInfo = wx.getStorageSync('user')
  40. this.setData({
  41. photo: userInfo.headImage ? api.total.split('.if')[0]+userInfo.headImage :'/images/default-urser.png',
  42. viewName: userInfo.userName,
  43. roleType:wx.getStorageSync('user').roleType
  44. })
  45. // if (!userInfo){
  46. // let { viewName = '', photo = '' } = await getUserInfo()
  47. // this.setData({
  48. // photo,
  49. // viewName
  50. // })
  51. // }else{
  52. // this.setData({
  53. // photo: userInfo.avatarUrl,
  54. // viewName: userInfo.nickName
  55. // })
  56. // }
  57. },
  58. navigate_auth:function(e){
  59. if (e.currentTarget.dataset.url){
  60. wx.navigateTo({
  61. url: e.currentTarget.dataset.url,
  62. })
  63. }else{
  64. wx.showToast({
  65. title: '功能开发中',
  66. icon:'none'
  67. })
  68. }
  69. },
  70. updateimage:function(){
  71. let that=this
  72. wx.chooseImage({
  73. count:1,
  74. success: function(res) {
  75. wx.showLoading({
  76. title: '正在上传',
  77. })
  78. wx.uploadFile({
  79. url: api.updateimage,
  80. filePath: res.tempFilePaths[0],
  81. header: { 'content-type': 'application/x-www-form-urlencoded;charset=utf-8', },
  82. name: 'file',
  83. formData: {
  84. 'fileType': 'image',
  85. 'loginId': wx.getStorageSync('loginId')
  86. },
  87. success(res) {
  88. wx.hideLoading()
  89. if (JSON.parse(res.data).status == true) {
  90. let user = wx.getStorageSync('user')
  91. user.headImage = JSON.parse(res.data).headImage
  92. wx.setStorageSync('user', user)
  93. that.setData({
  94. photo: api.total.split('.if')[0]+user.headImage
  95. })
  96. wx.showToast({
  97. title: '修改成功',
  98. icon:'none'
  99. })
  100. }
  101. }
  102. })
  103. },
  104. })
  105. },
  106. // goLogin,
  107. // navigate_auth_native
  108. })