index.vue 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217
  1. <template>
  2. <view class="container">
  3. <!-- 个人信息卡片 -->
  4. <view class="profile-card">
  5. <image class="avatar" :src="avatarUrl" mode="aspectFill" />
  6. <view class="profile-info">
  7. <view class="phone">{{ nickname }}</view>
  8. <view class="phone">{{ phone }}</view>
  9. <view class="profile-link" @click="goToProfile">个人信息 ></view>
  10. </view>
  11. </view>
  12. <!-- 我的学习模块 -->
  13. <view class="section">
  14. <view class="section-title">我的学习</view>
  15. <view class="study-row">
  16. <view class="study-card" v-for="item in studyList" :key="item.title" @click="goTo(item.path)">
  17. <image :src="item.icon" class="study-icon" />
  18. <view class="study-title">{{ item.title }}</view>
  19. </view>
  20. </view>
  21. </view>
  22. <view class="section list-section">
  23. <!-- <view class="section-title">商家店铺后台</view> -->
  24. <view class="menu-list-vertical">
  25. <view v-for="(item, idx) in menuList" :key="item.title">
  26. <view class="menu-item-vertical" @click="goTo(item.path)">
  27. <image :src="item.icon" class="menu-icon-vertical" />
  28. <view class="menu-title-vertical">{{ item.title }}</view>
  29. <text class="arrow">›</text>
  30. </view>
  31. <view v-if="idx !== menuList.length-1" class="divider"></view>
  32. </view>
  33. </view>
  34. </view>
  35. </view>
  36. </template>
  37. <script>
  38. export default {
  39. data() {
  40. return {
  41. avatarUrl: '',
  42. phone: '',
  43. nickname:'',
  44. studyList: [
  45. { title: '日历', icon: '/static/calender.png', path: '/pages/calendar/index' },
  46. { title: '我的下载', icon: '/static/xiazai.png', path: '/pages/search/index' },
  47. { title: '错题本', icon: '/static/cuotiben.png', path: '/pages/search/index' },
  48. { title: '超级会员', icon: '/static/supperhuiyuan.png', path: '/pages/discover/index' },
  49. { title: '订阅店铺', icon: '/static/dingyuedianpu.png', path: '/pages/discover/index' },
  50. ],
  51. menuList: [
  52. // <!-- 商家后台模块 -->
  53. { title: '商家店铺后台', icon: '/static/shangjiadianpu.png', path: '/pages/mine/Merchant' },
  54. { title: '回收站', icon: '/static/huishouzhan.png', path: '/pages/mine/recycle' },
  55. { title: '通知设置', icon: '/static/tongzhi.png', path: '/pages/mine/notify' },
  56. { title: '意见反馈', icon: '/static/yijianfankui.png', path: '/pages/mine/feedback' },
  57. { title: '在线客服', icon: '/static/kefu.png', path: '/pages/mine/service' },
  58. { title: '了解小鹅通', icon: '/static/liaojie.png', path: '/pages/mine/about' },
  59. { title: '设置', icon: '/static/shezhi.png', path: '/pages/mine/setting' },
  60. ]
  61. }
  62. },
  63. onLoad() {
  64. this.getUid()
  65. },
  66. methods: {
  67. goToProfile() {
  68. uni.navigateTo({ url: '/pages/mine/profile' })
  69. },
  70. goTo(path) {
  71. uni.navigateTo({ url: path })
  72. },
  73. async getUid() {
  74. // 假设 uid 存在本地缓存(如登录后存储),否则请根据实际情况获取
  75. try {
  76. const res = await uni.request({
  77. url: "http://localhost:9527/api/getUid",
  78. method: 'GET'
  79. })
  80. console.log(res)
  81. if (res.statusCode === 200) {
  82. this.nickname=res.data.data.nickname
  83. this.avatarUrl = res.data.data.avatarUrl
  84. this.phone = res.data.data.phone
  85. } else {
  86. this.avatarUrl = this.defaultAvatar
  87. this.phone = '获取失败'
  88. }
  89. } catch (e) {
  90. this.avatarUrl = this.defaultAvatar
  91. this.phone = '网络错误'
  92. }
  93. }
  94. }
  95. }
  96. </script>
  97. <style lang="scss">
  98. .container {
  99. min-height: 100vh;
  100. background: #f7f8fa;
  101. padding-bottom: 120rpx;
  102. padding-top: 80rpx;
  103. }
  104. .profile-card {
  105. display: flex;
  106. align-items: center;
  107. background: #fff;
  108. border-radius: 20rpx;
  109. margin: 0 24rpx 24rpx 24rpx;
  110. padding: 32rpx 24rpx;
  111. box-shadow: 0 4rpx 16rpx rgba(0,0,0,0.04);
  112. }
  113. .avatar {
  114. width: 120rpx;
  115. height: 120rpx;
  116. border-radius: 50%;
  117. margin-right: 32rpx;
  118. border: 2rpx solid #eee;
  119. }
  120. .profile-info {
  121. flex: 1;
  122. }
  123. .phone {
  124. font-size: 36rpx;
  125. font-weight: bold;
  126. color: #222;
  127. }
  128. .profile-link {
  129. color: #409EFF;
  130. font-size: 28rpx;
  131. margin-top: 8rpx;
  132. cursor: pointer;
  133. }
  134. .section {
  135. margin: 0 24rpx 24rpx 24rpx;
  136. background: #fff;
  137. border-radius: 20rpx;
  138. box-shadow: 0 4rpx 16rpx rgba(0,0,0,0.04);
  139. padding: 24rpx 0 0 0;
  140. }
  141. .section-title {
  142. font-size: 30rpx;
  143. font-weight: 600;
  144. color: #333;
  145. margin-left: 32rpx;
  146. margin-bottom: 16rpx;
  147. }
  148. .study-row {
  149. display: flex;
  150. flex-direction: row;
  151. justify-content: space-between;
  152. padding: 0 24rpx 24rpx 24rpx;
  153. }
  154. .study-card {
  155. flex: 1;
  156. margin: 0 8rpx;
  157. background: #f8fafc;
  158. border-radius: 16rpx;
  159. box-shadow: 0 2rpx 8rpx rgba(0,0,0,0.03);
  160. display: flex;
  161. flex-direction: column;
  162. align-items: center;
  163. padding: 24rpx 0 16rpx 0;
  164. cursor: pointer;
  165. transition: box-shadow 0.2s;
  166. }
  167. .study-card:active {
  168. box-shadow: 0 4rpx 16rpx rgba(0,0,0,0.08);
  169. }
  170. .study-icon {
  171. width: 56rpx;
  172. height: 56rpx;
  173. margin-bottom: 8rpx;
  174. }
  175. .study-title {
  176. font-size: 24rpx;
  177. color: #555;
  178. }
  179. .list-section {
  180. padding-bottom: 0;
  181. }
  182. .menu-list-vertical {
  183. margin: 0 0 0 0;
  184. }
  185. .menu-item-vertical {
  186. display: flex;
  187. align-items: center;
  188. padding: 0 32rpx;
  189. height: 96rpx;
  190. background: #fff;
  191. cursor: pointer;
  192. position: relative;
  193. }
  194. .menu-icon-vertical {
  195. width: 40rpx;
  196. height: 40rpx;
  197. margin-right: 24rpx;
  198. }
  199. .menu-title-vertical {
  200. flex: 1;
  201. font-size: 28rpx;
  202. color: #333;
  203. }
  204. .arrow {
  205. color: #bbb;
  206. font-size: 36rpx;
  207. margin-left: 8rpx;
  208. }
  209. .divider {
  210. height: 1rpx;
  211. background: #f0f0f0;
  212. margin: 0 32rpx;
  213. }
  214. </style>