UserSelection.vue 3.1 KB

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