Browse Source

前台历史记录调整

赵启卫 2 năm trước cách đây
mục cha
commit
e8b8d3d72b
2 tập tin đã thay đổi với 120 bổ sung7 xóa
  1. 74 2
      application/wap/controller/My.php
  2. 46 5
      application/wap/view/first/my/history.html

+ 74 - 2
application/wap/controller/My.php

xqd xqd
@@ -14,8 +14,10 @@ namespace app\wap\controller;
 use Api\Express;
 use app\wap\model\special\SpecialRecord;
 use app\wap\model\special\SpecialLog;
+use app\wap\model\special\SpecialBuy;
 use app\wap\model\special\SpecialSource;
 use app\wap\model\special\SpecialRelation;
+use app\admin\model\questions\Relation;
 use app\wap\model\user\SmsCode;
 use app\wap\model\store\StoreOrderCartInfo;
 use app\wap\model\recommend\Recommend;
@@ -506,8 +508,78 @@ class My extends AuthController
      /**
       * 学籍档案-学习记录
       */
-    public function history(){
-        
+    public function history($page = 1, $limit = 10000, $op = ''){
+        if ($op == 'xuefenlist'){
+            $model = SpecialBuy::alias('sb')->where('sb.uid', $this->uid)->page((int)$page, (int)$limit);
+            $model = $model->join('Special s', 's.id = sb.special_id');
+            $model = $model->join('specialSubject ss', 's.subject_id = ss.id');
+            $orderList = $model->order('sb.add_time DESC')->field('s.*, sb.add_time as log_time, ss.name as subject_name')->select();
+            $orderList = count($orderList) > 0 ? $orderList->toArray() : [];
+            $orderList1 = [];
+            foreach ($orderList as &$item) {
+                $flag = 1;
+                if (!isset($item['money'])) $item['money'] = 0;
+                $item['money'] = (float)$item['money'];
+                $item['image'] = get_oss_process($item['image'], 0);
+                $item['count'] = 0;
+                $specialSourceId = SpecialSource::alias('ss')->where('ss.special_id', $item['id'])
+                    ->field('ss.*, sw.viewing_time, sw.percentage')
+                    ->join('specialWatch sw', 'ss.special_id = sw.special_id', 'left')
+                    ->select();
+                if ($specialSourceId) $item['count'] = count($specialSourceId);
+                foreach ($specialSourceId as $v) {
+                    if ($v['percentage'] < 100) {
+                        $flag = 0;
+                        break;
+                    } 
+                }
+                if ($flag == 1){
+                   //关联试题
+                    //判断是否有考试
+                    $join1 = [
+                        ['ExaminationRecord er', 'er.test_id = r.relation_id and er.uid = ' . $this->uid, 'left'],
+                    ];
+                    $examlist = Relation::alias('r')->where('r.relationship_id', $item['id'])->where('r.relationship', 2)
+                    ->field('r.relation_id as test_id, er.score')->join($join1)->select();
+                    if ($examlist) {
+                        foreach ($examlist as $v) {
+                            if ($v['score'] < 60) {
+                                $flag = 0;
+                                break;
+                            }
+                        }
+                    }
+                }
+                if ($flag == 1) {
+                    $orderList1[] = $item;
+                }
+            }
+            return JsonService::successful($orderList1);
+        }
+        //时长获取
+        if ($op == 'shichanglist'){
+            $model = SpecialBuy::alias('sb')->where('sb.uid', $this->uid)->page((int)$page, (int)$limit);
+            $model = $model->join('Special s', 's.id = sb.special_id');
+            $model = $model->join('specialSubject ss', 's.subject_id = ss.id');
+            $orderList = $model->order('sb.add_time DESC')->field('s.*, sb.add_time as log_time, ss.name as subject_name')->select();
+            $orderList = count($orderList) > 0 ? $orderList->toArray() : [];
+            foreach ($orderList as &$item) {
+                if (!isset($item['money'])) $item['money'] = 0;
+                $item['money'] = (float)$item['money'];
+                $item['image'] = get_oss_process($item['image'], 0);
+                $item['count'] = 0;
+                $item['shichang'] = 0;
+                $specialSourceId = SpecialSource::alias('ss')->where('ss.special_id', $item['id'])
+                    ->field('ss.*, sw.viewing_time, sw.percentage')
+                    ->join('specialWatch sw', 'ss.special_id = sw.special_id', 'left')
+                    ->select();
+                if ($specialSourceId) $item['count'] = count($specialSourceId);
+                foreach ($specialSourceId as $v) {
+                    $item['shichang'] += $v['viewing_time'];
+                }
+            }
+            return JsonService::successful($orderList);
+        }
         return $this->fetch();
     }
 }

