index.js 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. const util = require("../../../utils/util")
  2. const app = getApp()
  3. Page({
  4. data: {
  5. spinShow: false,
  6. userInfo:{},
  7. },
  8. onShow: function () {
  9. app.checkLogin( userInfo=>{
  10. this.setData({userInfo})
  11. } )
  12. },
  13. doLoginByCode( code ){
  14. app.formPost( "Auth.WxLoginByCode", {code}).then( (res)=>{
  15. if( res.code == 200){
  16. this.setData( {userInfo: res.data})
  17. app.setUserInfo( res.data )
  18. }
  19. })
  20. },
  21. doGetPhoneNumber( code, iv, encryptedData ){
  22. let param = {code, iv, encryptedData }
  23. app.formPost( "Auth.WxLoginByPhone", param).then( (res)=>{
  24. if( res.code == 200){
  25. this.setData( {userInfo: res.data})
  26. app.setUserInfo( res.data )
  27. }
  28. })
  29. },
  30. logOut() {
  31. wx.setStorageSync('userId', '')
  32. wx.setStorageSync('token', '')
  33. wx.setStorageSync('@openid', '')
  34. let userInfo = {}
  35. this.setData({userInfo})
  36. app.setUserInfo( userInfo )
  37. wx.navigateTo({
  38. url: '/pages/index/index',
  39. })
  40. },
  41. gotoIdentify(){
  42. wx.navigateTo({
  43. url: '/pages/user/identify/index',
  44. })
  45. }
  46. })