index.js 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. import {
  2. createStoreBindings
  3. } from 'mobx-miniprogram-bindings'
  4. import {
  5. store
  6. } from "../../store/index";
  7. Page({
  8. data: {},
  9. onLoad() {
  10. this.storeBindings = createStoreBindings(this, {
  11. store,
  12. fields: ["token", "phone"],
  13. actions: ["setStore"],
  14. });
  15. },
  16. onUnload() {
  17. this.storeBindings.destroyStoreBindings();
  18. },
  19. onShow() {
  20. if (typeof this.getTabBar === 'function' &&
  21. this.getTabBar()) {
  22. this.getTabBar().setData({
  23. selected: 3
  24. })
  25. }
  26. },
  27. goto() {
  28. const token = this.data.token ?? ""
  29. if (token === '') {
  30. wx.navigateTo({
  31. url: "../../userLogin/pages/login/index"
  32. })
  33. }
  34. },
  35. goOrder() {
  36. const token = this.data.token ?? ""
  37. if (token === '') {
  38. wx.showModal({
  39. title: '提示',
  40. content: '是否去登录?',
  41. success(res) {
  42. if (res.confirm) {
  43. wx.navigateTo({
  44. url: "../../userLogin/pages/login/index"
  45. })
  46. }
  47. }
  48. })
  49. } else {
  50. wx.switchTab({
  51. url: '/pages/order/index'
  52. })
  53. }
  54. },
  55. pagelogout() {
  56. wx.showModal({
  57. title: '提示',
  58. content: '是否确认退出登录',
  59. success: async (res) => {
  60. if (res.confirm) {
  61. await this.setStore()
  62. }
  63. }
  64. })
  65. },
  66. })