add_stu_require.vue 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640
  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" :checked="item.checked"></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" :checked="item.checked"></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" :checked="item.checked"></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. courseWeekday: [],
  107. // 表单数据
  108. baseFormData: {
  109. name: '',
  110. phone: '',
  111. wxid: '',
  112. subjectSmall: '1-1',
  113. mode: '教员上门',
  114. sex: '男',
  115. salary: 0,
  116. courseWeekday: [],
  117. goal: '',
  118. teacherType: '专职教员',
  119. teacherEdu: '',
  120. teacherGender: '男',
  121. teacherProfilePhoto: '有',
  122. teacherDemanded: '',
  123. locationStr: '',
  124. locationAl: ''
  125. },
  126. coursePrice: [],
  127. // 选择课程
  128. courseTree: [{
  129. text: '一年级',
  130. value: '1-0',
  131. children: [{
  132. text: '1.1班',
  133. value: '1-1'
  134. }
  135. ]
  136. }
  137. ],
  138. // 单选辅导方式数据源
  139. modes: [{
  140. text: '教员上门',
  141. value: '教员上门'
  142. }, {
  143. text: '学员上门',
  144. value: '学员上门'
  145. }, {
  146. text: '线上辅导',
  147. value: '线上辅导'
  148. }],
  149. // 单选性别数据源
  150. sexs: [{
  151. text: '男',
  152. value: '男'
  153. }, {
  154. text: '女',
  155. value: '女'
  156. }],
  157. // 单选老师身份
  158. identifies: [{
  159. text: '专职教员',
  160. value: '专职教员'
  161. }, {
  162. text: '学生教员',
  163. value: '学生教员'
  164. }],
  165. educations: [{
  166. value: '专科在读',
  167. text: '专科在读及以上'
  168. }, {
  169. value: '专科毕业',
  170. text: '专科毕业及以上'
  171. }, {
  172. value: '本科在读',
  173. text: '本科在读及以上'
  174. }, {
  175. value: '本科毕业',
  176. text: '本科毕业及以上'
  177. }, {
  178. value: '硕士在读',
  179. text: '硕士在读及以上'
  180. }, {
  181. value: '硕士毕业',
  182. text: '硕士毕业及以上'
  183. }, {
  184. value: '博士在读',
  185. text: '博士在读及以上'
  186. }, {
  187. value: '博士毕业',
  188. text: '博士毕业及以上'
  189. }, {
  190. value: '不限',
  191. text: '不限'
  192. }],
  193. // 单选老师性别
  194. sexsTeacher: [{
  195. text: '男',
  196. value: '男'
  197. }, {
  198. text: '女',
  199. value: '女'
  200. }],
  201. // 单选老师有无照片
  202. hasPhotoes: [{
  203. text: '有',
  204. value: '有'
  205. }, {
  206. text: '无',
  207. value: '无'
  208. }],
  209. // 上课时间
  210. // 上午
  211. timeAM: [{
  212. value: 'A1',
  213. name: '1',
  214. checked: false
  215. },
  216. {
  217. name: '2',
  218. value: 'A2',
  219. checked: false
  220. },
  221. {
  222. name: '3',
  223. value: 'A3',
  224. checked: false
  225. },
  226. {
  227. name: '4',
  228. value: 'A4',
  229. checked: false
  230. },
  231. {
  232. name: '5',
  233. value: 'A5',
  234. checked: false
  235. },
  236. {
  237. name: '6',
  238. value: 'A6',
  239. checked: false
  240. },
  241. {
  242. name: '7',
  243. value: 'A7',
  244. checked: false
  245. }
  246. ],
  247. // 下午
  248. timePM: [{
  249. value: 'P1',
  250. name: '1',
  251. checked: false
  252. },
  253. {
  254. name: '2',
  255. value: 'P2',
  256. checked: false
  257. },
  258. {
  259. name: '3',
  260. value: 'P3',
  261. checked: false
  262. },
  263. {
  264. name: '4',
  265. value: 'P4',
  266. checked: false
  267. },
  268. {
  269. name: '5',
  270. value: 'P5',
  271. checked: false
  272. },
  273. {
  274. name: '6',
  275. value: 'P6',
  276. checked: false
  277. },
  278. {
  279. name: '7',
  280. value: 'P7',
  281. checked: false
  282. }
  283. ],
  284. // 晚上
  285. timeEvening: [{
  286. name: '1',
  287. value: 'E1',
  288. checked: false
  289. },
  290. {
  291. name: '2',
  292. value: 'E2',
  293. checked: false
  294. },
  295. {
  296. name: '3',
  297. value: 'E3',
  298. checked: false
  299. },
  300. {
  301. name: '4',
  302. value: 'E4',
  303. checked: false
  304. },
  305. {
  306. name: '5',
  307. value: 'E5',
  308. checked: false
  309. },
  310. {
  311. name: '6',
  312. value: 'E6',
  313. checked: false
  314. },
  315. {
  316. name: '7',
  317. value: 'E7',
  318. checked: false
  319. }
  320. ],
  321. rules: {
  322. name: {
  323. rules: [{
  324. required: true,
  325. errorMessage: '请输入姓名',
  326. }]
  327. },
  328. wxid: {
  329. rules: [{
  330. required: true,
  331. errorMessage: '请输入微信号',
  332. }, {
  333. errorMessage: '请输入正确的微信号',
  334. pattern: '^[a-zA-Z][a-zA-Z\\d_-]{5,19}$',
  335. }]
  336. },
  337. salary: {
  338. rules: [{
  339. required: true,
  340. errorMessage: '请输入课时费'
  341. }]
  342. },
  343. }
  344. };
  345. },
  346. created() {
  347. this.getPriceAndTree()
  348. },
  349. onLoad(option) {
  350. if (option.item !== undefined) {
  351. let item = JSON.parse(decodeURIComponent(option.item))
  352. item.datetime = null
  353. item.deal = null
  354. item.deleted = null
  355. item.display = null
  356. item.id = null
  357. item.locked = null
  358. item.requireId = null
  359. item.uid = null
  360. item.verifyRefuseReason = null
  361. item.verifyStatus = null
  362. // console.log(item)
  363. this.baseFormData = item
  364. this.courseWeekday = item.courseWeekday.split(",")
  365. this.baseFormData.courseWeekday = this.courseWeekday
  366. // console.log(this.baseFormData)
  367. // console.log("选中的日期:" + this.courseWeekday)
  368. for (let i = 0; i < this.courseWeekday.length; i++) {
  369. for (let x = 0; x < this.timeAM.length; x++) {
  370. if (this.courseWeekday[i] == this.timeAM[x].value) {
  371. this.timeAM[x].checked = true
  372. this.courseAM.push(this.courseWeekday[i])
  373. }
  374. }
  375. for (let y = 0; y < this.timePM.length; y++) {
  376. if (this.courseWeekday[i] == this.timePM[y].value) {
  377. // console.log(this.timePM[y].value)
  378. this.timePM[y].checked = true
  379. this.coursePM.push(this.courseWeekday[i])
  380. }
  381. }
  382. for (let z = 0; z < this.timeEvening.length; z++) {
  383. if (this.courseWeekday[i] == this.timeEvening[z].value) {
  384. this.timeEvening[z].checked = true
  385. this.courseEV.push(this.courseWeekday[i])
  386. }
  387. }
  388. }
  389. }
  390. },
  391. methods: {
  392. // 手机号
  393. // 手机号
  394. async getPhoneNumber(e) {
  395. // console.log(e.detail.code)
  396. if (e.detail.code === undefined) return uni.$showMsg('获取手机号失败!')
  397. const query = {
  398. code: e.detail.code
  399. }
  400. const {
  401. data: result
  402. } = await uni.$http.get('/ucenter/mini-program-openid-uid/wxGetPhone', query)
  403. if (result.code === 20000) {
  404. this.baseFormData.phone = result.data.phone
  405. return uni.$showMsg('获取手机成功!')
  406. }
  407. },
  408. // 树形结构的课程和价格表
  409. async getPriceAndTree() {
  410. const {
  411. data: result
  412. } = await uni.$http.get('/education/course-price/treeAndPrice')
  413. // console.log(result)
  414. this.courseTree = result.data.treeCourse
  415. this.coursePrice = result.data.coursePrice
  416. },
  417. // 上午复选框
  418. chechboxChangeAM(e) {
  419. this.courseAM.push(e.detail.value)
  420. },
  421. // 下午复选框
  422. chechboxChangePM(e) {
  423. this.coursePM.push(e.detail.value)
  424. },
  425. // 晚上复选框
  426. chechboxChangeEvening(e) {
  427. this.courseEV.push(e.detail.value)
  428. },
  429. // 获取老师地理位置
  430. getLocation() {
  431. // wx.choosePoi({
  432. // success: res => {
  433. // console.log(res)
  434. // if (res.type === 0) {
  435. // // 不显示位置
  436. // this.baseFormData.locationStr = ''
  437. // } else if (res.type === 2) {
  438. // // 详细位置
  439. // this.baseFormData.locationStr = res.address
  440. // } else if (res.type === 1) {
  441. // // 概要位置
  442. // this.baseFormData.locationStr = res.city
  443. // }
  444. // }
  445. // })
  446. wx.chooseLocation({
  447. success: res => {
  448. if (res.errMsg === 'chooseLocation:ok') {
  449. this.baseFormData.locationStr = res.address + res.name
  450. this.baseFormData.locationAl = res.latitude + ',' + res.longitude
  451. }
  452. }
  453. })
  454. },
  455. // 提交
  456. submit() {
  457. if (this.isLoading) {
  458. return uni.$showMsg('操作过快,请耐心等待…')
  459. }
  460. this.isLoading = true
  461. this.baseFormData.courseWeekday = []
  462. this.$refs.baseForm.validate().then(res => {
  463. if (this.baseFormData.phone === '') return uni.$showMsg('手机号未获取!')
  464. if (this.baseFormData.locationStr === '') return uni.$showMsg('请选择地址!')
  465. if (this.baseFormData.subjectSmall === '1-1' || this.baseFormData.subjectSmall === '') return uni.$showMsg('请选择课程')
  466. if (this.courseAM.length === 0 && this.coursePM.length === 0 && this.courseEV.length === 0 ) return uni.$showMsg('请选择上课时间!')
  467. if (this.courseAM[this.courseAM.length - 1] == '' && this.coursePM.length === 0 && this.courseEV.length === 0 ) return uni.$showMsg('请选择上课时间!')
  468. if (this.courseAM.length === 0 && this.coursePM[this.coursePM.length - 1] == '' && this.courseEV.length === 0 ) return uni.$showMsg('请选择上课时间!')
  469. if (this.courseAM.length === 0 && this.coursePM.length === 0 && this.courseEV[this.courseEV.length - 1] == '' ) return uni.$showMsg('请选择上课时间!')
  470. if (this.courseAM[this.courseAM.length - 1] == '' && this.coursePM[this.coursePM.length - 1] == '' && this.courseEV.length === 0 ) return uni.$showMsg('请选择上课时间!')
  471. if (this.courseAM[this.courseAM.length - 1] == '' && this.coursePM.length === 0 && this.courseEV[this.courseEV.length - 1] == '' ) return uni.$showMsg('请选择上课时间!')
  472. if (this.courseAM.length === 0 && this.coursePM[this.coursePM.length - 1] == '' && this.courseEV[this.courseEV.length - 1] == '' ) return uni.$showMsg('请选择上课时间!')
  473. if (this.courseAM[this.courseAM.length - 1] == '' && this.coursePM[this.coursePM.length - 1] == '' && this.courseEV[this.courseEV.length - 1] == '' ) return uni.$showMsg('请选择上课时间!')
  474. if (this.courseAM.length > 0) {
  475. this.baseFormData.courseWeekday.push(this.courseAM[this.courseAM.length - 1])
  476. }
  477. if (this.coursePM.length > 0) {
  478. this.baseFormData.courseWeekday.push(this.coursePM[this.coursePM.length - 1])
  479. }
  480. if (this.courseEV.length > 0) {
  481. this.baseFormData.courseWeekday.push(this.courseEV[this.courseEV.length - 1])
  482. }
  483. // 上课时间
  484. this.baseFormData.courseWeekday = this.baseFormData.courseWeekday.join()
  485. // 末尾为,
  486. if (this.baseFormData.courseWeekday.slice(-1) === ',') {
  487. this.baseFormData.courseWeekday = this.baseFormData.courseWeekday.substring(0, this.baseFormData.courseWeekday.length - 1)
  488. }
  489. // 开始为,
  490. if (this.baseFormData.courseWeekday.slice(0,1) === ',') {
  491. let temp = this.baseFormData.courseWeekday.substring(1, this.baseFormData.courseWeekday.length )
  492. this.baseFormData.courseWeekday = temp
  493. }
  494. // 教员学历
  495. if (this.baseFormData.teacherEdu === '') return uni.$showMsg('请选择教员学历!')
  496. // 课时费
  497. let city = this.userinfo.city
  498. for(let i = 0; i < this.coursePrice.length; i++) {
  499. if(this.coursePrice[i].courseName === this.baseFormData.subjectSmall) {
  500. // console.log(this.coursePrice[i].priceMapping.stu_price_2_l)
  501. // 二线城市
  502. if (city != '北京' || city != '上海' || city != '广州' || city != '深圳') {
  503. // 学生
  504. if (this.baseFormData.teacherType === '学生教员') {
  505. if (this.coursePrice[i].priceMapping.stu_price_2_l > this.baseFormData.salary || this.baseFormData.salary > this.coursePrice[i].priceMapping.stu_price_2_h) {
  506. this.errorPrice = '价格在' + this.coursePrice[i].priceMapping.stu_price_2_l + '~' + this.coursePrice[i].priceMapping.stu_price_2_h + '之间'
  507. return uni.$showMsg('请合理选择课时费')
  508. }
  509. } else {
  510. if (this.coursePrice[i].priceMapping.fulltime_price_2_l > this.baseFormData.salary || this.baseFormData.salary > this.coursePrice[i].priceMapping.fulltime_price_2_h) {
  511. this.errorPrice = '价格在' + this.coursePrice[i].priceMapping.fulltime_price_2_l + '~' + this.coursePrice[i].priceMapping.fulltime_price_2_h + '元之间'
  512. return uni.$showMsg('请合理选择课时费')
  513. }
  514. }
  515. } else {
  516. // 学生
  517. if (this.baseFormData.teacherType === '学生教员') {
  518. if (this.coursePrice[i].priceMapping.stu_price_1_l > this.baseFormData.salary || this.baseFormData.salary > this.coursePrice[i].priceMapping.stu_price_1_h) {
  519. this.errorPrice = '价格在' + this.coursePrice[i].priceMapping.stu_price_1_l + '~' + this.coursePrice[i].priceMapping.stu_price_1_h + '之间'
  520. return uni.$showMsg('请合理选择课时费')
  521. }
  522. } else {
  523. if (this.coursePrice[i].priceMapping.fulltime_price_1_l > this.baseFormData.salary || this.baseFormData.salary > this.coursePrice[i].priceMapping.fulltime_price_1_h) {
  524. this.errorPrice = '价格在' + this.coursePrice[i].priceMapping.fulltime_price_1_l + '~' + this.coursePrice[i].priceMapping.fulltime_price_1_h + '之间'
  525. return uni.$showMsg('请合理选择课时费')
  526. }
  527. }
  528. }
  529. }
  530. }
  531. // 课程科目
  532. for (let x = 0; x < this.courseTree.length; x++) {
  533. for (let y = 0; y < this.courseTree[x].children.length; y++) {
  534. if (this.courseTree[x].children[y].value === this.baseFormData.subjectSmall) {
  535. this.baseFormData.subjectBig = this.courseTree[x].value
  536. }
  537. }
  538. }
  539. console.log(this.baseFormData)
  540. uni.request({
  541. url: 'http://192.168.0.207:8222/education/student-requirements/publishRequirements',
  542. data: this.baseFormData,
  543. header: {
  544. token: uni.getStorageSync('token')
  545. },
  546. method: 'POST',
  547. success: res => {
  548. uni.$showMsg(res.data.message)
  549. setTimeout(() => {
  550. uni.switchTab({
  551. url: '/pages/my/my'
  552. })
  553. }, 1000)
  554. }
  555. })
  556. }).catch(err => {
  557. this.isLoading = false
  558. // console.log(err)
  559. })
  560. this.isLoading = false
  561. }
  562. }
  563. }
  564. </script>
  565. <style lang="scss" scoped>
  566. .tr-container{
  567. display: flex;
  568. position: relative;
  569. width: 96%;
  570. flex-direction: column;
  571. font-size: 26rpx;
  572. /* border: 1rpx solid gray; */
  573. margin: -10px 20rpx;
  574. margin-bottom: 20px;
  575. }
  576. .tr_1 {
  577. display: flex;
  578. position: relative;
  579. height: 80rpx;
  580. line-height: 80rpx;
  581. }
  582. .tr_2{
  583. display: block;
  584. height: 80rpx;
  585. line-height: 80rpx;
  586. }
  587. .th_0,
  588. .th_1,
  589. .th_2,
  590. .th2_0,
  591. .th2_1,
  592. .th2_2{
  593. width: 12%;
  594. height: 80rpx;
  595. line-height: 80rpx;
  596. border-right: 1rpx solid gray;
  597. border-bottom: 1rpx solid gray;
  598. text-align: center;
  599. }
  600. .th_0,
  601. .th_1,
  602. .th_2{
  603. border-top: 1rpx solid gray;
  604. }
  605. .th_0,
  606. .th2_0{
  607. border-left: 1rpx solid gray;
  608. }
  609. .th2_0{
  610. float: left;
  611. width: 12%;
  612. height: 80rpx;
  613. line-height: 80rpx;
  614. text-align: center;
  615. /* background-color: greenyellow; */
  616. }
  617. </style>