user.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494
  1. <template>
  2. <view class="container">
  3. <!-- 顶部用户信息卡片(优化版) -->
  4. <view class="user-card">
  5. <image class="avatar" :src="userInfo.avatarUrl || '@/static/login/logo.png'" mode="aspectFill"></image>
  6. <view class="user-info">
  7. <view class="info-top">
  8. <view class="username">{{userInfo.name}}</view>
  9. <view class="phone">{{filterPhone(userInfo.phone)}}</view>
  10. </view>
  11. <!-- 配送时间 - 优化样式 -->
  12. <view class="delivery-time">
  13. <view class="time-item">
  14. <text class="time-text">配送时间 {{userInfo.deliveryStart}}~{{userInfo.deliveryEnd}}</text>
  15. </view>
  16. </view>
  17. </view>
  18. </view>
  19. <!-- 钱包余额卡片 -->
  20. <!-- <view class="wallet-card">-->
  21. <!-- <view class="wallet-header">-->
  22. <!-- <text class="title">我的钱包</text>-->
  23. <!-- <text class="subtitle">实时更新</text>-->
  24. <!-- </view>-->
  25. <!-- <view class="balance-container">-->
  26. <!-- <view class="balance-item">-->
  27. <!-- <text class="label">可用余额</text>-->
  28. <!-- <text class="value">¥{{formatMoney(walletBalance)}}</text>-->
  29. <!-- </view>-->
  30. <!-- <view class="balance-item">-->
  31. <!-- <text class="label">待提现</text>-->
  32. <!-- <text class="value">¥{{formatMoney(toBeWithdrawn)}}</text>-->
  33. <!-- </view>-->
  34. <!-- </view>-->
  35. <!-- </view>-->
  36. <!-- 快捷功能区 -->
  37. <view class="quick-actions">
  38. <!-- <view class="action-item" @click="navTo('income')">-->
  39. <!-- <image class="icon" src="@/static/icons/withdraw.png" mode="aspectFit"></image>-->
  40. <!-- <text class="text">收益明细</text>-->
  41. <!-- </view>-->
  42. <!-- <view class="action-item" @click="navTo('withdraw')">-->
  43. <!-- <image class="icon" src="@/static/icons/withdraw.png" mode="aspectFit"></image>-->
  44. <!-- <text class="text">提现</text>-->
  45. <!-- </view>-->
  46. <view class="action-item" @click="navTo('profile')">
  47. <image class="icon" src="@/static/icons/profile.png" mode="aspectFit"></image>
  48. <text class="text">资料填写</text>
  49. </view>
  50. <view class="action-item" @click="navTo('review')">
  51. <image class="icon" src="@/static/icons/review.png" mode="aspectFit"></image>
  52. <text class="text">评价列表</text>
  53. </view>
  54. </view>
  55. <!-- 交易记录列表 -->
  56. <!-- <view class="transaction-section">-->
  57. <!-- <view class="section-header">-->
  58. <!-- <text class="title">交易记录</text>-->
  59. <!-- <text class="more" @click="viewAllTransactions">查看全部</text>-->
  60. <!-- </view>-->
  61. <!-- <view class="transaction-list">-->
  62. <!-- <view class="transaction-item" v-for="item in transactions" :key="item.id" @click="viewDetail(item)">-->
  63. <!-- <view class="left">-->
  64. <!-- <view class="type">{{getTypeText(item.transactionType)}}</view>-->
  65. <!-- <view class="time">{{item.createTime}}</view>-->
  66. <!-- </view>-->
  67. <!-- <view class="right" :class="{'income': item.amount > 0, 'expense': item.amount < 0}">-->
  68. <!-- {{item.amount > 0 ? '+' : ''}}{{formatMoney(item.amount)}}-->
  69. <!-- </view>-->
  70. <!-- </view>-->
  71. <!-- <view class="load-more" @click="loadMore" v-if="hasMore">-->
  72. <!-- <text>{{loading ? '加载中...' : '加载更多'}}</text>-->
  73. <!-- <image v-if="!loading" class="arrow" src="" mode="aspectFit"></image>-->
  74. <!-- </view>-->
  75. <!-- </view>-->
  76. <!-- </view>-->
  77. <!-- 底部操作栏 -->
  78. <view class="bottom-bar">
  79. <button class="logout-btn" @click="onLogout">退出登录</button>
  80. </view>
  81. </view>
  82. </template>
  83. <script>
  84. import {
  85. mapState,
  86. mapMutations
  87. } from 'vuex';
  88. export default {
  89. computed: {
  90. ...mapState(['token', 'userInfo'])
  91. },
  92. data() {
  93. return {
  94. walletBalance: 0,
  95. toBeWithdrawn: 0,
  96. transactions: [],
  97. page: 1,
  98. pageSize: 10,
  99. total: 0,
  100. loading: false,
  101. hasMore: true
  102. };
  103. },
  104. onLoad() {
  105. this.initData();
  106. },
  107. onShow() {
  108. this.refreshData();
  109. },
  110. methods: {
  111. ...mapMutations(['logout']),
  112. initData() {
  113. this.userInfo = uni.getStorageSync("usemall_userInfo") || {};
  114. this.loadMore();
  115. },
  116. refreshData() {
  117. this.page = 1;
  118. this.hasMore = true;
  119. this.getWalletInfo();
  120. this.getTransactions(true);
  121. },
  122. filterPhone(val) {
  123. return val ? val.toString().slice(0, 3) + '****' + val.toString().slice(-4) : '';
  124. },
  125. formatMoney(amount) {
  126. const num = Number(amount || 0);
  127. return num.toFixed(2);
  128. },
  129. navTo(url) {
  130. const pages = {
  131. income: '../income/income',
  132. withdraw: '../wallet/withdraw',
  133. transaction: '../wallet/transaction-list',
  134. profile: '../profile/edit',
  135. review: '../review/review-list'
  136. };
  137. uni.navigateTo({
  138. url: pages[url] || url
  139. });
  140. },
  141. viewAllTransactions() {
  142. this.navTo('transaction');
  143. },
  144. onLogout() {
  145. uni.showModal({
  146. title: '提示',
  147. content: '确定要退出登录吗?',
  148. success: (res) => {
  149. if (res.confirm) {
  150. this.logout();
  151. uni.reLaunch({
  152. url: '/pages/login/login'
  153. });
  154. }
  155. }
  156. });
  157. },
  158. getWalletInfo() {
  159. this.request("get", "rider/wallet/info", this.token).then(res => {
  160. if (res.code === 200) {
  161. this.walletBalance = res.data.walletBalance || 0;
  162. this.toBeWithdrawn = res.data.toBeWithdrawn || 0;
  163. }
  164. });
  165. },
  166. getTransactions(refresh = false) {
  167. if (this.loading) return;
  168. this.loading = true;
  169. if (refresh) {
  170. this.page = 1;
  171. }
  172. this.request("get", "rider/wallet/transactions", this.token, {
  173. page: this.page,
  174. size: this.pageSize
  175. }).then(res => {
  176. if (res.code === 200) {
  177. const newData = res.rows || [];
  178. this.transactions = refresh ? newData : [...this.transactions, ...newData];
  179. this.total = res.total || 0;
  180. this.hasMore = this.transactions.length < this.total;
  181. }
  182. }).finally(() => {
  183. this.loading = false;
  184. });
  185. },
  186. loadMore() {
  187. if (this.hasMore && !this.loading) {
  188. this.page++;
  189. this.getTransactions();
  190. }
  191. },
  192. viewDetail(item) {
  193. uni.navigateTo({
  194. url: `/pages/wallet/detail?id=${item.id}`
  195. });
  196. },
  197. getTypeText(type) {
  198. const types = {
  199. 1: '收入',
  200. 2: '支出',
  201. 3: '提现',
  202. 4: '退款'
  203. };
  204. return types[type] || '交易';
  205. }
  206. }
  207. };
  208. </script>
  209. <style lang="scss" scoped>
  210. .container {
  211. padding: 20rpx;
  212. background-color: #f7f7f7;
  213. min-height: 85vh;
  214. padding-bottom: 120rpx;
  215. }
  216. /* 用户信息卡片 - 优化版 */
  217. .user-card {
  218. display: flex;
  219. align-items: center;
  220. padding: 30rpx;
  221. background: linear-gradient(135deg, #437CE8, #437CE8);
  222. border-radius: 16rpx;
  223. margin-bottom: 20rpx;
  224. color: #fff;
  225. box-shadow: 0 4rpx 12rpx rgba(74, 144, 226, 0.3);
  226. .avatar {
  227. width: 120rpx;
  228. height: 120rpx;
  229. border-radius: 50%;
  230. border: 4rpx solid rgba(255, 255, 255, 0.3);
  231. flex-shrink: 0;
  232. }
  233. .user-info {
  234. margin-left: 24rpx;
  235. flex: 1;
  236. display: flex;
  237. flex-direction: column;
  238. .info-top {
  239. margin-bottom: 15rpx;
  240. .username {
  241. font-size: 36rpx;
  242. font-weight: bold;
  243. margin-bottom: 8rpx;
  244. line-height: 1.2;
  245. }
  246. .phone {
  247. font-size: 26rpx;
  248. opacity: 0.9;
  249. }
  250. }
  251. /* 配送时间 - 优化样式 */
  252. .delivery-time {
  253. background: rgba(255, 255, 255, 0.15);
  254. border-radius: 8rpx;
  255. padding: 12rpx 15rpx;
  256. backdrop-filter: blur(5px);
  257. .time-item {
  258. display: flex;
  259. align-items: center;
  260. .time-icon {
  261. width: 28rpx;
  262. height: 28rpx;
  263. margin-right: 10rpx;
  264. filter: brightness(0) invert(1);
  265. }
  266. .time-text {
  267. font-size: 26rpx;
  268. opacity: 0.95;
  269. }
  270. }
  271. }
  272. }
  273. }
  274. /* 钱包卡片 */
  275. .wallet-card {
  276. background-color: #fff;
  277. border-radius: 16rpx;
  278. padding: 30rpx;
  279. margin-bottom: 20rpx;
  280. box-shadow: 0 4rpx 12rpx rgba(0, 0, 0, 0.05);
  281. .wallet-header {
  282. display: flex;
  283. justify-content: space-between;
  284. align-items: center;
  285. margin-bottom: 30rpx;
  286. .title {
  287. font-size: 32rpx;
  288. font-weight: bold;
  289. color: #333;
  290. }
  291. .subtitle {
  292. font-size: 24rpx;
  293. color: #999;
  294. }
  295. }
  296. .balance-container {
  297. display: flex;
  298. justify-content: space-around;
  299. text-align: center;
  300. .balance-item {
  301. .label {
  302. display: block;
  303. font-size: 26rpx;
  304. color: #666;
  305. margin-bottom: 10rpx;
  306. }
  307. .value {
  308. font-size: 36rpx;
  309. font-weight: bold;
  310. color: #ff6b35;
  311. }
  312. }
  313. }
  314. }
  315. /* 快捷功能区 */
  316. .quick-actions {
  317. display: grid;
  318. grid-template-columns: 1fr 1fr;
  319. gap: 30rpx;
  320. background-color: #fff;
  321. border-radius: 16rpx;
  322. padding: 30rpx;
  323. margin-bottom: 20rpx;
  324. box-shadow: 0 4rpx 12rpx rgba(0, 0, 0, 0.05);
  325. .action-item {
  326. display: flex;
  327. flex-direction: column;
  328. align-items: center;
  329. padding: 20rpx 0;
  330. .icon {
  331. width: 60rpx;
  332. height: 60rpx;
  333. margin-bottom: 15rpx;
  334. }
  335. .text {
  336. font-size: 28rpx;
  337. color: #333;
  338. }
  339. }
  340. }
  341. /* 交易记录区域 */
  342. .transaction-section {
  343. background-color: #fff;
  344. border-radius: 16rpx;
  345. padding: 20rpx 0;
  346. box-shadow: 0 4rpx 12rpx rgba(0, 0, 0, 0.05);
  347. .section-header {
  348. display: flex;
  349. justify-content: space-between;
  350. align-items: center;
  351. padding: 0 30rpx 20rpx;
  352. border-bottom: 1rpx solid #f0f0f0;
  353. .title {
  354. font-size: 32rpx;
  355. font-weight: bold;
  356. color: #333;
  357. }
  358. .more {
  359. font-size: 26rpx;
  360. color: #437CE8;
  361. }
  362. }
  363. .transaction-list {
  364. .transaction-item {
  365. display: flex;
  366. justify-content: space-between;
  367. align-items: center;
  368. padding: 25rpx 30rpx;
  369. border-bottom: 1rpx solid #f0f0f0;
  370. &:last-child {
  371. border-bottom: none;
  372. }
  373. .left {
  374. .type {
  375. font-size: 30rpx;
  376. color: #333;
  377. margin-bottom: 8rpx;
  378. }
  379. .time {
  380. font-size: 24rpx;
  381. color: #999;
  382. }
  383. }
  384. .right {
  385. font-size: 32rpx;
  386. font-weight: bold;
  387. &.income {
  388. color: #4caf50;
  389. }
  390. &.expense {
  391. color: #f44336;
  392. }
  393. }
  394. }
  395. .load-more {
  396. display: flex;
  397. justify-content: center;
  398. align-items: center;
  399. padding: 25rpx 0;
  400. color: #437CE8;
  401. font-size: 28rpx;
  402. .arrow {
  403. width: 24rpx;
  404. height: 24rpx;
  405. margin-left: 10rpx;
  406. }
  407. }
  408. }
  409. }
  410. /* 底部操作栏 */
  411. .bottom-bar {
  412. position: fixed;
  413. bottom: 0;
  414. left: 0;
  415. right: 0;
  416. padding: 20rpx;
  417. background-color: #fff;
  418. box-shadow: 0 -2rpx 10rpx rgba(0, 0, 0, 0.05);
  419. .logout-btn {
  420. background-color: #f8f8f8;
  421. color: #f44336;
  422. border: none;
  423. height: 80rpx;
  424. line-height: 80rpx;
  425. border-radius: 40rpx;
  426. font-size: 30rpx;
  427. &::after {
  428. border: none;
  429. }
  430. }
  431. }
  432. </style>