my.vue 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372
  1. <template>
  2. <view class="my-page">
  3. <view class="user-section">
  4. <!-- 自定义头部 -->
  5. <view class="custom-header" :style="{paddingTop: statusBarHeight + 'px'}">
  6. <view class="header-content">
  7. <view class="back-btn" @click="goBack">
  8. <u-icon name="arrow-left" color="#fff" size="20"></u-icon>
  9. </view>
  10. <text class="title">个人中心</text>
  11. <view class="placeholder"></view>
  12. </view>
  13. </view>
  14. <image class="bg" src="https://zkzh-2025.oss-cn-beijing.aliyuncs.com/shop/images/my_bg.png"
  15. mode="aspectFill"></image>
  16. <view class="user-info-box" :style="{marginTop: (statusBarHeight + 44) + 'px'}">
  17. <view class="portrait-box" @click="checkLogin">
  18. <image class="portrait" :src="userInfo.avatar || defaultAvatar" mode="aspectFill"></image>
  19. </view>
  20. <view class="info-box" @click="checkLogin">
  21. <text class="username">{{isLogin ? (userInfo.nickName || '用户' + userInfo.userId) : '请登录'}}</text>
  22. <text class="user-id" v-if="isLogin">ID: {{userInfo.userId}}</text>
  23. </view>
  24. </view>
  25. </view>
  26. <view class="cover-container">
  27. <!-- 我的订单 -->
  28. <view class="order-section">
  29. <view class="sec-header" @click="navTo('/pages_user/user/storeOrder?status=')">
  30. <text class="sec-title">我的订单</text>
  31. <view class="more">
  32. <text>全部订单</text>
  33. <u-icon name="arrow-right" size="12" color="#999"></u-icon>
  34. </view>
  35. </view>
  36. <view class="order-grid">
  37. <view class="order-item" v-for="(item, index) in orderMenu" :key="index" @click="handleMenu(item)">
  38. <image :src="item.icon" mode="aspectFit" class="order-icon"></image>
  39. <text>{{item.name}}</text>
  40. </view>
  41. </view>
  42. </view>
  43. <!-- 常用功能 -->
  44. <view class="history-section icon">
  45. <view class="list-item" @click="navTo('/pages/user/address')">
  46. <image class="es-icon-48" src="/static/image/my/address_management_icon.png" mode=""></image>
  47. <text>地址管理</text>
  48. <u-icon name="arrow-right" size="14" color="#999" class="arrow"></u-icon>
  49. </view>
  50. <view class="list-item" @click="navTo('/pages_shopping/shopping/myCoupon')">
  51. <image class="es-icon-48" src="/static/image/my/coupon_collection.png" mode=""></image>
  52. <text>优惠券</text>
  53. <u-icon name="arrow-right" size="14" color="#999" class="arrow"></u-icon>
  54. </view>
  55. <view class="list-item" @click="navTo('/pages/user/about')">
  56. <image class="es-icon-48" src="/static/image/my/feedback_icon.png" mode=""></image>
  57. <text>关于我们</text>
  58. <u-icon name="arrow-right" size="14" color="#999" class="arrow"></u-icon>
  59. </view>
  60. <!-- <view class="list-item" @click="navTo('/pages/user/wallet/wallet')">
  61. <u-icon name="wallet" size="20" color="#e07472"></u-icon>
  62. <text>我的钱包</text>
  63. <u-icon name="arrow-right" size="14" color="#999" class="arrow"></u-icon>
  64. </view> -->
  65. <!-- <view class="list-item">
  66. <u-icon name="server-fill" size="20" color="#5fcda2"></u-icon>
  67. <text>联系客服</text>
  68. <u-icon name="arrow-right" size="14" color="#999" class="arrow"></u-icon>
  69. </view> -->
  70. <!-- <view class="list-item">
  71. <u-icon name="setting" size="20" color="#9789f7"></u-icon>
  72. <text>设置</text>
  73. <u-icon name="arrow-right" size="14" color="#999" class="arrow"></u-icon>
  74. </view> -->
  75. </view>
  76. </view>
  77. </view>
  78. </template>
  79. <script>
  80. import {
  81. getUserInfo
  82. } from '@/api/user'
  83. export default {
  84. data() {
  85. return {
  86. statusBarHeight: 20,
  87. defaultAvatar: '/static/image/hall/my_heads_icon.png',
  88. isLogin: false,
  89. userInfo: {},
  90. orderMenu: [{
  91. name: '待付款',
  92. icon: '/static/image/mall/payment.png',
  93. state: 0
  94. },
  95. {
  96. name: '待发货',
  97. icon: '/static/image/mall/send_goods.png',
  98. state: 1
  99. },
  100. {
  101. name: '待收货',
  102. icon: '/static/image/mall/sou_goods.png',
  103. state: 2
  104. },
  105. {
  106. name: '已完成',
  107. icon: '/static/image/mall/completed.png',
  108. state: 3
  109. },
  110. {
  111. name: '售后/退款',
  112. icon: '/static/image/mall/after_sales.png',
  113. url: '/pages_user/user/refundOrderList'
  114. }
  115. ]
  116. }
  117. },
  118. created() {
  119. this.statusBarHeight = uni.getSystemInfoSync().statusBarHeight;
  120. this.checkLoginStatus();
  121. },
  122. methods: {
  123. goBack() {
  124. uni.showTabBar()
  125. uni.switchTab({
  126. url: '/pages_im/pages/conversation/conversationList/index'
  127. })
  128. },
  129. checkLoginStatus() {
  130. const token = uni.getStorageSync('AppToken');
  131. if (token) {
  132. this.isLogin = true;
  133. this.getUserInfo();
  134. } else {
  135. this.isLogin = false;
  136. this.userInfo = {};
  137. }
  138. },
  139. checkLogin() {
  140. if (!this.isLogin) {
  141. uni.navigateTo({
  142. url: '/pages/auth/loginIndex'
  143. });
  144. }
  145. },
  146. getUserInfo() {
  147. getUserInfo().then(res => {
  148. if (res.code == 200 && res.user) {
  149. this.userInfo = res.user;
  150. }
  151. });
  152. },
  153. navTo(url) {
  154. uni.navigateTo({
  155. url: url
  156. });
  157. },
  158. handleMenu(item) {
  159. if (!this.isLogin) {
  160. uni.navigateTo({
  161. url: '/pages/auth/loginIndex'
  162. });
  163. return;
  164. }
  165. if (item.url) {
  166. return uni.navigateTo({
  167. url: item.url
  168. });
  169. }
  170. uni.navigateTo({
  171. url: `/pages_user/user/storeOrder?status=${item.state}`
  172. })
  173. }
  174. }
  175. }
  176. </script>
  177. <style scoped lang="scss">
  178. .my-page {
  179. height: 100%;
  180. background-color: #F5F7FA;
  181. }
  182. .custom-header {
  183. position: absolute;
  184. top: 0;
  185. left: 0;
  186. right: 0;
  187. z-index: 10;
  188. .header-content {
  189. height: 44px;
  190. display: flex;
  191. align-items: center;
  192. justify-content: space-between;
  193. padding: 0 30rpx;
  194. .title {
  195. color: #fff;
  196. font-size: 36rpx;
  197. font-weight: bold;
  198. }
  199. .back-btn,
  200. .placeholder {
  201. width: 40rpx;
  202. height: 40rpx;
  203. display: flex;
  204. align-items: center;
  205. justify-content: center;
  206. }
  207. }
  208. }
  209. .user-section {
  210. height: 420rpx;
  211. position: relative;
  212. overflow: hidden;
  213. .bg {
  214. position: absolute;
  215. left: 0;
  216. top: 0;
  217. width: 100%;
  218. height: 100%;
  219. background: linear-gradient(to bottom, #2583EB, #4FACFE);
  220. }
  221. .user-info-box {
  222. display: flex;
  223. align-items: center;
  224. position: relative;
  225. z-index: 1;
  226. padding: 0 30rpx;
  227. .portrait-box {
  228. width: 130rpx;
  229. height: 130rpx;
  230. border: 5rpx solid rgba(255, 255, 255, 0.5);
  231. border-radius: 50%;
  232. overflow: hidden;
  233. box-shadow: 0 4rpx 16rpx rgba(0, 0, 0, 0.1);
  234. background: #fff;
  235. .portrait {
  236. width: 100%;
  237. height: 100%;
  238. }
  239. }
  240. .info-box {
  241. display: flex;
  242. flex-direction: column;
  243. margin-left: 24rpx;
  244. color: #fff;
  245. .username {
  246. font-size: 38rpx;
  247. font-weight: bold;
  248. text-shadow: 0 2rpx 4rpx rgba(0, 0, 0, 0.1);
  249. }
  250. .user-id {
  251. font-size: 24rpx;
  252. margin-top: 10rpx;
  253. opacity: 0.9;
  254. }
  255. }
  256. }
  257. }
  258. .cover-container {
  259. margin-top: -100rpx;
  260. padding: 0 30rpx;
  261. position: relative;
  262. padding-bottom: 120rpx;
  263. .order-section {
  264. background: #fff;
  265. border-radius: 20rpx;
  266. padding: 20rpx 0;
  267. box-shadow: 0 4rpx 16rpx rgba(0, 0, 0, 0.04);
  268. .sec-header {
  269. display: flex;
  270. justify-content: space-between;
  271. align-items: center;
  272. padding: 0 30rpx 20rpx;
  273. border-bottom: 1rpx solid #f5f5f5;
  274. .sec-title {
  275. font-size: 30rpx;
  276. font-weight: bold;
  277. color: #333;
  278. }
  279. .more {
  280. display: flex;
  281. align-items: center;
  282. text {
  283. font-size: 24rpx;
  284. color: #999;
  285. margin-right: 6rpx;
  286. }
  287. }
  288. }
  289. .order-grid {
  290. display: flex;
  291. justify-content: space-around;
  292. padding: 30rpx 0 10rpx;
  293. .order-item {
  294. display: flex;
  295. flex-direction: column;
  296. align-items: center;
  297. .order-icon {
  298. width: 56rpx;
  299. height: 56rpx;
  300. margin-bottom: 12rpx;
  301. }
  302. text {
  303. font-size: 24rpx;
  304. color: #666;
  305. }
  306. }
  307. }
  308. }
  309. .history-section {
  310. background: #fff;
  311. border-radius: 20rpx;
  312. margin-top: 24rpx;
  313. box-shadow: 0 4rpx 16rpx rgba(0, 0, 0, 0.04);
  314. padding: 10rpx 0;
  315. .list-item {
  316. display: flex;
  317. align-items: center;
  318. padding: 30rpx 30rpx;
  319. border-bottom: 1rpx solid #f5f5f5;
  320. position: relative;
  321. &:last-child {
  322. border-bottom: none;
  323. }
  324. text {
  325. flex: 1;
  326. font-size: 30rpx;
  327. color: #333;
  328. margin-left: 24rpx;
  329. font-weight: 500;
  330. }
  331. .arrow {
  332. margin-left: auto;
  333. opacity: 0.5;
  334. }
  335. }
  336. }
  337. }
  338. </style>