+ 46 - 5
application/wap/view/first/my/history.html

xqd xqd xqd xqd xqd xqd
@@ -153,7 +153,7 @@
             <!-- 我的学分 -->
             <div class="credit-title">
                 <div class="title">我的学分</div>
-                <div class="credit">6</div>
+                <div class="credit">{{xuefencount}}</div>
             </div>
             <div class="credit-list">
                 <br />
@@ -174,7 +174,7 @@
                                     <div>{{ item.title }}</div>
                                     <div>
                                         <span class="labelItem">{{ item.subject_name }}</span>
-                                        <span class="creditinfo">3分</span>
+                                        <span class="creditinfo">{{ item.xuefen }}分</span>
                                     </div>
                                     <div class="price-wrap">
                                         <div class="price">¥<span>{{ item.money }}</span></div>
@@ -191,7 +191,7 @@
             <!-- 学习时间 -->
             <div class="credit-title">
                 <div class="title">学习时间</div>
-                <div class="credit">60分钟</div>
+                <div class="credit">{{shichang}}分钟</div>
             </div>
             <div class="credit-list">
                 <br />
@@ -277,7 +277,9 @@
                 loadend: false,
                 page: 1,
                 limit: 20,
-                loadTitle:''
+                loadTitle:'',
+                xuefencount:0,
+                shichang:0,
             },
             mounted: function () {
                 this.getActivitySignList();
@@ -324,9 +326,11 @@
                             limit: this.limit
                         }, function (res) {
                             var activityList = res.data.data;
-                            console.log(activityList);
                             for (let i in activityList) {
+                                that.xuefencount += activityList[i].xuefen;
+                                console.log(activityList[i].xuefen);
                                 activityList[i].add_time = moment(activityList[i].add_time * 1000).format('YYYY.MM.DD')
+                                
                             }
                             that.activityList = that.activityList.concat(activityList);
                             that.loading = false;
@@ -335,6 +339,43 @@
                             that.finished = that.limit > activityList.length;
                             that.$set(this, 'activityList', that.activityList);
                         });
+                    } else if (that.navActive == 1) {
+                        store.baseGet($h.U({ c: 'my', a: 'history', p: { page: that.page, limit: 10000,  op:'xuefenlist' } }), function (res) {
+                            var list = res.data.data;
+                            that.activityList.push.apply(that.activityList, list);
+                            that.loadend = list.length < that.limit;
+                            that.loadTitle = that.loadend ? '已全部加载完' : '上拉加载更多';
+                            that.page = that.page + 1;
+                            that.loading = false;
+                            that.xuefencount = 0;
+                            for (let i in that.activityList) {
+                                that.xuefencount += that.activityList[i].xuefen;
+                            }
+                            that.$set(this, 'activityList', that.activityList);
+                        }, function (res) {
+                            // that.loadTitle = '上拉加载更多';
+                            // that.loading = false;
+                        });
+                    } else if (that.navActive == 2) {
+                        store.baseGet($h.U({ c: 'my', a: 'history', p: { page: that.page, limit: 10000,  op:'shichanglist' } }), function (res) {
+                            var list = res.data.data;
+                            that.activityList.push.apply(that.activityList, list);
+                            that.loadend = list.length < that.limit;
+                            that.loadTitle = that.loadend ? '已全部加载完' : '上拉加载更多';
+                            that.page = that.page + 1;
+                            that.loading = false;
+                            that.shichang = 0;
+                            for (let i in that.activityList) {
+                                console.log(that.activityList[i].shichang);
+                                if (that.activityList[i].shichang){
+                                    that.shichang += parseInt(that.activityList[i].shichang / 60);
+                                }
+                            }
+                            that.$set(this, 'activityList', that.activityList);
+                        }, function (res) {
+                            // that.loadTitle = '上拉加载更多';
+                            // that.loading = false;
+                        });
                     } else {
                         store.baseGet($h.U({ c: 'my', a: 'special_log', p: { page: that.page, limit: that.limit,  op:'list' } }), function (res) {
                             var list = res.data.data;