index.js 3.2 KB

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