index.js 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. const util = require("../../../utils/util")
  2. const app = getApp()
  3. Page({
  4. data: {
  5. spinShow: false,
  6. userInfo:{},
  7. out:0,
  8. visit:0
  9. },
  10. onShow: function () {
  11. app.checkLogin( userInfo =>{
  12. this.setData({userInfo})
  13. if( userInfo.adminId >0){
  14. this.loadConfirm()
  15. }
  16. })
  17. },
  18. loadConfirm(){
  19. app.formPost('User.confirmInfo', {} ).then(res => {
  20. if (res.code === 200) {
  21. let {out, visit} = res.data;
  22. this.setData({out, visit});
  23. }
  24. })
  25. },
  26. goLogin( e){
  27. wx.navigateTo({
  28. url: '/pages/index/index',
  29. })
  30. },
  31. logOut() {
  32. wx.setStorageSync('userId', '')
  33. wx.setStorageSync('@token', '')
  34. wx.setStorageSync('@openid', '')
  35. let userInfo = {}
  36. this.setData({userInfo})
  37. app.setUserInfo( userInfo )
  38. },
  39. gotoConfirmOut( e ){
  40. if( this.data.userInfo.adminId==0){
  41. return;
  42. }
  43. wx.navigateTo({
  44. url: `/pages/user/out/index`,
  45. })
  46. },
  47. gotoConfirmVisit( e ){
  48. if( this.data.userInfo.adminId==0){
  49. return;
  50. }
  51. wx.navigateTo({
  52. url: `/pages/user/visit/index`,
  53. })
  54. }
  55. })