Silent 6 سال پیش
والد
کامیت
4431a27ae0
3فایلهای تغییر یافته به همراه39 افزوده شده و 20 حذف شده
  1. 15 1
      app/Http/Controllers/WeChat/ApiController.php
  2. 7 2
      wechat/pages/rate/rate.js
  3. 17 17
      wechat/pages/rate/rate.wxml

+ 15 - 1
app/Http/Controllers/WeChat/ApiController.php

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;
@@ -448,8 +449,21 @@ class ApiController extends Controller
 
     public function getRemarkTitles(Request $request)
     {
+        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', $student_course->id)->get()->pluck('teacher_id')->unique('teacher_id');
+            $teachers = Teacher::whereIn('id', $teacher_ids)->get();
+        }
         $titles = RemarkTitle::where('status', 2)->get();
-        return response()->json(['status' => 'success', 'titles' => $titles]);
+
+        return response()->json(['status' => 'success', 'titles' => $titles, 'teachers' => $teachers]);
     }
 
     public function remarkTeacher(Request $request)

+ 7 - 2
wechat/pages/rate/rate.js

xqd xqd
@@ -6,7 +6,8 @@ Page({
   data: {
     titles: [],
     course_name: '',
-    teacher: ''
+    teacher: '',
+    teachers: []
   },
   onLoad: function (options) {
     let that = this;
@@ -16,11 +17,15 @@ 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
+            titles: res.data.titles,
+            teachers: res.data.teachers
           })
         }
       }

+ 17 - 17
wechat/pages/rate/rate.wxml

xqd
@@ -1,18 +1,18 @@
-<zan-panel title='课程名称:{{ course_name }}\n讲师姓名:{{ teacher }}'>
-  <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>
+<form bindsubmit="formSubmit">
+  <view wx:for="{{ teachers }}" wx:for-item="out_item">
+    <zan-panel title='课程名称:{{ course_name }}\n讲师姓名:{{ teacher }}'>
+      <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>
       </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>
-  </form>
-</zan-panel>
+    </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>