Forráskód Böngészése

添加去学习功能

赵启卫 2 éve
szülő
commit
844c1227c6

+ 4 - 1
application/admin/controller/study/Plan.php

xqd xqd xqd
@@ -202,7 +202,7 @@ class Plan extends AuthController
                 ['special s', 's.id = it.cid and s.is_del = 0 and s.status = 1']
             ];
             $coulist = [];
-            $list = PlanItems::alias('it')->field('s.*')->join($join)->where($where)->select();
+            $list = PlanItems::alias('it')->field('s.*')->join($join)->where($where)->order('it.sort asc')->select();
             foreach($list as $v){
                 $coulist[$v['id']] = $v;
             }
@@ -233,6 +233,7 @@ class Plan extends AuthController
             PlanItems::where(['stepsid' => $id])->delete();
             if ($data['courseids']){
                 $items = [];
+                $i = 1;
                 foreach ($data['courseids'] as $one) {
                     $items[] = [
                         'stepsid' => $id,
@@ -240,7 +241,9 @@ class Plan extends AuthController
                         'cid' => $one,
                         'add_time' => time(),
                         'type' => 0,
+                        'sort' => $i,
                     ];
+                    $i++;
                 }
                 PlanItems::setAll($items);
             }

+ 36 - 1
application/wap/controller/Studyplan.php

xqd xqd xqd xqd
@@ -17,6 +17,7 @@ use app\admin\model\study\PlanBuy;
 use app\admin\model\study\PlanSteps;
 use app\admin\model\study\PlanItems;
 use app\wap\model\special\Special as SpecialModel;
+use app\wap\model\special\SpecialWatch as SpecialWatch;
 use app\wap\model\store\StoreOrder;
 use service\JsonService;
 use think\Url;
@@ -56,7 +57,7 @@ class Studyplan extends AuthController{
         $planinfo = Plan::get($id);
         if (!$planinfo) $this->failed('参数错误,无法访问', Url::build('index/index'));
         $planinfo['introduction'] = htmlspecialchars_decode($planinfo['introduction']);
-        $steps = PlanSteps::where('is_del', 0)->where('pid', $id)->select();
+        $steps = PlanSteps::where('is_del', 0)->where('pid', $id)->order('sort asc')->select();
         $stepids = [];
         $isPay = 0;
         $buyinfo = PlanBuy::where('planid', $id)->where('uid', $this->uid)->where('is_del', 0)->find();
@@ -74,6 +75,7 @@ class Studyplan extends AuthController{
             ->join($join)
             ->where('pid', $id)
             ->where('stepsid', 'in', $stepids)
+            ->order('sort asc')
             ->select();
         foreach ($items as $v) {
             $v['count'] = SpecialModel::numberChapters($v['type'], $v['id']);
@@ -155,4 +157,37 @@ class Studyplan extends AuthController{
             return JsonService::fail(StoreOrder::getErrorInfo('订单生成失败!'));
         }
     }
+
+    public function gotoStudy($id){
+        if (!$id) $this->failed('缺少参数,无法访问', Url::build('index/index'));
+        $planinfo = Plan::get($id);
+        if (!$planinfo) $this->failed('参数错误,无法访问', Url::build('index/index'));
+        $planinfo['introduction'] = htmlspecialchars_decode($planinfo['introduction']);
+        $steps = PlanSteps::where('is_del', 0)->where('pid', $id)->order('sort asc')->select();
+        foreach($steps as $v){
+            $stepids[] = $v['id'];
+        }
+        $join = [
+            ['special s', 's.id = it.cid and s.is_del = 0 and s.status = 1'],
+        ];
+        $items = PlanItems::alias('it')->field('s.*, it.stepsid,it.pid')
+            ->join($join)
+            ->where('pid', $id)
+            ->where('stepsid', 'in', $stepids)
+            ->order('sort asc')
+            ->select();
+        $spids = [];
+        foreach ($items as $v) {
+            $v['count'] = SpecialModel::numberChapters($v['type'], $v['id']);
+            $itemsList[$v['stepsid']][] = $v->toArray();
+            $spids[] = $v['pid'];
+        }
+        $buyinfo = PlanBuy::where('planid', $id)->where('uid', $this->uid)->where('is_del', 0)->find();
+        if (!$buyinfo) {
+            $this->failed('课程尚未购买,非法访问', Url::build('index/index'));
+        }
+        $spids = array_unique($spids);
+        $specialWatchList = SpecialWatch::where('special_id', 'in', $spids)->where('uid', $this->uid)->group('special_id')->order('add_time desc')->select();
+        print_r($specialWatchList);
+    }
 }

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

xqd
@@ -1104,7 +1104,7 @@
         <div class="wrap">
             <div class="video_footer_btn acea-row">
                 <div class="video_footer_btn_right acea-row row-column row-center-wrapper on" v-if="special.type != 4" @click="OpenPay(5)">
-                    <span class="video_footer_btn_left_pic">去学习</span>
+                    <span class="video_footer_btn_left_pic">去学习7</span>
                 </div>
                 <div class="video_footer_btn_right acea-row row-column row-center-wrapper on" v-if="special.type == 4" @click="OpenPay(6)">
                     <span class="video_footer_btn_left_pic">进入直播间</span>

+ 1 - 1
application/wap/view/first/studyplan/details.html

xqd
@@ -207,7 +207,7 @@
                     var that = this;
                 },
                 study: function (){
-                    alert('去学习');
+                    return window.location.href=$h.U({ c: 'studyplan', a: 'gotoStudy', q: {id: this.planinfo.id } });
                 },
                 //关闭登录
                 loginClose: function (val) {

+ 3 - 3
application/wap/view/first/studyplan/index.html

xqd xqd
@@ -51,7 +51,7 @@
                         <div class="price-wrap">
                             <div class="price" @click="planDetails(item.id)">¥<span>{{ item.sales }}</span></div>
                             <div>
-                                <input class="zybt" @click="planDetails(item.id)" v-if="item.isbuy" value="开始学习" type="button"/>
+                                <input class="zybt" @click="study(item.id)" v-if="item.isbuy" value="开始学习" type="button"/>
                                 <input class="zybt" @click="OpenPay(item)" v-if="!item.isbuy" value="购买学习" type="button"/>
                             </div>
                         </div>
@@ -145,8 +145,8 @@
                 planDetails: function (order_id) {
                     return window.location.href=$h.U({ c: 'studyplan', a: 'details', q: {id: order_id } });
                 },
-                study: function (){
-                    alert('去购买');
+                study: function (id){
+                    return window.location.href=$h.U({ c: 'studyplan', a: 'gotoStudy', q: {id: id } });
                 },
                 // 获取学习记录
                 geLogList: function () {

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

xqd
@@ -16031,7 +16031,7 @@ input:-webkit-autofill:focus {
     -webkit-align-items: center;
     -moz-box-align: center;
     align-items: center;
-    padding: .4rem .2rem .2rem .2rem;
+    padding: 1.6rem .2rem .2rem .2rem;
 }
 
 .user-page .user-section .img {