index.js 3.8 KB

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