Browse Source

微信扫码支付

lizhen_gitee 3 years ago
parent
commit
ac832ad82f

+ 163 - 169
addons/qrcode/config.php

@@ -2,222 +2,216 @@
 
 return [
     [
-        'name'    => 'text',
-        'title'   => '默认文本',
-        'type'    => 'string',
+        'name' => 'text',
+        'title' => '默认文本',
+        'type' => 'string',
         'content' => [],
-        'value'   => 'Hello world!',
-        'rule'    => 'required',
-        'msg'     => '',
-        'tip'     => '',
-        'ok'      => '',
-        'extend'  => '',
+        'value' => '觅TA',
+        'rule' => 'required',
+        'msg' => '',
+        'tip' => '',
+        'ok' => '',
+        'extend' => '',
     ],
     [
-        'name'    => 'size',
-        'title'   => '默认宽高',
-        'type'    => 'number',
+        'name' => 'size',
+        'title' => '默认宽高',
+        'type' => 'number',
         'content' => [],
-        'value'   => '300',
-        'rule'    => 'required',
-        'msg'     => '',
-        'tip'     => '',
-        'ok'      => '',
-        'extend'  => '',
+        'value' => '300',
+        'rule' => 'required',
+        'msg' => '',
+        'tip' => '',
+        'ok' => '',
+        'extend' => '',
     ],
     [
-        'name'    => 'padding',
-        'title'   => '默认边距',
-        'type'    => 'number',
+        'name' => 'padding',
+        'title' => '默认边距',
+        'type' => 'number',
         'content' => [],
-        'value'   => '15',
-        'rule'    => 'required',
-        'msg'     => '',
-        'tip'     => '',
-        'ok'      => '',
-        'extend'  => '',
+        'value' => '15',
+        'rule' => 'required',
+        'msg' => '',
+        'tip' => '',
+        'ok' => '',
+        'extend' => '',
     ],
     [
-        'name'    => 'format',
-        'title'   => '默认格式',
-        'type'    => 'radio',
+        'name' => 'format',
+        'title' => '默认格式',
+        'type' => 'radio',
         'content' => [
             'png' => 'PNG',
             'svg' => 'SVG(不支持标签)',
         ],
-        'value'   => 'png',
-        'rule'    => 'required',
-        'msg'     => '',
-        'tip'     => '',
-        'ok'      => '',
-        'extend'  => '',
+        'value' => 'png',
+        'rule' => 'required',
+        'msg' => '',
+        'tip' => '',
+        'ok' => '',
+        'extend' => '',
     ],
     [
-        'name'    => 'errorlevel',
-        'title'   => '容错级别',
-        'type'    => 'radio',
+        'name' => 'errorlevel',
+        'title' => '容错级别',
+        'type' => 'radio',
         'content' => [
-            'low'      => '低',
-            'medium'   => '中',
+            'low' => '低',
+            'medium' => '中',
             'quartile' => '高',
-            'high'     => '超高',
+            'high' => '超高',
         ],
-        'value'   => 'medium',
-        'rule'    => 'required',
-        'msg'     => '',
-        'tip'     => '',
-        'ok'      => '',
-        'extend'  => '',
+        'value' => 'medium',
+        'rule' => 'required',
+        'msg' => '',
+        'tip' => '',
+        'ok' => '',
+        'extend' => '',
     ],
     [
-        'name'    => 'foreground',
-        'title'   => '前景色',
-        'type'    => 'string',
-        'content' => [
-        ],
-        'value'   => '#000000',
-        'rule'    => 'required',
-        'msg'     => '',
-        'tip'     => '',
-        'ok'      => '',
-        'extend'  => '',
+        'name' => 'foreground',
+        'title' => '前景色',
+        'type' => 'string',
+        'content' => [],
+        'value' => '#000000',
+        'rule' => 'required',
+        'msg' => '',
+        'tip' => '',
+        'ok' => '',
+        'extend' => '',
     ],
     [
-        'name'    => 'background',
-        'title'   => '背景色',
-        'type'    => 'string',
-        'content' => [
-        ],
-        'value'   => '#ffffff',
-        'rule'    => 'required',
-        'msg'     => '',
-        'tip'     => '',
-        'ok'      => '',
-        'extend'  => '',
+        'name' => 'background',
+        'title' => '背景色',
+        'type' => 'string',
+        'content' => [],
+        'value' => '#ffffff',
+        'rule' => 'required',
+        'msg' => '',
+        'tip' => '',
+        'ok' => '',
+        'extend' => '',
     ],
     [
-        'name'    => 'label',
-        'title'   => '默认标签',
-        'type'    => 'string',
-        'content' => [
-        ],
-        'value'   => '',
-        'rule'    => '',
-        'msg'     => '',
-        'tip'     => '',
-        'ok'      => '',
-        'extend'  => '',
+        'name' => 'label',
+        'title' => '默认标签',
+        'type' => 'string',
+        'content' => [],
+        'value' => '',
+        'rule' => '',
+        'msg' => '',
+        'tip' => '',
+        'ok' => '',
+        'extend' => '',
     ],
     [
-        'name'    => 'labelfontsize',
-        'title'   => '标签字体大小',
-        'type'    => 'number',
-        'content' => [
-        ],
-        'value'   => '14',
-        'rule'    => '',
-        'msg'     => '',
-        'tip'     => '',
-        'ok'      => '',
-        'extend'  => '',
+        'name' => 'labelfontsize',
+        'title' => '标签字体大小',
+        'type' => 'number',
+        'content' => [],
+        'value' => '14',
+        'rule' => '',
+        'msg' => '',
+        'tip' => '',
+        'ok' => '',
+        'extend' => '',
     ],
     [
-        'name'    => 'labelfontpath',
-        'title'   => '标签字体',
-        'type'    => 'file',
+        'name' => 'labelfontpath',
+        'title' => '标签字体',
+        'type' => 'file',
         'content' => [],
-        'value'   => '/assets/fonts/SourceHanSansK-Regular.ttf',
-        'rule'    => 'required',
-        'msg'     => '',
-        'tip'     => '',
-        'ok'      => '',
-        'extend'  => '',
+        'value' => '/assets/fonts/SourceHanSansK-Regular.ttf',
+        'rule' => 'required',
+        'msg' => '',
+        'tip' => '',
+        'ok' => '',
+        'extend' => '',
     ],
     [
-        'name'    => 'labelalignment',
-        'title'   => '标签对齐方式',
-        'type'    => 'radio',
+        'name' => 'labelalignment',
+        'title' => '标签对齐方式',
+        'type' => 'radio',
         'content' => [
-            'left'   => '左',
+            'left' => '左',
             'center' => '居中',
-            'right'  => '右',
+            'right' => '右',
         ],
-        'value'   => 'center',
-        'rule'    => '',
-        'msg'     => '',
-        'tip'     => '',
-        'ok'      => '',
-        'extend'  => '',
+        'value' => 'center',
+        'rule' => '',
+        'msg' => '',
+        'tip' => '',
+        'ok' => '',
+        'extend' => '',
     ],
     [
-        'name'    => 'logo',
-        'title'   => '默认显示Logo',
-        'type'    => 'radio',
+        'name' => 'logo',
+        'title' => '默认显示Logo',
+        'type' => 'radio',
         'content' => [
-            0 => '否',
-            1 => '是'
+            '否',
+            '是',
         ],
-        'value'   => '0',
-        'rule'    => 'required',
-        'msg'     => '',
-        'tip'     => '',
-        'ok'      => '',
-        'extend'  => '',
+        'value' => '0',
+        'rule' => 'required',
+        'msg' => '',
+        'tip' => '',
+        'ok' => '',
+        'extend' => '',
     ],
     [
-        'name'    => 'logopath',
-        'title'   => 'Logo图片',
-        'type'    => 'image',
+        'name' => 'logopath',
+        'title' => 'Logo图片',
+        'type' => 'image',
         'content' => [],
-        'value'   => '/assets/img/qrcode.png',
-        'rule'    => 'required',
-        'msg'     => '',
-        'tip'     => '',
-        'ok'      => '',
-        'extend'  => '',
+        'value' => '/assets/img/qrcode.png',
+        'rule' => 'required',
+        'msg' => '',
+        'tip' => '',
+        'ok' => '',
+        'extend' => '',
     ],
     [
-        'name'    => 'logosize',
-        'title'   => 'Logo大小',
-        'type'    => 'number',
+        'name' => 'logosize',
+        'title' => 'Logo大小',
+        'type' => 'number',
         'content' => [],
-        'value'   => '50',
-        'rule'    => 'required',
-        'msg'     => '',
-        'tip'     => '',
-        'ok'      => '',
-        'extend'  => '',
+        'value' => '50',
+        'rule' => 'required',
+        'msg' => '',
+        'tip' => '',
+        'ok' => '',
+        'extend' => '',
     ],
     [
-        'name'    => 'writefile',
-        'title'   => '写入文件',
-        'type'    => 'radio',
+        'name' => 'writefile',
+        'title' => '写入文件',
+        'type' => 'radio',
         'content' => [
-            0 => '否',
-            1 => '是'
+            '否',
+            '是',
+        ],
+        'value' => '0',
+        'rule' => 'required',
+        'msg' => '',
+        'tip' => '',
+        'ok' => '',
+        'extend' => '',
+    ],
+    [
+        'name' => 'rewrite',
+        'title' => '伪静态',
+        'type' => 'array',
+        'content' => [],
+        'value' => [
+            'index/index' => '/qrcode$',
+            'index/build' => '/qrcode/build$',
         ],
-        'value'   => '0',
-        'rule'    => 'required',
-        'msg'     => '',
-        'tip'     => '',
-        'ok'      => '',
-        'extend'  => '',
-    ],
-    [
-        'name'    => 'rewrite',
-        'title'   => '伪静态',
-        'type'    => 'array',
-        'content' =>
-            [],
-        'value'   =>
-            [
-                'index/index' => '/qrcode$',
-                'index/build' => '/qrcode/build$',
-            ],
-        'rule'    => 'required',
-        'msg'     => '',
-        'tip'     => '',
-        'ok'      => '',
-        'extend'  => '',
+        'rule' => 'required',
+        'msg' => '',
+        'tip' => '',
+        'ok' => '',
+        'extend' => '',
     ],
 ];

