switchRoles.vue 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  1. <template>
  2. <view class="switch-roles">
  3. <nav-bar title="切换身份"></nav-bar>
  4. <view class="roles-content">
  5. <view class="content">
  6. <image src="/static/images/my/zhaopingzhe.svg" mode="scaleToFill" />
  7. <view class="roles-desc">你当前的身份是“{{userType==1?'求职者':'招聘者'}}”</view>
  8. <view class="roles-btn" @click="bindQe">切换为“{{userType==2?'求职者':'招聘者'}}”身份</view>
  9. </view>
  10. </view>
  11. </view>
  12. </template>
  13. <script>
  14. import navBar from "@/components/nav-bar/index.vue";
  15. export default {
  16. data() {
  17. return {
  18. userType:1
  19. }
  20. },
  21. components: {
  22. navBar,
  23. },
  24. onLoad(){
  25. this.getUserInfo()
  26. },
  27. methods: {
  28. /**
  29. * 获取个人信息
  30. */
  31. getUserInfo() {
  32. this.$Request.get("/app/user/selectUserById").then((res) => {
  33. if (res.code == 0) {
  34. if (res.data.userType == 1 || res.data.userType == null) {
  35. this.userType = 1;
  36. uni.setStorageSync("userType", 1);
  37. } else {
  38. this.userType = 2;
  39. uni.setStorageSync("userType", 2);
  40. }
  41. }
  42. });
  43. },
  44. // 切换身份
  45. bindQe() {
  46. let that = this;
  47. if (uni.getStorageSync("userId")) {
  48. let index=3-this.userType
  49. if (index == 1) {
  50. //企业换个人
  51. uni.showModal({
  52. title: "提示",
  53. content: "确认切换到求职者身份吗?",
  54. confirmColor: "#016BF6",
  55. complete(ret) {
  56. if (ret.confirm) {
  57. let data = {
  58. userType: 1,
  59. };
  60. that.$Request.postT("/app/user/updateUserEntity", data).then((res) => {
  61. if (res.code == 0) {
  62. uni.setStorageSync("userType", 1);
  63. uni.$emit('changeRole',{userType:index})
  64. uni.navigateBack()
  65. }
  66. });
  67. }
  68. },
  69. });
  70. } else if (index == 2) {
  71. //个人换企业
  72. uni.showModal({
  73. title: "提示",
  74. content: "确认切换到招聘者身份吗?",
  75. confirmColor: "#016BF6",
  76. complete(ret) {
  77. if (ret.confirm) {
  78. let data = {
  79. userType: 2,
  80. };
  81. that.$Request.postT("/app/user/updateUserEntity", data).then((res) => {
  82. if (res.code == 0) {
  83. uni.setStorageSync("userType", 2);
  84. uni.$emit('changeRole',{userType:index})
  85. uni.navigateBack()
  86. }
  87. });
  88. }
  89. },
  90. });
  91. }
  92. } else {
  93. this.noLogin();
  94. }
  95. },
  96. //未登录
  97. noLogin() {
  98. // uni.showModal({
  99. // title: '提示',
  100. // content: '您还未登录,请先登录',
  101. // confirmColor:'#016BF6',
  102. // success: function(res) {
  103. // if (res.confirm) {
  104. // console.log('用户点击确定');
  105. // // uni.reLaunch({
  106. // // url:'/pages/public/login'
  107. // // })
  108. // uni.navigateTo({
  109. // url: '/pages/public/login'
  110. // })
  111. // } else if (res.cancel) {
  112. // console.log('用户点击取消');
  113. // }
  114. // }
  115. // })
  116. this.$queue.toLogin('navigateTo')
  117. },
  118. },
  119. };
  120. </script>
  121. <style lang="scss" scoped>
  122. .switch-roles {
  123. background: linear-gradient(90deg, rgba(13, 39, 247, 1), rgba(19, 193, 234, 1) 100%);
  124. min-height: 100vh;
  125. padding-bottom: env(safe-area-inset-bottom);
  126. display: flex;
  127. flex-direction: column;
  128. .roles-content {
  129. width: 100%;
  130. flex: 1;
  131. padding-top: 10vh;
  132. box-sizing: border-box;
  133. .content {
  134. padding: 62rpx;
  135. box-sizing: border-box;
  136. display: flex;
  137. flex-direction: column;
  138. align-items: center;
  139. justify-content: center;
  140. image {
  141. width: 364rpx;
  142. height: 364rpx;
  143. }
  144. .roles-desc {
  145. color: rgba(255, 255, 255, 1);
  146. font-family: DM Sans;
  147. font-size: 32rpx;
  148. font-weight: 400;
  149. line-height: 48rpx;
  150. text-align: center;
  151. padding: 24rpx 0 36rpx 0;
  152. box-sizing: border-box;
  153. }
  154. .roles-btn {
  155. color: #016bf6;
  156. font-family: DM Sans;
  157. font-size: 32rpx;
  158. font-weight: 400;
  159. line-height: 48rpx;
  160. letter-spacing: 0%;
  161. background-color: #fff;
  162. text-align: center;
  163. padding: 16rpx 32rpx;
  164. box-sizing: border-box;
  165. border-radius: 100rpx;
  166. }
  167. }
  168. }
  169. }
  170. </style>