Просмотр исходного кода

Merge branch 'jeffry' of ssh://git.9026.com:2212/Silent/PianoTime

Mike 6 лет назад
Родитель
Сommit
a444f76312
32 измененных файлов с 590 добавлено и 168 удалено
  1. 5 0
      app/Http/Controllers/Admin/RemarkController.php
  2. 6 0
      app/Http/Controllers/Admin/TeacherController.php
  3. 93 38
      app/Http/Controllers/WeChat/ApiController.php
  4. 33 0
      app/Models/Student.php
  5. 30 0
      database/migrations/2018_08_13_170350_add_teacher_id_to_remark_detail.php
  6. 23 0
      database/seeds/RemarkSeeder.php
  7. 2 2
      resources/views/admin/remarks/index.blade.php
  8. 5 3
      resources/views/admin/students/courses/index.blade.php
  9. 1 1
      resources/views/admin/teachers/index.blade.php
  10. 5 3
      resources/views/teacher/students/courses/index.blade.php
  11. 3 2
      wechat/app.json
  12. 2 2
      wechat/pages/announce-detail/index.wxss
  13. 26 4
      wechat/pages/apply-leave/apply-leave.js
  14. 3 3
      wechat/pages/apply-leave/apply-leave.wxml
  15. 3 2
      wechat/pages/apply-leave/apply-leave.wxss
  16. 1 0
      wechat/pages/article-detail/index.wxml
  17. 8 2
      wechat/pages/article-detail/index.wxss
  18. 49 21
      wechat/pages/article/article.js
  19. 3 3
      wechat/pages/article/article.wxml
  20. 8 7
      wechat/pages/article/article.wxss
  21. 62 34
      wechat/pages/index/index.js
  22. 15 16
      wechat/pages/index/index.wxml
  23. 19 1
      wechat/pages/index/index.wxss
  24. 2 1
      wechat/pages/mycourse/mycourse.wxml
  25. 29 8
      wechat/pages/rate/rate.js
  26. 30 15
      wechat/pages/rate/rate.wxml
  27. 32 0
      wechat/pages/rate/rate.wxss
  28. 73 0
      wechat/pages/video/index.js
  29. 8 0
      wechat/pages/video/index.json
  30. 6 0
      wechat/pages/video/index.wxml
  31. 4 0
      wechat/pages/video/index.wxss
  32. 1 0
      wechat/utils/api.js

+ 5 - 0
app/Http/Controllers/Admin/RemarkController.php

xqd
@@ -45,6 +45,11 @@ class RemarkController extends Controller
             });
         }
 
+        foreach($list as $item) {
+            $item->average_score = RemarkDetail::where('remark_id', $item->id)->get()->avg('score');
+            $item->average_score = round($item->average_score, 1);
+        }
+
         $list = $this->paginate($list);
 
         list($pre_uri, $model_name) = array($this->pre_uri, $this->model_name);

+ 6 - 0
app/Http/Controllers/Admin/TeacherController.php

xqd xqd
@@ -3,6 +3,7 @@
 namespace App\Http\Controllers\Admin;
 
 use App\Models\Course;
+use App\Models\RemarkDetail;
 use App\Models\Teacher;
 use App\Models\TeacherCourse;
 use Illuminate\Http\Request;
@@ -36,6 +37,11 @@ class TeacherController extends Controller
 
         $list = $list->paginate()->withPath($this->getPaginateUrl());
 
+        foreach($list as $item) {
+            $item->average_score = RemarkDetail::where('remark_id', $item->id)->get()->avg('score');
+            $item->average_score = round($item->average_score, 1);
+        }
+
         list($pre_uri, $model_name) = array($this->pre_uri, $this->model_name);
         return view($this->view_path . 'index', compact('list', 'pre_uri', 'model_name'));
     }

+ 93 - 38
app/Http/Controllers/WeChat/ApiController.php

xqd xqd xqd xqd xqd xqd xqd xqd xqd xqd
@@ -15,6 +15,7 @@ use App\Models\Setting;
 use App\Models\Student;
 use App\Models\StudentCourse;
 use App\Models\StudentCourseTeacher;
+use App\Models\Teacher;
 use App\Models\WeChatUser;
 use Carbon\Carbon;
 use EasyWeChat\Factory;
@@ -212,7 +213,12 @@ class ApiController extends Controller
                 $result = 'ok';
             }
         }
-        return response()->json(['status' => 'success', 'result' => $result]);
+        $now = Carbon::today()->toDateTimeString();
+        $checkCard = CheckCard::where([
+            ['begin_date_time', '>', $now]
+        ])->whereNull('end_date_time')->orderBy('begin_date_time', 'desc')->first();
+
+        return response()->json(['status' => 'success', 'result' => $result, 'checkCard' => $checkCard]);
     }
 
     public function startCheckCard(Request $request)
@@ -270,7 +276,9 @@ class ApiController extends Controller
         if(empty($share_text) || empty($share_text->value)) {
             return response()->json(['status' => 'fail', 'info' => '找不到分享的文字!']);
         }
-        $text = str_replace_array('{days}', [$items->count() + 1], $share_text->value);
+        $now = Carbon::now()->toDateString();
+        $count = $items->contains($now) ? $items->count() : $items->count() + 1;
+        $text = str_replace_array('{days}', [$count], $share_text->value);
         $share_text_pos = Setting::where('key', 'share_text_pos')->first();
         if(empty($share_text_pos) || empty($share_text_pos->value) || count($pos = explode(',', $share_text_pos->value)) < 2) {
             return response()->json(['status' => 'fail', 'info' => '分享文字位置错误或未设置!']);
@@ -297,6 +305,9 @@ class ApiController extends Controller
                 $item->url = url($item->content);
             }
             $article_list = Content::where('type', 4)->orderBy('sort')->offset($article_offset)->limit(15)->get();
