张延森 3 年前
父节点
当前提交
80445db7d7
共有 2 个文件被更改,包括 3 次插入6 次删除
  1. 2
    5
      src/components/barcode/index.jsx
  2. 1
    1
      src/pages/index/index.jsx

+ 2
- 5
src/components/barcode/index.jsx 查看文件

@@ -5,12 +5,9 @@ import CodeText from './CodeText'
5 5
 import { code128 } from './drawCode'
6 6
 import './style.less'
7 7
 
8
-const widthRatio = 0.7;
9
-const barHeight = 80;
10
-
11 8
 export default (props) => {
12 9
 
13
-  const { code } = props
10
+  const { code, ratio, height } = props
14 11
 
15 12
   const canvasRef = useRef()
16 13
   const ctxRef = useRef()
@@ -24,7 +21,7 @@ export default (props) => {
24 21
       dpr: pixelRatio,
25 22
     }
26 23
   }, [])
27
-  const size = useMemo(() => ({ width: sysInfo.width * sysInfo.dpr * widthRatio, height: barHeight * sysInfo.dpr }), [sysInfo])
24
+  const size = useMemo(() => ({ width: sysInfo.width * sysInfo.dpr * ratio, height: height * sysInfo.dpr }), [sysInfo])
28 25
 
29 26
   const style = useMemo(() => ({ width: `${size.width}rpx`, height: `${size.height}rpx` }), [size])
30 27
 

+ 1
- 1
src/pages/index/index.jsx 查看文件

@@ -33,7 +33,7 @@ export default (props) => {
33 33
       <View className='index-UserQRcode-cententQR'>
34 34
         <CountDown className='index-UserQRcode-cententQR-Times' />
35 35
         <View className='index-UserQRcode-cententQR-Barcode'>
36
-          <BarCode width={300} height={100} code='322050442037' />
36
+          <BarCode ratio={0.7} height={80} code='322050442037' />
37 37
         </View>
38 38
       </View>
39 39
     </View>