index.js 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  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. // topList: [
  17. // {
  18. // title: '系统消息',
  19. // icon: 'systemMsg',
  20. // url: 'message/index',
  21. // },
  22. // {
  23. // title: '用户信息',
  24. // icon: 'material',
  25. // url: 'myInfo/index',
  26. // },
  27. // {
  28. // title: '一键定位',
  29. // icon: 'nav',
  30. // url: 'localtion/index',
  31. // }
  32. // ],
  33. list: [
  34. {
  35. title: '个人信息',
  36. icon: 'user-icon',
  37. url: '../student/user/user',
  38. },
  39. // {
  40. // title: '我的预约',
  41. // icon: 'yuyue',
  42. // url: 'reservation/index',
  43. // },
  44. // {
  45. // title: '我的排队',
  46. // icon: 'paidui',
  47. // url: '',
  48. // },
  49. // {
  50. // title: '我的材料',
  51. // icon: 'cailiao',
  52. // url: 'myData/myData',
  53. // },
  54. // {
  55. // title: '我的收藏',
  56. // icon: 'shoucang',
  57. // url: 'myCollect/index',
  58. // },
  59. // {
  60. // title: '我的评价',
  61. // icon: 'assess',
  62. // url: 'assess/assess',
  63. // },
  64. // {
  65. // title: '我的咨询',
  66. // icon: 'zixun',
  67. // url: 'advisory/advisory',
  68. // },
  69. // {
  70. // title: '我的投诉',
  71. // icon: 'tousu',
  72. // url: 'complaint/complaint',
  73. // },
  74. {
  75. title: '我的设置',
  76. icon: 'shezhi',
  77. url: 'setting/index',
  78. }
  79. ]
  80. })
  81. },
  82. async onShow() {
  83. let userInfo = wx.getStorageSync('userInfo')
  84. if (!userInfo){
  85. let { viewName = '', photo = '' } = await getUserInfo()
  86. this.setData({
  87. photo,
  88. viewName
  89. })
  90. }else{
  91. this.setData({
  92. photo: userInfo.avatarUrl,
  93. viewName: userInfo.nickName
  94. })
  95. }
  96. },
  97. navigate_auth:function(e){
  98. wx.navigateTo({
  99. url: e.currentTarget.dataset.url,
  100. })
  101. },
  102. updateimage:function(){
  103. let that=this
  104. wx.chooseImage({
  105. count:1,
  106. success: function(res) {
  107. wx.showLoading({
  108. title: '正在上传',
  109. })
  110. wx.uploadFile({
  111. url: api.updateimage,
  112. filePath: res.tempFilePaths[0],
  113. header: { 'content-type': 'application/x-www-form-urlencoded;charset=utf-8', },
  114. name: 'file',
  115. formData: {
  116. 'fileType': 'image',
  117. 'loginId': wx.getStorageSync('loginId')
  118. },
  119. success(res) {
  120. wx.hideLoading()
  121. console.log(res)
  122. if (JSON.parse(res.data).status == true) {
  123. let user = wx.getStorageSync('userInfo')
  124. user.avatarUrl = api.total.split('.if')[0] + JSON.parse(res.data).headImage
  125. wx.setStorageSync('userInfo', user)
  126. that.setData({
  127. photo: user.avatarUrl
  128. })
  129. wx.showToast({
  130. title: '修改成功',
  131. icon:'none'
  132. })
  133. }
  134. }
  135. })
  136. },
  137. })
  138. },
  139. goLogin,
  140. // navigate_auth_native
  141. })