index.js 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244
  1. import {
  2. imgServerUrl
  3. } from '../../config/config.js'
  4. import {
  5. getCenterInfo,
  6. getResume
  7. } from '../../services/index.js'
  8. import {
  9. updataStorageData
  10. } from '../../utils/storage.js'
  11. import {
  12. showToast
  13. } from '../../utils/tips.js'
  14. import {
  15. checkPhone
  16. } from '../../services/wx.js'
  17. var app = getApp()
  18. Page({
  19. data: {
  20. imgServerUrl: imgServerUrl,
  21. userInfo: {},
  22. noPhone: true,
  23. canIUse: wx.canIUse('button.open-type.getUserInfo'),
  24. percent: 0,
  25. userId: '',
  26. memberId: '',
  27. userToken: '',
  28. isLogin: false, //默认:未登录
  29. approveStatus: 0,
  30. },
  31. onLoad: function(options) {
  32. //获取用户user_id和member_id,判断是否处于登录态
  33. var userId = wx.getStorageSync("user_id");
  34. var userToken = wx.getStorageSync("user_token");
  35. var memberId = wx.getStorageSync("member_id");
  36. var isLogin = false;
  37. if (userId && memberId) {
  38. isLogin = true;
  39. } else {
  40. wx.navigateTo({
  41. url: '/pages/login/login',
  42. })
  43. }
  44. this.setData({
  45. phone: updataStorageData("phone"),
  46. isLogin: isLogin,
  47. userId: userId,
  48. memberId: memberId,
  49. userToken: userToken
  50. })
  51. },
  52. onShow: function() {
  53. var userId = wx.getStorageSync("user_id");
  54. var userToken = wx.getStorageSync("user_token");
  55. var memberId = wx.getStorageSync("member_id");
  56. var userInfo = wx.getStorageSync("userInfo");
  57. var isLogin = false;
  58. if (userId && memberId) {
  59. isLogin = true;
  60. this.setData({
  61. isLogin: isLogin,
  62. userId: userId,
  63. memberId: memberId,
  64. userToken: userToken
  65. })
  66. if (userInfo) {
  67. console.log('有info===', userInfo)
  68. this.setData({
  69. userInfo: userInfo
  70. })
  71. this.start();
  72. }
  73. app.globalData.userId = userId;
  74. app.globalData.userToken = userToken;
  75. app.globalData.memberId = memberId;
  76. }
  77. },
  78. start() {
  79. this.fetchData();
  80. this.getUserResume();
  81. },
  82. //获取用户简历详情
  83. getUserResume() {
  84. let paramsObj = {
  85. user_id: this.data.userId,
  86. user_token: this.data.userToken,
  87. member_id: this.data.memberId
  88. }
  89. Object.assign(paramsObj);
  90. getResume(paramsObj).then(data => {
  91. if (data.data.userResume) {
  92. var percent = 0;
  93. if (data.data.userResume.phone) {
  94. percent = 40 + percent;
  95. }
  96. if (data.data.userResume.expectationPosition) {
  97. percent = 30 + percent;
  98. }
  99. if (data.data.userResume.hpResumeWorkExperienceList.length > 0) {
  100. percent = 30 + percent;
  101. }
  102. this.setData({
  103. hpUserResumeId: data.data.userResume.id,
  104. userResume: data.data.userResume,
  105. percent: percent
  106. })
  107. }
  108. })
  109. },
  110. //获取用户认证状态
  111. fetchData() {
  112. let paramsObj = {
  113. user_id: this.data.userId,
  114. user_token: this.data.userToken,
  115. member_id: this.data.memberId
  116. }
  117. Object.assign(paramsObj);
  118. getCenterInfo(paramsObj).then(data => {
  119. let {
  120. approveStatus
  121. } = data.data
  122. this.setData({
  123. approveStatus, // 认证状态(0:未认证 1:等待认证 2:未通过 3:已认证) ,
  124. })
  125. })
  126. },
  127. // 简历
  128. tojianli() {
  129. if (!this.data.isLogin) {
  130. wx.navigateTo({
  131. url: '/pages/login/login',
  132. })
  133. return;
  134. }
  135. if (this.data.hpUserResumeId) {
  136. wx.navigateTo({
  137. url: '../jianli/index?hpUserResumeId=' + this.data.hpUserResumeId,
  138. })
  139. } else {
  140. wx.navigateTo({
  141. url: '../user-info/user-info',
  142. })
  143. }
  144. },
  145. //去认证页面
  146. toAuth() {
  147. if (!this.data.isLogin) {
  148. wx.navigateTo({
  149. url: '/pages/login/login',
  150. })
  151. return;
  152. }
  153. let approveState = this.data.approveStatus
  154. console.log(approveState)
  155. if (approveState == 0) {
  156. //身份认证
  157. wx.navigateTo({
  158. url: '../identification/index',
  159. })
  160. } else if (approveState == 3) {
  161. showToast("已认证")
  162. //个人信息页面
  163. // wx.navigateTo({
  164. // url: '../user-form/index',
  165. // })
  166. } else if (approveState == 2) {
  167. //认证不通过
  168. wx.navigateTo({
  169. url: '../result/index?type=auth&status=0',
  170. })
  171. } else if (approveState == 1) {
  172. //待审核
  173. wx.navigateTo({
  174. url: '../result/index?type=auth&status=2',
  175. })
  176. }
  177. },
  178. apply() {
  179. if (!this.data.isLogin) {
  180. wx.navigateTo({
  181. url: '/pages/login/login',
  182. })
  183. return;
  184. }
  185. //我的申请
  186. wx.navigateTo({
  187. url: '../apply-list/index',
  188. })
  189. },
  190. collection() {
  191. if (!this.data.isLogin) {
  192. wx.navigateTo({
  193. url: '/pages/login/login',
  194. })
  195. return;
  196. }
  197. //我的收藏
  198. wx.navigateTo({
  199. url: '../collection-list/index',
  200. })
  201. },
  202. interview() {
  203. if (!this.data.isLogin) {
  204. wx.navigateTo({
  205. url: '/pages/login/login',
  206. })
  207. return;
  208. }
  209. //面试邀请
  210. wx.navigateTo({
  211. url: '../interview/index',
  212. })
  213. },
  214. setup() {
  215. if (!this.data.isLogin) {
  216. wx.navigateTo({
  217. url: '/pages/login/login',
  218. })
  219. return;
  220. }
  221. //设置
  222. wx.navigateTo({
  223. url: '../set/index',
  224. })
  225. },
  226. toPayRoll() {
  227. if (!this.data.isLogin) {
  228. wx.navigateTo({
  229. url: '/pages/login/login',
  230. })
  231. return;
  232. }
  233. wx.navigateTo({
  234. url: '/pages/check-iphone/index?approveState=' + this.data.approveStatus,
  235. })
  236. },
  237. toLogin() {
  238. wx.navigateTo({
  239. url: '/pages/login/login',
  240. })
  241. }
  242. })