+ 9 - 2
application/index/controller/Recharge.php

@@ -5,6 +5,7 @@ namespace app\index\controller;
 use app\common\controller\Frontend;
 use think\Db;
 use addons\epay\library\Service;
+use think\Response;
 class Recharge extends Frontend
 {
 
@@ -28,7 +29,6 @@ class Recharge extends Frontend
         $pay_type  = input('pay_type','alipay');
         $mobile = input('mobile',0);
 
-
         if(!$rc_id){
             $this->error('请选择充值金额');
         }
@@ -89,7 +89,14 @@ class Recharge extends Frontend
         $res = Service::submitOrder($params);
         if($pay_type == 'wechat'){
             $code_url = $res['cod_url'];
-            $code_img = \EasyWeChat\OfficialAccount\Card\createQrCode();
+
+            $qrCode = \addons\qrcode\library\Service::qrcode(['text'=>$code_url]);
+            $response = Response::create()->header("Content-Type", 'image/png');
+
+            // 直接显示二维码
+            header('Content-Type: ' . $qrCode->getContentType());
+            $response->content($qrCode->writeString());
+            return $response;
         }else{
             return $res;
         }

+ 24 - 10
application/index/view/recharge/index.html

@@ -130,6 +130,7 @@
             height: 0.20rem;
             justify-content: space-between;
             margin-top: 0.10rem;
+            cursor: pointer;
           
         }
         .mode-left{
@@ -146,12 +147,14 @@
             font-size: 0.27rem;
             margin-right: 0.07rem;
         }
