UserSelection.vue 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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. <!-- 用户部分 -->
  10. <view class="button-group">
  11. <up-button type="success" shape="circle" class="button" @click="handleBtn(1)">用户</up-button>
  12. </view>
  13. <image src="../static/FRAME.png" style="background-color: red;"></image>
  14. <image src="../static/img_v3_02le_9fee240d-00fc-4f42-9391-4801b614cb9g.png"
  15. style="background-color: red; width: 80rpx; height: 60rpx;"></image>
  16. <!-- 志愿者部分 -->
  17. <view class="button-group">
  18. <up-button type="success" shape="circle" class="button" @click="handleBtn(2)">志愿者</up-button>
  19. </view>
  20. </view>
  21. </template>
  22. <script setup>
  23. import {
  24. userOrWorker
  25. } from '@/api/login';
  26. import store from "@/store"
  27. const imagePath1 = '/static/志愿者.png';
  28. const imagePath2 = '/static/用户.png';
  29. function handleBtn(userType = 0) { // 默认值 0
  30. const params = {
  31. userType: userType // 使用传入的 userType
  32. };
  33. // 把 userType 存入本地存储
  34. uni.setStorageSync('userType', userType);
  35. userOrWorker(params)
  36. .then(res => {
  37. // 重新拉取用户信息,储存本地
  38. store.dispatch('GetInfo').then(() => {
  39. uni.reLaunch({
  40. url: '/pages/index'
  41. });
  42. })
  43. })
  44. .catch(err => {
  45. console.error('设置失败:', err);
  46. });
  47. }
  48. </script>
  49. <style scoped>
  50. .Wrap {
  51. left: 0rpx;
  52. top: 0rpx;
  53. width: 342rpx;
  54. height: 80rpx;
  55. opacity: 1;
  56. background: rgba(0, 0, 0, 0);
  57. }
  58. .Wraph1 {
  59. font-size: 30rpx;
  60. font-weight: 400;
  61. letter-spacing: 0rpx;
  62. line-height: 36rpx;
  63. color: rgba(45, 58, 78, 1);
  64. text-align: center;
  65. vertical-align: middle;
  66. }
  67. </style>