index.js 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246
  1. import {
  2. resumeExp
  3. } from '../../services/index.js'
  4. import {
  5. imgServerUrl
  6. } from '../../config/config.js'
  7. import {
  8. showToast
  9. } from '../../utils/tips.js'
  10. import {
  11. formatNumber,
  12. argusToTimestamp,
  13. formateym,
  14. formateYM,
  15. formatetime,
  16. } from '../../utils/util.js'
  17. const app = getApp();
  18. let end_time = [];
  19. Page({
  20. data: {
  21. imgServerUrl: imgServerUrl,
  22. comName: '',
  23. jobName: '',
  24. startDate: '请选择入职时间',
  25. endDate: '请选择离职时间',
  26. startDateEnd: '',
  27. endTime: formatetime(new Date(), '-', false),
  28. hpUserExpId: '', //求职者工作经验表
  29. hpUserResumeId: '', //用户简历表id
  30. years: [],
  31. months: [],
  32. pick_view: true,
  33. touch_end: true
  34. },
  35. onLoad: function(options) {
  36. this.pushYear();
  37. // this.pushMonths();
  38. let {
  39. hpUserResumeId,
  40. index
  41. } = options
  42. if (typeof index != "undefined") {
  43. let expList = wx.getStorageSync('expList')[index]
  44. this.setData({
  45. comName: expList.workCompany,
  46. jobName: expList.workPosition,
  47. hpUserResumeId: expList.resumeId,
  48. hpUserExpId: expList.id,
  49. startDate: expList.workStartDate ? expList.workStartDate : "请选择入职时间",
  50. endDate: expList.workEndDate ? expList.workEndDate : "请选择离职时间"
  51. })
  52. } else {
  53. this.setData({
  54. hpUserResumeId
  55. })
  56. }
  57. },
  58. pushYear() {
  59. const year = new Date().getFullYear();
  60. const mouth = new Date().getMonth();
  61. const _len = year - 2015;
  62. const years = this.data.years;
  63. for (let i = 0; i <= _len; i++) {
  64. years.push(2015 + i + '年')
  65. }
  66. years.push('至今');
  67. end_time[0] = years.length - 2;
  68. end_time[1] = mouth;
  69. this.setData({
  70. years,
  71. }, _ => {
  72. this.pushMonths(end_time);
  73. })
  74. },
  75. pushMonths(end_time) {
  76. // const end_time = this.data.end_time;
  77. const mouth = new Date().getMonth() + 1;
  78. const months = [];
  79. const _len = this.data.years.length;
  80. if (this.data.years[end_time[0]] === '至今') {
  81. this.setData({
  82. months: []
  83. }, _ => {
  84. this.setData({
  85. end_time
  86. })
  87. })
  88. return
  89. }
  90. if (end_time[0] === _len - 2) {
  91. for (let i = 0; i < mouth; i++) {
  92. months.push(i + 1)
  93. }
  94. this.setData({
  95. months: months.map(formatNumber)
  96. }, _ => {
  97. this.setData({
  98. end_time
  99. })
  100. })
  101. return
  102. }
  103. this.setData({
  104. months: ['01', '02', '03', '04', '05', '06', '07', '08', '09', '10', '11', '12']
  105. }, _ => {
  106. this.setData({
  107. end_time
  108. })
  109. })
  110. },
  111. showEndDate() {
  112. this.setData({
  113. pick_view: false
  114. })
  115. },
  116. endDateCancel() {
  117. this.setData({
  118. pick_view: true
  119. })
  120. },
  121. endDateSure() {
  122. if (this.data.touch_end) {
  123. const years = this.data.years;
  124. const months = this.data.months;
  125. console.log(years)
  126. console.log(end_time)
  127. if (end_time[0] === years.length - 1) {
  128. this.setData({
  129. endDate: years[years.length - 1],
  130. pick_view: true,
  131. })
  132. } else {
  133. this.setData({
  134. endDate: `${years[end_time[0]]}${Number(months[end_time[1]])}月`,
  135. pick_view: true,
  136. })
  137. }
  138. }
  139. },
  140. catchtap() {
  141. },
  142. touchEnd() {
  143. this.setData({
  144. touch_end: true
  145. })
  146. },
  147. touchStart() {
  148. this.setData({
  149. touch_end: false
  150. })
  151. },
  152. //入职时间
  153. startDateChange(e) {
  154. this.setData({
  155. startDate: formateYM(e.detail.value)
  156. })
  157. },
  158. //离职时间
  159. endDateChange(e) {
  160. console.log(e);
  161. end_time = e.detail.value;
  162. if (end_time[1] > this.data.months.length - 1) {
  163. end_time[1] = this.data.months.length - 1
  164. }
  165. if (end_time[1] < 0) {
  166. end_time[1] = 0
  167. }
  168. // this.setData({
  169. // end_time: end_time,
  170. // })
  171. this.pushMonths(end_time);
  172. // this.setData({
  173. // endDate: formateYM(e.detail.value)
  174. // })
  175. },
  176. //公司名称
  177. changeComName(e) {
  178. this.setData({
  179. comName: e.detail.value.excludeSpecial().excludeSpace()
  180. })
  181. },
  182. //工作职位
  183. changeJobName(e) {
  184. this.setData({
  185. jobName: e.detail.value.excludeSpecial().excludeSpace()
  186. })
  187. },
  188. //验证
  189. check() {
  190. let {
  191. comName,
  192. jobName,
  193. startDate,
  194. endDate
  195. } = this.data
  196. if (comName == "") {
  197. showToast('请填写公司名称')
  198. return false
  199. }
  200. if (jobName == "") {
  201. showToast("请填写职位")
  202. return false
  203. }
  204. if (startDate == '请选择入职时间') {
  205. showToast("请选择入职时间")
  206. return false
  207. }
  208. if (endDate == '请选择离职时间') {
  209. showToast("请选择离职时间")
  210. return false
  211. }
  212. return true
  213. },
  214. submit() {
  215. let flag = this.check()
  216. if (!flag) {
  217. return
  218. }
  219. let {
  220. comName,
  221. jobName,
  222. hpUserResumeId,
  223. hpUserExpId,
  224. startDate,
  225. endDate
  226. } = this.data
  227. let paramsObj = {
  228. resumeId: hpUserResumeId,
  229. workCompany: comName,
  230. workPosition: jobName,
  231. workStartDate: startDate,
  232. workEndDate: endDate,
  233. workExperienceId: hpUserExpId,
  234. user_id: app.globalData.userId,
  235. user_token: app.globalData.userToken,
  236. member_id: app.globalData.memberId
  237. }
  238. Object.assign(paramsObj);
  239. resumeExp(paramsObj).then(data => {
  240. console.log(data)
  241. showToast('保存成功', 'success')
  242. wx.navigateBack()
  243. })
  244. },
  245. })