西藏巴青项目

index.vue 9.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439
  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 { 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. if (!isTabBarPage()) {
  166. return
  167. }
  168. syncTabBarText((k) => this.$t(k))
  169. const p = uni.setNavigationBarTitle({
  170. title: this.$t(this.navTitleKey)
  171. })
  172. if (p && typeof p.catch === 'function') {
  173. p.catch(() => {})
  174. }
  175. })
  176. }
  177. }
  178. }
  179. </script>
  180. <style lang="scss" scoped>
  181. @import '@/styles/morandi.scss';
  182. @import '@/styles/tab-page.scss';
  183. .mine-page {
  184. display: flex;
  185. flex-direction: column;
  186. min-width: 0;
  187. min-height: 100%;
  188. background: $morandi-bg-page;
  189. box-sizing: border-box;
  190. /* #ifdef H5 */
  191. height: 100vh;
  192. height: 100dvh;
  193. overflow: hidden;
  194. /* #endif */
  195. }
  196. .mine-scroll {
  197. flex: 1;
  198. min-height: 0;
  199. height: 0;
  200. min-width: 0;
  201. padding: 24rpx 24rpx 40rpx;
  202. box-sizing: border-box;
  203. /* #ifdef H5 */
  204. height: 100%;
  205. min-height: 1px;
  206. /* #endif */
  207. }
  208. .mine-profile {
  209. position: relative;
  210. display: flex;
  211. flex-direction: row;
  212. align-items: center;
  213. gap: 28rpx;
  214. min-width: 0;
  215. margin-bottom: 24rpx;
  216. padding: 36rpx 28rpx 40rpx;
  217. border-radius: 20rpx;
  218. overflow: hidden;
  219. box-sizing: border-box;
  220. background: linear-gradient(145deg, #3d9b6e 0%, #22c55e 48%, #a7f3d0 100%);
  221. box-shadow: 0 12rpx 36rpx rgba(61, 155, 110, 0.2);
  222. &::before,
  223. &::after {
  224. content: '';
  225. position: absolute;
  226. border-radius: 50%;
  227. background: rgba(255, 255, 255, 0.14);
  228. pointer-events: none;
  229. }
  230. &::before {
  231. width: 200rpx;
  232. height: 200rpx;
  233. top: -72rpx;
  234. right: -48rpx;
  235. }
  236. &::after {
  237. width: 120rpx;
  238. height: 120rpx;
  239. bottom: -32rpx;
  240. left: -24rpx;
  241. background: rgba(255, 255, 255, 0.1);
  242. }
  243. }
  244. .mine-profile__avatar {
  245. position: relative;
  246. z-index: 1;
  247. flex-shrink: 0;
  248. width: 144rpx;
  249. height: 144rpx;
  250. border-radius: 50%;
  251. display: flex;
  252. align-items: center;
  253. justify-content: center;
  254. background: #ffffff;
  255. border: 4rpx solid rgba(255, 255, 255, 0.9);
  256. box-sizing: border-box;
  257. box-shadow: 0 8rpx 24rpx rgba(0, 0, 0, 0.12);
  258. }
  259. .mine-profile__avatar-img {
  260. width: 100%;
  261. height: 100%;
  262. border-radius: 50%;
  263. }
  264. .mine-profile__meta {
  265. position: relative;
  266. z-index: 1;
  267. flex: 1;
  268. min-width: 0;
  269. display: flex;
  270. flex-direction: column;
  271. gap: 10rpx;
  272. }
  273. .mine-profile__name {
  274. font-size: 40rpx;
  275. font-weight: 700;
  276. line-height: 1.35;
  277. color: #ffffff;
  278. word-break: break-word;
  279. overflow-wrap: anywhere;
  280. text-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.08);
  281. }
  282. .mine-profile__hint {
  283. font-size: 26rpx;
  284. color: rgba(255, 255, 255, 0.9);
  285. line-height: 1.45;
  286. }
  287. .mine-auth-bar {
  288. margin-bottom: 24rpx;
  289. min-width: 0;
  290. ::v-deep .u-button {
  291. border-radius: 999rpx !important;
  292. box-shadow: 0 8rpx 20rpx rgba(34, 197, 94, 0.25);
  293. }
  294. }
  295. .mine-logout-wrap {
  296. margin-top: 32rpx;
  297. min-width: 0;
  298. padding: 8rpx 0 0;
  299. ::v-deep .u-button {
  300. border-radius: 16rpx !important;
  301. border-color: $morandi-border-strong !important;
  302. color: $morandi-text-secondary !important;
  303. background: $morandi-bg-card !important;
  304. }
  305. }
  306. .mine-card {
  307. margin-bottom: 24rpx;
  308. }
  309. .mine-card__txt {
  310. color: $morandi-text-muted;
  311. line-height: 1.55;
  312. word-break: break-word;
  313. overflow-wrap: anywhere;
  314. }
  315. .mine-cells {
  316. display: flex;
  317. flex-direction: column;
  318. min-width: 0;
  319. border-radius: 20rpx;
  320. overflow: hidden;
  321. background: $morandi-bg-card;
  322. border: 1rpx solid $morandi-border;
  323. box-sizing: border-box;
  324. box-shadow: 0 8rpx 28rpx rgba(74, 69, 66, 0.06);
  325. }
  326. .mine-cell {
  327. display: flex;
  328. flex-direction: row;
  329. align-items: center;
  330. min-width: 0;
  331. padding: 28rpx 24rpx;
  332. gap: 20rpx;
  333. box-sizing: border-box;
  334. border-bottom: 1rpx solid $morandi-border-soft;
  335. background: $morandi-bg-card;
  336. transition: background 0.15s ease;
  337. }
  338. .mine-cell:last-child {
  339. border-bottom-width: 0;
  340. }
  341. .mine-cell:active {
  342. background: $morandi-highlight;
  343. }
  344. .mine-cell__icon-wrap {
  345. flex-shrink: 0;
  346. width: 72rpx;
  347. height: 72rpx;
  348. border-radius: 20rpx;
  349. display: flex;
  350. align-items: center;
  351. justify-content: center;
  352. background: #e8f5ec;
  353. box-sizing: border-box;
  354. }
  355. .mine-cell:nth-child(1) .mine-cell__icon-wrap {
  356. background: #e8f0e6;
  357. }
  358. .mine-cell:nth-child(2) .mine-cell__icon-wrap {
  359. background: #e4eaef;
  360. }
  361. .mine-cell:nth-child(3) .mine-cell__icon-wrap {
  362. background: #efeae4;
  363. }
  364. .mine-cell:nth-child(4) .mine-cell__icon-wrap {
  365. background: #ebe4dc;
  366. }
  367. .mine-cell__title {
  368. flex: 1;
  369. min-width: 0;
  370. font-size: 30rpx;
  371. font-weight: 500;
  372. color: $morandi-text;
  373. word-break: break-word;
  374. overflow-wrap: anywhere;
  375. }
  376. .mine-cell__value {
  377. flex-shrink: 1;
  378. max-width: 280rpx;
  379. font-size: 26rpx;
  380. color: $morandi-accent-soft;
  381. text-align: right;
  382. word-break: break-word;
  383. overflow-wrap: anywhere;
  384. }
  385. .mine-cell__trail {
  386. display: flex;
  387. flex-direction: row;
  388. align-items: center;
  389. gap: 8rpx;
  390. flex-shrink: 0;
  391. }
  392. .mine-page.lang-bo {
  393. .mine-profile__name {
  394. font-size: 34rpx;
  395. }
  396. .mine-cell__title {
  397. font-size: 28rpx;
  398. }
  399. }
  400. </style>