switchRoles.vue 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  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.$emit('changeRole',{userType:index})
  63. uni.navigateBack()
  64. }
  65. });
  66. }
  67. },
  68. });
  69. } else if (index == 2) {
  70. //个人换企业
  71. uni.showModal({
  72. title: "提示",
  73. content: "确认切换到招聘者身份吗?",
  74. confirmColor: "#016BF6",
  75. complete(ret) {
  76. if (ret.confirm) {
  77. let data = {
  78. userType: 2,
  79. };
  80. that.$Request.postT("/app/user/updateUserEntity", data).then((res) => {
  81. if (res.code == 0) {
  82. uni.$emit('changeRole',{userType:index})
  83. uni.navigateBack()
  84. }
  85. });
  86. }
  87. },
  88. });
  89. }
  90. } else {
  91. this.noLogin();
  92. }
  93. },
  94. //未登录
  95. noLogin() {
  96. // uni.showModal({
  97. // title: '提示',
  98. // content: '您还未登录,请先登录',
  99. // confirmColor:'#016BF6',
  100. // success: function(res) {
  101. // if (res.confirm) {
  102. // console.log('用户点击确定');
  103. // // uni.reLaunch({
  104. // // url:'/pages/public/login'
  105. // // })
  106. // uni.navigateTo({
  107. // url: '/pages/public/login'
  108. // })
  109. // } else if (res.cancel) {
  110. // console.log('用户点击取消');
  111. // }
  112. // }
  113. // })
  114. uni.navigateTo({
  115. url: "/pages/public/login",
  116. });
  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. position: absolute;
  125. left: 0;
  126. right: 0;
  127. top: 0;
  128. bottom: 0;
  129. display: flex;
  130. flex-direction: column;
  131. .roles-content {
  132. width: 100%;
  133. flex: 1;
  134. overflow: hidden;
  135. overflow-y: auto;
  136. padding-top: 10vh;
  137. box-sizing: border-box;
  138. .content {
  139. padding: 62rpx;
  140. box-sizing: border-box;
  141. display: flex;
  142. flex-direction: column;
  143. align-items: center;
  144. justify-content: center;
  145. image {
  146. width: 364rpx;
  147. height: 364rpx;
  148. }
  149. .roles-desc {
  150. color: rgba(255, 255, 255, 1);
  151. font-family: DM Sans;
  152. font-size: 32rpx;
  153. font-weight: 400;
  154. line-height: 48rpx;
  155. text-align: center;
  156. padding: 24rpx 0 36rpx 0;
  157. box-sizing: border-box;
  158. }
  159. .roles-btn {
  160. color: #016bf6;
  161. font-family: DM Sans;
  162. font-size: 32rpx;
  163. font-weight: 400;
  164. line-height: 48rpx;
  165. letter-spacing: 0%;
  166. background-color: #fff;
  167. text-align: center;
  168. padding: 16rpx 32rpx;
  169. box-sizing: border-box;
  170. border-radius: 100rpx;
  171. }
  172. }
  173. }
  174. }
  175. </style>