user-info.js 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  1. import {
  2. imgServerUrl,
  3. imgServerUrl_new
  4. } from '../../config/config.js'
  5. import {
  6. resumeBase,
  7. eduList,
  8. groupApply,
  9. positionApply
  10. } from '../../services/index.js'
  11. import {
  12. uploadImg
  13. } from '../../services/uploadFile.js'
  14. import {
  15. showToast
  16. } from '../../utils/tips.js'
  17. import {
  18. argusToTimestamp
  19. } from '../../utils/util.js'
  20. import {
  21. updataStorageData
  22. } from '../../utils/storage.js'
  23. const app = getApp();
  24. Page({
  25. data: {
  26. imgServerUrl: imgServerUrl,
  27. imgServerUrl_new: imgServerUrl_new,
  28. sex: ["男", "女"],
  29. sex_index: 0,
  30. eduList: ["请选择", "小学", "中学", "高中", "大专", "本科", "研究生", "博士", "博士后"],
  31. eduIndex: 1,
  32. avatar: '',
  33. headImg: '',
  34. name: '',
  35. year: '',
  36. iphone: '',
  37. hpUserResumeId: null
  38. },
  39. onLoad: function(options) {
  40. let {
  41. hpUserResumeId = null, progress = 0
  42. } = options
  43. this.setData({
  44. hpUserResumeId
  45. })
  46. this.setData({
  47. avatar: (app.globalData.userInfo && app.globalData.userInfo.avatarUrl) ? app.globalData.userInfo.avatarUrl : `${imgServerUrl}/images/avatar/man.png`,
  48. endDate: new Date().getFullYear(),
  49. year: '1993'
  50. })
  51. let phone = updataStorageData('phone')
  52. if (phone) {
  53. this.setData({
  54. iphone: phone
  55. })
  56. }
  57. if (hpUserResumeId) {
  58. let userResume = wx.getStorageSync('userResume')
  59. if (userResume.id) {
  60. this.setData({
  61. hpUserResumeId: userResume.id,
  62. avatar: userResume.headImg,
  63. name: userResume.realName,
  64. sex_index: userResume.gender == 1 ? 0 : 1,
  65. year: userResume.birthYear,
  66. iphone: userResume.phone,
  67. eduIndex: userResume.highestQualification ? Number(userResume.highestQualification) : 0
  68. })
  69. }
  70. }
  71. },
  72. //改变学历
  73. bindPickerChange(e) {
  74. console.log(e)
  75. let {
  76. value
  77. } = e.detail
  78. this.setData({
  79. eduIndex: value
  80. })
  81. },
  82. //改变性别
  83. bindSexChange(e) {
  84. console.log(e)
  85. let {
  86. value
  87. } = e.detail
  88. this.setData({
  89. sex_index: value
  90. })
  91. },
  92. //姓名改变
  93. changeName(e) {
  94. console.log(e)
  95. let {
  96. value
  97. } = e.detail
  98. this.setData({
  99. name: value.excludeSpecial().excludeSpace()
  100. })
  101. },
  102. //改变出生年月
  103. changeYear(e) {
  104. console.log(e)
  105. let {
  106. value
  107. } = e.detail
  108. this.setData({
  109. year: value
  110. })
  111. },
  112. //手机号改变
  113. changeIphone(e) {
  114. console.log(e)
  115. let {
  116. value
  117. } = e.detail
  118. this.setData({
  119. iphone: value.excludeSpecial().excludeSpace()
  120. })
  121. },
  122. //上传图片
  123. changeImg() {
  124. var up_type = '0';
  125. uploadImg(up_type).then(res => {
  126. let image = res.data.imgUrl
  127. this.setData({
  128. avatar: `${imgServerUrl_new}` + image,
  129. headImg: image
  130. })
  131. })
  132. },
  133. //验证
  134. check() {
  135. let {
  136. avatar,
  137. name,
  138. year,
  139. iphone
  140. } = this.data
  141. if (avatar == (imgServerUrl + "/images/avatar/man.png")) {
  142. showToast('请上传头像');
  143. return false;
  144. }
  145. if (name == "") {
  146. showToast('请输入用户名');
  147. return false;
  148. }
  149. if (this.data.iphone == "" || this.data.iphone.length != 11) {
  150. showToast('请输入11位手机号');
  151. return false;
  152. }
  153. return true
  154. },
  155. //保存
  156. submit() {
  157. let flag = this.check()
  158. if (!flag) {
  159. return
  160. }
  161. let {
  162. sex_index,
  163. eduIndex,
  164. avatar,
  165. headImg,
  166. name,
  167. year,
  168. iphone,
  169. hpUserResumeId
  170. } = this.data
  171. let paramsObj = {
  172. highestQualification: eduIndex,
  173. birthYear: year,
  174. gender: sex_index == 0 ? 1 : 2,
  175. realName: name,
  176. phone: iphone,
  177. avatar: headImg,
  178. user_id: app.globalData.userId,
  179. user_token: app.globalData.userToken
  180. }
  181. Object.assign(paramsObj);
  182. resumeBase(paramsObj).then(data => {
  183. showToast('保存成功', 'success');
  184. wx.setStorageSync("userResume", data.data.userResume);
  185. wx.navigateBack();
  186. })
  187. },
  188. onError(err) {
  189. app.aldstat.sendEvent('报错', {
  190. 'err': err
  191. });
  192. },
  193. })