doum
2026-06-18 93de43267e1663031fe5dc2f5ae40d128a182a76
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
<template>
  <view class="cu-auth-page">
    <view class="cu-auth-page__title">选择身份</view>
    <view class="cu-auth-page__sub">切换角色后需使用对应身份重新登录</view>
 
    <view class="cu-role-card cu-role-card--ops" @click="goOps">
      <view class="cu-role-card__icon">
        <u-icon name="setting-fill" color="#40a9ff" size="28" />
      </view>
      <view class="cu-role-card__main">
        <view class="cu-role-card__name">运维人员</view>
        <view class="cu-role-card__desc">工单、巡检、设备运维</view>
      </view>
      <text class="cu-role-card__arrow">›</text>
    </view>
 
    <view class="cu-role-card cu-role-card--merchant" @click="goMerchant">
      <view class="cu-role-card__icon">
        <u-icon name="home-fill" color="#fa8c16" size="28" />
      </view>
      <view class="cu-role-card__main">
        <view class="cu-role-card__name">商户</view>
        <view class="cu-role-card__desc">交电费、查合同、查账单</view>
      </view>
      <text class="cu-role-card__arrow">›</text>
    </view>
  </view>
</template>
 
<script>
export default {
  onLoad (option) {
    if (option && option.switch === '1') return
    const userType = uni.getStorageSync('userType')
    const token = uni.getStorageSync('token')
    if (userType === 0 && token) {
      uni.redirectTo({ url: '/pages/index' })
    } else if (userType === 1 && token) {
      uni.redirectTo({ url: '/pages/customer/index' })
    }
  },
  methods: {
    goOps () {
      uni.setStorageSync('userType', 0)
      uni.redirectTo({ url: '/pages/login' })
    },
    goMerchant () {
      uni.setStorageSync('userType', 1)
      uni.redirectTo({ url: '/pages/customer/login' })
    }
  }
}
</script>