index.js 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. // pages/welcome/index.js
  2. import * as API_Passport from '../../api/passport.js'
  3. import * as Common from '../../utils/common'
  4. const app =getApp()
  5. Page({
  6. /**
  7. * 页面的初始数据
  8. */
  9. data: {
  10. },
  11. /**
  12. * 生命周期函数--监听页面加载
  13. */
  14. onLoad: function (options) {
  15. wx.getSetting({
  16. complete: (res) => {
  17. console.log('w',!res.authSetting['scope.userInfo'])
  18. if (!res.authSetting['scope.userInfo']) {
  19. wx.removeStorageSync('welcome')
  20. wx.removeStorageSync('hasAuthorize')
  21. } else {
  22. // if(wx.getStorageSync('authorInfo')!==''){
  23. // wx.switchTab({
  24. // url: '/pages/store/index',
  25. // })
  26. // return
  27. // }
  28. wx.setStorageSync('welcome', true)
  29. wx.setStorageSync('hasAuthorize', true)
  30. Common.hasUserInfoAutoLogin()
  31. }
  32. },
  33. })
  34. },
  35. /**
  36. * 生命周期函数--监听页面初次渲染完成
  37. */
  38. onReady: function () {
  39. },
  40. /**
  41. * 生命周期函数--监听页面显示
  42. */
  43. onShow: function () {
  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. getUserInfo(e){
  71. const {
  72. errMsg
  73. } = e.detail
  74. if (errMsg === 'getUserInfo:ok') {
  75. wx.setStorageSync('welcome', true)
  76. wx.setStorageSync('hasAuthorize', true)
  77. Common.hasUserInfoAutoLogin()
  78. }
  79. },
  80. loadsuccess(e){
  81. console.log('s',e)
  82. },
  83. loaderror(e){
  84. console.log('e',e)
  85. }
  86. })