zhengyiming
2025-02-10 0f686ea1fe4700a909a6159efcf1fcb0e1f88a17
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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
<template>
  <PageLayout class="mine-page-wrapper" :need-auth="false">
    <template #navigationBar>
      <TransparentNavigationBar
        title="个人中心"
        :is-absolute="false"
        mode="dark"
      ></TransparentNavigationBar>
    </template>
    <template #bg>
      <img :src="OssAssets.mine.Bg" class="mine-page-bg" :style="{ height: `${bgHeight}px` }" />
    </template>
    <ContentView>
      <UserHomeTopView :showUserHomePageBtn="isLogin" :showOperation="isLogin">
        <template #avatar>
          <div class="mine-avatar-wrapper" @click="goLogin">
            <UserAvatar :size="60" class="mine-avatar" />
            <div class="user-info" v-if="isLogin">
              <div class="user-info-item">{{ userDetail?.userName ?? '' }}</div>
              <div class="user-info-item2" v-if="isCertified">
                {{ userDetail?.customerName ?? '' }}
              </div>
              <div class="user-info-unCertified" v-else @click.stop="goAuthentication">
                <img :src="IconUnCertified" class="user-info-unCertified-icon" />
                <div class="user-info-unCertified-text">未认证</div>
              </div>
            </div>
            <div class="mine-go-login" v-else>去登录</div>
          </div>
        </template>
      </UserHomeTopView>
    </ContentView>
    <ContentScrollView v-if="isLogin" class="mine-content-scroll-view">
      <div class="mine-id-menu-wrapper">
        <img :src="IconLamp" class="mine-id-menu-icon" />
        <div class="mine-id-menu-text">
          您当前的身份为{{ MatchMakingIdentityEnumText[matchMakingIdentity] }}
        </div>
        <div class="mine-id-menu-btn" @click="goPage(RouterPath.toggleMatchMakingIdentity)">
          切换身份
        </div>
      </div>
      <div class="mine-menu-list">
        <div class="mine-menu-list-item" @click="goBusinessManagement">
          <img :src="IconMenuBusiness" class="mine-menu-list-item-icon" />
          <div class="mine-menu-list-item-text">业务管理</div>
        </div>
        <div class="mine-menu-list-item" @click="goTradeChatRecord">
          <img :src="IconMenuContact" class="mine-menu-list-item-icon" />
          <div class="mine-menu-list-item-text">联系记录</div>
        </div>
      </div>
      <List class="mine-setting-list">
        <ListItem :icon="IconMessage" title="消息" @click="goMessage">
          <template #extra>
            <nut-badge
              :value="myMessageCount.unReadCount ?? 0"
              class="mine-setting-badge"
              :hidden="!myMessageCount.unReadCount"
            ></nut-badge>
          </template>
        </ListItem>
        <ListItem :icon="IconSetting" title="设置" @click="goSetting"></ListItem>
      </List>
    </ContentScrollView>
  </PageLayout>
</template>
 
<script setup lang="ts">
import {
  PageLayout,
  TransparentNavigationBar,
  ContentScrollView,
  UserHomeTopView,
} from '@/components';
import IconUnCertified from '@/assets/mine/icon-unCertified.png';
import IconLamp from '@/assets/mine/icon-lamp.png';
import IconMenuBusiness from '@/assets/mine/icon-menu-business.png';
import IconMenuContact from '@/assets/mine/icon-menu-contact.png';
import IconSetting from '@/assets/mine/icon-setting.png';
import IconMessage from '@/assets/mine/icon-message.png';
import { useUser, useIsLogin, useGoLogin, useMyMessageCount } from '@/hooks';
import Taro from '@tarojs/taro';
import { RouterPath, OssAssets } from '@/constants';
import { MatchMakingIdentityEnumText, MatchMakingIdentityEnum } from '@12333/constants';
import { List, ListItem } from '@12333/components';
import { useSystemStore } from '@/stores/modules/system';
 
const { userDetail, isCertified, matchMakingIdentity } = useUser();
const isLogin = useIsLogin();
const systemStore = useSystemStore();
 
const { goLoginFn } = useGoLogin();
const bgHeight = computed(() => 133 + systemStore.navHeight);
 
function goLogin() {
  if (!isLogin.value) {
    goLoginFn();
  }
}
 
function goPage(routeName: string) {
  Taro.navigateTo({
    url: routeName,
  });
}
 
function goSetting() {
  goPage(RouterPath.setting);
}
 
function goMessage() {
  goPage(RouterPath.messageList);
}
 
function goBusinessManagement() {
  if (matchMakingIdentity.value === MatchMakingIdentityEnum.Employing) {
    goPage(RouterPath.orderManage);
  } else if (matchMakingIdentity.value === MatchMakingIdentityEnum.Contributors) {
    goPage(RouterPath.resourceManage);
  }
}
 
Taro.showShareMenu({
  showShareItems: ['shareAppMessage'],
});
 
Taro.useShareAppMessage((res) => {
  return {
    title: `${userDetail.value?.contacter}名片`,
    path: `${RouterPath.userHomePage}?userId=${userDetail.value?.userId}`,
    imageUrl: userDetail.value?.avatarUrl,
  };
});
 
const { myMessageCount } = useMyMessageCount();
 
function goAuthentication() {
  goPage(RouterPath.authenticationHome);
}
 
function goTradeChatRecord() {
  goPage(RouterPath.tradeChatRecord);
}
</script>
 
<style lang="scss">
@import '@/styles/common.scss';
@import './index.scss';
 
.mine-setting-badge {
  margin-right: 20px;
}
</style>