| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411 |
- import {
- imgServerUrl
- } from '../../config/config.js'
- import {
- getCenterInfo,
- getResume,
- getMoneyAccountDetail,
- myPoint
- } from '../../services/index.js'
- import {
- showToast
- } from '../../utils/tips.js'
- var app = getApp()
- Page({
- data: {
- imgServerUrl: imgServerUrl,
- userInfo: {},
- noPhone: true,
- canIUse: wx.canIUse('button.open-type.getUserInfo'),
- percent: 0,
- userId: '',
- memberId: '',
- userToken: '',
- isLogin: false, //默认:未登录
- approveStatus: 0,
- hpMember: {},
- userResume: {},
- hpUserResumeId: '',
- visible: false,
- message_title: '薪资查询',
- actions: [{
- name: '稍后再说',
- color: '#327AE1',
- },
- {
- name: '立即认证',
- color: '#327AE1',
- fontWeight: 500
- },
- ],
- },
- onLoad: function (options) {
- },
- onShow: function () {
- //获取用户user_id和member_id,判断是否处于登录态
- var userId = wx.getStorageSync("user_id");
- var userToken = wx.getStorageSync("user_token");
- var memberId = wx.getStorageSync("member_id");
- var userInfo = wx.getStorageSync("userInfo");
- var hpMember = wx.getStorageSync('hpMember');
- var phone = wx.getStorageSync("phone");
- this.setData({
- hpUserResumeId: '',
- userResume: {},
- percent: 0
- })
- var isLogin = false;
- if (userId && memberId) {
- isLogin = true;
- //必传参数放于app全局变量内
- app.globalData.userId = userId;
- app.globalData.userToken = userToken;
- app.globalData.memberId = memberId;
- if (userInfo) {
- app.globalData.userInfo = userInfo;
- }
- this.start();
- }
- this.setData({
- avatar: (app.globalData.userInfo && app.globalData.userInfo.avatarUrl) ? app.globalData.userInfo.avatarUrl : `${imgServerUrl}/images/avatar/man.png`,
- isLogin: isLogin,
- userInfo: userInfo,
- hpMember: hpMember,
- phone: phone
- })
- },
- /**
- * 用户点击右上角分享
- */
- onShareAppMessage: function () {
- },
- start() {
- this.fetchData();
- this.getUserResume();
- // this.getWallt();
- this.getSign();
- },
- // 获取钱包信息
- getWallt() {
- getMoneyAccountDetail({
- user_id: wx.getStorageSync('user_id'),
- user_token: wx.getStorageSync('user_token'),
- member_id: wx.getStorageSync('member_id'),
- }).then(res => {
- if (res.errcode === 0) {
- this.setData({
- moneyBalance: res.data.MpMemberAccountAPI.moneyBalance.toFixed(2) + ' 元'
- })
- }
- })
- },
- // 获取积分信息
- getSign() {
- myPoint({
- user_id: wx.getStorageSync('user_id'),
- user_token: wx.getStorageSync('user_token'),
- member_id: wx.getStorageSync('member_id'),
- }).then(res => {
- if (res.errcode === 0) {
- this.setData({
- pointsBalance: res.data.mpMemberAccount.pointsBalance + ' 分',
- moneyBalance: res.data.mpMemberAccount.moneyBalance.toFixed(2) + ' 元'
- })
- }
- })
- },
- //获取用户简历详情
- getUserResume() {
- let paramsObj = {
- user_id: app.globalData.userId,
- user_token: app.globalData.userToken,
- member_id: app.globalData.memberId
- }
- Object.assign(paramsObj);
- getResume(paramsObj).then(data => {
- if (data.data.userResume) {
- var percent = 0;
- if (data.data.userResume.phone) {
- percent = 40 + percent;
- }
- if (data.data.userResume.expectationPosition) {
- percent = 40 + percent;
- }
- if (data.data.userResume.hpResumeWorkExperienceList.length > 0) {
- percent = 20 + percent;
- }
- this.setData({
- hpUserResumeId: data.data.userResume.id,
- userResume: data.data.userResume,
- percent: percent.toString()
- // percent: '25'
- })
- }
- })
- },
- //获取用户认证状态
- fetchData() {
- let paramsObj = {
- user_id: app.globalData.userId,
- user_token: app.globalData.userToken,
- member_id: app.globalData.memberId
- }
- Object.assign(paramsObj);
- getCenterInfo(paramsObj).then(data => {
- let {
- approveStatus
- } = data.data
- this.setData({
- approveStatus, // 认证状态(0:未认证 1:等待认证 2:未通过 3:已认证) ,
- })
- })
- },
- // 去首页
- toPosition() {
- wx.switchTab({
- url: '/pages/index/index',
- })
- },
- // 简历
- tojianli() {
- if (!this.data.isLogin) {
- wx.navigateTo({
- url: '/pages/login/login',
- })
- return;
- }
- if (this.data.hpUserResumeId) {
- wx.navigateTo({
- url: '../jianli/index?hpUserResumeId=' + this.data.hpUserResumeId,
- })
- } else {
- wx.navigateTo({
- url: '../user-info/user-info',
- })
- }
- },
- //去认证页面
- toAuth() {
- if (!this.data.isLogin) {
- wx.navigateTo({
- url: '/pages/login/login',
- })
- return;
- }
- let approveState = this.data.approveStatus
- if (approveState == 0) {
- //身份认证
- wx.navigateTo({
- url: '../identification/index',
- })
- } else if (approveState == 3) {
- showToast("已认证")
- //个人信息页面
- // wx.navigateTo({
- // url: '../user-form/index',
- // })
- } else if (approveState == 2) {
- //认证不通过
- wx.navigateTo({
- url: '../result/index?type=auth&status=0',
- })
- } else if (approveState == 1) {
- //待审核
- wx.navigateTo({
- url: '../result/index?type=auth&status=2',
- })
- }
- },
- checkStatus() {
- let approveState = this.data.approveStatus
- if (!wx.getStorageSync("user_id") || !wx.getStorageSync("user_token") || !wx.getStorageSync("member_id")) {
- wx.showModal({
- title: '提示',
- content: '你还未登录,请先登录小程序',
- showCancel: false,
- success: res => {
- if (res.confirm) {
- // wx.navigateBack({
- // delta: 1,
- // })
- wx.navigateTo({
- url: '/pages/login/login',
- })
- }
- }
- })
- return false;
- }
- if (approveState == 0) {
- wx.showModal({
- title: '提示',
- content: '你还未认证,请先进行身份认证',
- showCancel: false,
- success: res => {
- if (res.confirm) {
- //身份认证
- wx.navigateTo({
- url: '../identification/index',
- })
- }
- }
- })
- return false
- } else if (approveState == 2) {
- //认证不通过
- wx.navigateTo({
- url: '../result/index?type=auth&status=0',
- })
- return false;
- } else if (approveState == 1) {
- //待审核
- wx.navigateTo({
- url: '../result/index?type=auth&status=2',
- })
- return false
- }
- return true
- },
- apply() {
- if (!this.data.isLogin) {
- wx.navigateTo({
- url: '/pages/login/login',
- })
- return;
- }
- //我的申请
- wx.navigateTo({
- url: '../apply-list/index',
- })
- },
- collection() {
- if (!this.data.isLogin) {
- wx.navigateTo({
- url: '/pages/login/login',
- })
- return;
- }
- //我的收藏
- wx.navigateTo({
- url: '../collection-list/index',
- })
- },
- interview() {
- if (!this.data.isLogin) {
- wx.navigateTo({
- url: '/pages/login/login',
- })
- return;
- }
- //面试邀请
- wx.navigateTo({
- url: '../interview/index',
- })
- },
- setup() {
- if (!this.data.isLogin) {
- wx.navigateTo({
- url: '/pages/login/login',
- })
- return;
- }
- //设置
- wx.navigateTo({
- url: '../setting/pages/set/index',
- })
- },
- toPayRoll(e) {
- if (!this.data.isLogin) {
- wx.showModal({
- title: '提示',
- content: '你还未登录,请先登录小程序',
- showCancel: false,
- success: res => {
- if (res.confirm) {
- // wx.navigateBack({
- // delta: 1,
- // })
- wx.navigateTo({
- url: '/pages/login/login',
- })
- }
- }
- })
- return false;
- }
- if (this.data.approveStatus === 0) {
- this.setData({
- message_title: e.currentTarget.dataset.title,
- visible: true
- })
- return
- }
- const {
- url,
- title
- } = e.currentTarget.dataset;
- if (wx.getStorageSync('user_id') && wx.getStorageSync('member_id') && this.checkStatus()) {
- wx.navigateTo({
- url: `/pages/check-iphone/index?phone=${this.data.phone}&&title=${title}&&url=${url}`
- })
- }
- },
- toLogin() {
- wx.navigateTo({
- url: '/pages/login/login',
- })
- },
- toDetail(e) {
- const {
- url
- } = e.currentTarget.dataset;
- if (wx.getStorageSync('user_id') && wx.getStorageSync('member_id')) {
- wx.navigateTo({
- url,
- fail: () => {
- wx.switchTab({
- url,
- })
- }
- })
- } else {
- wx.showModal({
- title: '提示',
- content: '你还未登录,请先登录小程序',
- showCancel: false,
- success: res => {
- if (res.confirm) {
- // wx.navigateBack({
- // delta: 1,
- // })
- wx.navigateTo({
- url: '/pages/login/login',
- })
- }
- }
- })
- }
- },
- handel(e) {
- if (!this.data.isLogin) {
- wx.navigateTo({
- url: '/pages/login/login',
- })
- return;
- }
- const {
- index
- } = e.detail;
- this.setData({
- visible: false
- })
- if (index === 1) {
- this.toAuth();
- }
- }
- })
|