123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405 |
- // pages/coursePublish/coursePublish.js
- Page({
- /**
- * 页面的初始数据
- */
- data: {
- courseOption: '', //课程类别
- showCourseOptions: false, //课程类别选项是否展示
- courseOptionIndex:'', //选中课程的索引
- teachPosition: '', //辅导方式
- chosedTeachPosition: false, //辅导方式选项是否展示
- teachTimeAM: [], //上午授课时间
- teachTimePM: [], //下午授课时间
- teachTimeEvening: [], //晚上授课时间
- teachTime: [], //合并后的授课时间
- successExperience: '', //成功经验
- selfIntroduction: '', //自我介绍
- // 课程类别
- courseOptions: [{
- name: "小学",
- choesd: false
- },
- {
- name: "初中",
- choesd: false
- },
- {
- name: "高中",
- choesd: false
- },
- {
- name: "大学",
- choesd: false
- },
- {
- name: "音乐",
- choesd: false
- },
- {
- name: "舞蹈",
- choesd: false
- },
- {
- name: "语言",
- choesd: false
- },
- {
- name: "体育",
- choesd: false
- },
- {
- name: "美术",
- choesd: false
- },
- {
- name: "书法",
- choesd: false
- },
- {
- name: "少儿编程",
- choesd: false
- },
- {
- name: "计算机",
- choesd: false
- },
- {
- name: "其他",
- choesd: false
- }
- ],
- // 辅导方式
- teachPositions: [{
- opType: '老师上门',
- choesd: false
- },
- {
- opType: '学员上门',
- choesd: false
- }, {
- opType: '线上辅导',
- choesd: false
- }, {
- opType: '老师住家',
- choesd: false
- },
- {
- opType: '学员住家',
- 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'
- }
- ]
- },
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad(options) {
- },
- // 选择课程类别
- // 打开课程类别(大类)选项区
- toChooseCourseOptions() {
- this.setData({
- showCourseOptions: true
- })
- },
- // 定义退出下拉选区的方法
- hiddenCourseOptions() {
- this.setData({
- showCourseOptions: false
- })
- },
- // 从下拉区选择课程类别内容
- onChooseCourseOptions(e) {
- let index = e.currentTarget.dataset.index
- let courseOptions = this.data.courseOptions
- for (let i = 0; i < courseOptions.length; i++) {
- if (i == index) {
- courseOptions[i].chosed = !courseOptions[i].chosed
- } else {
- courseOptions[i].chosed = false
- }
- }
- this.setData({
- courseOptions
- })
- },
- // 课程类别(大类)确定按钮的点击事件
- confirmCourseOptions() {
- let courseOptions = this.data.courseOptions
- let index
- for (let i = 0; i < courseOptions.length; i++) {
- if (courseOptions[i].chosed) {
- index = i
- }
- }
- let courseOption = courseOptions[index]?.name || ''
- let courseOptionIndex = index
- this.setData({
- courseOption,
- courseOptionIndex
- })
- this.hiddenCourseOptions()
- },
- // 辅导方式
- // 打开辅导方式选项区
- toChosedTeachPosition() {
- this.setData({
- chosedTeachPosition: true
- })
- },
- // 关闭辅导方式选项区的方法
- hiddenTeachPosition() {
- this.setData({
- chosedTeachPosition: false
- })
- },
- // 从下拉选区选择辅导方式内容
- onTeachPosition(e) {
- let index = e.currentTarget.dataset.index
- let teachPositions = this.data.teachPositions
- for (let i = 0; i < teachPositions.length; i++) {
- if (i == index) {
- teachPositions[i].chosed = !teachPositions[i].chosed
- } else {
- teachPositions[i].chosed = false
- }
- }
- this.setData({
- teachPositions
- })
- },
- // 辅导方式确定按钮点击事件
- confirmTeachPosition() {
- let teachPositions = this.data.teachPositions
- let index
- for (let i = 0; i < teachPositions.length; i++) {
- if (teachPositions[i].chosed) {
- index = i
- }
- }
- let teachPosition = teachPositions[index]?.opType || ''
- this.setData({
- teachPosition
- })
- this.hiddenTeachPosition()
- },
- // 选择授课时间
- // 上午
- chechboxChangeAM(e) {
- // console.log(e)
- let teachTimeAM = this.data.teachTimeAM
- teachTimeAM = e.detail.value
- this.setData({
- teachTimeAM
- })
- // console.log(teachTimeAM)
- },
- // 下午
- chechboxChangePM(e) {
- // console.log(e)
- let teachTimePM = this.data.teachTimePM
- teachTimePM = e.detail.value
- this.setData({
- teachTimePM
- })
- // console.log(teachTimePM)
- },
- // 晚上
- chechboxChangeEvening(e) {
- // console.log(e)
- let teachTimeEvening = this.data.teachTimeEvening
- teachTimeEvening = e.detail.value
- this.setData({
- teachTimeEvening
- })
- // console.log(teachTimeEvening)
- },
- // 合并授课时间的函数
- joinTime() {
- let teachTimeAM = this.data.teachTimeAM
- let teachTimePM = this.data.teachTimePM
- let teachTimeEvening = this.data.teachTimeEvening
- let teachTime = this.data.teachTime
- teachTime = teachTimeAM.concat(teachTimePM, teachTimeEvening)
- this.setData({
- teachTime
- })
- // console.log("授课时间为:" + teachTime)
- },
- // 获取成功经验
- getSuccess(e) {
- console.log(e.detail.value)
- this.setData({
- successExperience: e.detail.value
- })
- },
- // 获取自我介绍
- getSelfIntroduction(e) {
- this.setData({
- selfIntroduction: e.detail.value
- })
- },
- // 发布课程按钮的点击事件
- toPublisCourse() {
- this.joinTime()
- wx.setStorageSync('course', {
- teachPosition: this.data.teachPosition,
- teachTime: this.data.teachTime,
- successExperience: this.data.successExperience,
- selfIntroduction: this.data.selfIntroduction
- })
- },
- /**
- * 生命周期函数--监听页面初次渲染完成
- */
- onReady() {
- },
- /**
- * 生命周期函数--监听页面显示
- */
- onShow() {
- },
- /**
- * 生命周期函数--监听页面隐藏
- */
- onHide() {
- },
- /**
- * 生命周期函数--监听页面卸载
- */
- onUnload() {
- },
- /**
- * 页面相关事件处理函数--监听用户下拉动作
- */
- onPullDownRefresh() {
- },
- /**
- * 页面上拉触底事件的处理函数
- */
- onReachBottom() {
- },
- /**
- * 用户点击右上角分享
- */
- onShareAppMessage() {
- }
- })
|