index.vue 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371
  1. <template>
  2. <view class="mine-container">
  3. <!-- 自定义导航栏 -->
  4. <view class="custom-navbar" :style="{paddingTop: statusBarHeight + 'px'}">
  5. <view class="navbar-content">
  6. <text class="navbar-title">我的</text>
  7. </view>
  8. </view>
  9. <!-- 用户登录/注册卡片 -->
  10. <view class="login-card" :style="{marginTop: navbarHeight + 'rpx'}" @click="handleLoginCardClick">
  11. <view class="login-card-content">
  12. <view class="avatar-section">
  13. <view v-if="!avatar" class="avatar-placeholder">
  14. <view class="iconfont icon-people avatar-icon"></view>
  15. </view>
  16. <image v-if="avatar" :src="avatar" class="avatar-image" mode="aspectFill"></image>
  17. </view>
  18. <view class="login-info">
  19. <view v-if="!name" class="login-text">点击登录/注册</view>
  20. <view v-else class="user-name">{{ name }}</view>
  21. <view v-if="!name" class="login-desc">登录后获取更多功能信息</view>
  22. </view>
  23. </view>
  24. <view class="login-card-bg">
  25. <!-- 背景装饰图案 -->
  26. </view>
  27. </view>
  28. <!-- 第一个菜单卡片 -->
  29. <view class="menu-card">
  30. <view class="menu-item" @click="handleToInfo">
  31. <view class="menu-item-left">
  32. <view class="menu-icon-wrapper account-icon">
  33. <view class="iconfont icon-user menu-icon"></view>
  34. </view>
  35. <text class="menu-text">账号信息</text>
  36. </view>
  37. <view class="iconfont icon-right arrow-icon"></view>
  38. </view>
  39. <view class="menu-divider"></view>
  40. <view class="menu-item" @click="handleToOrderRevenue">
  41. <view class="menu-item-left">
  42. <view class="menu-icon-wrapper revenue-icon">
  43. <text class="revenue-symbol">¥</text>
  44. </view>
  45. <text class="menu-text">订单收益</text>
  46. </view>
  47. <view class="iconfont icon-right arrow-icon"></view>
  48. </view>
  49. </view>
  50. <!-- 第二个菜单卡片 -->
  51. <view class="menu-card">
  52. <view class="menu-item" @click="handleClearCache">
  53. <view class="menu-item-left">
  54. <view class="menu-icon-wrapper cache-icon">
  55. <view class="iconfont icon-clean menu-icon"></view>
  56. </view>
  57. <text class="menu-text">本地缓存</text>
  58. </view>
  59. </view>
  60. <view class="menu-divider"></view>
  61. <view class="menu-item" @click="handleAbout">
  62. <view class="menu-item-left">
  63. <view class="menu-icon-wrapper about-icon">
  64. <view class="iconfont icon-help menu-icon"></view>
  65. </view>
  66. <text class="menu-text">关于我们</text>
  67. </view>
  68. <view class="iconfont icon-right arrow-icon"></view>
  69. </view>
  70. <view class="menu-divider"></view>
  71. <view class="menu-item" @click="handleLogout">
  72. <view class="menu-item-left">
  73. <view class="menu-icon-wrapper logout-icon">
  74. <view class="iconfont icon-logout menu-icon"></view>
  75. </view>
  76. <text class="menu-text">退出登录</text>
  77. </view>
  78. </view>
  79. </view>
  80. <!-- 底部导航栏 -->
  81. <bar-navigasi-handap></bar-navigasi-handap>
  82. </view>
  83. </template>
  84. <script>
  85. import BarNavigasiHandap from "@/components/barNavigasiHandap.vue"
  86. export default {
  87. components: {
  88. BarNavigasiHandap
  89. },
  90. data() {
  91. return {
  92. name: this.$store.state.user.name,
  93. statusBarHeight: 0
  94. }
  95. },
  96. onLoad() {
  97. // 获取状态栏高度
  98. const systemInfo = uni.getSystemInfoSync()
  99. this.statusBarHeight = systemInfo.statusBarHeight || 0
  100. },
  101. computed: {
  102. avatar() {
  103. return this.$store.state.user.avatar
  104. },
  105. navbarHeight() {
  106. // 状态栏高度(px转rpx) + 导航栏高度(88rpx) + 间距(30rpx)
  107. return (this.statusBarHeight * 2) + 88 + 30
  108. }
  109. },
  110. methods: {
  111. handleLoginCardClick() {
  112. if (!this.name) {
  113. this.$tab.reLaunch('/pages/login')
  114. } else {
  115. this.$tab.navigateTo('/pages/mine/info/index')
  116. }
  117. },
  118. handleToInfo() {
  119. if (!this.name) {
  120. this.$tab.reLaunch('/pages/login')
  121. return
  122. }
  123. this.$tab.navigateTo('/pages/mine/info/index')
  124. },
  125. handleToOrderRevenue() {
  126. if (!this.name) {
  127. this.$tab.reLaunch('/pages/login')
  128. return
  129. }
  130. this.$modal.showToast('模块建设中~')
  131. },
  132. handleClearCache() {
  133. this.$modal.confirm('确定要清理本地缓存吗?').then(() => {
  134. // 清理缓存的逻辑
  135. uni.clearStorageSync()
  136. this.$modal.msgSuccess('缓存清理成功')
  137. })
  138. },
  139. handleAbout() {
  140. this.$tab.navigateTo('/pages/mine/about/index')
  141. },
  142. handleLogout() {
  143. if (!this.name) {
  144. this.$tab.reLaunch('/pages/login')
  145. return
  146. }
  147. this.$modal.confirm('确定注销并退出系统吗?').then(() => {
  148. this.$store.dispatch('LogOut').then(() => {}).finally(() => {
  149. this.$tab.reLaunch('/pages/index')
  150. })
  151. })
  152. }
  153. }
  154. }
  155. </script>
  156. <style lang="scss" scoped>
  157. page {
  158. background-color: #f5f5f5;
  159. }
  160. .mine-container {
  161. width: 100%;
  162. min-height: 100vh;
  163. padding-bottom: 120rpx;
  164. background-color: #f5f5f5;
  165. // 自定义导航栏
  166. .custom-navbar {
  167. position: fixed;
  168. top: 0;
  169. left: 0;
  170. right: 0;
  171. z-index: 999;
  172. background-color: transparent;
  173. .navbar-content {
  174. display: flex;
  175. align-items: center;
  176. justify-content: center;
  177. height: 88rpx;
  178. .navbar-title {
  179. font-size: 36rpx;
  180. font-weight: 500;
  181. color: #000000;
  182. }
  183. }
  184. }
  185. // 登录卡片
  186. .login-card {
  187. position: relative;
  188. margin: 0 30rpx 40rpx 30rpx;
  189. padding: 40rpx 30rpx;
  190. background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
  191. border-radius: 24rpx;
  192. overflow: hidden;
  193. box-shadow: 0 4rpx 12rpx rgba(0, 0, 0, 0.05);
  194. .login-card-content {
  195. display: flex;
  196. align-items: center;
  197. position: relative;
  198. z-index: 2;
  199. .avatar-section {
  200. .avatar-placeholder {
  201. width: 120rpx;
  202. height: 120rpx;
  203. border-radius: 50%;
  204. background-color: #e0e0e0;
  205. display: flex;
  206. align-items: center;
  207. justify-content: center;
  208. .avatar-icon {
  209. font-size: 60rpx;
  210. color: #999999;
  211. }
  212. }
  213. .avatar-image {
  214. width: 120rpx;
  215. height: 120rpx;
  216. border-radius: 50%;
  217. }
  218. }
  219. .login-info {
  220. margin-left: 30rpx;
  221. flex: 1;
  222. .login-text {
  223. font-size: 36rpx;
  224. font-weight: 600;
  225. color: #000000;
  226. margin-bottom: 12rpx;
  227. }
  228. .user-name {
  229. font-size: 36rpx;
  230. font-weight: 600;
  231. color: #000000;
  232. margin-bottom: 12rpx;
  233. }
  234. .login-desc {
  235. font-size: 26rpx;
  236. color: #999999;
  237. }
  238. }
  239. }
  240. .login-card-bg {
  241. position: absolute;
  242. right: -60rpx;
  243. top: -60rpx;
  244. width: 240rpx;
  245. height: 240rpx;
  246. background: linear-gradient(135deg, rgba(59, 130, 246, 0.15) 0%, rgba(147, 197, 253, 0.15) 100%);
  247. border-radius: 50%;
  248. z-index: 1;
  249. opacity: 0.6;
  250. }
  251. }
  252. // 菜单卡片
  253. .menu-card {
  254. margin: 0 30rpx 30rpx 30rpx;
  255. background-color: #ffffff;
  256. border-radius: 24rpx;
  257. overflow: hidden;
  258. box-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.04);
  259. .menu-item {
  260. display: flex;
  261. align-items: center;
  262. justify-content: space-between;
  263. padding: 32rpx 30rpx;
  264. background-color: #ffffff;
  265. .menu-item-left {
  266. display: flex;
  267. align-items: center;
  268. flex: 1;
  269. .menu-icon-wrapper {
  270. width: 64rpx;
  271. height: 64rpx;
  272. border-radius: 16rpx;
  273. display: flex;
  274. align-items: center;
  275. justify-content: center;
  276. margin-right: 24rpx;
  277. &.account-icon {
  278. background-color: #e3f2fd;
  279. .menu-icon {
  280. color: #1976d2;
  281. }
  282. }
  283. &.revenue-icon {
  284. background-color: #fff3e0;
  285. position: relative;
  286. .revenue-symbol {
  287. font-size: 32rpx;
  288. font-weight: 600;
  289. color: #ff9800;
  290. }
  291. }
  292. &.cache-icon {
  293. background-color: #f3e5f5;
  294. .menu-icon {
  295. color: #9c27b0;
  296. }
  297. }
  298. &.about-icon {
  299. background-color: #e8f5e9;
  300. .menu-icon {
  301. color: #4caf50;
  302. }
  303. }
  304. &.logout-icon {
  305. background-color: #ffebee;
  306. .menu-icon {
  307. color: #f44336;
  308. }
  309. }
  310. .menu-icon {
  311. font-size: 36rpx;
  312. color: #333333;
  313. }
  314. }
  315. .menu-text {
  316. font-size: 32rpx;
  317. color: #000000;
  318. }
  319. }
  320. .arrow-icon {
  321. font-size: 28rpx;
  322. color: #cccccc;
  323. }
  324. }
  325. .menu-divider {
  326. height: 1rpx;
  327. background-color: #f0f0f0;
  328. margin: 0 30rpx;
  329. }
  330. }
  331. }
  332. </style>