index.vue 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271
  1. <template>
  2. <view class="page-container">
  3. <!-- 顶部背景 -->
  4. <view class="top-bg">
  5. <view class="status_bar" :style="{ height: statusBarHeight }"></view>
  6. <view class="top-title">个人中心</view>
  7. </view>
  8. <!-- 用户卡片 -->
  9. <view class="user-card">
  10. <view class="user-info" @click="navgetTo('/pages_user/user/personInfo')">
  11. <image class="avatar" :src="user.avatarUrl ? user.avatarUrl : '/static/avatar.png'" mode="aspectFill"></image>
  12. <view class="info-content">
  13. <view class="name-row">
  14. <text class="nickname">{{ user.nickname || '立即登录' }}</text>
  15. <image class="arrow-right" src="/static/right_arrow_right.png" mode="aspectFit"></image>
  16. </view>
  17. <view class="welcome-text">Hi,欢迎来到小程序</view>
  18. </view>
  19. </view>
  20. </view>
  21. <!-- 菜单列表 -->
  22. <view class="menu-list">
  23. <view class="menu-item" @click="navgetTo('/pages_user/user/storeOrder')">
  24. <view class="left">
  25. <image class="icon" src="/static/manageTabIcon/training.png" mode="aspectFit"></image>
  26. <text class="label">我的课程</text>
  27. </view>
  28. <image class="arrow" src="/static/right_arrow_right.png" mode="aspectFit"></image>
  29. </view>
  30. <view class="menu-item" @click="navgetTo('/pages_user/user/message')">
  31. <view class="left">
  32. <image class="icon" src="/static/manageTabIcon/liveclasses.png" mode="aspectFit"></image>
  33. <text class="label">我的消息</text>
  34. </view>
  35. <image class="arrow" src="/static/right_arrow_right.png" mode="aspectFit"></image>
  36. </view>
  37. </view>
  38. <view class="menu-list mt24">
  39. <view class="menu-item" @click="makePhoneCall">
  40. <view class="left">
  41. <image class="icon" src="/static/service_center.png" mode="aspectFit"></image>
  42. <text class="label">客服中心</text>
  43. </view>
  44. <view class="right">
  45. <text class="phone-num">400-023-8558</text>
  46. <image class="arrow" src="/static/right_arrow_right.png" mode="aspectFit"></image>
  47. </view>
  48. </view>
  49. <view class="menu-item" @click="navgetTo('/pages_user/user/personInfo')">
  50. <view class="left">
  51. <image class="icon" src="/static/set_icon.png" mode="aspectFit"></image>
  52. <text class="label">设置</text>
  53. </view>
  54. <image class="arrow" src="/static/right_arrow_right.png" mode="aspectFit"></image>
  55. </view>
  56. </view>
  57. <!-- 退出登录 -->
  58. <view class="logout-btn" v-if="UserInfo" @tap="loginOUt">
  59. 退出登录
  60. </view>
  61. </view>
  62. </template>
  63. <script>
  64. import {
  65. getUserInfo
  66. } from '@/api/user'
  67. export default {
  68. data() {
  69. return {
  70. user: {
  71. nickname: "",
  72. avatarUrl: "/static/avatar.png"
  73. },
  74. statusBarHeight: uni.getStorageSync('menuInfo') ? uni.getStorageSync('menuInfo').statusBarHeight : 20,
  75. UserInfo: uni.getStorageSync('AppToken')
  76. };
  77. },
  78. onShow() {
  79. this.UserInfo = uni.getStorageSync('AppToken')
  80. if (this.UserInfo) {
  81. this.getUserInfo()
  82. }
  83. },
  84. methods: {
  85. getUserInfo() {
  86. getUserInfo().then(
  87. res => {
  88. if (res.code == 200 && res.user != null) {
  89. this.user = res.user;
  90. }
  91. }
  92. );
  93. },
  94. navgetTo(url) {
  95. this.utils.isLogin().then(res => {
  96. if (res) {
  97. uni.navigateTo({
  98. url: url
  99. })
  100. }
  101. })
  102. },
  103. makePhoneCall() {
  104. uni.makePhoneCall({
  105. phoneNumber: '400-023-8558'
  106. });
  107. },
  108. loginOUt() {
  109. this.utils.loginOut();
  110. this.UserInfo = "";
  111. this.user = {
  112. nickname: "",
  113. avatarUrl: "/static/avatar.png"
  114. };
  115. }
  116. }
  117. }
  118. </script>
  119. <style lang="scss" scoped>
  120. .page-container {
  121. width: 100%;
  122. min-height: 100vh;
  123. background-color: #F8F9FB;
  124. padding-bottom: 120rpx;
  125. }
  126. .top-bg {
  127. width: 100%;
  128. height: 380rpx;
  129. background: linear-gradient(180deg, #5C4BFF 0%, #7E71FF 100%);
  130. display: flex;
  131. flex-direction: column;
  132. .status_bar {
  133. width: 100%;
  134. }
  135. .top-title {
  136. height: 88rpx;
  137. display: flex;
  138. align-items: center;
  139. justify-content: center;
  140. font-size: 36rpx;
  141. font-weight: bold;
  142. color: #FFFFFF;
  143. }
  144. }
  145. .user-card {
  146. margin: -160rpx 30rpx 0;
  147. background: #FFFFFF;
  148. border-radius: 24rpx;
  149. padding: 40rpx;
  150. box-shadow: 0 4rpx 20rpx rgba(92, 75, 255, 0.1);
  151. .user-info {
  152. display: flex;
  153. align-items: center;
  154. .avatar {
  155. width: 120rpx;
  156. height: 120rpx;
  157. border-radius: 50%;
  158. margin-right: 30rpx;
  159. background-color: #f5f5f5;
  160. }
  161. .info-content {
  162. flex: 1;
  163. .name-row {
  164. display: flex;
  165. align-items: center;
  166. margin-bottom: 12rpx;
  167. .nickname {
  168. font-size: 40rpx;
  169. font-weight: bold;
  170. color: #1A1A1A;
  171. margin-right: 12rpx;
  172. }
  173. .arrow-right {
  174. width: 24rpx;
  175. height: 24rpx;
  176. }
  177. }
  178. .welcome-text {
  179. font-size: 26rpx;
  180. color: #999999;
  181. }
  182. }
  183. }
  184. }
  185. .menu-list {
  186. margin: 30rpx 30rpx 0;
  187. background: #FFFFFF;
  188. border-radius: 24rpx;
  189. padding: 0 30rpx;
  190. .menu-item {
  191. display: flex;
  192. align-items: center;
  193. justify-content: space-between;
  194. height: 110rpx;
  195. border-bottom: 1rpx solid #F5F6F8;
  196. &:last-child {
  197. border-bottom: none;
  198. }
  199. .left {
  200. display: flex;
  201. align-items: center;
  202. .icon {
  203. width: 44rpx;
  204. height: 44rpx;
  205. margin-right: 20rpx;
  206. }
  207. .label {
  208. font-size: 30rpx;
  209. color: #1A1A1A;
  210. font-weight: 500;
  211. }
  212. }
  213. .right {
  214. display: flex;
  215. align-items: center;
  216. .phone-num {
  217. font-size: 28rpx;
  218. color: #666666;
  219. margin-right: 12rpx;
  220. }
  221. }
  222. .arrow {
  223. width: 24rpx;
  224. height: 24rpx;
  225. }
  226. }
  227. }
  228. .mt24 {
  229. margin-top: 24rpx;
  230. }
  231. .logout-btn {
  232. margin: 40rpx 30rpx;
  233. height: 100rpx;
  234. background: #FFFFFF;
  235. border-radius: 24rpx;
  236. display: flex;
  237. align-items: center;
  238. justify-content: center;
  239. font-size: 32rpx;
  240. font-weight: bold;
  241. color: #5C4BFF;
  242. }
  243. </style>