index.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497
  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(item.tabIndex)">
  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. import { getPhone } from '@/api/system/phone.js';
  88. export default {
  89. components: { ErpTabBar, ErpNavBar },
  90. data() {
  91. return {
  92. assets,
  93. isLogin: false,
  94. customerInfo: null,
  95. servicePhone: '13888888888',
  96. orderStates: [
  97. { label: '待审核', tabIndex: 2, icon: assets.minePendingReview },
  98. { label: '待签批', tabIndex: 4, icon: assets.minePendingSign },
  99. { label: '生产中', tabIndex: 5, icon: assets.mineProducing },
  100. { label: '已完成', tabIndex: 6, icon: assets.mineCompleted }
  101. ],
  102. menuList: [
  103. { label: '用户协议', icon: assets.mineProtocol, id: 'agreement' },
  104. { label: '隐私政策', icon: assets.minePrivacy, id: 'privacy' },
  105. { label: '投诉与建议', icon: assets.mineComplaint, id: 'complaint' },
  106. { label: '联系客服', icon: assets.mineService, id: 'service' }
  107. ]
  108. }
  109. },
  110. onShow() {
  111. this.isLogin = !!uni.getStorageSync('isLogin');
  112. if (this.isLogin) {
  113. this.loadCustomerInfo();
  114. }
  115. this.loadServicePhone();
  116. },
  117. methods: {
  118. async loadServicePhone() {
  119. try {
  120. const res = await getPhone();
  121. if (res.data && res.data.servicePhone) {
  122. this.servicePhone = res.data.servicePhone;
  123. }
  124. } catch (e) {
  125. console.error('加载客服电话失败', e);
  126. }
  127. },
  128. async loadCustomerInfo() {
  129. try {
  130. const res = await getMyInfo();
  131. this.customerInfo = res.data;
  132. } catch (e) {
  133. console.error('[mine] 加载客户信息失败', e);
  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. }
  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. .tags-row {
  305. display: flex;
  306. align-items: center;
  307. margin-bottom: 12rpx;
  308. }
  309. .customer-tag {
  310. font-size: 24rpx;
  311. color: #C1001C;
  312. background: rgba(193, 0, 28, 0.1);
  313. padding: 6rpx 16rpx;
  314. border-radius: 8rpx;
  315. font-weight: 500;
  316. }
  317. .phone-text {
  318. font-size: 26rpx;
  319. color: #999;
  320. }
  321. /* 设置图标 & 右侧箭头 */
  322. .settings-btn {
  323. width: 60rpx;
  324. height: 60rpx;
  325. display: flex;
  326. align-items: center;
  327. justify-content: center;
  328. }
  329. .settings-icon {
  330. width: 44rpx;
  331. height: 44rpx;
  332. opacity: 0.6;
  333. }
  334. .arrow-icon-right {
  335. width: 24rpx;
  336. height: 24rpx;
  337. opacity: 0.4;
  338. }
  339. /* 通用卡片样式 */
  340. .section-card {
  341. background: #fff;
  342. border-radius: 24rpx;
  343. padding: 40rpx 30rpx;
  344. margin-bottom: 30rpx;
  345. box-shadow: 0 8rpx 30rpx rgba(0, 0, 0, 0.02);
  346. }
  347. /* 订单统计区块 */
  348. .section-header {
  349. display: flex;
  350. justify-content: space-between;
  351. align-items: center;
  352. margin-bottom: 40rpx;
  353. }
  354. .section-title {
  355. font-size: 32rpx;
  356. font-weight: bold;
  357. color: #333;
  358. }
  359. .more-link {
  360. display: flex;
  361. align-items: center;
  362. font-size: 26rpx;
  363. color: #999;
  364. }
  365. .arrow-icon {
  366. width: 20rpx;
  367. height: 20rpx;
  368. opacity: 0.5;
  369. margin-left: 6rpx;
  370. position: relative;
  371. top: 2rpx;
  372. }
  373. .stat-grid {
  374. display: flex;
  375. justify-content: space-around;
  376. }
  377. .stat-item {
  378. display: flex;
  379. flex-direction: column;
  380. align-items: center;
  381. }
  382. .stat-icon {
  383. width: 56rpx;
  384. height: 56rpx;
  385. margin-bottom: 16rpx;
  386. opacity: 0.8;
  387. }
  388. .stat-label {
  389. font-size: 26rpx;
  390. color: #666;
  391. }
  392. /* 菜单列表区块 */
  393. .menu-card {
  394. padding: 10rpx 30rpx;
  395. }
  396. .menu-item {
  397. display: flex;
  398. justify-content: space-between;
  399. align-items: center;
  400. padding: 36rpx 0;
  401. border-bottom: 1rpx solid #f5f6f7;
  402. }
  403. .menu-item:last-child {
  404. border-bottom: none;
  405. }
  406. .menu-left {
  407. display: flex;
  408. align-items: center;
  409. }
  410. .menu-icon {
  411. width: 44rpx;
  412. height: 44rpx;
  413. margin-right: 20rpx;
  414. opacity: 0.7;
  415. }
  416. .menu-label {
  417. font-size: 30rpx;
  418. color: #333;
  419. }
  420. /* 退出登录 */
  421. .logout-section {
  422. margin-top: 40rpx;
  423. }
  424. .logout-btn {
  425. width: 100%;
  426. height: 96rpx;
  427. background: #fff;
  428. color: #ff5e5e;
  429. border-radius: 24rpx;
  430. display: flex;
  431. align-items: center;
  432. justify-content: center;
  433. font-size: 32rpx;
  434. font-weight: bold;
  435. border: none;
  436. box-shadow: 0 4rpx 20rpx rgba(255, 94, 94, 0.05);
  437. transition: all 0.2s;
  438. }
  439. .logout-btn:active {
  440. background: #fff0f0;
  441. }
  442. button::after {
  443. border: none;
  444. }
  445. .bottom-placeholder {
  446. height: 180rpx;
  447. }
  448. </style>