index.js 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411
  1. import {
  2. imgServerUrl
  3. } from '../../config/config.js'
  4. import {
  5. getCenterInfo,
  6. getResume,
  7. getMoneyAccountDetail,
  8. myPoint
  9. } from '../../services/index.js'
  10. import {
  11. showToast
  12. } from '../../utils/tips.js'
  13. var app = getApp()
  14. Page({
  15. data: {
  16. imgServerUrl: imgServerUrl,
  17. userInfo: {},
  18. noPhone: true,
  19. canIUse: wx.canIUse('button.open-type.getUserInfo'),
  20. percent: 0,
  21. userId: '',
  22. memberId: '',
  23. userToken: '',
  24. isLogin: false, //默认:未登录
  25. approveStatus: 0,
  26. hpMember: {},
  27. userResume: {},
  28. hpUserResumeId: '',
  29. visible: false,
  30. message_title: '薪资查询',
  31. actions: [{
  32. name: '稍后再说',
  33. color: '#327AE1',
  34. },
  35. {
  36. name: '立即认证',
  37. color: '#327AE1',
  38. fontWeight: 500
  39. },
  40. ],
  41. },
  42. onLoad: function (options) {
  43. },
  44. onShow: function () {
  45. //获取用户user_id和member_id,判断是否处于登录态
  46. var userId = wx.getStorageSync("user_id");
  47. var userToken = wx.getStorageSync("user_token");
  48. var memberId = wx.getStorageSync("member_id");
  49. var userInfo = wx.getStorageSync("userInfo");
  50. var hpMember = wx.getStorageSync('hpMember');
  51. var phone = wx.getStorageSync("phone");
  52. this.setData({
  53. hpUserResumeId: '',
  54. userResume: {},
  55. percent: 0
  56. })
  57. var isLogin = false;
  58. if (userId && memberId) {
  59. isLogin = true;
  60. //必传参数放于app全局变量内
  61. app.globalData.userId = userId;
  62. app.globalData.userToken = userToken;
  63. app.globalData.memberId = memberId;
  64. if (userInfo) {
  65. app.globalData.userInfo = userInfo;
  66. }
  67. this.start();
  68. }
  69. this.setData({
  70. avatar: (app.globalData.userInfo && app.globalData.userInfo.avatarUrl) ? app.globalData.userInfo.avatarUrl : `${imgServerUrl}/images/avatar/man.png`,
  71. isLogin: isLogin,
  72. userInfo: userInfo,
  73. hpMember: hpMember,
  74. phone: phone
  75. })
  76. },
  77. /**
  78. * 用户点击右上角分享
  79. */
  80. onShareAppMessage: function () {
  81. },
  82. start() {
  83. this.fetchData();
  84. this.getUserResume();
  85. // this.getWallt();
  86. this.getSign();
  87. },
  88. // 获取钱包信息
  89. getWallt() {
  90. getMoneyAccountDetail({
  91. user_id: wx.getStorageSync('user_id'),
  92. user_token: wx.getStorageSync('user_token'),
  93. member_id: wx.getStorageSync('member_id'),
  94. }).then(res => {
  95. if (res.errcode === 0) {
  96. this.setData({
  97. moneyBalance: res.data.MpMemberAccountAPI.moneyBalance.toFixed(2) + ' 元'
  98. })
  99. }
  100. })
  101. },
  102. // 获取积分信息
  103. getSign() {
  104. myPoint({
  105. user_id: wx.getStorageSync('user_id'),
  106. user_token: wx.getStorageSync('user_token'),
  107. member_id: wx.getStorageSync('member_id'),
  108. }).then(res => {
  109. if (res.errcode === 0) {
  110. this.setData({
  111. pointsBalance: res.data.mpMemberAccount.pointsBalance + ' 分',
  112. moneyBalance: res.data.mpMemberAccount.moneyBalance.toFixed(2) + ' 元'
  113. })
  114. }
  115. })
  116. },
  117. //获取用户简历详情
  118. getUserResume() {
  119. let paramsObj = {
  120. user_id: app.globalData.userId,
  121. user_token: app.globalData.userToken,
  122. member_id: app.globalData.memberId
  123. }
  124. Object.assign(paramsObj);
  125. getResume(paramsObj).then(data => {
  126. if (data.data.userResume) {
  127. var percent = 0;
  128. if (data.data.userResume.phone) {
  129. percent = 40 + percent;
  130. }
  131. if (data.data.userResume.expectationPosition) {
  132. percent = 40 + percent;
  133. }
  134. if (data.data.userResume.hpResumeWorkExperienceList.length > 0) {
  135. percent = 20 + percent;
  136. }
  137. this.setData({
  138. hpUserResumeId: data.data.userResume.id,
  139. userResume: data.data.userResume,
  140. percent: percent.toString()
  141. // percent: '25'
  142. })
  143. }
  144. })
  145. },
  146. //获取用户认证状态
  147. fetchData() {
  148. let paramsObj = {
  149. user_id: app.globalData.userId,
  150. user_token: app.globalData.userToken,
  151. member_id: app.globalData.memberId
  152. }
  153. Object.assign(paramsObj);
  154. getCenterInfo(paramsObj).then(data => {
  155. let {
  156. approveStatus
  157. } = data.data
  158. this.setData({
  159. approveStatus, // 认证状态(0:未认证 1:等待认证 2:未通过 3:已认证) ,
  160. })
  161. })
  162. },
  163. // 去首页
  164. toPosition() {
  165. wx.switchTab({
  166. url: '/pages/index/index',
  167. })
  168. },
  169. // 简历
  170. tojianli() {
  171. if (!this.data.isLogin) {
  172. wx.navigateTo({
  173. url: '/pages/login/login',
  174. })
  175. return;
  176. }
  177. if (this.data.hpUserResumeId) {
  178. wx.navigateTo({
  179. url: '../jianli/index?hpUserResumeId=' + this.data.hpUserResumeId,
  180. })
  181. } else {
  182. wx.navigateTo({
  183. url: '../user-info/user-info',
  184. })
  185. }
  186. },
  187. //去认证页面
  188. toAuth() {
  189. if (!this.data.isLogin) {
  190. wx.navigateTo({
  191. url: '/pages/login/login',
  192. })
  193. return;
  194. }
  195. let approveState = this.data.approveStatus
  196. if (approveState == 0) {
  197. //身份认证
  198. wx.navigateTo({
  199. url: '../identification/index',
  200. })
  201. } else if (approveState == 3) {
  202. showToast("已认证")
  203. //个人信息页面
  204. // wx.navigateTo({
  205. // url: '../user-form/index',
  206. // })
  207. } else if (approveState == 2) {
  208. //认证不通过
  209. wx.navigateTo({
  210. url: '../result/index?type=auth&status=0',
  211. })
  212. } else if (approveState == 1) {
  213. //待审核
  214. wx.navigateTo({
  215. url: '../result/index?type=auth&status=2',
  216. })
  217. }
  218. },
  219. checkStatus() {
  220. let approveState = this.data.approveStatus
  221. if (!wx.getStorageSync("user_id") || !wx.getStorageSync("user_token") || !wx.getStorageSync("member_id")) {
  222. wx.showModal({
  223. title: '提示',
  224. content: '你还未登录,请先登录小程序',
  225. showCancel: false,
  226. success: res => {
  227. if (res.confirm) {
  228. // wx.navigateBack({
  229. // delta: 1,
  230. // })
  231. wx.navigateTo({
  232. url: '/pages/login/login',
  233. })
  234. }
  235. }
  236. })
  237. return false;
  238. }
  239. if (approveState == 0) {
  240. wx.showModal({
  241. title: '提示',
  242. content: '你还未认证,请先进行身份认证',
  243. showCancel: false,
  244. success: res => {
  245. if (res.confirm) {
  246. //身份认证
  247. wx.navigateTo({
  248. url: '../identification/index',
  249. })
  250. }
  251. }
  252. })
  253. return false
  254. } else if (approveState == 2) {
  255. //认证不通过
  256. wx.navigateTo({
  257. url: '../result/index?type=auth&status=0',
  258. })
  259. return false;
  260. } else if (approveState == 1) {
  261. //待审核
  262. wx.navigateTo({
  263. url: '../result/index?type=auth&status=2',
  264. })
  265. return false
  266. }
  267. return true
  268. },
  269. apply() {
  270. if (!this.data.isLogin) {
  271. wx.navigateTo({
  272. url: '/pages/login/login',
  273. })
  274. return;
  275. }
  276. //我的申请
  277. wx.navigateTo({
  278. url: '../apply-list/index',
  279. })
  280. },
  281. collection() {
  282. if (!this.data.isLogin) {
  283. wx.navigateTo({
  284. url: '/pages/login/login',
  285. })
  286. return;
  287. }
  288. //我的收藏
  289. wx.navigateTo({
  290. url: '../collection-list/index',
  291. })
  292. },
  293. interview() {
  294. if (!this.data.isLogin) {
  295. wx.navigateTo({
  296. url: '/pages/login/login',
  297. })
  298. return;
  299. }
  300. //面试邀请
  301. wx.navigateTo({
  302. url: '../interview/index',
  303. })
  304. },
  305. setup() {
  306. if (!this.data.isLogin) {
  307. wx.navigateTo({
  308. url: '/pages/login/login',
  309. })
  310. return;
  311. }
  312. //设置
  313. wx.navigateTo({
  314. url: '../setting/pages/set/index',
  315. })
  316. },
  317. toPayRoll(e) {
  318. if (!this.data.isLogin) {
  319. wx.showModal({
  320. title: '提示',
  321. content: '你还未登录,请先登录小程序',
  322. showCancel: false,
  323. success: res => {
  324. if (res.confirm) {
  325. // wx.navigateBack({
  326. // delta: 1,
  327. // })
  328. wx.navigateTo({
  329. url: '/pages/login/login',
  330. })
  331. }
  332. }
  333. })
  334. return false;
  335. }
  336. if (this.data.approveStatus === 0) {
  337. this.setData({
  338. message_title: e.currentTarget.dataset.title,
  339. visible: true
  340. })
  341. return
  342. }
  343. const {
  344. url,
  345. title
  346. } = e.currentTarget.dataset;
  347. if (wx.getStorageSync('user_id') && wx.getStorageSync('member_id') && this.checkStatus()) {
  348. wx.navigateTo({
  349. url: `/pages/check-iphone/index?phone=${this.data.phone}&&title=${title}&&url=${url}`
  350. })
  351. }
  352. },
  353. toLogin() {
  354. wx.navigateTo({
  355. url: '/pages/login/login',
  356. })
  357. },
  358. toDetail(e) {
  359. const {
  360. url
  361. } = e.currentTarget.dataset;
  362. if (wx.getStorageSync('user_id') && wx.getStorageSync('member_id')) {
  363. wx.navigateTo({
  364. url,
  365. fail: () => {
  366. wx.switchTab({
  367. url,
  368. })
  369. }
  370. })
  371. } else {
  372. wx.showModal({
  373. title: '提示',
  374. content: '你还未登录,请先登录小程序',
  375. showCancel: false,
  376. success: res => {
  377. if (res.confirm) {
  378. // wx.navigateBack({
  379. // delta: 1,
  380. // })
  381. wx.navigateTo({
  382. url: '/pages/login/login',
  383. })
  384. }
  385. }
  386. })
  387. }
  388. },
  389. handel(e) {
  390. if (!this.data.isLogin) {
  391. wx.navigateTo({
  392. url: '/pages/login/login',
  393. })
  394. return;
  395. }
  396. const {
  397. index
  398. } = e.detail;
  399. this.setData({
  400. visible: false
  401. })
  402. if (index === 1) {
  403. this.toAuth();
  404. }
  405. }
  406. })