person.js 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. // pages/person/person.js
  2. const app = getApp()
  3. Page({
  4. /**
  5. * 页面的初始数据
  6. */
  7. data: {
  8. hasUserInfo: false
  9. },
  10. /**
  11. * 生命周期函数--监听页面加载
  12. */
  13. onLoad: async function (options) {
  14. let userInfo = await app.getWxUserInfo()
  15. console.log(2222222222222)
  16. console.log(userInfo);
  17. if (userInfo) {
  18. this.setData({
  19. userInfo: userInfo,
  20. hasUserInfo: true,
  21. hasMobile: userInfo.mobile ? true : false
  22. })
  23. }
  24. },
  25. /**
  26. * 生命周期函数--监听页面初次渲染完成
  27. */
  28. onReady: function () {
  29. },
  30. /**
  31. * 生命周期函数--监听页面显示
  32. */
  33. onShow: async function () {
  34. let userInfo = await app.getWxUserInfo()
  35. console.log(2222222222222)
  36. console.log(userInfo);
  37. if (userInfo) {
  38. this.setData({
  39. userInfo: userInfo,
  40. hasUserInfo: true,
  41. hasMobile: userInfo.mobile ? true : false
  42. })
  43. }
  44. },
  45. /**
  46. * 生命周期函数--监听页面隐藏
  47. */
  48. onHide: function () {
  49. },
  50. /**
  51. * 生命周期函数--监听页面卸载
  52. */
  53. onUnload: function () {
  54. },
  55. /**
  56. * 页面相关事件处理函数--监听用户下拉动作
  57. */
  58. onPullDownRefresh: function () {
  59. },
  60. /**
  61. * 页面上拉触底事件的处理函数
  62. */
  63. onReachBottom: function () {
  64. },
  65. /**
  66. * 用户点击右上角分享
  67. */
  68. onShareAppMessage: function () {
  69. },
  70. getInfo: async function (e) {
  71. const _self = this
  72. let userInfo = e.detail.userInfo
  73. userInfo['encryptedData'] = e.detail.encryptedData
  74. userInfo['iv'] = e.detail.iv
  75. let info = await app.wxLogin(userInfo);
  76. let hasMobile = false;
  77. if (info.mobile) {
  78. hasMobile = true
  79. }
  80. _self.setData({
  81. hasUserInfo: true,
  82. userInfo: info,
  83. hasMobile: hasMobile,
  84. })
  85. },
  86. gotoComment: async function (e) {
  87. console.log(this)
  88. const isAuth = await app.isAuth()
  89. if (!isAuth) {
  90. wx.redirectTo({
  91. url: '/pages/prompt/prompt?page=pages/comments/comments',
  92. })
  93. return
  94. }
  95. wx.navigateTo({
  96. url: '../comments/comments?title=我的评论&commentstype=my',
  97. })
  98. },
  99. gotoPersonInfo: function (e) {
  100. wx.navigateTo({
  101. url: '../personinfo/personinfo',
  102. })
  103. },
  104. gotoOrder: function (e) {
  105. wx.switchTab({
  106. url: '../personorder/personorder',
  107. })
  108. }
  109. })