index.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482
  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="employeeInfo && employeeInfo.avatarUrl ? employeeInfo.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">{{ employeeInfo ? employeeInfo.name : '' }}</text>
  21. <text class="phone-text">{{ employeeInfo ? employeeInfo.phone : '' }}</text>
  22. </view>
  23. <!-- 新增:右侧设置图标 -->
  24. <view class="settings-btn" @click="goToSettings">
  25. <image class="settings-icon" :src="assets.mineSettings" mode="aspectFit"></image>
  26. </view>
  27. </view>
  28. <!-- 1. 未登录状态卡片 -->
  29. <view class="user-card unlogged" v-else @click="goToLogin">
  30. <view class="avatar-box gray-avatar">
  31. <image class="avatar-img" src="https://img.icons8.com/material-outlined/100/cccccc/user.png"
  32. mode="aspectFit"></image>
  33. </view>
  34. <view class="info-box">
  35. <text class="nickname login-hint">未登录</text>
  36. <text class="phone-text">点击此处登录,体验完整功能</text>
  37. </view>
  38. <image class="arrow-icon-right" :src="assets.mineArrow"></image>
  39. </view>
  40. <!-- 2. 我的订单 (线性图标) -->
  41. <view class="section-card">
  42. <view class="section-header">
  43. <text class="section-title">我的订单</text>
  44. <view class="more-link" @click="goToOrderList(0)">
  45. <text>全部</text>
  46. <image class="arrow-icon" :src="assets.mineArrow"></image>
  47. </view>
  48. </view>
  49. <view class="stat-grid">
  50. <view class="stat-item" v-for="(item, index) in orderStates" :key="index"
  51. @click="goToOrderList(item.tabIndex)">
  52. <image class="stat-icon" :src="item.icon" mode="aspectFit"></image>
  53. <text class="stat-label">{{ item.label }}</text>
  54. </view>
  55. </view>
  56. </view>
  57. <!-- 3. 功能菜单列表 (线性图标) -->
  58. <view class="section-card menu-card">
  59. <view class="menu-item" v-for="(menu, index) in menuList" :key="index"
  60. @click="handleMenuClick(menu)">
  61. <view class="menu-left">
  62. <image class="menu-icon" :src="menu.icon" mode="aspectFit"></image>
  63. <text class="menu-label">{{ menu.label }}</text>
  64. </view>
  65. <image class="arrow-icon-right" :src="assets.mineArrow"></image>
  66. </view>
  67. </view>
  68. <!-- 4. 退出登录按钮 (仅登录后显示) -->
  69. <view class="logout-section" v-if="isLogin">
  70. <button class="logout-btn" @click="handleLogout">退出登录</button>
  71. </view>
  72. <view class="bottom-placeholder"></view>
  73. </view>
  74. </scroll-view>
  75. <erp-tab-bar active="mine"></erp-tab-bar>
  76. </view>
  77. </template>
  78. <script>
  79. import ErpTabBar from '@/components/erp-tab-bar.vue';
  80. import ErpNavBar from '@/components/erp-nav-bar.vue';
  81. import assets from '@/utils/assets.js';
  82. import { getMyInfo } from '@/api/system/employee.js';
  83. import { logout } from '@/api/auth.js';
  84. import { getPhone } from '@/api/system/phone.js';
  85. export default {
  86. components: { ErpTabBar, ErpNavBar },
  87. data() {
  88. return {
  89. assets,
  90. isLogin: false,
  91. employeeInfo: null,
  92. servicePhone: '13888888888',
  93. orderStates: [
  94. { label: '待审核', tabIndex: 2, icon: assets.minePendingReview },
  95. { label: '待签批', tabIndex: 4, icon: assets.minePendingSign },
  96. { label: '生产中', tabIndex: 5, icon: assets.mineProducing },
  97. { label: '已完成', tabIndex: 6, icon: assets.mineCompleted }
  98. ],
  99. menuList: [
  100. { label: '用户协议', icon: assets.mineProtocol, id: 'agreement' },
  101. { label: '隐私政策', icon: assets.minePrivacy, id: 'privacy' },
  102. { label: '投诉与建议', icon: assets.mineComplaint, id: 'complaint' },
  103. { label: '联系客服', icon: assets.mineService, id: 'service' }
  104. ]
  105. }
  106. },
  107. onShow() {
  108. this.isLogin = !!uni.getStorageSync('isLogin');
  109. if (this.isLogin) {
  110. this.loadEmployeeInfo();
  111. }
  112. this.loadServicePhone();
  113. },
  114. methods: {
  115. async loadServicePhone() {
  116. try {
  117. const res = await getPhone();
  118. if (res.data && res.data.servicePhone) {
  119. this.servicePhone = res.data.servicePhone;
  120. }
  121. } catch (e) {
  122. console.error('加载客服电话失败', e);
  123. uni.showToast({ title: e || '加载客服电话失败', icon: 'none' });
  124. }
  125. },
  126. async loadEmployeeInfo() {
  127. try {
  128. const res = await getMyInfo();
  129. this.employeeInfo = res.data;
  130. } catch (e) {
  131. console.error('[mine] 加载员工信息失败', e);
  132. uni.showToast({ title: e || '加载员工信息失败', icon: 'none' });
  133. }
  134. },
  135. goToLogin() {
  136. uni.reLaunch({ url: '/pages/login/index' });
  137. },
  138. // 跳转至设置页面
  139. goToSettings() {
  140. if (this.isLogin) {
  141. uni.navigateTo({
  142. url: '/pages/mine/settings/index'
  143. });
  144. }
  145. },
  146. // 新增:跳转至订单列表
  147. goToOrderList(status) {
  148. if (!this.isLogin) {
  149. return this.goToLogin();
  150. }
  151. uni.navigateTo({
  152. url: `/pages/order/list/index?tab=${status}`
  153. });
  154. },
  155. handleLogout() {
  156. uni.showModal({
  157. title: '退出提示',
  158. content: '确认退出当前账号吗?',
  159. confirmColor: '#C1001C',
  160. success: async (res) => {
  161. if (res.confirm) {
  162. try {
  163. await logout();
  164. } catch (e) {
  165. console.error('[mine] 退出登录接口失败', e);
  166. uni.showToast({ title: e || '退出失败', icon: 'none' });
  167. }
  168. uni.removeStorageSync('token');
  169. uni.removeStorageSync('isLogin');
  170. this.isLogin = false;
  171. uni.reLaunch({ url: '/pages/login/index' });
  172. }
  173. }
  174. });
  175. },
  176. // 新增:菜单点击处理
  177. handleMenuClick(menu) {
  178. if (menu.id === 'agreement') {
  179. uni.navigateTo({ url: '/pages/mine/agreement/index' });
  180. } else if (menu.id === 'privacy') {
  181. uni.navigateTo({ url: '/pages/mine/privacy/index' });
  182. } else if (menu.id === 'complaint') {
  183. uni.navigateTo({ url: '/pages/mine/complaint/index' });
  184. } else if (menu.id === 'service') {
  185. uni.showModal({
  186. title: '联系客服',
  187. content: '客服电话:' + this.servicePhone,
  188. confirmText: '立即拨打',
  189. confirmColor: '#C1001C',
  190. cancelColor: '#999999',
  191. success: (res) => {
  192. if (res.confirm) {
  193. uni.makePhoneCall({
  194. phoneNumber: this.servicePhone
  195. });
  196. }
  197. }
  198. });
  199. }
  200. }
  201. }
  202. }
  203. </script>
  204. <style scoped>
  205. .mine-page {
  206. width: 100%;
  207. height: 100vh;
  208. background: #f7f8fa;
  209. position: relative;
  210. display: flex;
  211. flex-direction: column;
  212. overflow: hidden;
  213. }
  214. .mine-scroll {
  215. width: 100%;
  216. height: 100%;
  217. }
  218. /* 隐藏滚动条 */
  219. .mine-scroll ::-webkit-scrollbar {
  220. width: 0 !important;
  221. height: 0 !important;
  222. color: transparent !important;
  223. display: none !important;
  224. }
  225. /* 顶部定制背景:高级渐变蓝 + 柔和弧度 */
  226. .header-bg-shape {
  227. position: absolute;
  228. top: 0;
  229. left: 0;
  230. width: 100%;
  231. height: 380rpx;
  232. background: linear-gradient(135deg, #C1001C 0%, #F4D4F 100%);
  233. border-bottom-left-radius: 60rpx;
  234. border-bottom-right-radius: 60rpx;
  235. z-index: 1;
  236. box-shadow: 0 10rpx 30rpx rgba(193, 0, 28, 0.15);
  237. }
  238. .header-bg-gradient {
  239. width: 100%;
  240. height: 100%;
  241. background: linear-gradient(180deg, rgba(255, 255, 255, 0) 0%, rgba(255, 255, 255, 0.1) 100%);
  242. border-bottom-left-radius: 60rpx;
  243. border-bottom-right-radius: 60rpx;
  244. }
  245. /* 标题栏已恢复为原生,此处仅需正常的容器内边距即可 */
  246. .content-wrapper {
  247. position: relative;
  248. z-index: 2;
  249. flex: 1;
  250. display: flex;
  251. flex-direction: column;
  252. padding: 40rpx 30rpx 0;
  253. box-sizing: border-box;
  254. }
  255. /* 用户信息卡片 */
  256. .user-card {
  257. background: #fff;
  258. border-radius: 32rpx;
  259. padding: 50rpx 40rpx;
  260. display: flex;
  261. align-items: center;
  262. margin-bottom: 30rpx;
  263. margin-top: 20rpx;
  264. box-shadow: 0 16rpx 40rpx rgba(0, 0, 0, 0.05);
  265. }
  266. .user-card.unlogged {
  267. cursor: pointer;
  268. }
  269. .avatar-box {
  270. width: 130rpx;
  271. height: 130rpx;
  272. border-radius: 65rpx;
  273. background: #f5f6f7;
  274. margin-right: 30rpx;
  275. overflow: hidden;
  276. border: 4rpx solid #fff;
  277. box-shadow: 0 4rpx 12rpx rgba(0, 0, 0, 0.05);
  278. }
  279. .gray-avatar {
  280. background: #f0f0f0;
  281. display: flex;
  282. align-items: center;
  283. justify-content: center;
  284. }
  285. .avatar-img {
  286. width: 100%;
  287. height: 100%;
  288. }
  289. .info-box {
  290. flex: 1;
  291. display: flex;
  292. flex-direction: column;
  293. justify-content: center;
  294. }
  295. .nickname {
  296. font-size: 40rpx;
  297. font-weight: bold;
  298. color: #1a1a1a;
  299. margin-bottom: 12rpx;
  300. }
  301. .login-hint {
  302. color: #333;
  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>