西藏巴青项目

index.vue 7.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338
  1. <template>
  2. <view class="tab-page mine-page">
  3. <scroll-view scroll-y class="mine-scroll" enable-back-to-top>
  4. <view class="mine-profile">
  5. <view class="mine-profile__avatar">
  6. <image
  7. v-if="userAvatar"
  8. class="mine-profile__avatar-img"
  9. :src="userAvatar"
  10. mode="aspectFill"
  11. />
  12. <up-icon v-else name="account-fill" color="#22C55E" :size="56" />
  13. </view>
  14. <view class="mine-profile__meta">
  15. <text class="mine-profile__name">{{ displayName }}</text>
  16. <text v-if="!isLoggedIn" class="mine-profile__hint">登录后查看个人资料与业务数据</text>
  17. </view>
  18. </view>
  19. <view v-if="!isLoggedIn" class="mine-auth-bar">
  20. <up-button
  21. type="primary"
  22. color="#22C55E"
  23. text="去登录"
  24. @click="goLogin"
  25. />
  26. </view>
  27. <view v-if="isLoggedIn" class="mine-cells">
  28. <view
  29. v-for="row in infoRows"
  30. :key="row.id"
  31. class="mine-cell"
  32. >
  33. <view class="mine-cell__icon-wrap">
  34. <up-icon :name="row.icon" color="#22C55E" :size="22" />
  35. </view>
  36. <text class="mine-cell__title">{{ row.title }}</text>
  37. <text class="mine-cell__value">{{ row.value }}</text>
  38. </view>
  39. </view>
  40. <view v-if="isLoggedIn" class="mine-logout-wrap">
  41. <up-button
  42. type="info"
  43. plain
  44. text="退出登录"
  45. @click="handleLogout"
  46. />
  47. </view>
  48. </scroll-view>
  49. </view>
  50. </template>
  51. <script>
  52. import UIcon from 'uview-plus/components/u-icon/u-icon.vue'
  53. import UButton from 'uview-plus/components/u-button/u-button.vue'
  54. import { useUserStore } from '@/store/user'
  55. import { getPartnerIdentityLabel } from '@/utils/partnerRole'
  56. export default {
  57. components: {
  58. 'up-icon': UIcon,
  59. 'up-button': UButton
  60. },
  61. computed: {
  62. userStore() {
  63. return useUserStore()
  64. },
  65. isLoggedIn() {
  66. return this.userStore.isLoggedIn()
  67. },
  68. displayName() {
  69. return this.userStore.displayName() || '访客'
  70. },
  71. userAvatar() {
  72. return this.userStore.state.avatar
  73. },
  74. infoRows() {
  75. const roles = this.userStore.state.roles
  76. const phone = (this.userStore.state.phonenumber || '').trim()
  77. return [
  78. {
  79. id: 'identity',
  80. icon: 'account',
  81. title: '用户身份',
  82. value: getPartnerIdentityLabel(roles)
  83. },
  84. {
  85. id: 'entityType',
  86. icon: 'home',
  87. title: '主体类型',
  88. value: '--'
  89. },
  90. {
  91. id: 'contact',
  92. icon: 'phone',
  93. title: '联系方式',
  94. value: phone || '--'
  95. }
  96. ]
  97. }
  98. },
  99. onShow() {
  100. if (this.isLoggedIn && (!this.userStore.state.roles.length || !this.userStore.state.phonenumber)) {
  101. this.userStore.fetchUserInfo().catch(() => {})
  102. }
  103. },
  104. methods: {
  105. goLogin() {
  106. uni.navigateTo({ url: '/pages/login/index' })
  107. },
  108. handleLogout() {
  109. uni.showModal({
  110. title: '',
  111. content: '确定退出当前账号吗?',
  112. success: (res) => {
  113. if (!res.confirm) {
  114. return
  115. }
  116. this.userStore.logOut().then(() => {
  117. uni.reLaunch({ url: '/pages/login/index' })
  118. })
  119. }
  120. })
  121. }
  122. }
  123. }
  124. </script>
  125. <style lang="scss" scoped>
  126. @import '@/styles/morandi.scss';
  127. @import '@/styles/scroll-fill.scss';
  128. .mine-page {
  129. display: flex;
  130. flex-direction: column;
  131. min-width: 0;
  132. min-height: 100%;
  133. background: $morandi-bg-page;
  134. box-sizing: border-box;
  135. /* #ifdef H5 */
  136. flex: 1;
  137. height: 100%;
  138. min-height: 0;
  139. overflow: hidden;
  140. /* #endif */
  141. }
  142. .mine-scroll {
  143. @include flex-scroll-y;
  144. padding: 24rpx 24rpx 40rpx;
  145. }
  146. .mine-profile {
  147. position: relative;
  148. display: flex;
  149. flex-direction: row;
  150. align-items: center;
  151. gap: 28rpx;
  152. min-width: 0;
  153. margin-bottom: 24rpx;
  154. padding: 36rpx 28rpx 40rpx;
  155. border-radius: 20rpx;
  156. overflow: hidden;
  157. box-sizing: border-box;
  158. background: linear-gradient(145deg, #3d9b6e 0%, #22c55e 48%, #a7f3d0 100%);
  159. box-shadow: 0 12rpx 36rpx rgba(61, 155, 110, 0.2);
  160. &::before,
  161. &::after {
  162. content: '';
  163. position: absolute;
  164. border-radius: 50%;
  165. background: rgba(255, 255, 255, 0.14);
  166. pointer-events: none;
  167. }
  168. &::before {
  169. width: 200rpx;
  170. height: 200rpx;
  171. top: -72rpx;
  172. right: -48rpx;
  173. }
  174. &::after {
  175. width: 120rpx;
  176. height: 120rpx;
  177. bottom: -32rpx;
  178. left: -24rpx;
  179. background: rgba(255, 255, 255, 0.1);
  180. }
  181. }
  182. .mine-profile__avatar {
  183. position: relative;
  184. z-index: 1;
  185. flex-shrink: 0;
  186. width: 144rpx;
  187. height: 144rpx;
  188. border-radius: 50%;
  189. display: flex;
  190. align-items: center;
  191. justify-content: center;
  192. background: #ffffff;
  193. border: 4rpx solid rgba(255, 255, 255, 0.9);
  194. box-sizing: border-box;
  195. box-shadow: 0 8rpx 24rpx rgba(0, 0, 0, 0.12);
  196. }
  197. .mine-profile__avatar-img {
  198. width: 100%;
  199. height: 100%;
  200. border-radius: 50%;
  201. }
  202. .mine-profile__meta {
  203. position: relative;
  204. z-index: 1;
  205. flex: 1;
  206. min-width: 0;
  207. display: flex;
  208. flex-direction: column;
  209. gap: 10rpx;
  210. }
  211. .mine-profile__name {
  212. font-size: 40rpx;
  213. font-weight: 700;
  214. line-height: 1.35;
  215. color: #ffffff;
  216. word-break: break-word;
  217. overflow-wrap: anywhere;
  218. text-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.08);
  219. }
  220. .mine-profile__hint {
  221. font-size: 26rpx;
  222. color: rgba(255, 255, 255, 0.9);
  223. line-height: 1.45;
  224. }
  225. .mine-auth-bar {
  226. margin-bottom: 24rpx;
  227. min-width: 0;
  228. ::v-deep .u-button {
  229. border-radius: 999rpx !important;
  230. box-shadow: 0 8rpx 20rpx rgba(34, 197, 94, 0.25);
  231. }
  232. }
  233. .mine-logout-wrap {
  234. margin-top: 32rpx;
  235. min-width: 0;
  236. padding: 8rpx 0 0;
  237. ::v-deep .u-button {
  238. border-radius: 16rpx !important;
  239. border-color: $morandi-border-strong !important;
  240. color: $morandi-text-secondary !important;
  241. background: $morandi-bg-card !important;
  242. }
  243. }
  244. .mine-cells {
  245. display: flex;
  246. flex-direction: column;
  247. min-width: 0;
  248. border-radius: 20rpx;
  249. overflow: hidden;
  250. background: $morandi-bg-card;
  251. border: 1rpx solid $morandi-border;
  252. box-sizing: border-box;
  253. box-shadow: 0 8rpx 28rpx rgba(74, 69, 66, 0.06);
  254. }
  255. .mine-cell {
  256. display: flex;
  257. flex-direction: row;
  258. align-items: center;
  259. min-width: 0;
  260. padding: 28rpx 24rpx;
  261. gap: 20rpx;
  262. box-sizing: border-box;
  263. border-bottom: 1rpx solid $morandi-border-soft;
  264. background: $morandi-bg-card;
  265. }
  266. .mine-cell:last-child {
  267. border-bottom-width: 0;
  268. }
  269. .mine-cell__icon-wrap {
  270. flex-shrink: 0;
  271. width: 72rpx;
  272. height: 72rpx;
  273. border-radius: 20rpx;
  274. display: flex;
  275. align-items: center;
  276. justify-content: center;
  277. background: #e8f5ec;
  278. box-sizing: border-box;
  279. }
  280. .mine-cell:nth-child(1) .mine-cell__icon-wrap {
  281. background: #e8f0e6;
  282. }
  283. .mine-cell:nth-child(2) .mine-cell__icon-wrap {
  284. background: #e4eaef;
  285. }
  286. .mine-cell:nth-child(3) .mine-cell__icon-wrap {
  287. background: #efeae4;
  288. }
  289. .mine-cell__title {
  290. flex: 1;
  291. min-width: 0;
  292. font-size: 30rpx;
  293. font-weight: 500;
  294. color: $morandi-text;
  295. word-break: break-word;
  296. overflow-wrap: anywhere;
  297. }
  298. .mine-cell__value {
  299. flex-shrink: 1;
  300. max-width: 280rpx;
  301. font-size: 26rpx;
  302. color: $morandi-accent-soft;
  303. text-align: right;
  304. word-break: break-word;
  305. overflow-wrap: anywhere;
  306. }
  307. </style>