浏览代码

fix:修改学生信息和登录接口去token

seamwang 1 年之前
父节点
当前提交
763206d55d
共有 4 个文件被更改,包括 78 次插入28 次删除
  1. 12 0
      src/api/course.js
  2. 6 2
      src/common/utils/fetch.js
  3. 59 25
      src/pages/myStudents/myStudents.vue
  4. 1 1
      src/pages/studentcenter/works.vue

+ 12 - 0
src/api/course.js

@@ -116,3 +116,15 @@ export function _leaveType (params) {
116 116
 export function _askLeave (params) {
117 117
 	return fetch('/parents/schedule/student_leave', params)
118 118
 }
119
+//获取年级
120
+export function _getGrades () {
121
+	return fetch('/parents/init/get_grades')
122
+}
123
+//获取班级
124
+export function _getClasses (params) {
125
+	return fetch('/parents/init/get_classes', params)
126
+}
127
+//修改信息
128
+export function _fixStudent (params) {
129
+	return fetch('/parents/init/edit_student', params)
130
+}

+ 6 - 2
src/common/utils/fetch.js

@@ -3,6 +3,8 @@ import store from '@/store/index'
3 3
 // 统一请求方法
4 4
 export default function fetch (url, params = {}, method = 'POST', showFail = true) {
5 5
 	let showLoading = true
6
+	//不需要token请求
7
+	const noTokenUrls = ['/parents/login/wx_login', '/parents/login/wx_auth']
6 8
 	if (params && params.notShowLoading) {
7 9
 		showLoading = false
8 10
 	}
@@ -12,9 +14,11 @@ export default function fetch (url, params = {}, method = 'POST', showFail = tru
12 14
 			title: '加载中...'
13 15
 		})
14 16
 	}
17
+	if (!noTokenUrls.includes(url)) {
18
+		params.token = store.getters.token
19
+		params.student_id = params.student_id || store.getters.kid
20
+	}
15 21
 	url = process.env.VUE_APP_BASE_URL + url
