UserSelection.vue 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. <template>
  2. <view class="container">
  3. <img src="/static/serverImg/home/logo.png" alt="" class="logo">
  4. <view class="select-title">欢迎使用<text class="logo-title">金邻助家</text> </view>
  5. <view class="select-text">请选择您的身份开始使用</view>
  6. <view class="select-box">
  7. <view v-for="item in list" :key="item.key" class="select-item" :style="{ background: item.bgcColor }"
  8. @click="handleBtn(item.key)">
  9. <view class="select-img">
  10. <img :src="item.icon" alt="" style="width: 48px;height: 48px;">
  11. </view>
  12. <view class="select-text-box">
  13. <view class="select-lable">{{ item.label }}</view>
  14. <view class="select-box-text">{{ item.text }}</view>
  15. </view>
  16. </view>
  17. </view>
  18. <view class="logo-text">技术支持:重庆金树林科技有限公司</view>
  19. </view>
  20. </template>
  21. <script setup>
  22. import {
  23. userOrWorker
  24. } from '@/api/login';
  25. import store from "@/store"
  26. const list = [
  27. {
  28. label: '我是用户',
  29. text: '寻找并预约服务',
  30. icon: '/static/img/user.png',
  31. key: 1,
  32. bgcColor: 'rgba(221, 94, 69, 1)'
  33. },
  34. {
  35. label: '我是志愿者',
  36. text: '提供专业服务',
  37. icon: '/static/img/admin.png',
  38. key: 2,
  39. bgcColor: ' rgba(233, 91, 93, 1)'
  40. }
  41. ]
  42. function handleBtn(userType = 0) { // 默认值 0
  43. const params = {
  44. userType: userType // 使用传入的 userType
  45. };
  46. // 把 userType 存入本地存储
  47. uni.setStorageSync('userType', userType);
  48. userOrWorker(params)
  49. .then(res => {
  50. // 重新拉取用户信息,储存本地
  51. store.dispatch('GetInfo').then(() => {
  52. uni.reLaunch({
  53. url: '/pages/index'
  54. });
  55. })
  56. })
  57. .catch(err => {
  58. console.error('设置失败:', err);
  59. });
  60. }
  61. </script>
  62. <style scoped lang="scss">
  63. .container {
  64. padding: 28px 24px;
  65. display: flex;
  66. flex-direction: column;
  67. align-items: center;
  68. .select-title {
  69. font-size: 30px;
  70. font-weight: 400;
  71. line-height: 36px;
  72. color: rgba(45, 58, 78, 1);
  73. margin-bottom: 14px;
  74. }
  75. .select-text {
  76. font-size: 16px;
  77. font-weight: 400;
  78. line-height: 24px;
  79. color: rgba(75, 85, 99, 1);
  80. margin-bottom: 20px;
  81. }
  82. .select-box {
  83. width: 100%;
  84. .select-item {
  85. padding: 24px;
  86. display: flex;
  87. align-items: center;
  88. border-radius: 16px;
  89. margin-bottom: 24px;
  90. .select-img {
  91. margin-right: 24px;
  92. }
  93. .select-text-box {
  94. .select-lable {
  95. font-size: 20px;
  96. font-weight: 400;
  97. line-height: 28px;
  98. color: #fff;
  99. margin-bottom: 8px;
  100. }
  101. .select-box-text {
  102. font-size: 16px;
  103. font-weight: 400;
  104. line-height: 24px;
  105. color: #fff;
  106. }
  107. }
  108. }
  109. }
  110. }
  111. .logo {
  112. width: 232rpx;
  113. height: 232rpx;
  114. }
  115. .logo-title {
  116. font-size: 32px;
  117. color: rgba(221, 94, 69, 1);
  118. font-weight: bold;
  119. }
  120. .logo-text {
  121. font-size: 28rpx;
  122. font-weight: 400;
  123. line-height: 40rpx;
  124. color: rgba(107, 114, 128, 1);
  125. margin-top: 36rpx;
  126. }
  127. </style>