소스 검색

支付bug修复

赵启卫 2 년 전
부모
커밋
ef05846c66

+ 2 - 2
application/admin/model/study/PlanBuy.php

xqd
@@ -55,8 +55,8 @@ class PlanBuy extends ModelBasic {
                 $task_special = Special::PreWhere()->where(['id'=>$v['cid']])->find();
                 if (!$task_special) continue;
                 if ($task_special['is_show'] != 1) continue;
-                SpecialBuy::setBuySpecial($order_id, $uid, $v['cid'], $type, $task_special['validity'], $plan_id);
-                TestPaperObtain::setTestPaper($order_id, $uid, $v['cid'], 2);
+                SpecialBuy::setBuySpecial($order_id, $uid, $v['cid'], $type, $task_special['validity'], 0, $plan_id);
+                TestPaperObtain::setTestPaper($order_id, $uid, $v['cid'], 2, $plan_id);
             }
         }
         self::setBuyPlan($order_id, $uid, $plan_id, $type);

+ 2 - 2
application/wap/model/special/SpecialBuy.php

xqd xqd
@@ -94,7 +94,7 @@ class SpecialBuy extends ModelBasic
      * @param int $column_id
      * @return bool|object
      */
-    public static function setBuySpecial($order_id, $uid, $special_id, $type = 0, $validity = 0, $column_id = 0)
+    public static function setBuySpecial($order_id, $uid, $special_id, $type = 0, $validity = 0, $column_id = 0, $planid = 0)
     {
         $add_time = time();
         if (self::be(['uid' => $uid, 'special_id' => $special_id, 'column_id' => $column_id, 'type' => $type, 'is_del' => 0])) return false;
@@ -102,7 +102,7 @@ class SpecialBuy extends ModelBasic
         if ($validity > 0) {
             $validity_time = (int)bcadd(time(), bcmul($validity, 86400, 0), 0);
         }
-        return self::set(compact('order_id', 'column_id', 'uid', 'special_id', 'type', 'validity_time', 'add_time'));
+        return self::set(compact('order_id', 'column_id', 'uid', 'special_id', 'type', 'validity_time', 'add_time', 'planid'));
     }
 
     /**检查专题是否获得

+ 5 - 5
application/wap/model/topic/TestPaperObtain.php

xqd xqd xqd
@@ -32,11 +32,11 @@ class TestPaperObtain extends ModelBasic
      * @param $source
      * @return object
      */
-    public static function setUserTestPaper($order_id, $test_id, $uid, $type, $source)
+    public static function setUserTestPaper($order_id, $test_id, $uid, $type, $source, $planid)
     {
         $add_time = time();
         if (self::be(['uid' => $uid, 'test_id' => $test_id, 'type' => $type, 'is_del' => 0])) return false;
-        return self::set(compact('order_id', 'test_id', 'uid', 'type', 'source', 'add_time'));
+        return self::set(compact('order_id', 'test_id', 'uid', 'type', 'source', 'add_time', 'planid'));
     }
 
     /**判断是否获得试卷
@@ -60,7 +60,7 @@ class TestPaperObtain extends ModelBasic
      * @throws \think\db\exception\ModelNotFoundException
      * @throws \think\exception\DbException
      */
-    public static function setTestPaper($order_id, $uid, $special_id, $source)
+    public static function setTestPaper($order_id, $uid, $special_id, $source, $planid = 0)
     {
         if (!$uid || !$special_id) return false;
         $special = Special::PreWhere()->where(['id'=>$special_id])->find();
@@ -74,14 +74,14 @@ class TestPaperObtain extends ModelBasic
                 $test_ids = Relation::setWhere(2, $task_special['id'])->column('relation_id');
                 if (count($test_ids) <= 0) continue;
                 foreach ($test_ids as $ks => $value) {
-                    self::setUserTestPaper($order_id, $value, $uid, 2, $source);
+                    self::setUserTestPaper($order_id, $value, $uid, 2, $source, $planid);
                 }
             }
         }
         $test_ids = Relation::setWhere(2, $special_id)->column('relation_id');
         if (count($test_ids) <= 0) return false;
         foreach ($test_ids as $kf => $value) {
-            self::setUserTestPaper($order_id, $value, $uid, 2, $source);
+            self::setUserTestPaper($order_id, $value, $uid, 2, $source, $planid);
         }
     }
 

+ 2 - 2
application/wap/view/first/special/details.html

xqd
@@ -2599,10 +2599,10 @@
                                     }
                                 };
                                 var task = this.otherTaskList[0];
