Browse Source

二维码生成的问题

刘琳琳 2 days ago
parent
commit
c23d9375a9
3 changed files with 29 additions and 10 deletions
  1. 7 5
      pages/home/index.acss
  2. 3 3
      pages/home/index.axml
  3. 19 2
      utils/index/index.js

+ 7 - 5
pages/home/index.acss

@@ -95,8 +95,8 @@
 }
 
 .qrcode {
-  width: 70rpx;
-  height: 70rpx;
+  width: 60rpx;
+  height: 60rpx;
   margin-top: 5rpx;
   /* margin-right: 10rpx; */
 }
@@ -104,10 +104,12 @@
 .tip-text {
   font-size: 14rpx;
   color: #0E384D;
-  padding-right: 20rpx;
+  padding: 0 20rpx;
   text-align: center;
   line-height: 25rpx;
-  margin-top: 10rpx;
+  /*margin-top: 10rpx;*/
+  display: flex;
+  align-items: center;
 }
 
 .blod {
@@ -116,4 +118,4 @@
 
 .blue {
   color: #1677FF;
-}
+}

+ 3 - 3
pages/home/index.axml

@@ -40,7 +40,7 @@
     >
 
       <view a:if="{{snDisposition.zfbScanRegister  }}" class="qrcode-box">
-        支付宝
+        <text>支付宝</text>
         <image mode="scaleToFill" src="{{qrImgZFB}}" class="qrcode" data-src="{{qrImgZFB}}" />
       </view>
       <view class="tip-text">
@@ -48,10 +48,10 @@
         <!--<text class="blod blue">,支持支付宝</text> 、<text class="blod">微信</text> 扫码 -->
       </view>
       <view a:if="{{ snDisposition.wxScanRegister }}" class="qrcode-box">
-        微信
+        <text>微信</text>
         <image mode="scaleToFill" src="{{qrImgWX}}" class="qrcode" data-src="{{qrImgWX}}" />
       </view>
     </view>
     <bottom-parnel suerName="确定" onSure="sure" isHomePage="{{true}}" showBtn="{{false}}" />
   </view>
-</view>
+</view>

+ 19 - 2
utils/index/index.js

@@ -127,8 +127,25 @@ const getDate = data => {
 }
 
 const getQRCodeUrl = (content, isShow = true) => {
+  console.log(content, isShow)
   return new Promise((resolve, reject) => {
-    QRCode.toString(content, {
+    my.generateImageFromCode({
+      code: content,
+      format: 'QRCODE',
+      width: 100,
+      correctLevel: 'H',
+      codeColor: '#000',
+      backgroundColor: '#ffffff',
+      success: function (res) {
+        console.log('二维码临时路径:', res.image) // 这里是base64
+        resolve(res.image)
+      },
+      fail: function (err) {
+        console.log(err)
+        reject(err)
+      }
+    })
+    /*QRCode.toString(content, {
       type: 'png',
     }, function (err, url) {
       let str = (isShow ? 'data:image/svg+xml;base64,' : '') + Buffer(url).toString('base64');
@@ -136,7 +153,7 @@ const getQRCodeUrl = (content, isShow = true) => {
         reject(err)
       }
       resolve(str)
-    });
+    });*/
 
   })
 }