mine.js 2.3 KB

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