index.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484
  1. <template>
  2. <view class="mine-page">
  3. <erp-nav-bar title="个人中心" :show-back="false" bg-color="#C1001C" title-color="#ffffff" />
  4. <scroll-view class="mine-scroll" scroll-y enable-back-to-top :show-scrollbar="false" :enhanced="true">
  5. <!-- 顶部大气定制背景 (带柔和渐变与底部圆角弧度) -->
  6. <view class="header-bg-shape">
  7. <view class="header-bg-gradient"></view>
  8. </view>
  9. <!-- 整体内容下移 -->
  10. <view class="content-wrapper">
  11. <!-- 1. 登录状态卡片 -->
  12. <view class="user-card" v-if="isLogin">
  13. <view class="avatar-box">
  14. <image class="avatar-img"
  15. :src="customerInfo && customerInfo.avatarUrl ? customerInfo.avatarUrl : 'https://img.icons8.com/color/144/user.png'"
  16. mode="aspectFill">
  17. </image>
  18. </view>
  19. <view class="info-box">
  20. <text class="nickname">{{ customerInfo ? customerInfo.userName : '' }}</text>
  21. <view class="tags-row" v-if="customerInfo">
  22. <text class="customer-tag">授权客户: {{ customerInfo.authClientName || '无' }}</text>
  23. </view>
  24. <text class="phone-text">{{ customerInfo ? customerInfo.phone : '' }}</text>
  25. </view>
  26. <!-- 新增:右侧设置图标 -->
  27. <view class="settings-btn" @click="goToSettings">
  28. <image class="settings-icon" :src="assets.mineSettings" mode="aspectFit"></image>
  29. </view>
  30. </view>
  31. <!-- 1. 未登录状态卡片 -->
  32. <view class="user-card unlogged" v-else @click="goToLogin">
  33. <view class="avatar-box gray-avatar">
  34. <image class="avatar-img" src="https://img.icons8.com/material-outlined/100/cccccc/user.png"
  35. mode="aspectFit"></image>
  36. </view>
  37. <view class="info-box">
  38. <text class="nickname login-hint">未登录</text>
  39. <text class="phone-text">点击此处登录,体验完整功能</text>
  40. </view>
  41. <image class="arrow-icon-right" :src="assets.mineArrow"></image>
  42. </view>
  43. <!-- 2. 我的订单 (线性图标) -->
  44. <view class="section-card">
  45. <view class="section-header">
  46. <text class="section-title">我的订单</text>
  47. <view class="more-link" @click="goToOrderList(0)">
  48. <text>全部</text>
  49. <image class="arrow-icon" :src="assets.mineArrow"></image>
  50. </view>
  51. </view>
  52. <view class="stat-grid">
  53. <view class="stat-item" v-for="(item, index) in orderStates" :key="index"
  54. @click="goToOrderList(index + 1)">
  55. <image class="stat-icon" :src="item.icon" mode="aspectFit"></image>
  56. <text class="stat-label">{{ item.label }}</text>
  57. </view>
  58. </view>
  59. </view>
  60. <!-- 3. 功能菜单列表 (线性图标) -->
  61. <view class="section-card menu-card">
  62. <view class="menu-item" v-for="(menu, index) in menuList" :key="index"
  63. @click="handleMenuClick(menu)">
  64. <view class="menu-left">
  65. <image class="menu-icon" :src="menu.icon" mode="aspectFit"></image>
  66. <text class="menu-label">{{ menu.label }}</text>
  67. </view>
  68. <image class="arrow-icon-right" :src="assets.mineArrow"></image>
  69. </view>
  70. </view>
  71. <!-- 4. 退出登录按钮 (仅登录后显示) -->
  72. <view class="logout-section" v-if="isLogin">
  73. <button class="logout-btn" @click="handleLogout">退出登录</button>
  74. </view>
  75. <view class="bottom-placeholder"></view>
  76. </view>
  77. </scroll-view>
  78. <erp-tab-bar active="mine"></erp-tab-bar>
  79. </view>
  80. </template>
  81. <script>
  82. import ErpTabBar from '@/components/erp-tab-bar.vue';
  83. import ErpNavBar from '@/components/erp-nav-bar.vue';
  84. import assets from '@/utils/assets.js';
  85. import { getMyInfo } from '@/api/system/customer.js';
  86. import { logout } from '@/api/auth/index.js';
  87. export default {
  88. components: { ErpTabBar, ErpNavBar },
  89. data() {
  90. return {
  91. assets,
  92. isLogin: false,
  93. customerInfo: null,
  94. orderStates: [
  95. { label: '待审核', icon: assets.minePendingReview },
  96. { label: '待签批', icon: assets.minePendingSign },
  97. { label: '生产中', icon: assets.mineProducing },
  98. { label: '已完成', icon: assets.mineCompleted }
  99. ],
  100. menuList: [
  101. { label: '用户协议', icon: assets.mineProtocol, id: 'agreement' },
  102. { label: '隐私政策', icon: assets.minePrivacy, id: 'privacy' },
  103. { label: '投诉与建议', icon: assets.mineComplaint, id: 'complaint' },
  104. { label: '联系客服', icon: assets.mineService, id: 'service' }
  105. ]
  106. }
  107. },
  108. onShow() {
  109. this.isLogin = !!uni.getStorageSync('isLogin');
  110. if (this.isLogin) {
  111. this.loadCustomerInfo();
  112. }
  113. },
  114. methods: {
  115. async loadCustomerInfo() {
  116. try {
  117. const res = await getMyInfo();
  118. this.customerInfo = res.data;
  119. } catch (e) {
  120. console.error('[mine] 加载客户信息失败', e);
  121. }
  122. },
  123. goToLogin() {
  124. uni.reLaunch({ url: '/pages/login/index' });
  125. },
  126. // 跳转至设置页面
  127. goToSettings() {
  128. if (this.isLogin) {
  129. uni.navigateTo({
  130. url: '/pages/mine/settings/index'
  131. });
  132. }
  133. },
  134. // 新增:跳转至订单列表
  135. goToOrderList(status) {
  136. if (!this.isLogin) {
  137. return this.goToLogin();
  138. }
  139. uni.navigateTo({
  140. url: `/pages/order/list/index?tab=${status}`
  141. });
  142. },
  143. handleLogout() {
  144. uni.showModal({
  145. title: '退出提示',
  146. content: '确认退出当前账号吗?',
  147. confirmColor: '#C1001C',
  148. success: async (res) => {
  149. if (res.confirm) {
  150. try {
  151. await logout();
  152. } catch (e) {
  153. console.error('[mine] 退出登录接口失败', e);
  154. }
  155. uni.removeStorageSync('token');
  156. uni.removeStorageSync('isLogin');
  157. this.isLogin = false;
  158. uni.reLaunch({ url: '/pages/login/index' });
  159. }
  160. }
  161. });
  162. },
  163. // 新增:菜单点击处理
  164. handleMenuClick(menu) {
  165. if (menu.id === 'agreement') {
  166. uni.navigateTo({ url: '/pages/mine/agreement/index' });
  167. } else if (menu.id === 'privacy') {
  168. uni.navigateTo({ url: '/pages/mine/privacy/index' });
  169. } else if (menu.id === 'complaint') {
  170. uni.navigateTo({ url: '/pages/mine/complaint/index' });
  171. } else if (menu.id === 'service') {
  172. uni.showModal({
  173. title: '联系客服',
  174. content: '客服电话:138-8888-8888',
  175. confirmText: '立即拨打',
  176. confirmColor: '#C1001C',
  177. cancelColor: '#999999',
  178. success: (res) => {
  179. if (res.confirm) {
  180. uni.makePhoneCall({
  181. phoneNumber: '13888888888'
  182. });
  183. }
  184. }
  185. });
  186. }
  187. }
  188. }
  189. }
  190. </script>
  191. <style scoped>
  192. .mine-page {
  193. width: 100%;
  194. height: 100vh;
  195. background: #f7f8fa;
  196. position: relative;
  197. display: flex;
  198. flex-direction: column;
  199. overflow: hidden;
  200. }
  201. .mine-scroll {
  202. width: 100%;
  203. height: 100%;
  204. }
  205. /* 隐藏滚动条 */
  206. .mine-scroll ::-webkit-scrollbar {
  207. width: 0 !important;
  208. height: 0 !important;
  209. color: transparent !important;
  210. display: none !important;
  211. }
  212. /* 顶部定制背景:高级渐变蓝 + 柔和弧度 */
  213. .header-bg-shape {
  214. position: absolute;
  215. top: 0;
  216. left: 0;
  217. width: 100%;
  218. height: 380rpx;
  219. background: linear-gradient(135deg, #C1001C 0%, #F4D4F 100%);
  220. border-bottom-left-radius: 60rpx;
  221. border-bottom-right-radius: 60rpx;
  222. z-index: 1;
  223. box-shadow: 0 10rpx 30rpx rgba(193, 0, 28, 0.15);
  224. }
  225. .header-bg-gradient {
  226. width: 100%;
  227. height: 100%;
  228. background: linear-gradient(180deg, rgba(255, 255, 255, 0) 0%, rgba(255, 255, 255, 0.1) 100%);
  229. border-bottom-left-radius: 60rpx;
  230. border-bottom-right-radius: 60rpx;
  231. }
  232. /* 标题栏已恢复为原生,此处仅需正常的容器内边距即可 */
  233. .content-wrapper {
  234. position: relative;
  235. z-index: 2;
  236. flex: 1;
  237. display: flex;
  238. flex-direction: column;
  239. padding: 40rpx 30rpx 0;
  240. box-sizing: border-box;
  241. }
  242. /* 用户信息卡片 */
  243. .user-card {
  244. background: #fff;
  245. border-radius: 32rpx;
  246. padding: 50rpx 40rpx;
  247. display: flex;
  248. align-items: center;
  249. margin-bottom: 30rpx;
  250. margin-top: 20rpx;
  251. box-shadow: 0 16rpx 40rpx rgba(0, 0, 0, 0.05);
  252. }
  253. .user-card.unlogged {
  254. cursor: pointer;
  255. }
  256. .avatar-box {
  257. width: 130rpx;
  258. height: 130rpx;
  259. border-radius: 65rpx;
  260. background: #f5f6f7;
  261. margin-right: 30rpx;
  262. overflow: hidden;
  263. border: 4rpx solid #fff;
  264. box-shadow: 0 4rpx 12rpx rgba(0, 0, 0, 0.05);
  265. }
  266. .gray-avatar {
  267. background: #f0f0f0;
  268. display: flex;
  269. align-items: center;
  270. justify-content: center;
  271. }
  272. .avatar-img {
  273. width: 100%;
  274. height: 100%;
  275. }
  276. .info-box {
  277. flex: 1;
  278. display: flex;
  279. flex-direction: column;
  280. justify-content: center;
  281. }
  282. .nickname {
  283. font-size: 40rpx;
  284. font-weight: bold;
  285. color: #1a1a1a;
  286. margin-bottom: 12rpx;
  287. }
  288. .login-hint {
  289. color: #333;
  290. }
  291. .tags-row {
  292. display: flex;
  293. align-items: center;
  294. margin-bottom: 12rpx;
  295. }
  296. .customer-tag {
  297. font-size: 24rpx;
  298. color: #C1001C;
  299. background: rgba(193, 0, 28, 0.1);
  300. padding: 6rpx 16rpx;
  301. border-radius: 8rpx;
  302. font-weight: 500;
  303. }
  304. .phone-text {
  305. font-size: 26rpx;
  306. color: #999;
  307. }
  308. /* 设置图标 & 右侧箭头 */
  309. .settings-btn {
  310. width: 60rpx;
  311. height: 60rpx;
  312. display: flex;
  313. align-items: center;
  314. justify-content: center;
  315. }
  316. .settings-icon {
  317. width: 44rpx;
  318. height: 44rpx;
  319. opacity: 0.6;
  320. }
  321. .arrow-icon-right {
  322. width: 24rpx;
  323. height: 24rpx;
  324. opacity: 0.4;
  325. }
  326. /* 通用卡片样式 */
  327. .section-card {
  328. background: #fff;
  329. border-radius: 24rpx;
  330. padding: 40rpx 30rpx;
  331. margin-bottom: 30rpx;
  332. box-shadow: 0 8rpx 30rpx rgba(0, 0, 0, 0.02);
  333. }
  334. /* 订单统计区块 */
  335. .section-header {
  336. display: flex;
  337. justify-content: space-between;
  338. align-items: center;
  339. margin-bottom: 40rpx;
  340. }
  341. .section-title {
  342. font-size: 32rpx;
  343. font-weight: bold;
  344. color: #333;
  345. }
  346. .more-link {
  347. display: flex;
  348. align-items: center;
  349. font-size: 26rpx;
  350. color: #999;
  351. }
  352. .arrow-icon {
  353. width: 20rpx;
  354. height: 20rpx;
  355. opacity: 0.5;
  356. margin-left: 6rpx;
  357. position: relative;
  358. top: 2rpx;
  359. }
  360. .stat-grid {
  361. display: flex;
  362. justify-content: space-around;
  363. }
  364. .stat-item {
  365. display: flex;
  366. flex-direction: column;
  367. align-items: center;
  368. }
  369. .stat-icon {
  370. width: 56rpx;
  371. height: 56rpx;
  372. margin-bottom: 16rpx;
  373. opacity: 0.8;
  374. }
  375. .stat-label {
  376. font-size: 26rpx;
  377. color: #666;
  378. }
  379. /* 菜单列表区块 */
  380. .menu-card {
  381. padding: 10rpx 30rpx;
  382. }
  383. .menu-item {
  384. display: flex;
  385. justify-content: space-between;
  386. align-items: center;
  387. padding: 36rpx 0;
  388. border-bottom: 1rpx solid #f5f6f7;
  389. }
  390. .menu-item:last-child {
  391. border-bottom: none;
  392. }
  393. .menu-left {
  394. display: flex;
  395. align-items: center;
  396. }
  397. .menu-icon {
  398. width: 44rpx;
  399. height: 44rpx;
  400. margin-right: 20rpx;
  401. opacity: 0.7;
  402. }
  403. .menu-label {
  404. font-size: 30rpx;
  405. color: #333;
  406. }
  407. /* 退出登录 */
  408. .logout-section {
  409. margin-top: 40rpx;
  410. }
  411. .logout-btn {
  412. width: 100%;
  413. height: 96rpx;
  414. background: #fff;
  415. color: #ff5e5e;
  416. border-radius: 24rpx;
  417. display: flex;
  418. align-items: center;
  419. justify-content: center;
  420. font-size: 32rpx;
  421. font-weight: bold;
  422. border: none;
  423. box-shadow: 0 4rpx 20rpx rgba(255, 94, 94, 0.05);
  424. transition: all 0.2s;
  425. }
  426. .logout-btn:active {
  427. background: #fff0f0;
  428. }
  429. button::after {
  430. border: none;
  431. }
  432. .bottom-placeholder {
  433. height: 180rpx;
  434. }
  435. </style>