index.js 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. import { resumeEdu, eduList} from '../../services/index.js'
  2. import { imgServerUrl } from '../../config/config.js'
  3. import { showToast } from '../../utils/tips.js'
  4. import { argusToTimestamp, formateym } from '../../utils/util.js'
  5. Page({
  6. data: {
  7. imgServerUrl: imgServerUrl,
  8. name:'',
  9. eduList:[],
  10. eduIndex:0,
  11. startDate:'',
  12. endDate:'',
  13. hpUserEducationId:null,
  14. hpUserResumeId:''
  15. },
  16. onLoad: function (options) {
  17. this.fetchEduList()
  18. let { hpUserResumeId, index } = options
  19. if (typeof index != "undefined") {
  20. let eduList = wx.getStorageSync('eduList')[index]
  21. this.setData({
  22. name: eduList.schName,
  23. eduIndex: eduList.hpEducationId - 1,
  24. hpUserResumeId: eduList.hpUserResumeId,
  25. hpUserEducationId: eduList.hpUserEducationId,
  26. startDate: formateym(eduList.startTime+'000','-'),
  27. endDate: formateym(eduList.endTime+'000','-')
  28. })
  29. } else {
  30. this.setData({
  31. hpUserResumeId: hpUserResumeId
  32. })
  33. }
  34. },
  35. //入学时间
  36. startDateChange(e) {
  37. this.setData({
  38. startDate: e.detail.value
  39. })
  40. },
  41. //毕业时间
  42. endDateChange(e) {
  43. this.setData({
  44. endDate: e.detail.value
  45. })
  46. },
  47. //学校名称
  48. changeName(e) {
  49. this.setData({
  50. name: e.detail.detail.value.excludeSpecial().excludeSpace()
  51. })
  52. },
  53. //获取教育水平
  54. fetchEduList() {
  55. eduList().then(res => {
  56. this.setData({
  57. eduList: res.list
  58. })
  59. })
  60. },
  61. //改变学历
  62. bindEduChange(e) {
  63. let { value } = e.detail
  64. this.setData({
  65. eduIndex: value
  66. })
  67. },
  68. //验证
  69. check() {
  70. let { name, startDate, endDate } = this.data
  71. if (name == "") {
  72. showToast('请填写学校名称')
  73. return false
  74. }
  75. if (startDate.length == 0) {
  76. showToast("请选择入学时间")
  77. return false
  78. }
  79. if (endDate.length == 0) {
  80. showToast("请选择毕业时间")
  81. return false
  82. }
  83. return true
  84. },
  85. submit() {
  86. let flag = this.check()
  87. if (!flag) {
  88. return
  89. }
  90. let { name, startDate, endDate, eduList, eduIndex, hpUserEducationId, hpUserResumeId } = this.data
  91. let startTime = Math.floor(argusToTimestamp(startDate.split("-"))/1000)
  92. let endTime = Math.floor(argusToTimestamp(endDate.split("-"))/1000)
  93. resumeEdu({
  94. startTime,
  95. endTime,
  96. hpEducationId: eduList[eduIndex].hpEducationId,
  97. hpUserEducationId,
  98. hpUserResumeId: Number(hpUserResumeId),
  99. schName:name,
  100. }).then(data => {
  101. showToast('保存成功', 'success')
  102. wx.navigateBack()
  103. })
  104. },
  105. })