const EPS = 1e-4
const BASE_DEVICE_WIDTH = 750
let isIOS = false
let deviceWidth = 0
let deviceDPR = 0

export function checkDeviceWidth () {
  const {
    platform,
    pixelRatio,
    windowWidth
  } = uni.getSystemInfoSync()

  deviceWidth = windowWidth
  deviceDPR = pixelRatio
  isIOS = platform === 'ios'
}

export function upx2px (number, newDeviceWidth) {
  if (deviceWidth === 0) {
    checkDeviceWidth()
  }

  number = Number(number)
  if (number === 0) {
    return 0
  }
  number = (number / BASE_DEVICE_WIDTH) * (newDeviceWidth || deviceWidth)
  number = Math.floor(number + EPS)
  if (number === 0) {
    if (deviceDPR === 1 || !isIOS) {
      return 1
    } else {
      return 0.5
    }
  }
  return number
}

@@ -374,17 +374,18 @@
 Width) %7B
+%0D
 %0A
-
   if (de
@@ -506,22 +506,26 @@
 %0A  %7D%0D%0A  
-number
+let result
  = (numb
@@ -585,22 +585,70 @@
 dth)%0D%0A  
-number
+if (result %3C 0) %7B%0D%0A    result = -result%0D%0A  %7D%0D%0A  result
  = Math.
@@ -653,22 +653,22 @@
 h.floor(
-number
+result
  + EPS)%0D
@@ -666,38 +666,38 @@
 t + EPS)%0D%0A  if (
-number
+result
  === 0) %7B%0D%0A    i
@@ -785,24 +785,24 @@
     %7D%0D%0A  %7D%0D%0A
-
   return num
@@ -804,12 +804,35 @@
 n number
+ %3C 0 ? -result : result
 %0D%0A%7D%0A

upx 负数转换和正数不一致的问题