add_stu_require.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550
  1. <template>
  2. <view>
  3. <uni-forms ref="baseForm" :model="baseFormData" labelWidth="75px" :rules="rules" validateTrigger="bind">
  4. <uni-forms-item label="姓名" name="name" required>
  5. <uni-easyinput v-model="baseFormData.name" placeholder="请输入姓名" maxlength="6" trim="both" />
  6. </uni-forms-item>
  7. <uni-forms-item label="手机号" name="phone" required>
  8. <button open-type="getPhoneNumber" type="primary" size="mini"
  9. @getphonenumber="getPhoneNumber">获取手机号</button>
  10. </uni-forms-item>
  11. <uni-forms-item label="微信号" name="wxid" required>
  12. <uni-easyinput v-model="baseFormData.wxid" placeholder="微信号(不便接听电话时微信沟通)" maxlength="25"
  13. trim="both" />
  14. </uni-forms-item>
  15. <uni-forms-item label="地址:" name="locationStr" required>
  16. <uni-easyinput type="text" v-model="baseFormData.locationStr" @focus="getLocation" maxlength="250" trim="both" />
  17. </uni-forms-item>
  18. <uni-forms-item label="选择课程" required>
  19. <uni-data-picker placeholder="请选择课程" popup-title="课程大纲-具体课程" v-model="baseFormData.subjectSmall" :clearIcon="false"
  20. :localdata="courseTree" />
  21. </uni-forms-item>
  22. <uni-forms-item label="辅导方式" required>
  23. <uni-data-checkbox v-model="baseFormData.mode" :localdata="modes" />
  24. </uni-forms-item>
  25. <uni-forms-item label="学员性别" required>
  26. <uni-data-checkbox v-model="baseFormData.sex" :localdata="sexs" />
  27. </uni-forms-item>
  28. <uni-forms-item label="课时费" name="salary" required :errorMessage="errorPrice">
  29. <uni-easyinput v-model="baseFormData.salary" type="number" placeholder="请输入课时金额" />
  30. </uni-forms-item>
  31. <uni-forms-item label="上课时间" required>
  32. </uni-forms-item>
  33. <view class="tr-container">
  34. <view class="tr_1">
  35. <text class="th_0" decode="true">&ensp;&ensp;&ensp;&ensp;</text>
  36. <text class="th_1">周一</text>
  37. <text class="th_1">周二</text>
  38. <text class="th_1">周三</text>
  39. <text class="th_1">周四</text>
  40. <text class="th_1">周五</text>
  41. <text class="th_1">周六</text>
  42. <text class="th_1">周日</text>
  43. </view>
  44. <view class="tr_2">
  45. <checkbox-group @change="chechboxChangeAM">
  46. <view class="th2_0">上午</view>
  47. <label v-for="item in timeAM" :key="item.value">
  48. <checkbox class="th2_1" :value="item.value"></checkbox>
  49. </label>
  50. </checkbox-group>
  51. </view>
  52. <view class="tr_2">
  53. <checkbox-group @change="chechboxChangePM">
  54. <view class="th2_0">下午</view>
  55. <label v-for="item in timePM" :key="item.value">
  56. <checkbox class="th2_1" :value="item.value"></checkbox>
  57. </label>
  58. </checkbox-group>
  59. </view>
  60. <view class="tr_2">
  61. <checkbox-group @change="chechboxChangeEvening">
  62. <view class="th2_0">晚上</view>
  63. <label v-for="item in timeEvening" :key="item.value">
  64. <checkbox class="th2_1" :value="item.value"></checkbox>
  65. </label>
  66. </checkbox-group>
  67. </view>
  68. </view>
  69. <uni-forms-item label="期望目标" name="goal">
  70. <uni-easyinput type="textarea" v-model="baseFormData.goal" maxlength="100" trim="both" />
  71. </uni-forms-item>
  72. <uni-forms-item label="教员身份" required>
  73. <uni-data-checkbox v-model="baseFormData.teacherType" :localdata="identifies" />
  74. </uni-forms-item>
  75. <uni-forms-item label="教员学历" required>
  76. <uni-data-select v-model="baseFormData.teacherEdu" :localdata="educations" />
  77. </uni-forms-item>
  78. <uni-forms-item label="教员性别" required>
  79. <uni-data-checkbox v-model="baseFormData.teacherGender" :localdata="sexsTeacher" />
  80. </uni-forms-item>
  81. <uni-forms-item label="教员照片" required>
  82. <uni-data-checkbox v-model="baseFormData.teacherProfilePhoto" :localdata="hasPhotoes" />
  83. </uni-forms-item>
  84. <uni-forms-item label="对教员要求" name="teacherDemanded">
  85. <uni-easyinput type="textarea" v-model="baseFormData.teacherDemanded" maxlength="100" trim="both" />
  86. </uni-forms-item>
  87. </uni-forms>
  88. <view>
  89. <button type="primary" @click="submit">提交需求</button>
  90. </view>
  91. </view>
  92. </template>
  93. <script>
  94. import { mapState } from 'vuex'
  95. export default {
  96. computed: {
  97. ...mapState('m_user', ['userinfo'])
  98. },
  99. data() {
  100. return {
  101. loading: false,
  102. errorPrice: '',
  103. courseAM: [],
  104. coursePM: [],
  105. courseEV: [],
  106. // 表单数据
  107. baseFormData: {
  108. name: '',
  109. phone: '',
  110. wxid: '',
  111. subjectSmall: '1-1',
  112. mode: '教员上门',
  113. sex: '男',
  114. salary: 0,
  115. courseWeekday: [],
  116. goal: '',
  117. teacherType: '专职教员',
  118. teacherEdu: '',
  119. teacherGender: '男',
  120. teacherProfilePhoto: '有',
  121. teacherDemanded: '',
  122. locationStr: '',
  123. locationAl: ''
  124. },
  125. coursePrice: [],
  126. // 选择课程
  127. courseTree: [{
  128. text: '一年级',
  129. value: '1-0',
  130. children: [{
  131. text: '1.1班',
  132. value: '1-1'
  133. }
  134. ]
  135. }
  136. ],
  137. // 单选辅导方式数据源
  138. modes: [{
  139. text: '教员上门',
  140. value: '教员上门'
  141. }, {
  142. text: '学员上门',
  143. value: '学员上门'
  144. }, {
  145. text: '线上辅导',
  146. value: '线上辅导'
  147. }],
  148. // 单选性别数据源
  149. sexs: [{
  150. text: '男',
  151. value: '男'
  152. }, {
  153. text: '女',
  154. value: '女'
  155. }],
  156. // 单选老师身份
  157. identifies: [{
  158. text: '专职教员',
  159. value: '专职教员'
  160. }, {
  161. text: '学生教员',
  162. value: '学生教员'
  163. }],
  164. educations: [{
  165. value: '专科在读',
  166. text: '专科在读及以上'
  167. }, {
  168. value: '专科毕业',
  169. text: '专科毕业及以上'
  170. }, {
  171. value: '本科在读',
  172. text: '本科在读及以上'
  173. }, {
  174. value: '本科毕业',
  175. text: '本科毕业及以上'
  176. }, {
  177. value: '硕士在读',
  178. text: '硕士在读及以上'
  179. }, {
  180. value: '硕士毕业',
  181. text: '硕士毕业及以上'
  182. }, {
  183. value: '博士在读',
  184. text: '博士在读及以上'
  185. }, {
  186. value: '博士毕业',
  187. text: '博士毕业及以上'
  188. }, {
  189. value: '不限',
  190. text: '不限'
  191. }],
  192. // 单选老师性别
  193. sexsTeacher: [{
  194. text: '男',
  195. value: '男'
  196. }, {
  197. text: '女',
  198. value: '女'
  199. }],
  200. // 单选老师有无照片
  201. hasPhotoes: [{
  202. text: '有',
  203. value: '有'
  204. }, {
  205. text: '无',
  206. value: '无'
  207. }],
  208. // 上课时间
  209. // 上午
  210. timeAM: [{
  211. value: 'A1',
  212. name: '1'
  213. },
  214. {
  215. name: '2',
  216. value: 'A2'
  217. },
  218. {
  219. name: '3',
  220. value: 'A3'
  221. },
  222. {
  223. name: '4',
  224. value: 'A4'
  225. },
  226. {
  227. name: '5',
  228. value: 'A5'
  229. },
  230. {
  231. name: '6',
  232. value: 'A6'
  233. },
  234. {
  235. name: '7',
  236. value: 'A7'
  237. }
  238. ],
  239. // 下午
  240. timePM: [{
  241. value: 'P1',
  242. name: '1'
  243. },
  244. {
  245. name: '2',
  246. value: 'P2'
  247. },
  248. {
  249. name: '3',
  250. value: 'P3'
  251. },
  252. {
  253. name: '4',
  254. value: 'P4'
  255. },
  256. {
  257. name: '5',
  258. value: 'P5'
  259. },
  260. {
  261. name: '6',
  262. value: 'P6'
  263. },
  264. {
  265. name: '7',
  266. value: 'P7'
  267. }
  268. ],
  269. // 晚上
  270. timeEvening: [{
  271. name: '1',
  272. value: 'E1'
  273. },
  274. {
  275. name: '2',
  276. value: 'E2'
  277. },
  278. {
  279. name: '3',
  280. value: 'E3'
  281. },
  282. {
  283. name: '4',
  284. value: 'E4'
  285. },
  286. {
  287. name: '5',
  288. value: 'E5'
  289. },
  290. {
  291. name: '6',
  292. value: 'E6'
  293. },
  294. {
  295. name: '7',
  296. value: 'E7'
  297. }
  298. ],
  299. rules: {
  300. name: {
  301. rules: [{
  302. required: true,
  303. errorMessage: '请输入姓名',
  304. }]
  305. },
  306. wxid: {
  307. rules: [{
  308. required: true,
  309. errorMessage: '请输入微信号',
  310. }, {
  311. errorMessage: '请输入正确的微信号',
  312. pattern: '^[a-zA-Z][a-zA-Z\\d_-]{5,19}$',
  313. }]
  314. },
  315. salary: {
  316. rules: [{
  317. required: true,
  318. errorMessage: '请输入课时费'
  319. }]
  320. },
  321. }
  322. };
  323. },
  324. created() {
  325. this.getPriceAndTree()
  326. },
  327. methods: {
  328. // 手机号
  329. // 手机号
  330. async getPhoneNumber(e) {
  331. // console.log(e.detail.code)
  332. if (e.detail.code === undefined) return uni.$showMsg('获取手机号失败!')
  333. const query = {
  334. code: e.detail.code
  335. }
  336. const {
  337. data: result
  338. } = await uni.$http.get('/ucenter/mini-program-openid-uid/wxGetPhone', query)
  339. if (result.code === 20000) {
  340. this.baseFormData.phone = result.data.phone
  341. return uni.$showMsg('获取手机成功!')
  342. }
  343. },
  344. // 树形结构的课程和价格表
  345. async getPriceAndTree() {
  346. const {
  347. data: result
  348. } = await uni.$http.get('/education/course-price/treeAndPrice')
  349. // console.log(result)
  350. this.courseTree = result.data.treeCourse
  351. this.coursePrice = result.data.coursePrice
  352. },
  353. // 上午复选框
  354. chechboxChangeAM(e) {
  355. this.courseAM.push(e.detail.value)
  356. },
  357. // 下午复选框
  358. chechboxChangePM(e) {
  359. this.coursePM.push(e.detail.value)
  360. },
  361. // 晚上复选框
  362. chechboxChangeEvening(e) {
  363. this.courseEV.push(e.detail.value)
  364. },
  365. // 获取老师地理位置
  366. getLocation() {
  367. // wx.choosePoi({
  368. // success: res => {
  369. // console.log(res)
  370. // if (res.type === 0) {
  371. // // 不显示位置
  372. // this.baseFormData.locationStr = ''
  373. // } else if (res.type === 2) {
  374. // // 详细位置
  375. // this.baseFormData.locationStr = res.address
  376. // } else if (res.type === 1) {
  377. // // 概要位置
  378. // this.baseFormData.locationStr = res.city
  379. // }
  380. // }
  381. // })
  382. wx.chooseLocation({
  383. success: res => {
  384. if (res.errMsg === 'chooseLocation:ok') {
  385. this.baseFormData.locationStr = res.address + res.name
  386. this.baseFormData.locationAl = res.latitude + ',' + res.longitude
  387. }
  388. }
  389. })
  390. },
  391. // 提交
  392. submit() {
  393. if (this.isLoading) {
  394. return uni.$showMsg('操作过快,请耐心等待…')
  395. }
  396. this.isLoading = true
  397. this.baseFormData.courseWeekday = []
  398. this.$refs.baseForm.validate().then(res => {
  399. if (this.baseFormData.phone === '') return uni.$showMsg('手机号未获取!')
  400. if (this.baseFormData.locationStr === '') return uni.$showMsg('请选择地址!')
  401. if (this.baseFormData.subjectSmall === '1-1' || this.baseFormData.subjectSmall === '') return uni.$showMsg('请选择课程')
  402. if (this.courseAM.length === 0 && this.coursePM.length === 0 && this.courseEV.length === 0) return uni.$showMsg('请选择上课时间!')
  403. if (this.courseAM[this.courseAM.length - 1] == '' && this.coursePM.length === 0 && this.courseEV.length === 0) return uni.$showMsg('请选择上课时间!')
  404. if (this.courseAM.length === 0 && this.coursePM[this.coursePM.length - 1] == '' && this.courseEV.length === 0) return uni.$showMsg('请选择上课时间!')
  405. if (this.courseAM.length === 0 && this.coursePM.length === 0 && this.courseEV[this.courseEV.length - 1] == '') return uni.$showMsg('请选择上课时间!')
  406. if (this.courseAM[this.courseAM.length - 1] == '' && this.coursePM[this.coursePM.length - 1] == '' && this.courseEV.length === 0) return uni.$showMsg('请选择上课时间!')
  407. if (this.courseAM[this.courseAM.length - 1] == '' && this.coursePM.length === 0 && this.courseEV[this.courseEV.length - 1] == '') return uni.$showMsg('请选择上课时间!')
  408. if (this.courseAM.length === 0 && this.coursePM[this.coursePM.length - 1] == '' && this.courseEV[this.courseEV.length - 1] == '') return uni.$showMsg('请选择上课时间!')
  409. if (this.courseAM[this.courseAM.length - 1] == '' && this.coursePM[this.coursePM.length - 1] == '' && this.courseEV[this.courseEV.length - 1] == '') return uni.$showMsg('请选择上课时间!')
  410. if (this.courseAM.length > 0) {
  411. this.baseFormData.courseWeekday.push(this.courseAM[this.courseAM.length - 1])
  412. }
  413. if (this.coursePM.length > 0) {
  414. this.baseFormData.courseWeekday.push(this.coursePM[this.coursePM.length - 1])
  415. }
  416. if (this.courseEV.length > 0) {
  417. this.baseFormData.courseWeekday.push(this.courseEV[this.courseEV.length - 1])
  418. }
  419. // 上课时间
  420. this.baseFormData.courseWeekday = this.baseFormData.courseWeekday.join()
  421. // console.log(this.baseFormData.courseWeekday)
  422. // 教员学历
  423. if (this.baseFormData.teacherEdu === '') return uni.$showMsg('请选择教员学历!')
  424. // 课时费
  425. let city = this.userinfo.city
  426. for(let i = 0; i < this.coursePrice.length; i++) {
  427. if(this.coursePrice[i].courseName === this.baseFormData.subjectSmall) {
  428. // console.log(this.coursePrice[i].priceMapping.stu_price_2_l)
  429. // 二线城市
  430. if (city != '北京' || city != '上海' || city != '广州' || city != '深圳') {
  431. // 学生
  432. if (this.baseFormData.teacherType === '学生教员') {
  433. if (this.coursePrice[i].priceMapping.stu_price_2_l > this.baseFormData.salary || this.baseFormData.salary > this.coursePrice[i].priceMapping.stu_price_2_h) {
  434. this.errorPrice = '价格在' + this.coursePrice[i].priceMapping.stu_price_2_l + '~' + this.coursePrice[i].priceMapping.stu_price_2_h + '之间'
  435. return uni.$showMsg('请合理选择课时费')
  436. }
  437. } else {
  438. if (this.coursePrice[i].priceMapping.fulltime_price_2_l > this.baseFormData.salary || this.baseFormData.salary > this.coursePrice[i].priceMapping.fulltime_price_2_h) {
  439. this.errorPrice = '价格在' + this.coursePrice[i].priceMapping.fulltime_price_2_l + '~' + this.coursePrice[i].priceMapping.fulltime_price_2_h + '之间'
  440. return uni.$showMsg('请合理选择课时费')
  441. }
  442. }
  443. } else {
  444. // 学生
  445. if (this.baseFormData.teacherType === '学生教员') {
  446. if (this.coursePrice[i].priceMapping.stu_price_1_l > this.baseFormData.salary || this.baseFormData.salary > this.coursePrice[i].priceMapping.stu_price_1_h) {
  447. this.errorPrice = '价格在' + this.coursePrice[i].priceMapping.stu_price_1_l + '~' + this.coursePrice[i].priceMapping.stu_price_1_h + '之间'
  448. return uni.$showMsg('请合理选择课时费')
  449. }
  450. } else {
  451. if (this.coursePrice[i].priceMapping.fulltime_price_1_l > this.baseFormData.salary || this.baseFormData.salary > this.coursePrice[i].priceMapping.fulltime_price_1_h) {
  452. this.errorPrice = '价格在' + this.coursePrice[i].priceMapping.fulltime_price_1_l + '~' + this.coursePrice[i].priceMapping.fulltime_price_1_h + '之间'
  453. return uni.$showMsg('请合理选择课时费')
  454. }
  455. }
  456. }
  457. }
  458. }
  459. console.log(this.baseFormData)
  460. uni.request({
  461. url: 'http://192.168.0.207:8222/education/student-requirements/publishRequirements',
  462. data: this.baseFormData,
  463. header: {
  464. token: uni.getStorageSync('token')
  465. },
  466. method: 'POST',
  467. success: res => {
  468. uni.$showMsg(res.data.message)
  469. setTimeout(() => {
  470. uni.navigateBack()
  471. }, 1000)
  472. }
  473. })
  474. }).catch(err => {
  475. this.isLoading = false
  476. // console.log(err)
  477. })
  478. this.isLoading = false
  479. }
  480. }
  481. }
  482. </script>
  483. <style lang="scss" scoped>
  484. .tr-container{
  485. display: flex;
  486. position: relative;
  487. width: 96%;
  488. flex-direction: column;
  489. font-size: 26rpx;
  490. /* border: 1rpx solid gray; */
  491. margin: -10px 20rpx;
  492. margin-bottom: 20px;
  493. }
  494. .tr_1 {
  495. display: flex;
  496. position: relative;
  497. height: 80rpx;
  498. line-height: 80rpx;
  499. }
  500. .tr_2{
  501. display: block;
  502. height: 80rpx;
  503. line-height: 80rpx;
  504. }
  505. .th_0,
  506. .th_1,
  507. .th_2,
  508. .th2_0,
  509. .th2_1,
  510. .th2_2{
  511. width: 12%;
  512. height: 80rpx;
  513. line-height: 80rpx;
  514. border-right: 1rpx solid gray;
  515. border-bottom: 1rpx solid gray;
  516. text-align: center;
  517. }
  518. .th_0,
  519. .th_1,
  520. .th_2{
  521. border-top: 1rpx solid gray;
  522. }
  523. .th_0,
  524. .th2_0{
  525. border-left: 1rpx solid gray;
  526. }
  527. .th2_0{
  528. float: left;
  529. width: 12%;
  530. height: 80rpx;
  531. line-height: 80rpx;
  532. text-align: center;
  533. /* background-color: greenyellow; */
  534. }
  535. </style>