Pārlūkot izejas kodu

'完成学生需求页面'

machinecat520 2 gadi atpakaļ
vecāks
revīzija
1ea05d24c3
2 mainītis faili ar 172 papildinājumiem un 29 dzēšanām
  1. 159 4
      pages/stuNeed/stuNeed.js
  2. 13 25
      pages/stuNeed/stuNeed.wxml

+ 159 - 4
pages/stuNeed/stuNeed.js

@@ -17,6 +17,10 @@ Page({
         chosedTeachPosition: false, //辅导方式选项是否展示
         stuSex: '', //学生性别
         salary: '', //学生输入的酬金
+        schoolTimeAM: [], //上午上课时间
+        schoolTimePM: [], //下午上课时间
+        schoolTimeEvening: [], //晚上上课时间
+        schoolTime: [], //合并后的上课时间
         stuGoal: '', //学生输入的期望目标或效果
         chosedStuSex: false, //学生性别选项是否展示
         teacherAttr: '不限', //老师身份默认选项
@@ -28,7 +32,7 @@ Page({
         showTeachSex: false, //老师性别选项是否展示
         teacherImg: '不限', //老师头像是否上传默认选项
         showTeachImg: false, //老师头像是否上传的选项是否展示
-        toTeacherOtherNeed:'',  //对老师的其他需求
+        toTeacherOtherNeed: '', //对老师的其他需求
         // 课程类别
         courseList: [{
                 name: "小学",
@@ -822,6 +826,97 @@ Page({
                 imgUpload: '否',
                 choesd: false
             }
+        ],
+        // 上课时间
+        // 上午
+        timeAM: [{
+                name: '1',
+                value: 'A1'
+            },
+            {
+                name: '2',
+                value: 'A2'
+            },
+            {
+                name: '3',
+                value: 'A3'
+            },
+            {
+                name: '4',
+                value: 'A4'
+            },
+            {
+                name: '5',
+                value: 'A5'
+            },
+            {
+                name: '6',
+                value: 'A6'
+            },
+            {
+                name: '7',
+                value: 'A7'
+            }
+        ],
+        // 下午
+        timePM: [{
+                name: '1',
+                value: 'P1'
+            },
+            {
+                name: '2',
+                value: 'P2'
+            },
+            {
+                name: '3',
+                value: 'P3'
+            },
+            {
+                name: '4',
+                value: 'P4'
+            },
+            {
+                name: '5',
+                value: 'P5'
+            },
+            {
+                name: '6',
+                value: 'P6'
+            },
+            {
+                name: '7',
+                value: 'P7'
+            }
+        ],
+        // 晚上
+        timeEvening: [{
+                name: '1',
+                value: 'E1'
+            },
+            {
+                name: '2',
+                value: 'E2'
+            },
+            {
+                name: '3',
+                value: 'E3'
+            },
+            {
+                name: '4',
+                value: 'E4'
+            },
+            {
+                name: '5',
+                value: 'E5'
+            },
+            {
+                name: '6',
+                value: 'E6'
+            },
+            {
+                name: '7',
+                value: 'E7'
+            }
         ]
     },
 
@@ -1062,6 +1157,53 @@ Page({
         })
     },
 
+    // 选择上课时间
+    // 上午
+    chechboxChangeAM(e) {
+        // console.log(e)
+        let schoolTimeAM = this.data.schoolTimeAM
+        schoolTimeAM = e.detail.value
+        this.setData({
+            schoolTimeAM
+        })
+        // console.log(schoolTimeAM)
+    },
+
+    // 下午
+    chechboxChangePM(e) {
+        // console.log(e)
+        let schoolTimePM = this.data.schoolTimePM
+        schoolTimePM = e.detail.value
+        this.setData({
+            schoolTimePM
+        })
+        // console.log(schoolTimePM)
+    },
+
+    // 晚上
+    chechboxChangeEvening(e) {
+        // console.log(e)
+        let schoolTimeEvening = this.data.schoolTimeEvening
+        schoolTimeEvening = e.detail.value
+        this.setData({
+            schoolTimeEvening
+        })
+        // console.log(schoolTimeEvening)
+    },
+
+    // 合并上课时间的函数
+    joinTime() {
+        let schoolTimeAM = this.data.schoolTimeAM
+        let schoolTimePM = this.data.schoolTimePM
+        let schoolTimeEvening = this.data.schoolTimeEvening
+        let schoolTime = this.data.schoolTime
+        schoolTime = schoolTimeAM.concat(schoolTimePM, schoolTimeEvening)
+        this.setData({
+            schoolTime
+        })
+        // console.log("上课时间为:"+schoolTime)
+    },
+
     // 获取学生输入的期望达到的目标或效果
     getStuGoal(e) {
         this.setData({
@@ -1401,10 +1543,10 @@ Page({
     },
 
     // 对老师的其他需求
-    getOtherNeed(e){
+    getOtherNeed(e) {
         // console.log(e)
         this.setData({
-            toTeacherOtherNeed:e.detail.value
+            toTeacherOtherNeed: e.detail.value
         })
     },
 
@@ -1492,6 +1634,18 @@ Page({
               })
               return
         }
+        //判断上课时间是否选择
+        //调用上课时间合并的函数
+        this.joinTime()
+        // 判断上课时间是否为空
+        let schoolTime = this.data.schoolTime
+        if (schoolTime.length == 0) {
+            wx.showToast({
+                title: '请选择上课时间',
+                icon: 'none'
+            })
+            return
+        }
 
         // 存入本地缓存
         wx.setStorageSync('student', {
@@ -1503,12 +1657,13 @@ Page({
             teachPosition: this.data.teachPosition,
             stuSex: this.data.stuSex,
             salary: this.data.salary,
+            schoolTime: this.data.schoolTime,
             stuGoal: this.data.stuGoal,
             teacherAttr: this.data.teacherAttr,
             teacherEdu: this.data.teacherEdu,
             teacherSex: this.data.teacherSex,
             teacherImg: this.data.teacherImg,
-            toTeacherOtherNeed:this.data.toTeacherOtherNeed
+            toTeacherOtherNeed: this.data.toTeacherOtherNeed
         })
         wx.showToast({
             title: '提交成功',

+ 13 - 25
pages/stuNeed/stuNeed.wxml

@@ -65,42 +65,30 @@
                     <text class="th_1">周四</text>
                     <text class="th_1">周五</text>
                     <text class="th_1">周六</text>
-                    <text class="th_2">周日</text>
+                    <text class="th_1">周日</text>
                 </view>
                 <view class="tr_2">
-                    <checkbox-group>
+                    <checkbox-group bindchange="chechboxChangeAM">
                         <view class="th2_0">上午</view>
-                        <checkbox class="th2_1"></checkbox>
-                        <checkbox class="th2_1"></checkbox>
-                        <checkbox class="th2_1"></checkbox>
-                        <checkbox class="th2_1"></checkbox>
-                        <checkbox class="th2_1"></checkbox>
-                        <checkbox class="th2_1"></checkbox>
-                        <checkbox class="th2_2"></checkbox>
+                        <label wx:for="{{timeAM}}" wx:key="index">
+                            <checkbox class="th2_1" value="{{item.value}}"></checkbox>
+                        </label>
                     </checkbox-group>
                 </view>
                 <view class="tr_2">
-                    <checkbox-group>
+                    <checkbox-group bindchange="chechboxChangePM">
                         <view class="th2_0">下午</view>
-                        <checkbox class="th2_1"></checkbox>
-                        <checkbox class="th2_1"></checkbox>
-                        <checkbox class="th2_1"></checkbox>
-                        <checkbox class="th2_1"></checkbox>
-                        <checkbox class="th2_1"></checkbox>
-                        <checkbox class="th2_1"></checkbox>
-                        <checkbox class="th2_2"></checkbox>
+                        <label wx:for="{{timePM}}" wx:key="index">
+                        <checkbox class="th2_1" value="{{item.value}}"></checkbox>
+                        </label>
                     </checkbox-group>
                 </view>
                 <view class="tr_2">
-                    <checkbox-group>
+                    <checkbox-group bindchange="chechboxChangeEvening">
                         <view class="th2_0">晚上</view>
-                        <checkbox class="th2_1"></checkbox>
-                        <checkbox class="th2_1"></checkbox>
-                        <checkbox class="th2_1"></checkbox>
-                        <checkbox class="th2_1"></checkbox>
-                        <checkbox class="th2_1"></checkbox>
-                        <checkbox class="th2_1"></checkbox>
-                        <checkbox class="th2_2"></checkbox>
+                        <label wx:for="{{timeEvening}}" wx:key="index">
+                        <checkbox class="th2_1" value="{{item.value}}"></checkbox>
+                        </label>
                     </checkbox-group>
                 </view>
             </view>