+            foreach($article_list as $item) {
+                $item->publish_date = substr($item->updated_at, 0, 10);
+            }
             return response()->json(['status' => 'success', 'video_list' => $video_list, 'article_list' => $article_list, 'type' => $request->input('type')]);
         } else if($request->input('type') == 'video') {
             $list = Content::where('type', 3)->orderBy('sort')->offset($video_offset)->limit(15)->get();
@@ -310,6 +321,9 @@ class ApiController extends Controller
             }
         } else {
             $list = Content::where('type', 4)->orderBy('sort')->offset($article_offset)->limit(15)->get();
+            foreach($list as $item) {
+                $item->publish_date = substr($item->updated_at, 0, 10);
+            }
         }
 
         return response()->json(['status' => 'success', 'list' => $list, 'type' => $request->input('type')]);
@@ -341,20 +355,7 @@ class ApiController extends Controller
         $student_course->short_leave_times = $student->short_leave_times;
         $student_course->long_leave_times = $student->long_leave_times;
 
-        $today = Carbon::today();
-        $this_week_begin = null;
-        while($today->dayOfWeekIso != 1) {
-            $today = $today->subDay();
-        }
-        $this_week_begin = $today->toDateTimeString();
-        $this_week_end = $today->addDays(7)->toDateTimeString();
-
-        $tmp = Remark::where([
-            ['student_id', '=', $student->id],
-            ['created_at', '>=', $this_week_begin],
-            ['created_at', '<', $this_week_end],
-        ])->first();
-        $is_new = empty($tmp) ? true : false;
+        $is_new = $student->getIsNew();
 
         return response()->json(['status' => 'success', 'courseInfo' => $student_course, 'is_new' => $is_new]);
     }
@@ -428,6 +429,9 @@ class ApiController extends Controller
         if(empty($request->input('student_id')) || empty($student = Student::find($request->input('student_id')))) {
             return response()->json(['status' => 'fail', 'info' => '找不到学员']);
         }
