index.js 6.7 KB

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