123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520 |
- <template>
- <view style="background-color: #f5f5f5;">
- <uni-forms ref="baseForm" :model="baseFormData" labelWidth="80px" :rules="rules" labelPosition="top">
- <uni-forms-item label="授课科目:" required>
- <uni-data-picker placeholder="选择授课" popup-title="课程大纲-具体课程" v-model="baseFormData.subject[1]" :clearIcon="false" :localdata="courseTree" >
- </uni-data-picker>
- </uni-forms-item>
- <!-- <uni-forms-item v-for="(item, index) in dynamicsLists" :key="item.id" :label="item.label+''+(index+2)+':'" :name="'baseFormData.subject[' + item.id + ']'" >
- <uni-data-picker class="publish-course" placeholder="选择授课" popup-title="课程大纲-具体课程" v-model="baseFormData.subject[item.id]" :clearIcon="false" :localdata="courseTree" />
- </uni-forms-item> -->
- <uni-forms-item label="授课方式:" name="mode" required>
- <uni-data-checkbox v-model="baseFormData.mode" :localdata="modes" />
- </uni-forms-item>
- <uni-forms-item label="授课时间" required>
- </uni-forms-item>
- <view class="tr-container">
- <view class="tr_1">
- <text class="th_0" decode="true">    </text>
- <text class="th_1">周一</text>
- <text class="th_1">周二</text>
- <text class="th_1">周三</text>
- <text class="th_1">周四</text>
- <text class="th_1">周五</text>
- <text class="th_1">周六</text>
- <text class="th_1">周日</text>
- </view>
- <view class="tr_2">
- <checkbox-group @change="chechboxChangeAM">
- <view class="th2_0">上午</view>
- <label v-for="item in timeAM" :key="item.value">
- <checkbox class="th2_1" :value="item.value" :checked="item.checked"></checkbox>
- </label>
- </checkbox-group>
- </view>
- <view class="tr_2">
- <checkbox-group @change="chechboxChangePM">
- <view class="th2_0">下午</view>
- <label v-for="item in timePM" :key="item.value">
- <checkbox class="th2_1" :value="item.value" :checked="item.checked"></checkbox>
- </label>
- </checkbox-group>
- </view>
- <view class="tr_2">
- <checkbox-group @change="chechboxChangeEvening">
- <view class="th2_0">晚上</view>
- <label v-for="item in timeEvening" :key="item.value">
- <checkbox class="th2_1" :value="item.value" :checked="item.checked"></checkbox>
- </label>
- </checkbox-group>
- </view>
- </view>
- <uni-forms-item label="教龄:" name="teachAge" required>
- <uni-number-box v-model="baseFormData.teachAge" :min="1" ></uni-number-box>
- </uni-forms-item>
- <uni-forms-item label="老师位置:" name="location" required>
- <uni-easyinput type="text" v-model="baseFormData.location" @focus="getLocation" maxlength="250" trim="both" />
- </uni-forms-item>
- <uni-forms-item label="成功经验:" name="experience" required>
- <uni-easyinput type="textarea" v-model="baseFormData.experience" maxlength="250" trim="both" />
- </uni-forms-item>
- <uni-forms-item label="自我介绍:" name="introduce" required>
- <uni-easyinput type="textarea" v-model="baseFormData.introduce" maxlength="250" trim="both" />
- </uni-forms-item>
- </uni-forms>
- <view class="button-group">
- <!-- <button type="warn" size="mini" @click="add">新增授课科目</button> -->
- <button type="primary" size="default" @click="submit('baseForm')">发布课程</button>
- </view>
-
- <uni-popup ref="alertDialog" type="dialog">
- <uni-popup-dialog type="info" :confirmText="confirmText" title="温馨提示" :content="authentication" @close="dialogClose" @confirm="dialogConfirm"></uni-popup-dialog>
- </uni-popup>
- </view>
- </template>
- <script>
- import { mapState, mapMutations } from 'vuex'
-
- export default {
- computed: {
- ...mapState('m_user', ['authentication'])
- },
- data() {
- return {
- introduce: '',
- courseAM: [],
- coursePM: [],
- courseEV: [],
- confirmText: '',
- // 表单数据
- baseFormData: {
- subject: {
- 1: '1',
- 2: '1',
- 3: '1',
- 4: '1'
- },
- mode: [],
- teachTime: [],
- teachAge: 1,
- location: '',
- experience: '',
- introduce: '',
- subjectBig: ''
- },
- dynamicsLists: [],
- count: 1, // 选择课程计数
- // 选择课程
- courseTree: [{
- text: '一年级',
- value: '1-0',
- children: [{
- text: '1.1班',
- value: '1'
- }
- ]
- }
- ],
- // 单选授课方式数据源
- modes: [{
- text: '老师上门',
- value: '老师上门'
- }, {
- text: '学员上门',
- value: '学员上门'
- }, {
- text: '线上辅导',
- value: '线上辅导'
- }],
- // 上课时间
- // 上午
- timeAM: [{
- value: 'A1',
- name: '1',
- checked: false
-
- },
- {
- name: '2',
- value: 'A2',
- checked: false
- },
- {
- name: '3',
- value: 'A3',
- checked: false
- },
- {
- name: '4',
- value: 'A4',
- checked: false
- },
- {
- name: '5',
- value: 'A5',
- checked: false
- },
- {
- name: '6',
- value: 'A6',
- checked: false
- },
- {
- name: '7',
- value: 'A7',
- checked: false
- }
- ],
- // 下午
- timePM: [{
- value: 'P1',
- name: '1',
- checked: false
- },
- {
- name: '2',
- value: 'P2',
- checked: false
- },
- {
- name: '3',
- value: 'P3',
- checked: false
- },
- {
- name: '4',
- value: 'P4',
- checked: false
- },
- {
- name: '5',
- value: 'P5',
- checked: false
- },
- {
- name: '6',
- value: 'P6',
- checked: false
- },
- {
- name: '7',
- value: 'P7',
- checked: false
- }
- ],
- // 晚上
- timeEvening: [{
- name: '1',
- value: 'E1',
- checked: false
- },
- {
- name: '2',
- value: 'E2',
- checked: false
- },
- {
- name: '3',
- value: 'E3',
- checked: false
- },
- {
- name: '4',
- value: 'E4',
- checked: false
- },
- {
- name: '5',
- value: 'E5',
- checked: false
- },
- {
- name: '6',
- value: 'E6',
- checked: false
- },
- {
- name: '7',
- value: 'E7',
- checked: false
- }
- ],
- rules: {
- subject: {
- rules: [{
- required: true,
- errorMessage: '授课科目不能为空',
- }]
- },
- mode: {
- rules: [{
- required: true,
- errorMessage: '授课方式不能为空',
- }]
- },
- location: {
- rules: [{
- required: true,
- errorMessage: '地理位置不能为空',
- }]
- },
- introduce: {
- rules: [{
- required: true,
- errorMessage: '自我介绍不能为空',
- }]
- },
- experience: {
- rules: [{
- required: true,
- errorMessage: '成功经验不能为空',
- }]
- }
- }
- };
- },
- created() {
- this.getPriceAndTree(),
- this.getPersonAuthorize()
- },
- methods: {
- ...mapMutations('m_user', ['updateAuthentication']),
- // 获取认证信息
- async getPersonAuthorize() {
- const { data: result } = await uni.$http.get('/education/teacher-certifications/findVerifyStatus')
- // console.log(result)
- const auth = result.message
- this.updateAuthentication(auth)
- if (auth === '审核中') {
- this.confirmText = '请耐心等待'
- this.$refs.alertDialog.open()
- } else if (auth !== '已通过') {
- this.confirmText = '去认证'
- this.$refs.alertDialog.open()
- }
- },
- // 查询未成交的课程
- // async queryNoDealCourse() {
- // const {
- // data: result1
- // } = await uni.$http.get('/education/teacher-courses/queryPersonNoDeal')
- // this.countNoDeal = result1.data.count
- // },
-
- // 取消按钮
- dialogClose() {
- this.$refs.alertDialog.close()
- uni.navigateBack()
- },
- // 确定按钮
- dialogConfirm() {
- this.$refs.alertDialog.close()
- if (this.authentication === '审核中') {
- uni.navigateBack()
- } else if (this.authentication !== '已通过'){
- uni.navigateTo({
- url: '/subpkg/add_teacher_authorize/add_teacher_authorize'
- })
- }
- },
- // 获取老师地理位置
- getLocation() {
- // wx.choosePoi({
- // success: res => {
- // console.log(res)
- // if (res.type === 0) {
- // // 不显示位置
- // this.baseFormData.location = ''
- // } else if (res.type === 2) {
- // // 详细位置
- // this.baseFormData.location = res.address
- // } else if (res.type === 1) {
- // // 概要位置
- // this.baseFormData.location = res.city
- // }
-
- // }
- // })
- wx.chooseLocation({
- success: res => {
- if (res.errMsg === 'chooseLocation:ok') {
- this.baseFormData.location = res.address + res.name
- this.baseFormData.locationAl = res.latitude + ',' + res.longitude
- }
- }
- })
- },
- // add() {
- // this.count++
- // if (this.dynamicsLists.length > 2) return uni.$showMsg('新增授权科目过多!')
- // this.dynamicsLists.push({
- // label: '授课科目',
- // id: this.count
- // })
- // },
- // del(id) {
- // let index = this.dynamicsLists.findIndex(v => v.id === id)
- // this.dynamicsLists.splice(index, 1)
- // },
-
- // 树形结构的课程和价格表
- async getPriceAndTree() {
- const {
- data: result
- } = await uni.$http.get('/education/course-price/treeAndPrice')
- this.courseTree = result.data.treeCourse
- },
- // 上午复选框
- chechboxChangeAM(e) {
- this.courseAM.push(e.detail.value)
- },
- // 下午复选框
- chechboxChangePM(e) {
- this.coursePM.push(e.detail.value)
- },
- // 晚上复选框
- chechboxChangeEvening(e) {
- this.courseEV.push(e.detail.value)
- },
- submit(ref) {
- this.baseFormData.teachTime = []
- if (this.courseAM.length === 0 && this.coursePM.length === 0 && this.courseEV.length === 0 ) return uni.$showMsg('请选择授课时间!')
- if (this.courseAM[this.courseAM.length - 1] == '' && this.coursePM.length === 0 && this.courseEV.length === 0 ) return uni.$showMsg('请选择授课时间!')
- if (this.courseAM.length === 0 && this.coursePM[this.coursePM.length - 1] == '' && this.courseEV.length === 0 ) return uni.$showMsg('请选择授课时间!')
- if (this.courseAM.length === 0 && this.coursePM.length === 0 && this.courseEV[this.courseEV.length - 1] == '' ) return uni.$showMsg('请选择授课时间!')
- if (this.courseAM[this.courseAM.length - 1] == '' && this.coursePM[this.coursePM.length - 1] == '' && this.courseEV.length === 0 ) return uni.$showMsg('请选择授课时间!')
- if (this.courseAM[this.courseAM.length - 1] == '' && this.coursePM.length === 0 && this.courseEV[this.courseEV.length - 1] == '' ) return uni.$showMsg('请选择授课时间!')
- if (this.courseAM.length === 0 && this.coursePM[this.coursePM.length - 1] == '' && this.courseEV[this.courseEV.length - 1] == '' ) return uni.$showMsg('请选择授课时间!')
- if (this.courseAM[this.courseAM.length - 1] == '' && this.coursePM[this.coursePM.length - 1] == '' && this.courseEV[this.courseEV.length - 1] == '' ) return uni.$showMsg('请选择授课时间!')
-
- if (this.courseAM.length > 0) {
- this.baseFormData.teachTime.push(this.courseAM[this.courseAM.length - 1])
- }
- if (this.coursePM.length > 0) {
- this.baseFormData.teachTime.push(this.coursePM[this.coursePM.length - 1])
- }
- if (this.courseEV.length > 0) {
- this.baseFormData.teachTime.push(this.courseEV[this.courseEV.length - 1])
- }
- // 上课时间
- this.baseFormData.teachTime = this.baseFormData.teachTime.join()
- // 末尾为,
- if (this.baseFormData.teachTime.slice(-1) === ',') {
- this.baseFormData.teachTime = this.baseFormData.teachTime.substring(0, this.baseFormData.teachTime.length - 1)
- }
- // 开始为,
- if (this.baseFormData.teachTime.slice(0,1) === ',') {
- let temp = this.baseFormData.teachTime.substring(1, this.baseFormData.teachTime.length )
- this.baseFormData.teachTime = temp
- }
-
- if (this.baseFormData.subject[1] === '1') {
- return uni.$showMsg('请选择授课科目')
- }
- // for (let i = 1; i <= this.dynamicsLists.length + 1; i++) {
- // if (this.baseFormData.subject[i] === '1') {
- // return uni.$showMsg('请选择授课科目' + i)
- // }
- // }
-
- // 授课科目
- for (let x = 0; x < this.courseTree.length; x++) {
- for (let y = 0; y < this.courseTree[x].children.length; y++) {
- if (this.courseTree[x].children[y].value === this.baseFormData.subject[1]) {
- this.baseFormData.subjectBig = this.courseTree[x].value + '/' + this.baseFormData.subject[1]
- }
- }
- }
-
- if (this.baseFormData.location === '') return uni.$showMsg('请输入位置!')
-
- this.$refs[ref].validate().then(res => {
- console.log(this.baseFormData)
- uni.request({
- url: 'http://192.168.0.207:8222/education/teacher-courses/publishCourse',
- data: JSON.stringify(this.baseFormData),
- header: {
- token: uni.getStorageSync('token')
- },
- method: 'POST',
- success: res => {
- // this.isLoading = false
- console.log(res)
- uni.$showMsg(res.data.message)
- setTimeout(() => {
- uni.navigateBack()
- }, 1000)
- }
- })
- }).catch(err => {
- console.log('err', err);
- })
- }
- }
- }
- </script>
- <style lang="scss" scoped>
- // .button-group {
- // margin-top: 15px;
- // display: flex;
- // justify-content: space-around;
- // }
- .tr-container{
- display: flex;
- position: relative;
- width: 96%;
- flex-direction: column;
- font-size: 26rpx;
- /* border: 1rpx solid gray; */
- margin: -10px 20rpx;
- margin-bottom: 20px;
- }
-
- .tr_1 {
- display: flex;
- position: relative;
- height: 80rpx;
- line-height: 80rpx;
- }
- .tr_2{
- display: block;
- height: 80rpx;
- line-height: 80rpx;
- }
-
- .th_0,
- .th_1,
- .th_2,
- .th2_0,
- .th2_1,
- .th2_2{
- width: 12%;
- height: 80rpx;
- line-height: 80rpx;
- border-right: 1rpx solid gray;
- border-bottom: 1rpx solid gray;
- text-align: center;
- }
-
- .th_0,
- .th_1,
- .th_2{
- border-top: 1rpx solid gray;
- }
-
- .th_0,
- .th2_0{
- border-left: 1rpx solid gray;
- }
-
- .th2_0{
- float: left;
- width: 12%;
- height: 80rpx;
- line-height: 80rpx;
- text-align: center;
- /* background-color: greenyellow; */
- }
- </style>
|