index.js 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. // nova-tourism/components/my/index.js
  2. let Parse = getApp().Parse;
  3. const company = getApp().globalData.company
  4. const auth = require('../../service/auth.service')
  5. const login = require("../../../utils/login");
  6. Component({
  7. /**
  8. * 组件的属性列表
  9. */
  10. properties: {
  11. },
  12. /**
  13. * 组件的初始数据
  14. */
  15. data: {
  16. statusBarHeight: 0,
  17. screenHeight: 0,
  18. customHeight: 0,
  19. bottomNavHeight: 0,
  20. contentHeight: 0,
  21. uid: null,
  22. User1List: [],
  23. },
  24. lifetimes: {
  25. detached: function () {},
  26. attached: async function () {
  27. const systemInfo = wx.getSystemInfoSync();
  28. const statusBarHeight = systemInfo.statusBarHeight || 0;
  29. const screenHeight = systemInfo.screenHeight || 0;
  30. const custom = wx.getMenuButtonBoundingClientRect();
  31. const customHeight = custom.height + 10 + 2 || 0;
  32. const bottomNavHeight = systemInfo.screenHeight - systemInfo.safeArea.bottom || 0;
  33. const contentHeight = (screenHeight - bottomNavHeight - 50 - statusBarHeight - customHeight) * 750 / systemInfo.windowWidth;
  34. this.setData({
  35. statusBarHeight,
  36. screenHeight,
  37. customHeight,
  38. bottomNavHeight,
  39. contentHeight,
  40. uid: Parse.User.current()?.id
  41. });
  42. this.getname()
  43. },
  44. },
  45. /**
  46. * 组件的方法列表
  47. */
  48. methods: {
  49. /**退出登录 */
  50. outLogin() {
  51. wx.showModal({
  52. title: '提示',
  53. content: '你确定退出登录吗?',
  54. showCancel: true,
  55. cancelText: '取消',
  56. cancelColor: '#000000',
  57. confirmText: '确定',
  58. confirmColor: '#3CC51F',
  59. success: (result) => {
  60. if (result.confirm) {
  61. auth.logout()
  62. }
  63. },
  64. fail: () => {},
  65. complete: () => {}
  66. });
  67. },
  68. gourl(e) {
  69. let userInfo = wx.getStorageSync("userLogin");
  70. if (userInfo == ''||!userInfo) {
  71. console.log(userInfo);
  72. login.loginNow()
  73. return
  74. }
  75. const url = e.currentTarget.dataset.url;
  76. wx.navigateTo({
  77. url: `${url}`,
  78. });
  79. },
  80. //获取头像名称
  81. async getname() {
  82. const currentUser = Parse.User.current();
  83. let Userquery = new Parse.Query('_User');
  84. Userquery.equalTo('company', company);
  85. Userquery.equalTo('objectId', currentUser.id);
  86. Userquery.notEqualTo('isDeleted', true)
  87. let P2 = await Userquery.find();
  88. let User1List = P2.map(item => item.toJSON());
  89. this.setData({
  90. User1List
  91. })
  92. console.log(this.data.User1List);
  93. },
  94. //我是商户
  95. merchant() {
  96. let userInfo = wx.getStorageSync("userLogin");
  97. if (userInfo == ''||!userInfo) {
  98. console.log(userInfo);
  99. login.loginNow()
  100. return
  101. }
  102. let merchant = wx.getStorageSync('merchant');
  103. if (merchant) {
  104. wx.navigateTo({
  105. url: '/nova-tourism/pages/my/merchant/merchant-home/index'
  106. });
  107. } else {
  108. wx.navigateTo({
  109. url: '/nova-tourism/pages/my/merchant/login/index'
  110. });
  111. }
  112. },
  113. goorder(e) {
  114. let userInfo = wx.getStorageSync("userLogin");
  115. if (userInfo == ''||!userInfo) {
  116. console.log(userInfo);
  117. login.loginNow()
  118. return
  119. }
  120. const url = e.currentTarget.dataset.url;
  121. const active = e.currentTarget.dataset.active;
  122. wx.navigateTo({
  123. url: `${url}?active=` + active,
  124. });
  125. },
  126. gorefund() {
  127. let userInfo = wx.getStorageSync("userLogin");
  128. if (userInfo == ''||!userInfo) {
  129. console.log(userInfo);
  130. login.loginNow()
  131. return
  132. }
  133. wx.navigateTo({
  134. url: '../../pages/my/my-order/my-refund/index',
  135. });
  136. }
  137. }
  138. })