西藏巴青项目

index.vue 10KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450
  1. <template>
  2. <view :key="layoutKey" :class="pageRootClass" class="tab-page mine-page">
  3. <scroll-view scroll-y class="mine-scroll" enable-back-to-top>
  4. <!-- 第一行:大头像 + 用户名 -->
  5. <view class="mine-profile">
  6. <view class="mine-profile__avatar">
  7. <image
  8. v-if="userAvatar"
  9. class="mine-profile__avatar-img"
  10. :src="userAvatar"
  11. mode="aspectFill"
  12. />
  13. <up-icon v-else name="account-fill" color="#22C55E" :size="56" />
  14. </view>
  15. <view class="mine-profile__meta">
  16. <text class="text-body mine-profile__name">{{ displayName }}</text>
  17. <text v-if="!isLoggedIn" class="text-body mine-profile__hint">{{ $t('minePage.guestHint') }}</text>
  18. </view>
  19. </view>
  20. <view v-if="!isLoggedIn" class="mine-auth-bar">
  21. <up-button
  22. type="primary"
  23. color="#22C55E"
  24. :text="$t('minePage.loginBtn')"
  25. @click="goLogin"
  26. />
  27. </view>
  28. <!-- 第二行:说明卡片 -->
  29. <!-- <view class="mine-card tp-card">
  30. <text class="text-body mine-card__txt">{{ $t('minePage.cardIntro') }}</text>
  31. </view> -->
  32. <!-- 第三行:单元格列表 -->
  33. <view class="mine-cells">
  34. <view
  35. v-for="row in menuRows"
  36. :key="row.id"
  37. class="mine-cell"
  38. role="button"
  39. @click="onCell(row)"
  40. >
  41. <view class="mine-cell__icon-wrap">
  42. <up-icon :name="row.icon" color="#22C55E" :size="22" />
  43. </view>
  44. <text class="text-body mine-cell__title">{{ $t(row.titleKey) }}</text>
  45. <view class="mine-cell__trail">
  46. <text v-if="row.id === 'lang'" class="text-body mine-cell__value">{{ currentLangLabel }}</text>
  47. <up-icon name="arrow-right" color="#B5AEA6" :size="18" />
  48. </view>
  49. </view>
  50. </view>
  51. <view v-if="isLoggedIn" class="mine-logout-wrap">
  52. <up-button
  53. type="info"
  54. plain
  55. :text="$t('minePage.logoutBtn')"
  56. @click="handleLogout"
  57. />
  58. </view>
  59. </scroll-view>
  60. </view>
  61. </template>
  62. <script>
  63. import UIcon from 'uview-plus/components/u-icon/u-icon.vue'
  64. import UButton from 'uview-plus/components/u-button/u-button.vue'
  65. import tabPage from '@/mixins/tabPage'
  66. import { setStoredLocale } from '@/utils/locale'
  67. import { ensureTabBarEntry, isTabBarPage, syncTabBarText } from '@/utils/tabBar'
  68. import { useUserStore } from '@/store/user'
  69. export default {
  70. components: {
  71. 'up-icon': UIcon,
  72. 'up-button': UButton
  73. },
  74. mixins: [tabPage],
  75. data() {
  76. return {
  77. navTitleKey: 'nav.mine',
  78. menuRows: [
  79. // { id: 'editProfile', icon: 'edit-pen', titleKey: 'minePage.editProfile' },
  80. // { id: 'orders', icon: 'order', titleKey: 'minePage.myOrders' },
  81. { id: 'booking', icon: 'calendar', titleKey: 'minePage.myBooking' },
  82. { id: 'enroll', icon: 'file-text', titleKey: 'minePage.myEnrollment' },
  83. // { id: 'address', icon: 'map', titleKey: 'minePage.address' },
  84. { id: 'lang', icon: 'setting', titleKey: 'minePage.langVersion' }
  85. ]
  86. }
  87. },
  88. computed: {
  89. userStore() {
  90. return useUserStore()
  91. },
  92. isLoggedIn() {
  93. return this.userStore.isLoggedIn()
  94. },
  95. displayName() {
  96. const name = this.userStore.displayName()
  97. return name || this.$t('minePage.displayName')
  98. },
  99. userAvatar() {
  100. return this.userStore.state.avatar
  101. },
  102. currentLangLabel() {
  103. return this.lang === 'bo' ? this.$t('lang.switchBo') : this.$t('lang.switchZh')
  104. }
  105. },
  106. onShow() {
  107. if (this.isLoggedIn && !this.userStore.state.roles.length) {
  108. this.userStore.fetchUserInfo().catch(() => {})
  109. }
  110. },
  111. methods: {
  112. goLogin() {
  113. uni.navigateTo({ url: '/pages/login/index' })
  114. },
  115. handleLogout() {
  116. uni.showModal({
  117. title: '',
  118. content: this.$t('minePage.logoutConfirm'),
  119. success: (res) => {
  120. if (!res.confirm) {
  121. return
  122. }
  123. this.userStore.logOut().then(() => {
  124. uni.reLaunch({ url: '/pages/login/index' })
  125. })
  126. }
  127. })
  128. },
  129. onCell(row) {
  130. if (row.id === 'lang') {
  131. this.openLangSheet()
  132. return
  133. }
  134. if (row.id === 'booking') {
  135. uni.navigateTo({ url: '/package-a/my-booking/index' })
  136. return
  137. }
  138. if (row.id === 'enroll') {
  139. if (!this.isLoggedIn) {
  140. this.goLogin()
  141. return
  142. }
  143. uni.navigateTo({ url: '/package-a/my-enrollment/index' })
  144. return
  145. }
  146. uni.showToast({
  147. title: this.$t('minePage.toastSoon'),
  148. icon: 'none'
  149. })
  150. },
  151. openLangSheet() {
  152. uni.showActionSheet({
  153. itemList: [this.$t('lang.switchZh'), this.$t('lang.switchBo')],
  154. success: (res) => {
  155. if (res.tapIndex === 0) this.applyLang('zh')
  156. else if (res.tapIndex === 1) this.applyLang('bo')
  157. }
  158. })
  159. },
  160. applyLang(code) {
  161. const next = setStoredLocale(code)
  162. this.$i18n.locale = next
  163. this.layoutKey += 1
  164. this.$nextTick(() => {
  165. const applyLangUi = () => {
  166. if (!isTabBarPage()) {
  167. return
  168. }
  169. syncTabBarText((k) => this.$t(k))
  170. const p = uni.setNavigationBarTitle({
  171. title: this.$t(this.navTitleKey)
  172. })
  173. if (p && typeof p.catch === 'function') {
  174. p.catch(() => {})
  175. }
  176. }
  177. if (isTabBarPage()) {
  178. applyLangUi()
  179. return
  180. }
  181. ensureTabBarEntry().then((ok) => {
  182. if (ok) {
  183. applyLangUi()
  184. }
  185. })
  186. })
  187. }
  188. }
  189. }
  190. </script>
  191. <style lang="scss" scoped>
  192. @import '@/styles/morandi.scss';
  193. @import '@/styles/tab-page.scss';
  194. .mine-page {
  195. display: flex;
  196. flex-direction: column;
  197. min-width: 0;
  198. min-height: 100%;
  199. background: $morandi-bg-page;
  200. box-sizing: border-box;
  201. /* #ifdef H5 */
  202. height: 100vh;
  203. height: 100dvh;
  204. overflow: hidden;
  205. /* #endif */
  206. }
  207. .mine-scroll {
  208. flex: 1;
  209. min-height: 0;
  210. height: 0;
  211. min-width: 0;
  212. padding: 24rpx 24rpx 40rpx;
  213. box-sizing: border-box;
  214. /* #ifdef H5 */
  215. height: 100%;
  216. min-height: 1px;
  217. /* #endif */
  218. }
  219. .mine-profile {
  220. position: relative;
  221. display: flex;
  222. flex-direction: row;
  223. align-items: center;
  224. gap: 28rpx;
  225. min-width: 0;
  226. margin-bottom: 24rpx;
  227. padding: 36rpx 28rpx 40rpx;
  228. border-radius: 20rpx;
  229. overflow: hidden;
  230. box-sizing: border-box;
  231. background: linear-gradient(145deg, #3d9b6e 0%, #22c55e 48%, #a7f3d0 100%);
  232. box-shadow: 0 12rpx 36rpx rgba(61, 155, 110, 0.2);
  233. &::before,
  234. &::after {
  235. content: '';
  236. position: absolute;
  237. border-radius: 50%;
  238. background: rgba(255, 255, 255, 0.14);
  239. pointer-events: none;
  240. }
  241. &::before {
  242. width: 200rpx;
  243. height: 200rpx;
  244. top: -72rpx;
  245. right: -48rpx;
  246. }
  247. &::after {
  248. width: 120rpx;
  249. height: 120rpx;
  250. bottom: -32rpx;
  251. left: -24rpx;
  252. background: rgba(255, 255, 255, 0.1);
  253. }
  254. }
  255. .mine-profile__avatar {
  256. position: relative;
  257. z-index: 1;
  258. flex-shrink: 0;
  259. width: 144rpx;
  260. height: 144rpx;
  261. border-radius: 50%;
  262. display: flex;
  263. align-items: center;
  264. justify-content: center;
  265. background: #ffffff;
  266. border: 4rpx solid rgba(255, 255, 255, 0.9);
  267. box-sizing: border-box;
  268. box-shadow: 0 8rpx 24rpx rgba(0, 0, 0, 0.12);
  269. }
  270. .mine-profile__avatar-img {
  271. width: 100%;
  272. height: 100%;
  273. border-radius: 50%;
  274. }
  275. .mine-profile__meta {
  276. position: relative;
  277. z-index: 1;
  278. flex: 1;
  279. min-width: 0;
  280. display: flex;
  281. flex-direction: column;
  282. gap: 10rpx;
  283. }
  284. .mine-profile__name {
  285. font-size: 40rpx;
  286. font-weight: 700;
  287. line-height: 1.35;
  288. color: #ffffff;
  289. word-break: break-word;
  290. overflow-wrap: anywhere;
  291. text-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.08);
  292. }
  293. .mine-profile__hint {
  294. font-size: 26rpx;
  295. color: rgba(255, 255, 255, 0.9);
  296. line-height: 1.45;
  297. }
  298. .mine-auth-bar {
  299. margin-bottom: 24rpx;
  300. min-width: 0;
  301. ::v-deep .u-button {
  302. border-radius: 999rpx !important;
  303. box-shadow: 0 8rpx 20rpx rgba(34, 197, 94, 0.25);
  304. }
  305. }
  306. .mine-logout-wrap {
  307. margin-top: 32rpx;
  308. min-width: 0;
  309. padding: 8rpx 0 0;
  310. ::v-deep .u-button {
  311. border-radius: 16rpx !important;
  312. border-color: $morandi-border-strong !important;
  313. color: $morandi-text-secondary !important;
  314. background: $morandi-bg-card !important;
  315. }
  316. }
  317. .mine-card {
  318. margin-bottom: 24rpx;
  319. }
  320. .mine-card__txt {
  321. color: $morandi-text-muted;
  322. line-height: 1.55;
  323. word-break: break-word;
  324. overflow-wrap: anywhere;
  325. }
  326. .mine-cells {
  327. display: flex;
  328. flex-direction: column;
  329. min-width: 0;
  330. border-radius: 20rpx;
  331. overflow: hidden;
  332. background: $morandi-bg-card;
  333. border: 1rpx solid $morandi-border;
  334. box-sizing: border-box;
  335. box-shadow: 0 8rpx 28rpx rgba(74, 69, 66, 0.06);
  336. }
  337. .mine-cell {
  338. display: flex;
  339. flex-direction: row;
  340. align-items: center;
  341. min-width: 0;
  342. padding: 28rpx 24rpx;
  343. gap: 20rpx;
  344. box-sizing: border-box;
  345. border-bottom: 1rpx solid $morandi-border-soft;
  346. background: $morandi-bg-card;
  347. transition: background 0.15s ease;
  348. }
  349. .mine-cell:last-child {
  350. border-bottom-width: 0;
  351. }
  352. .mine-cell:active {
  353. background: $morandi-highlight;
  354. }
  355. .mine-cell__icon-wrap {
  356. flex-shrink: 0;
  357. width: 72rpx;
  358. height: 72rpx;
  359. border-radius: 20rpx;
  360. display: flex;
  361. align-items: center;
  362. justify-content: center;
  363. background: #e8f5ec;
  364. box-sizing: border-box;
  365. }
  366. .mine-cell:nth-child(1) .mine-cell__icon-wrap {
  367. background: #e8f0e6;
  368. }
  369. .mine-cell:nth-child(2) .mine-cell__icon-wrap {
  370. background: #e4eaef;
  371. }
  372. .mine-cell:nth-child(3) .mine-cell__icon-wrap {
  373. background: #efeae4;
  374. }
  375. .mine-cell:nth-child(4) .mine-cell__icon-wrap {
  376. background: #ebe4dc;
  377. }
  378. .mine-cell__title {
  379. flex: 1;
  380. min-width: 0;
  381. font-size: 30rpx;
  382. font-weight: 500;
  383. color: $morandi-text;
  384. word-break: break-word;
  385. overflow-wrap: anywhere;
  386. }
  387. .mine-cell__value {
  388. flex-shrink: 1;
  389. max-width: 280rpx;
  390. font-size: 26rpx;
  391. color: $morandi-accent-soft;
  392. text-align: right;
  393. word-break: break-word;
  394. overflow-wrap: anywhere;
  395. }
  396. .mine-cell__trail {
  397. display: flex;
  398. flex-direction: row;
  399. align-items: center;
  400. gap: 8rpx;
  401. flex-shrink: 0;
  402. }
  403. .mine-page.lang-bo {
  404. .mine-profile__name {
  405. font-size: 34rpx;
  406. }
  407. .mine-cell__title {
  408. font-size: 28rpx;
  409. }
  410. }
  411. </style>