+        if(empty($request->input('type')) || !in_array($request->input('type'), [1, 2])) {
+            return response()->json(['status' => 'fail', 'info' => '找不到学员']);
+        }
         $student_course = StudentCourse::where('student_id', $student->id)->first();
         if(empty($student_course)) {
             return response()->json(['status' => 'fail', 'info' => '暂无课程']);
@@ -436,6 +440,7 @@ class ApiController extends Controller
             'student_id' => $student->id,
             'course_id' => $student_course->course_id,
             'student_course_id' => $student_course->id,
+            'type' => $request->input('type'),
             'date' => $request->input('date'),
             'days' => $request->input('days'),
             'remark' => $request->input('remark')
@@ -448,8 +453,45 @@ class ApiController extends Controller
 
     public function getRemarkTitles(Request $request)
     {
-        $titles = RemarkTitle::where('status', 2)->get();
-        return response()->json(['status' => 'success', 'titles' => $titles]);
+        if(empty($request->input('id')) || empty($student = Student::find($request->input('id')))) {
+            return response()->json(['status' => 'fail', 'info' => '找不到学员']);
+        }
+
+        if(empty($student_course = StudentCourse::where('student_id', $student->id)->first())) {
+            return response()->json(['status' => 'fail', 'info' => '找不到课程']);
+        }
+        if($student_course->assign_teacher == 1) {
+            $teachers = Teacher::all();
+        } else {
+            $teacher_ids = StudentCourseTeacher::where('student_course_id', $student_course->id)->get()->pluck('teacher_id')->unique();
+            $teachers = Teacher::whereIn('id', $teacher_ids)->get();
+        }
+
+        $is_new = $student->getIsNew();
+        if($is_new) {
+            $titles = RemarkTitle::where('status', 2)->get();
+            return response()->json(['status' => 'success', 'titles' => $titles, 'teachers' => $teachers, 'is_new' => $is_new]);
+        }
+
+        foreach($teachers as $teacher) {
+            $remark = Remark::where([
+                ['student_id', '=', $student->id],
+                ['teacher_id', '=', $teacher->id],
+            ])->first();
+            if(!empty($remark)) {
+                $remark_time = RemarkDetail::where([
+                    ['remark_id', '=', $remark->id],
+                    ['teacher_id', '=', $teacher->id],
+                ])->orderBy('updated_at', 'desc')->first();
+                $teacher->remark_time = empty($remark_time) ? '' : substr($remark_time->updated_at, 0, 10);
+                $teacher->average_score = $student->getThisWeekAverageScore($remark);
+            } else {
+                $teacher->remark_time = '';
+                $teacher->average_score = 0;
+            }
+        }
+
+        return response()->json(['status' => 'success', 'titles' => [], 'teachers' => $teachers, 'is_new' => $is_new]);
     }
 
     public function remarkTeacher(Request $request)
@@ -462,26 +504,39 @@ class ApiController extends Controller
         if(empty($student_course)) {
             return response()->json(['status' => 'fail', 'info' => '找不到课程']);
         }
-        $student_course_teacher = StudentCourseTeacher::where('student_id', $student->id)->first();
-        if(empty($student_course_teacher)) {
-            return response()->json(['status' => 'fail', 'info' => '找不到讲师']);
-        }
-        $remarks = $request->except(['student_id']);
-        foreach($remarks as $key => $value) {
-            $remark_title = RemarkTitle::find($key);
-            if(!empty($remark_title) && !empty($value) && $value != 'null') {
-                $res = Remark::create([
-                    'course_id' => $student_course->course_id,
-                    'teacher_id' => $student_course_teacher->teacher_id,
-                    'student_id' => $student->id,
-                ]);
-                RemarkDetail::create([
-                    'remark_id' => $res->id,
-                    'question' => $remark_title->name,
-                    'score' => $value,
-                ]);
-            } else {
-                return response()->json(['status' => 'fail', 'info' => '评价不能为空']);
+//        $student_course_teacher = StudentCourseTeacher::where('student_id', $student->id)->first();
+//        if(empty($student_course_teacher)) {
+//            return response()->json(['status' => 'fail', 'info' => '找不到讲师']);
+//        }
+//        $remarks = $request->except(['student_id']);
+        $data = $request->input('data');
+        if(!is_array($data)) {
+            return response()->json(['status' => 'fail', 'info' => '参数错误']);
+        }
+
+        foreach($data as $teacher_key => $teacher_value) {
+            $teacher = Teacher::find($teacher_key);
+            if(empty($teacher) || !is_array($teacher_value)) {
+                continue;
+            }
+            $remark = Remark::firstOrCreate([
+                'teacher_id' => $teacher->id,
+                'student_id' => $student->id
+            ], [
+                'course_id' => $student_course->course_id
+            ]);
+            $remark->updated_at = Carbon::now()->toDateTimeString();
+            $remark->save();
+            foreach($teacher_value as $title_key => $title_value) {
+                $remark_title = RemarkTitle::find($title_key);
+                if(!empty($remark_title)) {
+                    RemarkDetail::create([
+                        'remark_id' => $remark->id,
+                        'teacher_id' => $teacher->id,
+                        'question' => $remark_title->name,
+                        'score' => $title_value,
+                    ]);
+                }
             }
         }
 

+ 33 - 0
app/Models/Student.php

xqd
@@ -53,4 +53,37 @@ class Student extends Model
     {
         return StudentCourse::where('student_id', $this['id'])->first();
     }
+
+    public function getIsNew()
+    {
+        $today = Carbon::today();
+        $this_week_begin = null;
+        while($today->dayOfWeekIso != 1) {
+            $today = $today->subDay();
+        }
+        $this_week_begin = $today->toDateTimeString();
+        $this_week_end = $today->addDays(7)->toDateTimeString();
+
+        $tmp = Remark::where([
+            ['student_id', '=', $this['id']],
+            ['created_at', '>=', $this_week_begin],
+            ['created_at', '<', $this_week_end],
+        ])->first();
+        return empty($tmp) ? true : false;
+    }
+
+    public function getThisWeekAverageScore(Remark $remark)
+    {
+        $today = Carbon::today();
+        $this_week_begin = null;
+        while($today->dayOfWeekIso != 1) {
+            $today = $today->subDay();
+        }
+        $this_week_begin = $today->toDateTimeString();
+
+        return RemarkDetail::where([
+            ['remark_id', '=', $remark['id']],
+            ['created_at', '>=', $this_week_begin],
+        ])->get()->avg('score');
+    }
 }

+ 30 - 0
database/migrations/2018_08_13_170350_add_teacher_id_to_remark_detail.php

xqd
@@ -0,0 +1,30 @@
+<?php
+
+use Illuminate\Support\Facades\Schema;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Database\Migrations\Migration;
+
+class AddTeacherIdToRemarkDetail extends Migration
+{
+    /**
+     * Run the migrations.
+     *
+     * @return void
+     */
+    public function up()
+    {
+        Schema::table('remark_details', function (Blueprint $table) {
+            $table->unsignedInteger('teacher_id')->nullable()->after('id')->comment('讲师ID');
+        });
+    }
+
+    /**
+     * Reverse the migrations.
+     *
+     * @return void
+     */
+    public function down()
+    {
+        //
+    }
+}

+ 23 - 0
database/seeds/RemarkSeeder.php

xqd
@@ -0,0 +1,23 @@
+<?php
+
+use Illuminate\Database\Seeder;
+
+class RemarkSeeder extends Seeder
+{
+    /**
+     * Run the database seeds.
+     *
+     * @return void
+     */
+    public function run()
+    {
+        $remark_details = \App\Models\RemarkDetail::all();
+        foreach ($remark_details as $item) {
+            $remark = \App\Models\Remark::find($item->remark_id);
+            if(!empty($remark)) {
+                $item->teacher_id = $remark->teacher_id;
+                $item->save();
+            }
+        }
+    }
+}

+ 2 - 2
resources/views/admin/remarks/index.blade.php

xqd
@@ -53,9 +53,9 @@
                                         <tr>
                                             <td>{{ empty($item->teacher) ? '' : $item->teacher->name }}</td>
                                             <td>{{ empty($item->course) ? '' : $item->course->name }}</td>
-                                            <td></td>
+                                            <td>{{ $item->average_score }}</td>
                                             <td>{{ empty($item->student) ? '' : $item->student->name }}</td>
-                                            <td>{{ $item->created_at }}</td>
+                                            <td>{{ $item->updated_at }}</td>
                                             <td>
                                                 <div class="btn-group">
                                                     <a class="btn btn-sm btn-info btn-detail" href="{{ $pre_uri . 'detail?id=' . $item->id }}">详情</a>

+ 5 - 3
resources/views/admin/students/courses/index.blade.php

xqd
@@ -31,9 +31,11 @@
                                     </div>
                                 </form>
                             </div>
-                            <div class="col-sm-8 pull-right">
-                                <a href="{{ $pre_uri . 'create?student_id=' . $student->id }}" class="btn btn-sm btn-primary pull-right">添加{{ $model_name }}</a>
-                            </div>
+                            @if($list->count() == 0)
+                                <div class="col-sm-8 pull-right">
+                                    <a href="{{ $pre_uri . 'create?student_id=' . $student->id }}" class="btn btn-sm btn-primary pull-right">添加{{ $model_name }}</a>
+                                </div>
+                            @endif
                         </div>
                         <table class="table table-striped table-bordered table-hover dataTables-example dataTable" id="sg-main-table">
                             <thead>

+ 1 - 1
resources/views/admin/teachers/index.blade.php

xqd
@@ -56,7 +56,7 @@
                                             <td>{{ $item->id }}</td>
                                             <td>{{ $item->name }}</td>
                                             <td>{{ $item->courses->implode('name', ',') }}</td>
-                                            <td></td>
+                                            <td>{{ $item->average_score }}</td>
                                             <td>
                                                 <div class="btn-group">
                                                     <a class="btn btn-sm btn-info btn-edit" href="{{ $pre_uri . 'edit?id=' . $item->id }}">修改</a>

+ 5 - 3
resources/views/teacher/students/courses/index.blade.php

xqd
@@ -31,9 +31,11 @@
                                     </div>
                                 </form>
                             </div>
-                            <div class="col-sm-8 pull-right">
-                                <a href="{{ $pre_uri . 'create?student_id=' . $student->id }}" class="btn btn-sm btn-primary pull-right">添加{{ $model_name }}</a>
-                            </div>
+                            @if($list->count() == 0)
+                                <div class="col-sm-8 pull-right">
+                                    <a href="{{ $pre_uri . 'create?student_id=' . $student->id }}" class="btn btn-sm btn-primary pull-right">添加{{ $model_name }}</a>
+                                </div>
+                            @endif
                         </div>
                         <table class="table table-striped table-bordered table-hover dataTables-example dataTable" id="sg-main-table">
                             <thead>

+ 3 - 2
wechat/app.json

xqd
@@ -7,13 +7,14 @@
     "pages/article-detail/index",
     "pages/userinfo/userinfo",
     "pages/mycourse/mycourse",
-    "pages/rate/rate",
     "pages/rate-review/rate-review",
     "pages/my-log/my-log",
     "pages/apply-leave/apply-leave",
     "pages/login/index",
     "pages/bind-phone/index",
-    "pages/form/index"
+    "pages/rate/rate",
+    "pages/form/index",
+    "pages/video/index"
   ],
   "window": {
     "backgroundTextStyle": "light",

+ 2 - 2
wechat/pages/announce-detail/index.wxss

xqd
@@ -96,10 +96,10 @@
     padding: 5rpx 10rpx!important;
 }
 .sg-container {
-  background-color: white
+  background-color: white;
+  padding: 0 30rpx;
 }
 .sg-title {
-  text-align: center;
   font-size: 1.15rem;
   font-weight: bold;
   padding: 7px 0;

+ 26 - 4
wechat/pages/apply-leave/apply-leave.js

xqd xqd
@@ -38,6 +38,24 @@ Page({
   },
   formSubmit: function (e) {
     let value = e.detail.value
+    value.days = parseInt(value.days)
+    if(value.type == 0) {
+      if (value.days <= 0 || value.days > 7) {
+        wx.showModal({
+          title: '请假失败',
+          content: '短假可请天数为1到7天',
+        })
+        return false;
+      }
+    } else {
+      if (!(value.days >= 7 && value.days <= 60)) {
+        wx.showModal({
+          title: '请假失败',
+          content: '长假可请天数为7到60天',
+        })
+        return false;
+      }
+    }
     wx.request({
       url: api.applyLeaveUrl,
       method: 'GET',
@@ -49,11 +67,15 @@ Page({
         'remark': value.remark
       },
       success: res => {
-        if(res.data.status == 'success') {
-          wx.showToast({
+        if (res.data.status == 'success') {
+          wx.showModal({
             title: '请假成功',
-            icon: 'none',
-            duration: 800
+            content: '请假成功',
+            success: function (res) {
+              wx.switchTab({
+                url: '/pages/userinfo/userinfo',
+              })
+            }
           })
         } else {
           wx.showToast({

+ 3 - 3
wechat/pages/apply-leave/apply-leave.wxml

xqd xqd
@@ -14,7 +14,7 @@
       </zan-cell>
       <zan-cell title="天数">
         <view class="section">
-          <input placeholder="请输入请假天数" name='days'/>
+          <input placeholder="请输入请假天数" name='days' type='number'/>
         </view>
       </zan-cell>
       <zan-cell title="说明">
@@ -28,7 +28,7 @@
     <!-- <zan-button-group>
        <zan-button type="primary" btnclick="onSubmit">提交</zan-button>
     </zan-button-group> -->
-    <button formType="submit" type='primary' class='submit-btn'>提交</button>
+    <button formType="submit" type='primary' class='submit-btn' id='submit-btn'>提交</button>
   </view>
 </form>
-</view>
+</view>

+ 3 - 2
wechat/pages/apply-leave/apply-leave.wxss

xqd
@@ -1,3 +1,4 @@
-.submit-btn {
-  margin: 3px 3px
+#submit-btn {
+  margin: 40rpx 10rpx;
+  background-color: black;
 }

+ 1 - 0
wechat/pages/article-detail/index.wxml

xqd
@@ -2,5 +2,6 @@
 <import src="/wxParse/wxParse.wxml"/>
 <view class='sg-container'>
   <view class='sg-title'>{{ back_article.title }}</view>
+  <view class='sg-date'>{{ back_article.publish_date }}</view>
   <template is="wxParse" data="{{wxParseData:article.nodes}}" />
 </view>

+ 8 - 2
wechat/pages/article-detail/index.wxss

xqd
@@ -2,11 +2,17 @@
 @import "/wxParse/wxParse.wxss";
 
 .sg-container {
-  background-color: white
+  background-color: white;
+  padding: 0 30rpx;
 }
 .sg-title {
-  text-align: center;
   font-size: 1.15rem;
   font-weight: bold;
   padding: 7px 0;
+}
+.sg-date {
+  text-align: right;
+  padding: 4px 7px;
+  font-size: 0.8rem;
+  color: grey;
 }

+ 49 - 21
wechat/pages/article/article.js

xqd xqd xqd xqd xqd
@@ -12,6 +12,7 @@ Page({
     hide: "hide",
     show: !1,
     animationData: {},
+    show_video: null,
     tabList: [{
       tab: 'video',
       title: '视频'
@@ -20,21 +21,37 @@ Page({
       title: '文章'
     }],
     selectedTab: 'video',
+    selectedVideoIndex: null,
+    selectedVideoUrl: '',
+    showVideo: false
   },
-  onLoad: function (a) {
+  onLoad: function(a) {
     // app.pageOnLoad(this);
     this.loadMoreGoodsList('both');
   },
-  swiperTab: function (e) {
+  swiperTab: function(e) {
     var that = this;
     // console.log(e);
+    if (e.detail.currentItemId != 'video') {
+      this.setData({
+        show_video: null,
+        show: !0
+      });
+    }
     that.setData({
       selectedTab: e.detail.currentItemId
     });
   },
-  clickTab: function (e) {
+  clickTab: function(e) {
     var that = this;
     // console.log(e)
+    if (e.target.dataset.current != 'video') {
+      this.setData({
+        show_video: null,
+        show: !0
+      });
+    }
+    
     if (this.data.selectedTab === e.target.dataset.current) {
       return false;
     } else {
@@ -43,14 +60,21 @@ Page({
       })
     }
   },
-  onReady: function () { },
-  onShow: function () {
+  onReady: function() {},
+  onShow: function() {
     // app.pageOnShow(this);
   },
-  onHide: function () { },
-  onUnload: function () { },
-  onPullDownRefresh: function () { },
-  loadMoreGoodsList: function (tab) {
+  onHide: function() {
+    var context = wx.createVideoContext("video_" + this.data.show_video)
+    context.stop()
+    this.setData({
+      show_video: null,
+      show: !0
+    });
+  },
+  onUnload: function() {},
+  onPullDownRefresh: function() {},
+  loadMoreGoodsList: function(tab) {
     var tab = tab || this.data.selectedTab;
     var o = this;
     // if (!is_loading_more) {
@@ -159,18 +183,22 @@ Page({
     // });
     // }
   },
-  play: function (a) {
-    var t = a.currentTarget.dataset.index;
-    wx.createVideoContext("video_" + this.data.show_video).pause(), this.setData({
-      show_video: t,
-      show: !0
-    });
+  play: function(a) {
+    var url = a.currentTarget.dataset.url;
+    var title = a.currentTarget.dataset.title;
+    wx.navigateTo({
+      url: '/pages/video/index?url=' + url + '&title=' + title,
+    })
+    // wx.createVideoContext("video_" + this.data.show_video).pause(), this.setData({
+    //   show_video: t,
+    //   show: !0
+    // });
   },
-  onReachBottom: function () {
+  onReachBottom: function() {
     this.loadMoreGoodsList();
     // is_no_more || this.loadMoreGoodsList();
   },
-  more: function (a) {
+  more: function(a) {
     var t = this,
       o = a.target.dataset.index,
       i = t.data.video_list,
@@ -180,11 +208,11 @@ Page({
       });
     this.animation = e, -1 != i[o].show ? (e.rotate(0).step(), i[o].show = -1) : (e.rotate(0).step(),
       i[o].show = 0), t.setData({
-        video_list: i,
-        animationData: this.animation.export()
-      });
+      video_list: i,
+      animationData: this.animation.export()
+    });
   },
-  redirectToArticle: function (e) {
+  redirectToArticle: function(e) {
     let id = e.currentTarget.dataset.id;
     wx.navigateTo({
       url: '/pages/article-detail/index?id=' + id

+ 3 - 3
wechat/pages/article/article.wxml

xqd xqd
@@ -11,9 +11,8 @@
           <view class="info-content" wx:for="{{ video_list }}">
             <view class="info-bg" wx:if="{{ item.type == 3 }}">
               <view class="info-video">
-                <image bindtap="play" class="bg {{show_video==index?hide:''}}" data-index="{{index}}" src="{{item.pic_url}}"></image>
-                <image bindtap="play" class="play {{show_video==index?hide:''}}" data-index="{{index}}" src="/images/video-play.png"></image>
-                <video autoplay="true" class="{{show_video==index?'':hide}}" controls="controls" id="video_{{index}}" src="{{item.url}}" wx:if="{{show_video==index}}"></video>
+                <image bindtap="play" class="bg" src="{{item.pic_url}}" data-url="{{ item.url }}" data-title="{{ item.title }}"></image>
+                <image bindtap="play" class="play" src="/images/video-play.png" data-url="{{ item.url }}" data-title="{{ item.title }}"></image>
               </view>
               <view class="info-label">{{item.title||'未命名'}}</view>
               <!-- <view class="content {{item.show!=-1?'':'more'}}">{{item.content||'暂无信息'}}</view>   -->
@@ -37,6 +36,7 @@
           <view class="info-content" wx:for="{{ article_list }}">
             <view class='info-bg' catchtap='redirectToArticle' data-id='{{ item.id }}'>
               <view class="info-label">{{ item.title||'未命名' }}</view>
+              <view class="info-date">{{ item.publish_date }}</view>
             </view>
           </view>
         </view>

+ 8 - 7
wechat/pages/article/article.wxss

xqd xqd
@@ -20,6 +20,7 @@
   position: relative;
   width: 100%;
   height: 100%;
+  padding: 0 20rpx;
 }
 
 .info-content .info-video {
@@ -58,17 +59,17 @@
   left: 0;
 }
 
-.info-content .info-label {
-  width: 100%;
-  height: 100rpx;
+.info-content .info-label,
+.info-content .info-date {
+  display: inline;
   line-height: 100rpx;
-  padding: 0 24rpx;
-  white-space: nowrap;
-  text-overflow: ellipsis;
-  overflow: hidden;
   font-weight: bold;
 }
 
+.info-content .info-date {
+  float: right;
+}
+
 .modal {
   position: fixed;
   top: 0;

+ 62 - 34
wechat/pages/index/index.js

xqd xqd xqd xqd xqd xqd xqd xqd xqd
@@ -20,7 +20,8 @@ Page({
     shareText: '',
     shareTextPosX: '',
     shareTextPosY: '',
-    shareTempFilePath: ''
+    shareTempFilePath: '',
+    showPopup: false
   },
   onLoad: function () {
     wx.getSystemInfo({
@@ -49,6 +50,48 @@ Page({
       app.globalData.ptStudent = pt_student;
     }
 
+    wx.getLocation({
+      success: (res) => {
+        // let validLocation = this.validLocation(res.latitude, res.longitude)
+        wx.request({
+          url: api.checkPositionUrl,
+          method: 'GET',
+          data: {
+            latitude: res.latitude,
+            longitude: res.longitude,
+            student_id: pt_student.id
+          },
+          success: res => {
+            let validLocation = false;
+            if (res.data.status == 'success' && res.data.result == 'ok') {
+              validLocation = true;
+            } else {
+              validLocation = api.isTest ? true : false;
+            }
+            this.setData({
+              is_btn_disabled: !validLocation
+            })
+            if(validLocation) {
+              var start_time = wx.getStorageSync('check_card_start_time')
+              if(start_time) {
+                this.setData({
+                  startTime: start_time,
+                  isLearning: true
+                })
+                this.startClock()
+              }
+            }
+          },
+        });
+        this.setData({
+          currentLatitude: res.latitude,
+          currentLongitude: res.longitude,
+          accuracy: res.accuracy
+        })
+
+      }
+    })
+
     wx.request({
       url: api.getShareInfoUrl,
       method: 'GET',
@@ -56,7 +99,7 @@ Page({
         'student_id': pt_student.id
       },
       success: res => {
-        if(res.data.status == 'success') {
+        if (res.data.status == 'success') {
           this.setData({
             shareCanvasWidth: res.data.width,
             shareCanvasHeight: res.data.height,
@@ -76,34 +119,6 @@ Page({
         }
       }
     })
-
-    wx.getLocation({
-      success: (res) => {
-        // let validLocation = this.validLocation(res.latitude, res.longitude)
-        wx.request({
-          url: api.checkPositionUrl,
-          method: 'GET',
-          data: {
-            latitude: res.latitude,
-            longitude: res.longitude
-          },
-          success: res => {
-            if (res.data.status == 'success' && res.data.result == 'ok') {
-              let validLocation = api.isTest ? true : false;
-              this.setData({
-                is_btn_disabled: !validLocation
-              })
-            }
-          },
-        });
-        this.setData({
-          currentLatitude: res.latitude,
-          currentLongitude: res.longitude,
-          accuracy: res.accuracy
-        })
-
-      }
-    })
   },
   validLocation(latitude, longitude) {
     let res = api.isTest ? true : false;
@@ -122,6 +137,12 @@ Page({
     });
     return res;
   },
+  hidePhotoPopup() {
+    this.setData({
+      showPopup: false,
+      clock: '00:00:00'
+    })
+  },
   handleBtnClick() {
     wx.getLocation({
       success: (res) => {
@@ -136,9 +157,10 @@ Page({
           success: res => {
             let validLocation = false;
             if (res.data.status == 'success' && res.data.result == 'ok') {
+              validLocation = true;
+            } else {
               validLocation = api.isTest ? true : false;
             }
-            validLocation = api.isTest ? true : false;
             this.setData({
               is_btn_disabled: !validLocation
             })
@@ -193,9 +215,11 @@ Page({
         success: res => {
           if (res.data.status == 'success') {
             wx.setStorageSync('check_card_id', res.data.check_card_id)
+            var start_time = new Date().getTime()
+            wx.setStorageSync('check_card_start_time', start_time)
             that.setData({
               isLearning: !isLearning,
-              startTime: new Date().getTime()
+              startTime: start_time
             })
             that.startClock()
           } else {
@@ -239,6 +263,7 @@ Page({
       isLearning: false,
       showPopup: true
     })
+    wx.setStorageSync('check_card_start_time', '')
     const ctx = wx.createCanvasContext('shareCanvas')
     let width = this.data.shareCanvasWidth
     let height = this.data.shareCanvasHeight
@@ -295,11 +320,14 @@ Page({
     wx.saveImageToPhotosAlbum({
       filePath: this.data.shareTempFilePath,
       success: (res) => {
-        
+        // this.setData({
+        //   showPopup: false
+        // })
       },
       complete: res => {
         this.setData({
-          showPopup: false
+          showPopup: false,
+          clock: '00:00:00'
         })
       }
     })

+ 15 - 16
wechat/pages/index/index.wxml

xqd xqd
@@ -3,28 +3,22 @@
   <view class="logo">
     <image class="logo-img" src="../../images/img_gqsj_01@2x.png" style="width:208px; height:71px" />
   </view>
-  <swiper
-    style="height: {{bannerHeight}}px"
-    autoplay="true"
-    indicator-dots="true"
-    indicator-color="#fff"
-    indicator-active-color="red"
-  >
+  <swiper style="height: {{bannerHeight}}px" autoplay="true" indicator-dots="true" indicator-color="#fff" indicator-active-color="red">
     <swiper-item class="swiper-item">
-     <image src="../../images/img_banner01@2x.png" style="width: 100%; height: {{bannerHeight}}px"/>
-     <view class="swiper-item__text">
+      <image src="../../images/img_banner01@2x.png" style="width: 100%; height: {{bannerHeight}}px" />
+      <view class="swiper-item__text">
         <text class="swiper-item__title">钢琴课程</text>
         <text class="swiper-item__subtitle">带您提高音乐素养</text>
         <text class="swiper-item__desc">为您打造一系列定制课程</text>
-     </view>
+      </view>
     </swiper-item>
     <swiper-item class="swiper-item">
-     <image src="../../images/img_banner01@2x.png" style="width: 100%; height: {{bannerHeight}}px"/>
-     <view class="swiper-item__text">
+      <image src="../../images/img_banner01@2x.png" style="width: 100%; height: {{bannerHeight}}px" />
+      <view class="swiper-item__text">
         <text class="swiper-item__title">钢琴课程</text>
         <text class="swiper-item__subtitle">带您提高音乐素养</text>
         <text class="swiper-item__desc">为您打造一系列定制课程</text>
-     </view>
+      </view>
     </swiper-item>
   </swiper>
   <view class="time">
@@ -44,8 +38,13 @@
     <button class="start-btn" bindtap="handleBtnClick">{{isLearning ? '结束' : '开始' }}</button>
   </view>
   <zan-popup show="{{ showPopup }}" bindclose="togglePopup">
-    <canvas canvas-id="shareCanvas" style="width: {{shareCanvasWidth}}px; height:{{shareCanvasHeight}}px">
-    </canvas>
+    <view class='{{ showPopup ? "sg-show-popup" : "sg-hide-popup" }}'>
+      <view class='hide-popup-btn' bindtap='hidePhotoPopup'>
+        <icon type='cancel' color='white'></icon>
+      </view>
+      <canvas canvas-id="shareCanvas" style="width: {{shareCanvasWidth}}px; height:{{shareCanvasHeight}}px">
+      </canvas>
+    </view>
     <button class="share-btn" bindtap="handleShare" type='primary'>生成图片发到朋友圈</button>
   </zan-popup>
-</view>
+</view>

+ 19 - 1
wechat/pages/index/index.wxss

xqd xqd
@@ -112,6 +112,7 @@ swiper {
   width: 86.88px;
   height: 86.88px
 }
+.close-btn,
 .start-btn {
   position: relative;
   z-index: 1;
@@ -125,7 +126,24 @@ swiper {
   line-height: 86.88px;
   border: none;
 }
+
+.close-btn,
 .share-btn {
-  margin-top: 20px;
   width: 80%;
+}
+.sg-show-popup {
+  width: 100%;
+  height: 100%;
+}
+.sg-hide-popup {
+  width: 0;
+  height: 0;
+  margin-left: 1000rpx;
+  display: block;
+  overflow: hidden;
+}
+.hide-popup-btn {
+  position: fixed;
+  top: -50rpx;
+  right: -10rpx;
 }

+ 2 - 1
wechat/pages/mycourse/mycourse.wxml

xqd
@@ -1,5 +1,6 @@
-<zan-panel title='{{ courseInfo.course_name }}'>
+<zan-panel>
   <zan-cell-group>
+    <zan-cell title="课程名称" value="{{ courseInfo.course_name }}"></zan-cell>
     <zan-cell title="主讲老师" value="{{ courseInfo.teacher_names }}"></zan-cell>
     <zan-cell title="报名日期" value="{{ courseInfo.apply_date }}"></zan-cell>
     <zan-cell title="课程截至日期">

+ 29 - 8
wechat/pages/rate/rate.js

xqd xqd xqd
@@ -6,7 +6,9 @@ Page({
   data: {
     titles: [],
     course_name: '',
-    teacher: ''
+    teacher: '',
+    teachers: [],
+    is_new: true
   },
   onLoad: function (options) {
     let that = this;
@@ -16,18 +18,39 @@ Page({
     })
     wx.request({
       url: api.getRemarkTitlesUrl,
+      data: {
+        id: wx.getStorageSync('pt_student').id
+      },
       method: 'GET',
       success: res => {
-        if (res.data.status == 'success') {
-          that.setData({
-            titles: res.data.titles
-          })
-        }
+        // console.log(res.data)
+        that.setData({
+          is_new: res.data.is_new,
+          titles: res.data.titles,
+          teachers: res.data.teachers
+        })
       }
     })
   },
   formSubmit: function (e) {
     let data = e.detail.value;
+    for(var i in data) {
+      if(data[i] === null) {
+        wx.showModal({
+          title: '评价失败',
+          content: '评分不能为空',
+        })
+        return false;
+      }
+      data[i] = parseInt(data[i])
+      if (!(data[i] >= 0 && data[i] <= 10)) {
+        wx.showModal({
+          title: '评价失败',
+          content: '评分只能为0到10',
+        })
+        return false;
+      }
+    }
     data.student_id = wx.getStorageSync('pt_student').id
     wx.request({
       url: api.remarkTeacherUrl,
@@ -44,14 +67,12 @@ Page({
               })
             }
           })
-          
         } else {
           wx.showToast({
             title: res.data.info,
             icon: 'none',
             duration: 800
           })
-          
         }
       }
     })

+ 30 - 15
wechat/pages/rate/rate.wxml

xqd
@@ -1,18 +1,33 @@
-<zan-panel title='课程名称:{{ course_name }}\n讲师姓名:{{ teacher }}'>
+<view wx:if="{{ is_new }}">
   <form bindsubmit="formSubmit">
-    <view>
-      <view wx:for="{{ titles }}">
-        <zan-cell title="{{ item.name }}">
-          <zan-field placeholder="(满分10.0)" type="digit" name="{{ item.id }}">
-          </zan-field>
-        </zan-cell>
-      </view>
-      <zan-cell></zan-cell>
-      <zan-cell></zan-cell>
-      <zan-button-group>
-        <!-- <zan-button type="primary" bindtap="onSubmit">提交</zan-button> -->
-        <button formType="submit" type='primary' class='submit-btn'>提交</button>
-      </zan-button-group>
+    <view wx:for="{{ teachers }}" wx:for-item="out_item">
+      <zan-panel title='课程名称:{{ course_name }}\n讲师姓名:{{ out_item.name }}'>
+        <view>
+          <view wx:for="{{ titles }}">
+            <zan-cell title="{{ item.name }}">
+              <zan-field placeholder="(满分10)" inputType="number" name="data[{{ out_item.id }}][{{ item.id }}]">
+              </zan-field>
+            </zan-cell>
+          </view>
+        </view>
+      </zan-panel>
     </view>
+    <zan-button-group>
+      <!-- <zan-button type="primary" bindtap="onSubmit">提交</zan-button> -->
+      <button formType="submit" type='primary' class='submit-btn'>提交</button>
+    </zan-button-group>
   </form>
-</zan-panel>
+</view>
+<view wx:else>
+  <view wx:for="{{ teachers }}">
+    <view class='remark-box'>
+      <view class='remark-header'>
+        <view class='remark-title'>讲师姓名:{{ item.name }}<text class='remark-date'>{{ item.remark_time }}</text></view>
+      </view>
+      <view class='remark-body'>
+        <view class='remark-score-item'>平均分<text class='remark-score'>{{ item.average_score }}分</text>
+        </view>
+      </view>
+    </view>
+  </view>
+</view>

+ 32 - 0
wechat/pages/rate/rate.wxss

xqd
@@ -1,9 +1,41 @@
 .wrapper {
   padding: 0 15px;
 }
+
 .text-new {
   color: red;
 }
+
 .zan-field {
   border-bottom: 1px solid #9a9a9a;
+}
+
+.remark-box {
+  background-color: white;
+  padding: 15rpx 0;
+  color: grey;
+}
+
+.remark-header {
+  padding: 20rpx;
+  background-color: #f9f9f9;
+}
+
+.remark-score {
+  float: right;
+  color: grey;
+  font-size: 0.8rem;
+}
+
+.remark-body {
+  padding: 0 20rpx;
+  color: black;
+}
+
+.remark-score-item {
+  margin-top: 15rpx;
+}
+.remark-date {
+  float: right;
+  font-size: 0.8rem;
 }

+ 73 - 0
wechat/pages/video/index.js

xqd
@@ -0,0 +1,73 @@
+// pages/video/index.js
+Page({
+
+  /**
+   * 页面的初始数据
+   */
+  data: {
+    video_url: '',
+    title: '视频'
+  },
+
+  /**
+   * 生命周期函数--监听页面加载
+   */
+  onLoad: function (options) {
+    wx.setNavigationBarTitle({
+      title: options.title//页面标题为路由参数
+    })
+    this.setData({
+      video_url: options.url,
+      title: options.title
+    });
+  },
+
+  /**
+   * 生命周期函数--监听页面初次渲染完成
+   */
+  onReady: function () {
+  
+  },
+
+  /**
+   * 生命周期函数--监听页面显示
+   */
+  onShow: function () {
+  
+  },
+
+  /**
+   * 生命周期函数--监听页面隐藏
+   */
+  onHide: function () {
+  
+  },
+
+  /**
+   * 生命周期函数--监听页面卸载
+   */
+  onUnload: function () {
+  
+  },
+
+  /**
+   * 页面相关事件处理函数--监听用户下拉动作
+   */
+  onPullDownRefresh: function () {
+  
+  },
+
+  /**
+   * 页面上拉触底事件的处理函数
+   */
+  onReachBottom: function () {
+  
+  },
+
+  /**
+   * 用户点击右上角分享
+   */
+  onShareAppMessage: function () {
+  
+  }
+})

+ 8 - 0
wechat/pages/video/index.json

xqd
@@ -0,0 +1,8 @@
+{
+  "navigationBarBackgroundColor": "#000",
+  "navigationBarTextStyle": "white",
+  "usingComponents": {
+    "zan-card": "../../bower_components/zanui-weapp/dist/card/index"
+  },
+  "navigationBarTitleText": "视频"
+}

+ 6 - 0
wechat/pages/video/index.wxml

xqd
@@ -0,0 +1,6 @@
+<!--pages/video/index.wxml-->
+<view class='sg-container'>
+  <view class='sg-video-container'>
+    <video autoplay="true" controls="controls" id="video_id" src="{{ video_url }}"></video>
+  </view>
+</view>

+ 4 - 0
wechat/pages/video/index.wxss

xqd
@@ -0,0 +1,4 @@
+/* pages/video/index.wxss */
+.sg-video-container video {
+  width: 100%;
+}

+ 1 - 0
wechat/utils/api.js

xqd
@@ -20,4 +20,5 @@ module.exports = {
   getPhoneUrl: headUrl + 'getPhone',
   getFormSetUrl: headUrl + 'getFormSet',
   submitFormUrl: headUrl + 'submitForm',
+  applyLeaveUrl: headUrl + 'applyLeave',
 }