index.js 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238
  1. import {
  2. resumeIntent} from '../../services/index.js'
  3. import {
  4. imgServerUrl
  5. } from '../../config/config.js'
  6. import {
  7. showToast
  8. } from '../../utils/tips.js'
  9. let app = getApp()
  10. Page({
  11. data: {
  12. imgServerUrl: imgServerUrl,
  13. salaryList: [{
  14. "expectationSalary": null,
  15. "hightNum": '请选择'
  16. },
  17. {
  18. "expectationSalary": -1,
  19. "hightNum": '不限'
  20. },
  21. {
  22. "expectationSalary": 0,
  23. "hightNum": '1000~2000'
  24. },
  25. {
  26. "expectationSalary": 1,
  27. "hightNum": '2001~3000'
  28. },
  29. {
  30. "expectationSalary": 2,
  31. "hightNum": '3001~4000'
  32. },
  33. {
  34. "expectationSalary": 3,
  35. "hightNum": '4001~5000'
  36. },
  37. {
  38. "expectationSalary": 4,
  39. "hightNum": '5001~6000'
  40. },
  41. {
  42. "expectationSalary": 5,
  43. "hightNum": '6001~7000'
  44. },
  45. {
  46. "expectationSalary": 6,
  47. "hightNum": '7001~8000'
  48. },
  49. {
  50. "expectationSalary": 7,
  51. "hightNum": '8001~9000'
  52. },
  53. {
  54. "expectationSalary": 8,
  55. "hightNum": '9001~10000'
  56. }, {
  57. "expectationSalary": 9,
  58. "hightNum": '10000以上'
  59. }
  60. ],
  61. expectationPosition: [{ name: "普工" }, { name: "客服" }, { name: "销售" }, { name: "服务员" }, { name: "物流仓储" }, { name: "司机" }, { name: "才艺技能" }, { name: "文员助理" }, { name: "快递配送" }, { name: "促销导购" }, { name: "展会演出" }, { name: "家教培训" }, { name: "模特" }, { name: "贸易采购" }, { name: "厨师" }, { name: "编辑" }, { name: "线上推广" }, { name: "设计" }, { name: "技工" }, { name: "保洁" }, { name: "其它" }],
  62. region: {
  63. code: [],
  64. value: []
  65. }, //省市区
  66. name: '',
  67. expectationPositionIndex: 0,
  68. salaryIndex: 0,
  69. hpUserIntentionId: '',
  70. hpUserResumeId: '',
  71. disabled: false,
  72. cover: true,
  73. position: true,
  74. address: true,
  75. salary: true
  76. },
  77. onLoad: function (options) {
  78. let {
  79. hpUserResumeId
  80. } = options
  81. this.setData({
  82. hpUserResumeId: hpUserResumeId
  83. })
  84. if (hpUserResumeId) {
  85. let userResume = wx.getStorageSync('userResume')
  86. this.data.region.code = this.data.region.code.concat(userResume.expectationProvinceId);
  87. this.data.region.code = this.data.region.code.concat(userResume.expectationCityId);
  88. this.data.region.code = this.data.region.code.concat(userResume.expectationCountryId);
  89. const expectationPosition = this.data.expectationPosition;
  90. let arr = userResume.expectationAddress.split("-");
  91. for (let i = 0; i < arr.length; i++) {
  92. this.data.region.value = this.data.region.value.concat(arr[i]);
  93. }
  94. let expectationArray = userResume.expectationPosition;
  95. let lengthSalary = this.data.salaryList.length;
  96. let salaryIndex;
  97. for (let i = 0; i < lengthSalary; i++) {
  98. if (userResume.expectationSalary == this.data.salaryList[i].hightNum) {
  99. salaryIndex = i;
  100. }
  101. }
  102. expectationArray.split(',').forEach(value => {
  103. expectationPosition[value].active = true
  104. })
  105. if (userResume.id) {
  106. this.setData({
  107. hpUserResumeId: userResume.id,
  108. expectationPositionIndex: expectationArray,
  109. salaryIndex: salaryIndex,
  110. region: this.data.region,
  111. expectationPosition
  112. }, _ => {
  113. this.check()
  114. })
  115. }
  116. }
  117. },
  118. changeCover(e) {
  119. const { type } = e.currentTarget.dataset;
  120. if (type) {
  121. this.setData({
  122. [type]: !this.data[type]
  123. })
  124. } else {
  125. this.setData({
  126. position: true,
  127. address: true,
  128. salary: true
  129. })
  130. }
  131. this.setData({
  132. cover: !this.data.cover
  133. })
  134. },
  135. //改变薪资水平
  136. bindSalaryChange(e) {
  137. this.setData({
  138. salaryIndex: e.detail.value
  139. }, _ => {
  140. this.check()
  141. })
  142. },
  143. //改变期望岗位
  144. changeName(e) {
  145. const { index } = e.currentTarget.dataset;
  146. let expectationPositionIndex = this.data.expectationPositionIndex.split(',');
  147. const expectationPosition = this.data.expectationPosition;
  148. if (expectationPosition[index].active) {
  149. expectationPosition[index].active = false;
  150. const _index = expectationPositionIndex.findIndex(value => {
  151. return Number(value) === index;
  152. })
  153. expectationPositionIndex.splice(_index, 1)
  154. } else {
  155. expectationPosition[index].active = true;
  156. expectationPositionIndex.push(index)
  157. }
  158. this.setData({
  159. expectationPositionIndex: expectationPositionIndex.join(','),
  160. expectationPosition
  161. }, _ => {
  162. this.check()
  163. })
  164. },
  165. //改变期望地点
  166. bindRegionChange() {
  167. // console.log('picker发送选择改变,携带值为', e.detail)
  168. // this.data.region.code = e.detail.code;
  169. // this.data.region.value = e.detail.value;
  170. // this.setData({
  171. // region: this.data.region
  172. // }, _ => {
  173. // this.check()
  174. // })
  175. wx.navigateTo({
  176. url: `/pages/choose-city/index?title=期望地点&&region=${JSON.stringify(this.data.region)}`,
  177. })
  178. },
  179. //提交
  180. submit() {
  181. let flag = this.check(true)
  182. if (!flag) {
  183. return
  184. }
  185. let {
  186. expectationPositionIndex,
  187. salaryIndex,
  188. region,
  189. salaryList
  190. } = this.data
  191. let paramsObj = {
  192. expectationPosition: expectationPositionIndex,
  193. expectationSalary: salaryList[salaryIndex].expectationSalary,
  194. expectationProvinceId: region.code[0],
  195. expectationCityId: region.code[1],
  196. expectationCountryId: region.code[2],
  197. expectationAddress: region.value[0] + '-' + region.value[1] + '-' + region.value[2],
  198. user_id: app.globalData.userId,
  199. user_token: app.globalData.userToken,
  200. member_id: app.globalData.memberId
  201. }
  202. Object.assign(paramsObj);
  203. resumeIntent(paramsObj).then(data => {
  204. showToast('保存成功', 'success')
  205. wx.navigateBack()
  206. })
  207. },
  208. //验证
  209. check(status = false) {
  210. let {
  211. region,
  212. salaryList,
  213. salaryIndex
  214. } = this.data;
  215. this.setData({
  216. disabled: false
  217. })
  218. if (salaryList[salaryIndex].expectationSalary == null) {
  219. status && showToast('请选择期望薪资');
  220. return false
  221. }
  222. if (region.value.length == 0) {
  223. status && showToast('请选择期望地点');
  224. return false
  225. }
  226. this.setData({
  227. disabled: true
  228. })
  229. return true
  230. }
  231. })