index.js 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  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. checkPhone
  13. } from '../../services/wx.js'
  14. var app = getApp()
  15. Page({
  16. data: {
  17. imgServerUrl: imgServerUrl,
  18. userInfo: {},
  19. noPhone:true,
  20. canIUse: wx.canIUse('button.open-type.getUserInfo'),
  21. },
  22. onShow: function() {
  23. if (app.globalData.userInfo) {
  24. console.log('有info===', app.globalData)
  25. this.setData({
  26. userInfo: app.globalData.userInfo
  27. })
  28. } else if (this.data.canIUse) {
  29. // 由于 getUserInfo 是网络请求,可能会在 Page.onLoad 之后才返回
  30. // 所以此处加入 callback 以防止这种情况
  31. app.userInfoReadyCallback = res => {
  32. console.log('userInfoReadyCallback===', app.globalData)
  33. this.setData({
  34. userInfo: app.globalData.userInfo
  35. })
  36. }
  37. } else {
  38. // 在没有 open-type=getUserInfo 版本的兼容处理
  39. wx.getUserInfo({
  40. success: res => {
  41. app.globalData.userInfo = res.userInfo
  42. console.log('兼容处理===', app.globalData)
  43. this.setData({
  44. userInfo: useapp.globalData.userInforInfo
  45. })
  46. }
  47. })
  48. }
  49. this.fetchData();
  50. this.getUserResume();
  51. if (this.data.noPhone){
  52. //检查手机号
  53. checkPhone({
  54. user_id: app.globalData.userId,
  55. user_token: app.globalData.userToken
  56. }).then(data => {
  57. console.log("hh")
  58. })
  59. }
  60. },
  61. onLoad: function (options) {
  62. this.setData({
  63. phone: updataStorageData("phone")
  64. })
  65. },
  66. //获取用户简历详情
  67. getUserResume() {
  68. let paramsObj = {
  69. user_id: app.globalData.userId,
  70. user_token: app.globalData.userToken
  71. }
  72. Object.assign(paramsObj);
  73. getResume(paramsObj).then(data => {
  74. if (data.data.userResume) {
  75. this.setData({
  76. hpUserResumeId: data.data.userResume.id,
  77. userResume: data.data.userResume
  78. })
  79. }
  80. })
  81. },
  82. //获取用户认证状态
  83. fetchData() {
  84. let paramsObj = {
  85. user_id: app.globalData.userId,
  86. user_token: app.globalData.userToken
  87. }
  88. Object.assign(paramsObj);
  89. getCenterInfo(paramsObj).then(data => {
  90. let {
  91. approveStatus
  92. } = data.data
  93. this.setData({
  94. approveStatus, // 认证状态(0:未认证 1:等待认证 2:未通过 3:已认证) ,
  95. })
  96. })
  97. },
  98. // 简历
  99. tojianli() {
  100. if (this.data.hpUserResumeId) {
  101. wx.navigateTo({
  102. url: '../jianli/index?hpUserResumeId=' + this.data.hpUserResumeId,
  103. })
  104. } else {
  105. wx.navigateTo({
  106. url: '../user-info/user-info',
  107. })
  108. }
  109. },
  110. //去认证页面
  111. toAuth() {
  112. let approveState = this.data.approveStatus
  113. console.log(approveState)
  114. if (approveState == 0) {
  115. //身份认证
  116. wx.navigateTo({
  117. url: '../identification/index',
  118. })
  119. } else if (approveState == 3) {
  120. //个人信息页面
  121. wx.navigateTo({
  122. url: '../user-form/index',
  123. })
  124. } else if (approveState == 2) {
  125. //认证不通过
  126. wx.navigateTo({
  127. url: '../result/index?type=auth&status=0',
  128. })
  129. } else if (approveState == 1) {
  130. //待审核
  131. wx.navigateTo({
  132. url: '../result/index?type=auth&status=2',
  133. })
  134. }
  135. },
  136. apply(){
  137. //我的申请
  138. wx.navigateTo({
  139. url: '../apply-list/index',
  140. })
  141. },
  142. collection(){
  143. //我的收藏
  144. wx.navigateTo({
  145. url: '../collection-list/index',
  146. })
  147. },
  148. interview(){
  149. //面试邀请
  150. wx.navigateTo({
  151. url: '../interview/index',
  152. })
  153. },
  154. setup(){
  155. //设置
  156. wx.navigateTo({
  157. url: '../set/index',
  158. })
  159. }
  160. })