student_require_add.vue 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647
  1. <template>
  2. <view class="stu-require-container" style="background-color: #f0f0f0;">
  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="4" trim="both" />
  6. </uni-forms-item>
  7. <uni-forms-item label="手机号" name="phone" required>
  8. <button class="getPhone" 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 class="submitBtnWrapper">
  89. <button class="submitBtn" 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. onLoad(option) {
  347. this.getPriceAndTree()
  348. if (option.item !== undefined) {
  349. let item = JSON.parse(decodeURIComponent(option.item))
  350. this.formatStuNeed(item)
  351. }
  352. },
  353. methods: {
  354. // 格式化传递过来的stuneed信息
  355. formatStuNeed(item) {
  356. item.datetime = null
  357. item.deal = null
  358. item.deleted = null
  359. item.display = null
  360. item.id = null
  361. item.locked = null
  362. item.requireId = null
  363. item.uid = null
  364. item.verifyRefuseReason = null
  365. item.verifyStatus = null
  366. this.baseFormData = item
  367. this.courseWeekday = item.courseWeekday.split(",")
  368. this.baseFormData.courseWeekday = this.courseWeekday
  369. for (let i = 0; i < this.courseWeekday.length; i++) {
  370. for (let x = 0; x < this.timeAM.length; x++) {
  371. if (this.courseWeekday[i] == this.timeAM[x].value) {
  372. this.timeAM[x].checked = true
  373. this.courseAM.push(this.courseWeekday[i])
  374. }
  375. }
  376. for (let y = 0; y < this.timePM.length; y++) {
  377. if (this.courseWeekday[i] == 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. if (this.courseAM.length > 0) {
  390. this.courseAM.push(this.courseAM.join().split(','))
  391. }
  392. if (this.coursePM.length > 0) {
  393. this.coursePM.push(this.coursePM.join().split(','))
  394. }
  395. if (this.courseEV.length > 0) {
  396. this.courseEV.push(this.courseEV.join().split(','))
  397. }
  398. },
  399. // 手机号
  400. async getPhoneNumber(e) {
  401. if (e.detail.code === undefined) return uni.$showMsg('获取手机号失败!')
  402. const query = {
  403. code: e.detail.code
  404. }
  405. const {
  406. data: result
  407. } = await uni.$http.get('/ucenter/mini-program-openid-uid/wxGetPhone', query)
  408. if (result.code === 20000) {
  409. this.baseFormData.phone = result.data.phone
  410. return uni.$showMsg('获取手机成功!')
  411. }
  412. },
  413. // 树形结构的课程和价格表
  414. async getPriceAndTree() {
  415. const {
  416. data: result
  417. } = await uni.$http.get('/education/course-price/treeAndPrice')
  418. this.courseTree = result.data.treeCourse
  419. this.coursePrice = result.data.coursePrice
  420. },
  421. // 上午复选框
  422. chechboxChangeAM(e) {
  423. this.courseAM.push(e.detail.value)
  424. },
  425. // 下午复选框
  426. chechboxChangePM(e) {
  427. this.coursePM.push(e.detail.value)
  428. },
  429. // 晚上复选框
  430. chechboxChangeEvening(e) {
  431. this.courseEV.push(e.detail.value)
  432. },
  433. // 获取老师地理位置
  434. getLocation() {
  435. wx.chooseLocation({
  436. success: res => {
  437. if (res.errMsg === 'chooseLocation:ok') {
  438. this.baseFormData.locationStr = res.address + res.name
  439. this.baseFormData.locationAl = res.latitude + ',' + res.longitude
  440. }
  441. }
  442. })
  443. },
  444. // 提交
  445. submit() {
  446. if (this.isLoading) {
  447. return uni.$showMsg('操作过快,请耐心等待…')
  448. }
  449. this.isLoading = true
  450. this.baseFormData.courseWeekday = []
  451. this.$refs.baseForm.validate().then(res => {
  452. if (this.baseFormData.phone === '') return uni.$showMsg('手机号未获取!')
  453. if (this.baseFormData.locationStr === '') return uni.$showMsg('请选择地址!')
  454. if (this.baseFormData.subjectSmall === '1-1' || this.baseFormData.subjectSmall === '') return uni.$showMsg('请选择课程')
  455. if (this.courseAM.length === 0 && this.coursePM.length === 0 && this.courseEV.length === 0 ) return uni.$showMsg('请选择上课时间!')
  456. if (this.courseAM[this.courseAM.length - 1] == '' && this.coursePM.length === 0 && this.courseEV.length === 0 ) return uni.$showMsg('请选择上课时间!')
  457. if (this.courseAM.length === 0 && this.coursePM[this.coursePM.length - 1] == '' && this.courseEV.length === 0 ) return uni.$showMsg('请选择上课时间!')
  458. if (this.courseAM.length === 0 && this.coursePM.length === 0 && this.courseEV[this.courseEV.length - 1] == '' ) return uni.$showMsg('请选择上课时间!')
  459. if (this.courseAM[this.courseAM.length - 1] == '' && this.coursePM[this.coursePM.length - 1] == '' && this.courseEV.length === 0 ) return uni.$showMsg('请选择上课时间!')
  460. if (this.courseAM[this.courseAM.length - 1] == '' && this.coursePM.length === 0 && this.courseEV[this.courseEV.length - 1] == '' ) return uni.$showMsg('请选择上课时间!')
  461. if (this.courseAM.length === 0 && this.coursePM[this.coursePM.length - 1] == '' && this.courseEV[this.courseEV.length - 1] == '' ) return uni.$showMsg('请选择上课时间!')
  462. if (this.courseAM[this.courseAM.length - 1] == '' && this.coursePM[this.coursePM.length - 1] == '' && this.courseEV[this.courseEV.length - 1] == '' ) return uni.$showMsg('请选择上课时间!')
  463. if (this.courseAM.length > 0) {
  464. this.baseFormData.courseWeekday.push(this.courseAM[this.courseAM.length - 1])
  465. }
  466. if (this.coursePM.length > 0) {
  467. this.baseFormData.courseWeekday.push(this.coursePM[this.coursePM.length - 1])
  468. }
  469. if (this.courseEV.length > 0) {
  470. this.baseFormData.courseWeekday.push(this.courseEV[this.courseEV.length - 1])
  471. }
  472. // 上课时间
  473. this.baseFormData.courseWeekday = this.baseFormData.courseWeekday.join()
  474. // 末尾为,
  475. if (this.baseFormData.courseWeekday.slice(-1) === ',') {
  476. this.baseFormData.courseWeekday = this.baseFormData.courseWeekday.substring(0, this.baseFormData.courseWeekday.length - 1)
  477. }
  478. // 开始为,
  479. if (this.baseFormData.courseWeekday.slice(0,1) === ',') {
  480. let temp = this.baseFormData.courseWeekday.substring(1, this.baseFormData.courseWeekday.length )
  481. this.baseFormData.courseWeekday = temp
  482. }
  483. // 教员学历
  484. if (this.baseFormData.teacherEdu === '') return uni.$showMsg('请选择教员学历!')
  485. // 课时费
  486. let city = this.userinfo.city
  487. for(let i = 0; i < this.coursePrice.length; i++) {
  488. if(this.coursePrice[i].courseName === this.baseFormData.subjectSmall) {
  489. // console.log(this.coursePrice[i].priceMapping.stu_price_2_l)
  490. // 二线城市
  491. if (city != '北京' || city != '上海' || city != '广州' || city != '深圳') {
  492. // 学生
  493. if (this.baseFormData.teacherType === '学生教员') {
  494. if (this.coursePrice[i].priceMapping.stu_price_2_l > this.baseFormData.salary || this.baseFormData.salary > this.coursePrice[i].priceMapping.stu_price_2_h) {
  495. this.errorPrice = '价格在' + this.coursePrice[i].priceMapping.stu_price_2_l + '~' + this.coursePrice[i].priceMapping.stu_price_2_h + '之间'
  496. return uni.$showMsg('请合理选择课时费')
  497. }
  498. } else {
  499. if (this.coursePrice[i].priceMapping.fulltime_price_2_l > this.baseFormData.salary || this.baseFormData.salary > this.coursePrice[i].priceMapping.fulltime_price_2_h) {
  500. this.errorPrice = '价格在' + this.coursePrice[i].priceMapping.fulltime_price_2_l + '~' + this.coursePrice[i].priceMapping.fulltime_price_2_h + '元之间'
  501. return uni.$showMsg('请合理选择课时费')
  502. }
  503. }
  504. } else {
  505. // 学生
  506. if (this.baseFormData.teacherType === '学生教员') {
  507. if (this.coursePrice[i].priceMapping.stu_price_1_l > this.baseFormData.salary || this.baseFormData.salary > this.coursePrice[i].priceMapping.stu_price_1_h) {
  508. this.errorPrice = '价格在' + this.coursePrice[i].priceMapping.stu_price_1_l + '~' + this.coursePrice[i].priceMapping.stu_price_1_h + '之间'
  509. return uni.$showMsg('请合理选择课时费')
  510. }
  511. } else {
  512. if (this.coursePrice[i].priceMapping.fulltime_price_1_l > this.baseFormData.salary || this.baseFormData.salary > this.coursePrice[i].priceMapping.fulltime_price_1_h) {
  513. this.errorPrice = '价格在' + this.coursePrice[i].priceMapping.fulltime_price_1_l + '~' + this.coursePrice[i].priceMapping.fulltime_price_1_h + '之间'
  514. return uni.$showMsg('请合理选择课时费')
  515. }
  516. }
  517. }
  518. }
  519. }
  520. // 课程科目
  521. for (let x = 0; x < this.courseTree.length; x++) {
  522. for (let y = 0; y < this.courseTree[x].children.length; y++) {
  523. if (this.courseTree[x].children[y].value === this.baseFormData.subjectSmall) {
  524. this.baseFormData.subjectBig = this.courseTree[x].value
  525. }
  526. }
  527. }
  528. uni.request({
  529. url: `${uni.$http.baseUrl}/education/student-requirements/publishRequirements`,
  530. data: this.baseFormData,
  531. header: {
  532. token: uni.getStorageSync('token')
  533. },
  534. method: 'POST',
  535. success: res => {
  536. uni.$showMsg(res.data.message)
  537. setTimeout(() => {
  538. uni.navigateBack({
  539. delta: 2
  540. })
  541. }, 1000)
  542. }
  543. })
  544. }).catch(err => {
  545. this.isLoading = false
  546. })
  547. this.isLoading = false
  548. }
  549. }
  550. }
  551. </script>
  552. <!-- 设置页面背景 -->
  553. <style lang="scss">
  554. page{
  555. height: 100%;
  556. //background-color: #FFF2CC;
  557. }
  558. </style>
  559. <style lang="scss" scoped>
  560. .stu-require-container{
  561. width: 96%;
  562. height: 100%;
  563. padding-left: 20rpx;
  564. }
  565. .tr-container{
  566. display: flex;
  567. position: relative;
  568. width: 96%;
  569. flex-direction: column;
  570. font-size: 26rpx;
  571. /* border: 1rpx solid gray; */
  572. margin: -10px 20rpx;
  573. margin-bottom: 20px;
  574. }
  575. .tr_1 {
  576. display: flex;
  577. position: relative;
  578. height: 80rpx;
  579. line-height: 80rpx;
  580. }
  581. .tr_2{
  582. display: block;
  583. height: 80rpx;
  584. line-height: 80rpx;
  585. }
  586. .th_0,
  587. .th_1,
  588. .th_2,
  589. .th2_0,
  590. .th2_1,
  591. .th2_2{
  592. width: 12%;
  593. height: 80rpx;
  594. line-height: 80rpx;
  595. border-right: 1rpx solid gray;
  596. border-bottom: 1rpx solid gray;
  597. text-align: center;
  598. }
  599. .th_0,
  600. .th_1,
  601. .th_2{
  602. border-top: 1rpx solid gray;
  603. }
  604. .th_0,
  605. .th2_0{
  606. border-left: 1rpx solid gray;
  607. }
  608. .th2_0{
  609. float: left;
  610. width: 12%;
  611. height: 80rpx;
  612. line-height: 80rpx;
  613. text-align: center;
  614. /* background-color: greenyellow; */
  615. }
  616. // 提交按钮样式
  617. .submitBtnWrapper{
  618. height: 140rpx;
  619. align-items: center;
  620. }
  621. .submitBtn{
  622. width: 300rpx;
  623. border-radius: 50rpx;
  624. // margin-bottom: 40rpx;
  625. background-color: #35b882;
  626. }
  627. // 获取手机号按钮背景颜色
  628. .getPhone{
  629. background-color: #35b882;
  630. }
  631. </style>