mine.js 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. // pages/mine/mine.js
  2. Page({
  3. /**
  4. * 页面的初始数据
  5. */
  6. data: {
  7. //id
  8. idMyInfo:'idMyInfo',
  9. idCompanyInfo: 'idCompanyInfo',
  10. idAbout: 'idAbout',
  11. },
  12. /**
  13. * 生命周期函数--监听页面加载
  14. */
  15. onLoad: function (options) {
  16. },
  17. /**
  18. * 生命周期函数--监听页面初次渲染完成
  19. */
  20. onReady: function () {
  21. },
  22. btnClick: function (event) {
  23. var that = this
  24. var id = event.currentTarget.id
  25. if (id == that.data.idMyInfo){
  26. wx.navigateTo({
  27. url: '../perinfo/perinfo',
  28. })
  29. } else if (id == that.data.idCompanyInfo){
  30. } else if (id == that.data.idAbout){
  31. }
  32. },
  33. /**
  34. * 生命周期函数--监听页面显示
  35. */
  36. onShow: function () {
  37. this.setData({
  38. isRegistered: wx.getStorageSync('isRegistered'),
  39. isLogin: wx.getStorageSync('wxnickName') ? true : false,
  40. canIUse: wx.canIUse('button.open-type.getUserInfo'),
  41. headerImg: wx.getStorageSync('wxavatarUrl'),
  42. wxNickname: wx.getStorageSync('wxnickName'),
  43. isRegistered: wx.getStorageSync('isRegistered'),
  44. })
  45. },
  46. bindGetUserInfo: function (e) {
  47. var that = this
  48. var userInfo = e.detail.userInfo
  49. // console.log('bindGetUserInfo', userInfo)
  50. var nickName = userInfo.nickName
  51. var avatarUrl = userInfo.avatarUrl
  52. var gender = userInfo.gender //性别 0:未知、1:男、2:女
  53. var province = userInfo.province
  54. var city = userInfo.city
  55. var country = userInfo.country
  56. if (nickName && avatarUrl) {
  57. that.setData({
  58. wxNickname: nickName,
  59. wxHeader: avatarUrl,
  60. isLogin: true
  61. })
  62. try {
  63. wx.setStorageSync('wxavatarUrl', userInfo.avatarUrl)
  64. wx.setStorageSync('wxnickName', userInfo.nickName)
  65. } catch (e) {
  66. }
  67. }
  68. },
  69. /**
  70. * 生命周期函数--监听页面隐藏
  71. */
  72. onHide: function () {
  73. },
  74. /**
  75. * 生命周期函数--监听页面卸载
  76. */
  77. onUnload: function () {
  78. },
  79. /**
  80. * 页面相关事件处理函数--监听用户下拉动作
  81. */
  82. onPullDownRefresh: function () {
  83. },
  84. /**
  85. * 页面上拉触底事件的处理函数
  86. */
  87. onReachBottom: function () {
  88. },
  89. /**
  90. * 用户点击右上角分享
  91. */
  92. onShareAppMessage: function () {
  93. }
  94. })