16
-	params.token = store.getters.token
17
-	params.student_id = params.student_id || store.getters.kid
18 22
 	return new Promise((resolve, reject) => {
19 23
 		uni.request({
20 24
 			url,

+ 59 - 25
src/pages/myStudents/myStudents.vue

@@ -17,7 +17,7 @@
17 17
           <view class="students-title flex justify-between align-center">
18 18
             <view class="text-lg">学生列表</view>
19 19
             <view class="text-xs text-grey">
20
-              <text class="text-red">点击选择,左滑删除,右侧添加</text>
20
+              <text class="text-red">点击选择,左滑操作,右侧添加</text>
21 21
               <text class="cuIcon-roundaddfill text-cyan margin-left-xl add-icon" @tap="showModal" data-target="ChooseModal"></text>
22 22
             </view>
23 23
           </view>
@@ -47,7 +47,7 @@
47 47
                   <text class="cuIcon-check text-student font-check" v-if="item.id === kid"></text>
48 48
                 </view>
49 49
                 <view class="move student-move">
50
-                  <view class="bg-cyan" @tap.stop="fixStudent(item.id)">修改</view>
50
+                  <view class="bg-cyan" @tap.stop="fixStudent(item)">修改</view>
51 51
                   <view class="bg-red" @tap.stop="unbind(item.id)">删除</view>
52 52
                 </view>
53 53
               </view>
@@ -133,8 +133,9 @@
133 133
 
134 134
 <script>
135 135
 import { _getStudents, _bindStudent, _unbindStudent } from '@/api/auth'
136
-import { _shopList } from '@/api/course'
136
+import { _shopList, _getGrades, _getClasses, _fixStudent } from '@/api/course'
137 137
 import { mapGetters } from 'vuex'
138
+import validate from '@/common/utils/ys-validate'
138 139
 export default {
139 140
   data() {
140 141
     return {
@@ -149,23 +150,18 @@ export default {
149 150
       info: {
150 151
         id: '',
151 152
         name: '',
153
+        school_id: '',
152 154
         grade_id: '',
153 155
         class_id: ''
154 156
       },
157
+      rules: [
158
+        { name: 'grade_id', required: true, type: 'number', errmsg: '请选择相应年级' },
159
+        { name: 'class_id', required: true, type: 'number', errmsg: '请选择相应班级' }
160
+      ],
155 161
       gradeIndex: -1, //年级index
156 162
       classIndex: -1, //班级index
157
-      grades: [
158
-        { name: '一年级', id: 1 },
159
-        { name: '二年级', id: 2 },
160
-        { name: '三年级', id: 3 },
161
-        { name: '四年级', id: 4 },
162
-        { name: '五年级', id: 5 }
163
-      ], //年级列表
164
-      classes: [
165
-        { name: '一班', id: 1 },
166
-        { name: '二班', id: 2 },
167
-        { name: '三班', id: 3 }
168
-      ], //班级列表
163
+      grades: [], //年级列表
164
+      classes: [], //班级列表
169 165
       result: null,
170 166
       chooseList: [],
171 167
       moveModel: null,
@@ -191,6 +187,7 @@ export default {
191 187
         success: res => {}
192 188
       })
193 189
     }
190
+    this.get_grades()
194 191
   },
195 192
   methods: {
196 193
     showModal(e) {
@@ -234,29 +231,66 @@ export default {
234 231
         }
235 232
       })
236 233
     },
237
-    fixStudent(id) {
238
-      const item = this.result.student_data.find(item => item.id === id)
239
-      this.info.id = id
234
+    fixStudent(item) {
235
+      this.info.id = item.id
240 236
       this.info.name = item.name
237
+      this.info.school_id = item.school
241 238
       this.gradeIndex = this.grades.findIndex(e => e.name === item.grade_name)
242 239
       this.info.grade_id = this.grades[this.gradeIndex]['id']
243
-      this.classIndex = this.classes.findIndex(e => e.name === item.class_name)
244
-      this.info.class_id = this.classes[this.classIndex]['id']
240
+      this.get_classes().then(res => {
241
+        this.classIndex = res.findIndex(c => c.name === item.class_name)
242
+        this.info.class_id = this.classes[this.classIndex]['id']
243
+      })
245 244
       this.modalName = 'FixModal'
246 245
     },
247
-    get_grades() {},
248
-    get_classes() {},
246
+    get_grades() {
247
+      _getGrades().then(res => {
248
+        this.grades = res.data
249
+      })
250
+    },
251
+    get_classes() {
252
+      return new Promise((resolve, reject) => {
253
+        _getClasses({ school_id: this.info.school_id, grade_id: this.info.grade_id }).then(res => {
254
+          this.classes = res.data
255
+          resolve(res.data)
256
+        })
257
+      })
258
+    },
249 259
     gradeChange(e) {
250 260
       this.gradeIndex = e.detail.value
251
-      this.studentForm.grade_id = this.grades[this.gradeIndex].id
261
+      this.info.grade_id = this.grades[this.gradeIndex].id
252 262
       this.classIndex = -1
263
+      this.info.class_id = ''
253 264
       this.get_classes()
254 265
     },
255 266
     classChange(e) {
256 267
       this.classIndex = e.detail.value
257
-      this.studentForm.class_id = this.classes[this.classIndex].id
268
+      this.info.class_id = this.classes[this.classIndex].id
269
+    },
270
+    confirmFix() {
271
+      const validRes = validate.validate(this.info, this.rules)
272
+      if (!validRes.isOk) {
273
+        uni.showToast({
274
+          icon: 'none',
275
+          title: validRes.errmsg
276
+        })
277
+        return false
278
+      }
279
+      uni.showModal({
280
+        title: '确认',
281
+        content: '确定修改?',
282
+        confirmText: '确定',
283
+        cancelText: '取消',
284
+        success: res => {
285
+          if (res.confirm) {
286
+            _fixStudent(this.info).then(res => {
287
+              this.get_list()
288
+              this.hideModal()
289
+            })
290
+          }
291
+        }
292
+      })
258 293
     },
259
-    confirmFix() {},
260 294
     unbind(id) {
261 295
       const _self = this
262 296
       uni.showModal({

+ 1 - 1
src/pages/studentcenter/works.vue

@@ -14,7 +14,7 @@
14 14
         </view>
15 15
         <view>
16 16
           <view class="title margin-top-sm">课堂作品</view>
17
-          <view class="list">
17
+          <view class="list" v-if="detail.student_comment_data">
18 18
             <view class="cu-card case" v-for="(item, index) in detail.student_comment_data.data" :key="index">
19 19
               <view class="cu-item shadow">
20 20
                 <view class="image">