lrf402788946 4 rokov pred
rodič
commit
608f35062c
1 zmenil súbory, kde vykonal 6 pridanie a 4 odobranie
  1. 6 4
      app/service/qrcode.js

+ 6 - 4
app/service/qrcode.js

@@ -19,10 +19,12 @@ class QrcodeService extends CrudService {
     if (!user) throw new BusinessError(ErrorCode.DATA_NOT_EXIST, '为找到用户信息');
     const { mobile, name } = user;
     const url = `${this.uri}?id=${id}&mobile=${mobile}&name=${name}`;
-    const res = await QRCode.toDataURL(url, {
-      width: 200,
-    });
-    return res;
+    // const res = await QRCode.toDataURL(url, {
+    //   width: 200,
+    // });
+    const qrcode = await QRCode.toString(url, { type: 'png' });
+    const qrimage = `data:image/png;base64${Buffer(qrcode).toString('base64')}`;
+    return qrimage;
   }
 }