-        .zicon-xuanze{
+        .pay-ic{
             font-size: 0.20rem;
+        }
+        .zicon-xuanze{
             color: #46BB36;
         }
         .zicon-xuanze1{
-            font-size: 0.20rem;
+            color: #999;
         }
         .mode-tips{
             width: 7.50rem;
@@ -257,24 +260,22 @@
 
                 </div>-->
             </div>
-            <div class="mode-wrap">
+            <div class="mode-wrap" >
                 <div class="mode-title">充值方式</div>
-                <!--  
-                <div class="mode-item row">
+                <div class="mode-item row" data-type="wechat">
                     <div class="mode-left row">
                         <div class="zicon zicon-weixin"></div>
                         <div>微信充值</div>
                     </div>
-                    <div class="zicon zicon-xuanze"></div>
+                    <div class="zicon pay-ic zicon-xuanze1"></div>
                 </div>
-                -->
-                <div class="mode-item row">
+                <div class="mode-item row" data-type="alipay">
                     <div class="mode-left row">
                         <div class="zicon zicon-alipay"></div>
                         <div>支付宝充值</div>
                     </div>
                     <!-- <div class="zicon" :class="choosed ? 'zicon-xuanze' : 'zicon-xuanze1'" @click="changeIcon"></div> -->
-                    <div class="zicon zicon-xuanze"></div>
+                    <div class="zicon pay-ic zicon-xuanze"></div>
                 </div>
                 <div class="mode-tips row">
                     <div class="zicon zicon-tishi"></div>
@@ -282,10 +283,23 @@
                 </div>
             </div>
             <input type="submit" class="recharge-btn center active" value="立即充值" />
+            <input type="hidden" name="pay_type" value="alipay" class="payType">
             <!--<div class="recharge-btn center active">立即充值</div>-->
             </form>
         </div>
 
 	</div>
 </body>
-</html>
+</html>
+
+<script src="/assets/frontend/recharge/jquery.min.js"></script>
+<script>
+    $(".mode-item").click(function (e) {
+        $(this).find(".pay-ic").removeClass("zicon-xuanze1").addClass("zicon-xuanze");
+        $(this).siblings().find(".pay-ic").removeClass("zicon-xuanze").addClass("zicon-xuanze1");
+        var type = $(this).data("type");
+        $(".payType").val(type);
+        console.log($(".payType").val());
+    });
+
+</script>

File diff suppressed because it is too large
+ 1 - 0
public/assets/frontend/recharge/jquery.min.js


Some files were not shown because too many files changed in this diff