index.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485
  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: 1, icon: assets.minePendingReview },
  95. { label: '已确认', tabIndex: 2, icon: assets.minePendingSign },
  96. { label: '挤压完成', tabIndex: 3, icon: assets.mineProducing },
  97. { label: '生产完成', tabIndex: 4, icon: assets.mineCompleted }
  98. ],
  99. menuList: [
  100. { label: '库存信息', icon: assets.mineStock, id: 'stock' },
  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.loadEmployeeInfo();
  112. }
  113. this.loadServicePhone();
  114. },
  115. methods: {
  116. async loadServicePhone() {
  117. try {
  118. const res = await getPhone();
  119. if (res.data && res.data.servicePhone) {
  120. this.servicePhone = res.data.servicePhone;
  121. }
  122. } catch (e) {
  123. console.error('加载客服电话失败', e);
  124. uni.showToast({ title: e || '加载客服电话失败', icon: 'none' });
  125. }
  126. },
  127. async loadEmployeeInfo() {
  128. try {
  129. const res = await getMyInfo();
  130. this.employeeInfo = res.data;
  131. } catch (e) {
  132. console.error('[mine] 加载员工信息失败', e);
  133. uni.showToast({ title: e || '加载员工信息失败', icon: 'none' });
  134. }
  135. },
  136. goToLogin() {
  137. uni.reLaunch({ url: '/pages/login/index' });
  138. },
  139. // 跳转至设置页面
  140. goToSettings() {
  141. if (this.isLogin) {
  142. uni.navigateTo({
  143. url: '/pages/mine/settings/index'
  144. });
  145. }
  146. },
  147. // 新增:跳转至订单列表
  148. goToOrderList(status) {
  149. if (!this.isLogin) {
  150. return this.goToLogin();
  151. }
  152. uni.navigateTo({
  153. url: `/pages/order/list/index?tab=${status}`
  154. });
  155. },
  156. handleLogout() {
  157. uni.showModal({
  158. title: '退出提示',
  159. content: '确认退出当前账号吗?',
  160. confirmColor: '#C1001C',
  161. success: async (res) => {
  162. if (res.confirm) {
  163. try {
  164. await logout();
  165. } catch (e) {
  166. console.error('[mine] 退出登录接口失败', e);
  167. uni.showToast({ title: e || '退出失败', icon: 'none' });
  168. }
  169. uni.removeStorageSync('token');
  170. uni.removeStorageSync('isLogin');
  171. this.isLogin = false;
  172. uni.reLaunch({ url: '/pages/login/index' });
  173. }
  174. }
  175. });
  176. },
  177. // 新增:菜单点击处理
  178. handleMenuClick(menu) {
  179. if (menu.id === 'stock') {
  180. uni.navigateTo({ url: '/pages/mine/goodsStock/index' });
  181. } else if (menu.id === 'agreement') {
  182. uni.navigateTo({ url: '/pages/mine/agreement/index' });
  183. } else if (menu.id === 'privacy') {
  184. uni.navigateTo({ url: '/pages/mine/privacy/index' });
  185. } else if (menu.id === 'complaint') {
  186. uni.navigateTo({ url: '/pages/mine/complaint/index' });
  187. } else if (menu.id === 'service') {
  188. uni.showModal({
  189. title: '联系客服',
  190. content: '客服电话:' + this.servicePhone,
  191. confirmText: '立即拨打',
  192. confirmColor: '#C1001C',
  193. cancelColor: '#999999',
  194. success: (res) => {
  195. if (res.confirm) {
  196. uni.makePhoneCall({
  197. phoneNumber: this.servicePhone
  198. });
  199. }
  200. }
  201. });
  202. }
  203. }
  204. }
  205. }
  206. </script>
  207. <style scoped>
  208. .mine-page {
  209. width: 100%;
  210. height: 100vh;
  211. background: #f7f8fa;
  212. position: relative;
  213. display: flex;
  214. flex-direction: column;
  215. overflow: hidden;
  216. }
  217. .mine-scroll {
  218. width: 100%;
  219. height: 100%;
  220. }
  221. /* 隐藏滚动条 */
  222. .mine-scroll ::-webkit-scrollbar {
  223. width: 0 !important;
  224. height: 0 !important;
  225. color: transparent !important;
  226. display: none !important;
  227. }
  228. /* 顶部定制背景:高级渐变蓝 + 柔和弧度 */
  229. .header-bg-shape {
  230. position: absolute;
  231. top: 0;
  232. left: 0;
  233. width: 100%;
  234. height: 380rpx;
  235. background: linear-gradient(135deg, #C1001C 0%, #F4D4F 100%);
  236. border-bottom-left-radius: 60rpx;
  237. border-bottom-right-radius: 60rpx;
  238. z-index: 1;
  239. box-shadow: 0 10rpx 30rpx rgba(193, 0, 28, 0.15);
  240. }
  241. .header-bg-gradient {
  242. width: 100%;
  243. height: 100%;
  244. background: linear-gradient(180deg, rgba(255, 255, 255, 0) 0%, rgba(255, 255, 255, 0.1) 100%);
  245. border-bottom-left-radius: 60rpx;
  246. border-bottom-right-radius: 60rpx;
  247. }
  248. /* 标题栏已恢复为原生,此处仅需正常的容器内边距即可 */
  249. .content-wrapper {
  250. position: relative;
  251. z-index: 2;
  252. flex: 1;
  253. display: flex;
  254. flex-direction: column;
  255. padding: 40rpx 30rpx 0;
  256. box-sizing: border-box;
  257. }
  258. /* 用户信息卡片 */
  259. .user-card {
  260. background: #fff;
  261. border-radius: 32rpx;
  262. padding: 50rpx 40rpx;
  263. display: flex;
  264. align-items: center;
  265. margin-bottom: 30rpx;
  266. margin-top: 20rpx;
  267. box-shadow: 0 16rpx 40rpx rgba(0, 0, 0, 0.05);
  268. }
  269. .user-card.unlogged {
  270. cursor: pointer;
  271. }
  272. .avatar-box {
  273. width: 130rpx;
  274. height: 130rpx;
  275. border-radius: 65rpx;
  276. background: #f5f6f7;
  277. margin-right: 30rpx;
  278. overflow: hidden;
  279. border: 4rpx solid #fff;
  280. box-shadow: 0 4rpx 12rpx rgba(0, 0, 0, 0.05);
  281. }
  282. .gray-avatar {
  283. background: #f0f0f0;
  284. display: flex;
  285. align-items: center;
  286. justify-content: center;
  287. }
  288. .avatar-img {
  289. width: 100%;
  290. height: 100%;
  291. }
  292. .info-box {
  293. flex: 1;
  294. display: flex;
  295. flex-direction: column;
  296. justify-content: center;
  297. }
  298. .nickname {
  299. font-size: 40rpx;
  300. font-weight: bold;
  301. color: #1a1a1a;
  302. margin-bottom: 12rpx;
  303. }
  304. .login-hint {
  305. color: #333;
  306. }
  307. .phone-text {
  308. font-size: 26rpx;
  309. color: #999;
  310. }
  311. /* 设置图标 & 右侧箭头 */
  312. .settings-btn {
  313. width: 60rpx;
  314. height: 60rpx;
  315. display: flex;
  316. align-items: center;
  317. justify-content: center;
  318. }
  319. .settings-icon {
  320. width: 44rpx;
  321. height: 44rpx;
  322. opacity: 0.6;
  323. }
  324. .arrow-icon-right {
  325. width: 24rpx;
  326. height: 24rpx;
  327. opacity: 0.4;
  328. }
  329. /* 通用卡片样式 */
  330. .section-card {
  331. background: #fff;
  332. border-radius: 24rpx;
  333. padding: 40rpx 30rpx;
  334. margin-bottom: 30rpx;
  335. box-shadow: 0 8rpx 30rpx rgba(0, 0, 0, 0.02);
  336. }
  337. /* 订单统计区块 */
  338. .section-header {
  339. display: flex;
  340. justify-content: space-between;
  341. align-items: center;
  342. margin-bottom: 40rpx;
  343. }
  344. .section-title {
  345. font-size: 32rpx;
  346. font-weight: bold;
  347. color: #333;
  348. }
  349. .more-link {
  350. display: flex;
  351. align-items: center;
  352. font-size: 26rpx;
  353. color: #999;
  354. }
  355. .arrow-icon {
  356. width: 20rpx;
  357. height: 20rpx;
  358. opacity: 0.5;
  359. margin-left: 6rpx;
  360. position: relative;
  361. top: 2rpx;
  362. }
  363. .stat-grid {
  364. display: flex;
  365. justify-content: space-around;
  366. }
  367. .stat-item {
  368. display: flex;
  369. flex-direction: column;
  370. align-items: center;
  371. }
  372. .stat-icon {
  373. width: 56rpx;
  374. height: 56rpx;
  375. margin-bottom: 16rpx;
  376. opacity: 0.8;
  377. }
  378. .stat-label {
  379. font-size: 26rpx;
  380. color: #666;
  381. }
  382. /* 菜单列表区块 */
  383. .menu-card {
  384. padding: 10rpx 30rpx;
  385. }
  386. .menu-item {
  387. display: flex;
  388. justify-content: space-between;
  389. align-items: center;
  390. padding: 36rpx 0;
  391. border-bottom: 1rpx solid #f5f6f7;
  392. }
  393. .menu-item:last-child {
  394. border-bottom: none;
  395. }
  396. .menu-left {
  397. display: flex;
  398. align-items: center;
  399. }
  400. .menu-icon {
  401. width: 44rpx;
  402. height: 44rpx;
  403. margin-right: 20rpx;
  404. opacity: 0.7;
  405. }
  406. .menu-label {
  407. font-size: 30rpx;
  408. color: #333;
  409. }
  410. /* 退出登录 */
  411. .logout-section {
  412. margin-top: 40rpx;
  413. }
  414. .logout-btn {
  415. width: 100%;
  416. height: 96rpx;
  417. background: #fff;
  418. color: #ff5e5e;
  419. border-radius: 24rpx;
  420. display: flex;
  421. align-items: center;
  422. justify-content: center;
  423. font-size: 32rpx;
  424. font-weight: bold;
  425. border: none;
  426. box-shadow: 0 4rpx 20rpx rgba(255, 94, 94, 0.05);
  427. transition: all 0.2s;
  428. }
  429. .logout-btn:active {
  430. background: #fff0f0;
  431. }
  432. button::after {
  433. border: none;
  434. }
  435. .bottom-placeholder {
  436. height: 180rpx;
  437. }
  438. </style>