| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175 |
- <template>
- <view class="switch-roles">
- <nav-bar title="切换身份"></nav-bar>
- <view class="roles-content">
- <view class="content">
- <image src="/static/images/my/zhaopingzhe.svg" mode="scaleToFill" />
- <view class="roles-desc">你当前的身份是“{{userType==1?'求职者':'招聘者'}}”</view>
- <view class="roles-btn" @click="bindQe">切换为“{{userType==2?'求职者':'招聘者'}}”身份</view>
- </view>
- </view>
- </view>
- </template>
- <script>
- import navBar from "@/components/nav-bar/index.vue";
- export default {
- data() {
- return {
- userType:1
- }
- },
- components: {
- navBar,
- },
- onLoad(){
- this.getUserInfo()
- },
- methods: {
- /**
- * 获取个人信息
- */
- getUserInfo() {
- this.$Request.get("/app/user/selectUserById").then((res) => {
- if (res.code == 0) {
-
- if (res.data.userType == 1 || res.data.userType == null) {
- this.userType = 1;
- uni.setStorageSync("userType", 1);
- } else {
- this.userType = 2;
- uni.setStorageSync("userType", 2);
- }
- }
- });
- },
- // 切换身份
- bindQe() {
- let that = this;
- if (uni.getStorageSync("userId")) {
- let index=3-this.userType
-
- if (index == 1) {
- //企业换个人
- uni.showModal({
- title: "提示",
- content: "确认切换到求职者身份吗?",
- confirmColor: "#016BF6",
- complete(ret) {
- if (ret.confirm) {
- let data = {
- userType: 1,
- };
- that.$Request.postT("/app/user/updateUserEntity", data).then((res) => {
- if (res.code == 0) {
- uni.setStorageSync("userType", 1);
- uni.$emit('changeRole',{userType:index})
- uni.navigateBack()
- }
- });
-
-
- }
- },
- });
-
- } else if (index == 2) {
- //个人换企业
- uni.showModal({
- title: "提示",
- content: "确认切换到招聘者身份吗?",
- confirmColor: "#016BF6",
- complete(ret) {
- if (ret.confirm) {
- let data = {
- userType: 2,
- };
- that.$Request.postT("/app/user/updateUserEntity", data).then((res) => {
- if (res.code == 0) {
- uni.setStorageSync("userType", 2);
- uni.$emit('changeRole',{userType:index})
- uni.navigateBack()
- }
- });
- }
- },
- });
- }
- } else {
- this.noLogin();
- }
- },
- //未登录
- noLogin() {
- // uni.showModal({
- // title: '提示',
- // content: '您还未登录,请先登录',
- // confirmColor:'#016BF6',
- // success: function(res) {
- // if (res.confirm) {
- // console.log('用户点击确定');
- // // uni.reLaunch({
- // // url:'/pages/public/login'
- // // })
- // uni.navigateTo({
- // url: '/pages/public/login'
- // })
- // } else if (res.cancel) {
- // console.log('用户点击取消');
- // }
- // }
- // })
- this.$queue.toLogin('navigateTo')
- },
- },
- };
- </script>
- <style lang="scss" scoped>
- .switch-roles {
- background: linear-gradient(90deg, rgba(13, 39, 247, 1), rgba(19, 193, 234, 1) 100%);
- min-height: 100vh;
- padding-bottom: env(safe-area-inset-bottom);
- display: flex;
- flex-direction: column;
- .roles-content {
- width: 100%;
- flex: 1;
- padding-top: 10vh;
- box-sizing: border-box;
- .content {
- padding: 62rpx;
- box-sizing: border-box;
- display: flex;
- flex-direction: column;
- align-items: center;
- justify-content: center;
- image {
- width: 364rpx;
- height: 364rpx;
- }
- .roles-desc {
- color: rgba(255, 255, 255, 1);
- font-family: DM Sans;
- font-size: 32rpx;
- font-weight: 400;
- line-height: 48rpx;
- text-align: center;
- padding: 24rpx 0 36rpx 0;
- box-sizing: border-box;
- }
- .roles-btn {
- color: #016bf6;
- font-family: DM Sans;
- font-size: 32rpx;
- font-weight: 400;
- line-height: 48rpx;
- letter-spacing: 0%;
- background-color: #fff;
- text-align: center;
- padding: 16rpx 32rpx;
- box-sizing: border-box;
- border-radius: 100rpx;
- }
- }
- }
- }
- </style>
|