RoleSelectionPage.js 1.0 KB

123456789101112131415161718192021222324252627282930313233343536
  1. Component({
  2. data: {
  3. },
  4. methods: {
  5. //普通用户
  6. selectRegularUser(e) {
  7. let data = e.currentTarget.dataset;
  8. let url = data.path;
  9. // 存储普通用户信息到本地缓存
  10. wx.setStorageSync('userRole', 'regular'); // 存储角色为普通用户
  11. wx.setStorageSync('rolePath', url); // 存储路径(可选)
  12. // 可能还需要进行页面跳转或其他逻辑
  13. wx.reLaunch({
  14. url: '/shoping/Home/Home',
  15. });
  16. },
  17. //管理员
  18. selectAdmin(e) {
  19. let data = e.currentTarget.dataset;
  20. let url = data.path;
  21. // 存储管理员信息到本地缓存
  22. wx.setStorageSync('userRole', 'admin'); // 存储角色为管理员
  23. wx.setStorageSync('rolePath', url); // 存储路径(可选)
  24. // 可能还需要进行页面跳转或其他逻辑
  25. wx.reLaunch({
  26. url: '/pages/threshold/threshold',
  27. });
  28. },
  29. // 隐藏返回首页按钮
  30. onShow: function() {
  31. if(wx.canIUse('hideHomeButton')) {
  32. wx.hideHomeButton();
  33. }
  34. }
  35. },
  36. });