-                                if (task.special_task) {
+                                if (task && task.special_task) {
                                     task = task.special_task[0];
                                 }
-                                if (task.is_light) {
+                                if (task && task.is_light) {
                                     if (task.light_type === 1) {
                                         opt.a = 'single_text_detail';
                                     }

+ 9 - 8
application/wap/view/first/studyplan/details.html

xqd
@@ -259,14 +259,15 @@
                     store.baseGet($h.U({c: 'index', a: 'user_login'}), function (res) {
                         this.money = this.money;
                         this.payDialogOpen = true;
-                        // var opt = {
-                        //     c: 'studyplan',
-                        //     a: 'details',
-                        //     q: {
-                        //         id: this.planinfo.id
-                        //     }
-                        // };
-                        // window.location.assign($h.U(opt));
+                        $h.pushMsg('支付成功');
+                        var opt = {
+                            c: 'studyplan',
+                            a: 'details',
+                            q: {
+                                id: this.planinfo.id
+                            }
+                        };
+                        window.location.assign($h.U(opt));
                     }.bind(this), function () {
                         vm.loginShow = true;
                     });

+ 79 - 9
application/wap/view/first/studyplan/index.html

xqd xqd xqd xqd xqd
@@ -51,8 +51,8 @@
                         <div class="price-wrap">
                             <div class="price" @click="planDetails(item.id)">¥<span>{{ item.sales }}</span></div>
                             <div>
-                                <input class="zybt" @click="study(item.id)" v-if="item.isbuy == 1" value="开始学习" type="button"/>
-                                <input class="zybt" @click="buy(item.id)" v-if="!item.isbuy" value="购买学习" type="button"/>
+                                <input class="zybt" @click="planDetails(item.id)" v-if="item.isbuy" value="开始学习" type="button"/>
+                                <input class="zybt" @click="OpenPay(item)" v-if="!item.isbuy" value="购买学习" type="button"/>
                             </div>
                         </div>
                     </div>
@@ -65,13 +65,37 @@
         </div>
     </div>
     <quick-menu></quick-menu>
+    <!-- 支付弹窗 -->
+    <pay-dialog :open.sync="payDialogOpen" :money="money" :now_money="now_money" :special_id="planinfo.id" :link_pay_uid="link_pay_uid"
+                :pay_type_num="pay_type_num" :pink-id="pinkId" :is-wechat="isWechat" :is-alipay="is_alipay" :is-balance="is_yue"
+                :template-id="templateId" :wxpay-h5="wxpayH5" :is-member="isMember" @change="changeVal">
+    </pay-dialog>
+    <!-- 登录弹窗 -->
+    <base-login :login-show="loginShow" :site-name="site_name" @login-close="loginClose"></base-login>
 </div>
 {/block}
 {block name="foot"}
 <script>
-    require(['vue', 'store', 'helper', '{__WAP_PATH}zsff/js/quick.js'], function (Vue, store, $h) {
+    
+    require(['vue', 'store', 'helper', '{__WAP_PATH}zsff/js/quick.js',
+    'components/pay-dialog/index', 'components/base-login/index'
+    ], function (Vue, store, $h, quick, PayDialog, BaseLogin) {
+        var isPay = 0;
+        var link_pay_uid = 0;
+        var is_yue = {$is_yue? 'true': 'false'};
+        var is_alipay = {$is_alipay? 'true': 'false'};
+        var isWechat = {$isWechat? 'true': 'false'};
+        var isPay = {$isPay? 'true': 'false'};
+        var wxpayH5 = {$is_h5_wechat_payment_switch? 'true': 'false'};
+        var now_money = {$now_money};
+        var isMember = {$is_member};
+        var site_name = '{$Auth_site_name}';
         var app = new Vue({
             el: '#app',
+            components: {
+                'base-login': BaseLogin,
+                'pay-dialog': PayDialog,
+            },
             data: {
                 navs: ['全部', '待核销', '已核销'],
                 navActive: 0,
@@ -80,7 +104,25 @@
                 loadend: false,
                 page: 1,
                 limit: 20,
-                loadTitle:''
+                loadTitle:'',
+                planinfo:{},
+                //支付登录相关
+                payDialogOpen: false,
+                loginShow: false,
+                is_pay: isPay,
+                money:0,
+                link_pay_uid:link_pay_uid,
+                pay_type_num: 7, //新增的 学习计划支付类型
+                pinkId: 0,
+                isWechat: isWechat,
+                is_pay: isPay,
+                is_alipay: is_alipay, //支付宝是否开启
+                is_yue: is_yue, //余额是否开启
+                now_money: now_money, //余额
+                templateId: '',
+                wxpayH5:wxpayH5,
+                isMember:isMember,
+                site_name:site_name,
             },
             mounted: function () {
                 this.geLogList();
@@ -103,11 +145,8 @@
                 planDetails: function (order_id) {
                     return window.location.href=$h.U({ c: 'studyplan', a: 'details', q: {id: order_id } });
                 },
-                buy: function (){
-                    alert('去购买');
-                },
                 study: function (){
-                    alert('去学习');
+                    alert('去购买');
                 },
                 // 获取学习记录
                 geLogList: function () {
@@ -127,7 +166,38 @@
                         that.loadTitle = '上拉加载更多';
                         that.loading = false;
                     });
-                }
+                },
+                //所有插件回调处理事件
+                changeVal: function (opt) {
+                    if (typeof opt != 'object') opt = {};
+                    var action = opt.action || '';
+                    var value = opt.value || '';
+                    this[action] && this[action](value);
+                },
+                //打开支付插件,并检测登录状态,没有登录,打开登录插件
+                OpenPay: function (plan) {
+                    this.planinfo = plan;
+                    this.money = plan.sales;
+                    var vm = this;
+                    store.baseGet($h.U({c: 'index', a: 'user_login'}), function (res) {
+                        this.payDialogOpen = true;
+                        var opt = {
+                            c: 'studyplan',
+                            a: 'details',
+                            q: {
+                                id: this.planinfo.id
+                            }
+                        };
+                        window.location.assign($h.U(opt));
+                    }.bind(this), function () {
+                        vm.loginShow = true;
+                    });
+                },
+                //关闭登录
+                loginClose: function (val) {
+                    this.loginShow = false;
+                    val && this.logComplete();
+                },
             }
         });
     });

+ 2 - 1
public/wap/first/zsff/css/style.css

xqd xqd
@@ -16031,7 +16031,7 @@ input:-webkit-autofill:focus {
     -webkit-align-items: center;
     -moz-box-align: center;
     align-items: center;
-    padding: .2rem .2rem .2rem .2rem;
+    padding: .4rem .2rem .2rem .2rem;
 }
 
 .user-page .user-section .img {
@@ -16041,6 +16041,7 @@ input:-webkit-autofill:focus {
     border-radius: 50%;
     -o-object-fit: cover;
     object-fit: cover;
+    margin-left:0.2rem;
 }
 
 .user-page .user-section .text-wrap {