index.js 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. //index.js
  2. //获取应用实例
  3. const app = getApp()
  4. import Toast from '../../miniprogram/miniprogram_npm/vant-weapp/toast/toast'
  5. Page({
  6. data: {
  7. motto: 'Hello World',
  8. },
  9. //事件处理函数
  10. bindViewTap: function () {
  11. wx.navigateTo({
  12. url: '../logs/logs'
  13. })
  14. },
  15. classBtn: function () {
  16. const openid = app.globalData.openid;
  17. if (!openid) {
  18. Toast.fail('未找到用户信息,请重新进入');
  19. // wx.showToast({
  20. // title: '未找到用户信息',
  21. // icon: 'none'
  22. // })
  23. return;
  24. }
  25. const user = app.globalData.userInfo;
  26. if (!user) {
  27. this.toBind();
  28. return;
  29. }
  30. wx.redirectTo({
  31. url: '../work/index?type=0',
  32. })
  33. },
  34. beedroomBtn: function () {
  35. const openid = app.globalData.openid;
  36. if (!openid) {
  37. Toast.fail('未找到用户信息,请重新进入');
  38. // wx.showToast({
  39. // title: '未找到用户信息',
  40. // icon: 'none'
  41. // })
  42. return;
  43. }
  44. const user = app.globalData.userInfo;
  45. if (!user) {
  46. this.toBind();
  47. return;
  48. }
  49. wx.redirectTo({
  50. url: '../work/index?type=1',
  51. })
  52. },
  53. toBind() {
  54. wx.redirectTo({
  55. url: '/pages/bind/index',
  56. })
  57. },
  58. })