sys-tool.js 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. var businessT = require('business-tool.js')
  2. var _isLongScreen = false
  3. var _suffixOfClass = ''
  4. var _sysInfo = {}
  5. var _rpxToPx = 0
  6. var _isIphoneX = false
  7. function adaptor() {
  8. var res = wx.getSystemInfoSync()
  9. businessT.debugLog(res)
  10. _sysInfo = res
  11. _rpxToPx = res.screenWidth / 750
  12. var start = res.model.indexOf('iPhone X')
  13. if (start == 0) {
  14. _suffixOfClass = '-X'
  15. _isIphoneX = true
  16. }
  17. if (res.screenHeight / res.screenWidth >= 1.85) {
  18. _isLongScreen = true
  19. }
  20. }
  21. //返回rpx
  22. function usableHeight(remove) {
  23. var h = 750 / _sysInfo.windowWidth * _sysInfo.windowHeight
  24. if (_isIphoneX) {
  25. return h - remove - 68
  26. } else {
  27. return h - remove
  28. }
  29. }
  30. function suffixOfClass() {
  31. return _suffixOfClass
  32. }
  33. function isLongScreen() {
  34. return _isLongScreen
  35. }
  36. function sysInfo() {
  37. return _sysInfo
  38. }
  39. function rpxToPx() {
  40. return _rpxToPx
  41. }
  42. module.exports = {
  43. adaptor: adaptor,
  44. suffixOfClass: suffixOfClass,
  45. isLongScreen: isLongScreen,
  46. sysInfo: sysInfo,
  47. rpxToPx: rpxToPx,
  48. usableHeight: usableHeight
  49. }