123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550 |
- <template>
- <view>
- <uni-forms ref="baseForm" :model="baseFormData" labelWidth="75px" :rules="rules" validateTrigger="bind">
- <uni-forms-item label="姓名" name="name" required>
- <uni-easyinput v-model="baseFormData.name" placeholder="请输入姓名" maxlength="6" trim="both" />
- </uni-forms-item>
- <uni-forms-item label="手机号" name="phone" required>
- <button open-type="getPhoneNumber" type="primary" size="mini"
- @getphonenumber="getPhoneNumber">获取手机号</button>
- </uni-forms-item>
- <uni-forms-item label="微信号" name="wxid" required>
- <uni-easyinput v-model="baseFormData.wxid" placeholder="微信号(不便接听电话时微信沟通)" maxlength="25"
- trim="both" />
- </uni-forms-item>
- <uni-forms-item label="地址:" name="locationStr" required>
- <uni-easyinput type="text" v-model="baseFormData.locationStr" @focus="getLocation" maxlength="250" trim="both" />
- </uni-forms-item>
- <uni-forms-item label="选择课程" required>
- <uni-data-picker placeholder="请选择课程" popup-title="课程大纲-具体课程" v-model="baseFormData.subjectSmall" :clearIcon="false"
- :localdata="courseTree" />
- </uni-forms-item>
- <uni-forms-item label="辅导方式" required>
- <uni-data-checkbox v-model="baseFormData.mode" :localdata="modes" />
- </uni-forms-item>
- <uni-forms-item label="学员性别" required>
- <uni-data-checkbox v-model="baseFormData.sex" :localdata="sexs" />
- </uni-forms-item>
- <uni-forms-item label="课时费" name="salary" required :errorMessage="errorPrice">
- <uni-easyinput v-model="baseFormData.salary" type="number" placeholder="请输入课时金额" />
- </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"></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"></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"></checkbox>
- </label>
- </checkbox-group>
- </view>
- </view>
- <uni-forms-item label="期望目标" name="goal">
- <uni-easyinput type="textarea" v-model="baseFormData.goal" maxlength="100" trim="both" />
- </uni-forms-item>
- <uni-forms-item label="教员身份" required>
- <uni-data-checkbox v-model="baseFormData.teacherType" :localdata="identifies" />
- </uni-forms-item>
- <uni-forms-item label="教员学历" required>
- <uni-data-select v-model="baseFormData.teacherEdu" :localdata="educations" />
- </uni-forms-item>
- <uni-forms-item label="教员性别" required>
- <uni-data-checkbox v-model="baseFormData.teacherGender" :localdata="sexsTeacher" />
- </uni-forms-item>
- <uni-forms-item label="教员照片" required>
- <uni-data-checkbox v-model="baseFormData.teacherProfilePhoto" :localdata="hasPhotoes" />
- </uni-forms-item>
- <uni-forms-item label="对教员要求" name="teacherDemanded">
- <uni-easyinput type="textarea" v-model="baseFormData.teacherDemanded" maxlength="100" trim="both" />
- </uni-forms-item>
- </uni-forms>
- <view>
- <button type="primary" @click="submit">提交需求</button>
- </view>
- </view>
- </template>
- <script>
- import { mapState } from 'vuex'
-
- export default {
- computed: {
- ...mapState('m_user', ['userinfo'])
- },
- data() {
- return {
- loading: false,
- errorPrice: '',
- courseAM: [],
- coursePM: [],
- courseEV: [],
- // 表单数据
- baseFormData: {
- name: '',
- phone: '',
- wxid: '',
- subjectSmall: '1-1',
- mode: '教员上门',
- sex: '男',
- salary: 0,
- courseWeekday: [],
- goal: '',
- teacherType: '专职教员',
- teacherEdu: '',
- teacherGender: '男',
- teacherProfilePhoto: '有',
- teacherDemanded: '',
- locationStr: '',
- locationAl: ''
- },
- coursePrice: [],
- // 选择课程
- courseTree: [{
- text: '一年级',
- value: '1-0',
- children: [{
- text: '1.1班',
- value: '1-1'
- }
- ]
- }
- ],
- // 单选辅导方式数据源
- modes: [{
- text: '教员上门',
- value: '教员上门'
- }, {
- text: '学员上门',
- value: '学员上门'
- }, {
- text: '线上辅导',
- value: '线上辅导'
- }],
- // 单选性别数据源
- sexs: [{
- text: '男',
- value: '男'
- }, {
- text: '女',
- value: '女'
- }],
- // 单选老师身份
- identifies: [{
- text: '专职教员',
- value: '专职教员'
- }, {
- text: '学生教员',
- value: '学生教员'
- }],
- educations: [{
- value: '专科在读',
- text: '专科在读及以上'
- }, {
- value: '专科毕业',
- text: '专科毕业及以上'
- }, {
- value: '本科在读',
- text: '本科在读及以上'
- }, {
- value: '本科毕业',
- text: '本科毕业及以上'
- }, {
- value: '硕士在读',
- text: '硕士在读及以上'
- }, {
- value: '硕士毕业',
- text: '硕士毕业及以上'
- }, {
- value: '博士在读',
- text: '博士在读及以上'
- }, {
- value: '博士毕业',
- text: '博士毕业及以上'
- }, {
- value: '不限',
- text: '不限'
- }],
- // 单选老师性别
- sexsTeacher: [{
- text: '男',
- value: '男'
- }, {
- text: '女',
- value: '女'
- }],
- // 单选老师有无照片
- hasPhotoes: [{
- text: '有',
- value: '有'
- }, {
- text: '无',
- value: '无'
- }],
- // 上课时间
- // 上午
- timeAM: [{
- value: 'A1',
- name: '1'
-
- },
- {
- 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: [{
- value: 'P1',
- name: '1'
-
- },
- {
- 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'
- }
- ],
- rules: {
- name: {
- rules: [{
- required: true,
- errorMessage: '请输入姓名',
- }]
- },
- wxid: {
- rules: [{
- required: true,
- errorMessage: '请输入微信号',
- }, {
- errorMessage: '请输入正确的微信号',
- pattern: '^[a-zA-Z][a-zA-Z\\d_-]{5,19}$',
- }]
- },
- salary: {
- rules: [{
- required: true,
- errorMessage: '请输入课时费'
- }]
- },
- }
- };
- },
- created() {
- this.getPriceAndTree()
- },
- methods: {
- // 手机号
- // 手机号
- async getPhoneNumber(e) {
- // console.log(e.detail.code)
- if (e.detail.code === undefined) return uni.$showMsg('获取手机号失败!')
- const query = {
- code: e.detail.code
- }
- const {
- data: result
- } = await uni.$http.get('/ucenter/mini-program-openid-uid/wxGetPhone', query)
- if (result.code === 20000) {
- this.baseFormData.phone = result.data.phone
- return uni.$showMsg('获取手机成功!')
- }
- },
- // 树形结构的课程和价格表
- async getPriceAndTree() {
- const {
- data: result
- } = await uni.$http.get('/education/course-price/treeAndPrice')
- // console.log(result)
- this.courseTree = result.data.treeCourse
- this.coursePrice = result.data.coursePrice
- },
- // 上午复选框
- chechboxChangeAM(e) {
- this.courseAM.push(e.detail.value)
- },
- // 下午复选框
- chechboxChangePM(e) {
- this.coursePM.push(e.detail.value)
- },
- // 晚上复选框
- chechboxChangeEvening(e) {
- this.courseEV.push(e.detail.value)
- },
- // 获取老师地理位置
- getLocation() {
- // wx.choosePoi({
- // success: res => {
- // console.log(res)
- // if (res.type === 0) {
- // // 不显示位置
- // this.baseFormData.locationStr = ''
- // } else if (res.type === 2) {
- // // 详细位置
- // this.baseFormData.locationStr = res.address
- // } else if (res.type === 1) {
- // // 概要位置
- // this.baseFormData.locationStr = res.city
- // }
-
- // }
- // })
- wx.chooseLocation({
- success: res => {
- if (res.errMsg === 'chooseLocation:ok') {
- this.baseFormData.locationStr = res.address + res.name
- this.baseFormData.locationAl = res.latitude + ',' + res.longitude
- }
- }
- })
- },
- // 提交
- submit() {
- if (this.isLoading) {
- return uni.$showMsg('操作过快,请耐心等待…')
- }
- this.isLoading = true
- this.baseFormData.courseWeekday = []
- this.$refs.baseForm.validate().then(res => {
- if (this.baseFormData.phone === '') return uni.$showMsg('手机号未获取!')
- if (this.baseFormData.locationStr === '') return uni.$showMsg('请选择地址!')
- if (this.baseFormData.subjectSmall === '1-1' || this.baseFormData.subjectSmall === '') return uni.$showMsg('请选择课程')
- 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.courseWeekday.push(this.courseAM[this.courseAM.length - 1])
- }
- if (this.coursePM.length > 0) {
- this.baseFormData.courseWeekday.push(this.coursePM[this.coursePM.length - 1])
- }
- if (this.courseEV.length > 0) {
- this.baseFormData.courseWeekday.push(this.courseEV[this.courseEV.length - 1])
- }
- // 上课时间
- this.baseFormData.courseWeekday = this.baseFormData.courseWeekday.join()
- // console.log(this.baseFormData.courseWeekday)
- // 教员学历
- if (this.baseFormData.teacherEdu === '') return uni.$showMsg('请选择教员学历!')
-
- // 课时费
- let city = this.userinfo.city
- for(let i = 0; i < this.coursePrice.length; i++) {
- if(this.coursePrice[i].courseName === this.baseFormData.subjectSmall) {
- // console.log(this.coursePrice[i].priceMapping.stu_price_2_l)
- // 二线城市
- if (city != '北京' || city != '上海' || city != '广州' || city != '深圳') {
- // 学生
- if (this.baseFormData.teacherType === '学生教员') {
- if (this.coursePrice[i].priceMapping.stu_price_2_l > this.baseFormData.salary || this.baseFormData.salary > this.coursePrice[i].priceMapping.stu_price_2_h) {
- this.errorPrice = '价格在' + this.coursePrice[i].priceMapping.stu_price_2_l + '~' + this.coursePrice[i].priceMapping.stu_price_2_h + '之间'
- return uni.$showMsg('请合理选择课时费')
- }
- } else {
- if (this.coursePrice[i].priceMapping.fulltime_price_2_l > this.baseFormData.salary || this.baseFormData.salary > this.coursePrice[i].priceMapping.fulltime_price_2_h) {
- this.errorPrice = '价格在' + this.coursePrice[i].priceMapping.fulltime_price_2_l + '~' + this.coursePrice[i].priceMapping.fulltime_price_2_h + '之间'
- return uni.$showMsg('请合理选择课时费')
- }
- }
- } else {
- // 学生
- if (this.baseFormData.teacherType === '学生教员') {
- if (this.coursePrice[i].priceMapping.stu_price_1_l > this.baseFormData.salary || this.baseFormData.salary > this.coursePrice[i].priceMapping.stu_price_1_h) {
- this.errorPrice = '价格在' + this.coursePrice[i].priceMapping.stu_price_1_l + '~' + this.coursePrice[i].priceMapping.stu_price_1_h + '之间'
- return uni.$showMsg('请合理选择课时费')
- }
- } else {
- if (this.coursePrice[i].priceMapping.fulltime_price_1_l > this.baseFormData.salary || this.baseFormData.salary > this.coursePrice[i].priceMapping.fulltime_price_1_h) {
- this.errorPrice = '价格在' + this.coursePrice[i].priceMapping.fulltime_price_1_l + '~' + this.coursePrice[i].priceMapping.fulltime_price_1_h + '之间'
- return uni.$showMsg('请合理选择课时费')
- }
- }
- }
- }
- }
- console.log(this.baseFormData)
-
- uni.request({
- url: 'http://192.168.0.207:8222/education/student-requirements/publishRequirements',
- data: this.baseFormData,
- header: {
- token: uni.getStorageSync('token')
- },
- method: 'POST',
- success: res => {
- uni.$showMsg(res.data.message)
- setTimeout(() => {
- uni.navigateBack()
- }, 1000)
- }
- })
-
- }).catch(err => {
- this.isLoading = false
- // console.log(err)
- })
- this.isLoading = false
- }
- }
- }
- </script>
- <style lang="scss" scoped>
- .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>
|