You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

31 lines
1.1 KiB

3 months ago
4 months ago
3 months ago
  1. export let goPage = (url, params = {}, type = 'navigateTo') => {
  2. uni.$u.route({
  3. url,
  4. params,
  5. type
  6. })
  7. }
  8. export let detectOrient = (dome) => {
  9. var width = document.documentElement.clientWidth,
  10. height = document.documentElement.clientHeight,
  11. // $wrapper = document.getElementsByTagName('body')[0],
  12. $wrapper = document.querySelector(dome),
  13. style = "";
  14. if (width >= height) { // 横屏
  15. style += "width:" + width + "px;"; // 注意旋转后的宽高切换
  16. style += "height:" + height + "px;";
  17. style += "-webkit-transform: rotate(0); transform: rotate(0);";
  18. style += "-webkit-transform-origin: 0 0;";
  19. style += "transform-origin: 0 0;";
  20. console.log(1)
  21. } else { // 竖屏
  22. style += "width:" + height + "px;";
  23. style += "height:" + width + "px;";
  24. style += "-webkit-transform: rotate(90deg); transform: rotate(90deg);";
  25. // 注意旋转中点的处理
  26. style += "-webkit-transform-origin: " + width / 2 + "px " + width / 2 + "px;";
  27. style += "transform-origin: " + width / 2 + "px " + width / 2 + "px;";
  28. console.log(2)
  29. }
  30. $wrapper.style.cssText = style;
  31. }