wlzboy
2025-09-25 4648a3bee638e9a99d2d80b66f8833b261a2db91
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
<template>
  <view class="container">
    <uni-list>
      <uni-list-item showExtraIcon="true" :extraIcon="{type: 'person-filled'}" title="用户名" :rightText="user.userName" />
      <uni-list-item showExtraIcon="true" :extraIcon="{type: 'phone-filled'}" title="手机号码" :rightText="user.phonenumber" />
      <uni-list-item showExtraIcon="true" :extraIcon="{type: 'location-filled'}" title="绑定车辆" :rightText="boundVehicle || '未绑定'" />
      <uni-list-item showExtraIcon="true" :extraIcon="{type: 'info-filled'}" title="App版本号" :rightText="version" />
      <uni-list-item showExtraIcon="true" :extraIcon="{type: 'email-filled'}" title="邮箱" :rightText="user.email" />
      <uni-list-item showExtraIcon="true" :extraIcon="{type: 'auth-filled'}" title="岗位" :rightText="postGroup" />
      <uni-list-item showExtraIcon="true" :extraIcon="{type: 'staff-filled'}" title="角色" :rightText="roleGroup" />
      <uni-list-item showExtraIcon="true" :extraIcon="{type: 'calendar-filled'}" title="创建日期" :rightText="user.createTime" />
    </uni-list>
    
    <!-- 绑定/解绑车辆操作 -->
    <view class="vehicle-actions" v-if="boundVehicle">
      <button class="unbind-btn" @click="unbindVehicle">取消绑定车辆</button>
    </view>
    <view class="vehicle-actions" v-else>
      <button class="bind-btn" @click="goToBindVehicle">绑定车辆</button>
    </view>
  </view>
</template>
 
<script>
  import { getUserProfile } from "@/api/system/user"
 
  export default {
    data() {
      return {
        user: {},
        roleGroup: "",
        postGroup: "",
        boundVehicle: "", // 模拟绑定的车辆信息
        version: getApp().globalData.config.appInfo.version || "1.0.0" // App版本号
      }
    },
    onLoad() {
      this.getUser()
    },
    methods: {
      getUser() {
        getUserProfile().then(response => {
          this.user = response.data
          this.roleGroup = response.roleGroup
          this.postGroup = response.postGroup
        })
      },
      
      // 跳转到绑定车辆页面
      goToBindVehicle() {
        this.$tab.navigateTo('/pages/bind-vehicle')
      },
      
      // 取消绑定车辆
      unbindVehicle() {
        this.$modal.confirm('是否取消绑定车辆?').then(() => {
          // 这里可以调用API取消绑定车辆
          this.boundVehicle = ""
          this.$modal.showToast('取消绑定成功')
        }).catch(() => {
          // 用户取消操作
        })
      }
    }
  }
</script>
 
<style lang="scss">
  page {
    background-color: #ffffff;
  }
  
  .vehicle-actions {
    padding: 30rpx;
    text-align: center;
    
    .bind-btn, .unbind-btn {
      width: 80%;
      height: 80rpx;
      border-radius: 10rpx;
      font-size: 32rpx;
    }
    
    .bind-btn {
      background-color: #007AFF;
      color: white;
    }
    
    .unbind-btn {
      background-color: #ff4d4f;
      color: white;
    }
  }
</style>