mine.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636
  1. <template>
  2. <view>
  3. <view class="mine-container">
  4. <view class="mine-header">
  5. <up-image width="136rpx" height="136rpx" :show-loading="true" :src="userInfo.avatar"></up-image>
  6. <view class="header-info">
  7. <text class="info-name" @click="onLogin">{{ userInfo.nickName }}</text>
  8. <up-icon name="setting-fill" size="25" @click="handLsetTing" v-if="userType == 1"></up-icon>
  9. </view>
  10. </view>
  11. <view class="status-card2" v-if="userType == 1">
  12. <view v-for="(listItem, listIndex) in userList" :key="listIndex" @click="onClick(listItem)">
  13. <view class="status-card-item2">
  14. <view class="status-card2-left">
  15. <view class="grid-img-box">
  16. <up-icon :name="listItem.iconName" :size="22"></up-icon>
  17. </view>
  18. <text class="grid-text">{{ listItem.name }}</text>
  19. </view>
  20. <up-icon name="arrow-right"></up-icon>
  21. </view>
  22. <up-divider v-if="listIndex !== userList.length - 1"></up-divider>
  23. </view>
  24. </view>
  25. <view class="list-box" v-if="userType == 2">
  26. <view class="mine-card price-card">
  27. <view v-for="(item, index) in priceList" :key="item.key" class="price-item"
  28. :style="{ alignItems: index === 0 ? 'flex-start' : 'flex-end' }" @click="onClick(item)">
  29. <view class="price-name flex-center"> {{ item.name }} </view>
  30. <view class="price-data flex-center">
  31. {{ index === 0 ? '¥' : '' }}<up-count-to :startVal="0" :endVal="data[item.key]"
  32. :decimals="item.decimals"></up-count-to>
  33. </view>
  34. <text class="grid-min-price" v-if="item.key === 'balance'">待入账 ¥{{ data[item.balance] }}</text>
  35. </view>
  36. </view>
  37. <view class="mine-card status-card">
  38. <view class="status-card-item" v-for="(listItem, listIndex) in adminList"
  39. :key="listIndex + 'adminList'" @click="onClick(listItem)">
  40. <view class="grid-img-box">
  41. <up-icon :name="listItem.iconName" color="rgba(51, 51, 51, 1)" size="25"></up-icon>
  42. </view>
  43. <text class="grid-text">{{ listItem.name }}</text>
  44. </view>
  45. </view>
  46. <view class="mine-card count-card">
  47. <view class="count-title">订单统计</view>
  48. <view class="count-list">
  49. <view class="count-item" v-for="(item, index) in orderList" :key="index + 'orderList'"
  50. @click="onClick(item)">
  51. <up-count-to :startVal="0" :endVal="data[item.key]"
  52. :color="data[item.key] > 0 ? 'rgba(221, 94, 69, 1)' : ''"></up-count-to>
  53. <text class="count-item-text">{{ item.name }}</text>
  54. </view>
  55. </view>
  56. </view>
  57. <view class="mine-card rate-card">
  58. <view class="count-title">好评率</view>
  59. <view class="rate-list">
  60. <view class="rate-box">
  61. <label class="rate-count">{{ rateValue }}</label>
  62. <text class="rate-text">优秀</text>
  63. </view>
  64. <up-rate v-model="rateValue" active-color="rgba(255, 87, 4, 1)" inactive-color="#b2b2b2"
  65. gutter="20" readonly></up-rate>
  66. </view>
  67. </view>
  68. </view>
  69. <view class="logout-box" v-if="getToken()">
  70. <view class="logout-btn" @click="onLogou">退出登陆</view>
  71. </view>
  72. </view>
  73. <CustomTabBar page="mine" />
  74. </view>
  75. </template>
  76. <script setup>
  77. import { onMounted, ref } from 'vue';
  78. import {
  79. onLoad,
  80. onShow
  81. } from '@dcloudio/uni-app';
  82. import store from "@/store"
  83. import { getVolunteerAccountInfo, volunteerOrderStatistics } from "@/api/mine";
  84. import CustomTabBar from '@/components/CustomTabBar/index.vue'
  85. import { getToken } from '@/utils/auth'
  86. import { showConfirm } from '@/utils/common'
  87. const userInfo = ref({
  88. avatar: '/static/serverImg/mine/user.png',
  89. nickName: '登陆/注册'
  90. })
  91. const data = ref({
  92. balance: 0.0,
  93. reservationCount: 0,
  94. doingCount: 0,
  95. finishedCount: 0,
  96. cancelCount: 0,
  97. orderCount: 0,
  98. orderFrozenBalance: 0
  99. });
  100. const rateValue = ref(5)
  101. const priceList = [{
  102. name: '账户余额',
  103. key: 'balance',
  104. decimals: 2,
  105. balance: 'orderFrozenBalance',
  106. page: '/pages_mine/pages/wallet/index'
  107. },
  108. {
  109. name: '订单总数',
  110. key: 'orderCount',
  111. decimals: 0,
  112. switchPage: '/pages/classify',
  113. value: 0
  114. }
  115. ]
  116. const orderList = ref([{
  117. name: '预约单',
  118. key: 'reservationCount',
  119. switchPage: '/pages/classify',
  120. value: 1
  121. },
  122. {
  123. name: '进行单',
  124. key: 'doingCount',
  125. switchPage: '/pages/classify',
  126. value: 2
  127. },
  128. {
  129. name: '完成单',
  130. key: 'finishedCount',
  131. switchPage: '/pages/classify',
  132. value: 3
  133. },
  134. {
  135. name: '取消单',
  136. key: 'cancelCount',
  137. switchPage: '/pages/classify',
  138. value: 4
  139. }
  140. ]);
  141. const userType = uni.getStorageSync('userType'); //读取本地存储
  142. const adminList = ref(
  143. [
  144. {
  145. name: '差评申述',
  146. iconName: 'chat',
  147. page: '/pages_mine/pages/bad/index'
  148. },
  149. // {
  150. // name: '资质申请',
  151. // iconName: 'chat',
  152. // page: '/pages_home/pages/qualifications/index'
  153. // },
  154. {
  155. name: '帮助与客服',
  156. iconName: 'kefu-ermai',
  157. },
  158. {
  159. name: '用户端',
  160. iconName: 'account',
  161. operate: () => {
  162. uni.setStorageSync('userType', 1);
  163. uni.reLaunch({
  164. url: '/pages/index'
  165. });
  166. }
  167. },
  168. ]);
  169. const userList = ref([
  170. {
  171. name: '钱包',
  172. iconName: 'rmb-circle',
  173. page: '/pages_mine/pages/wallet/index'
  174. },
  175. {
  176. name: '浏览记录',
  177. iconName: 'eye',
  178. },
  179. {
  180. name: '收藏',
  181. iconName: 'star',
  182. },
  183. {
  184. name: '评论',
  185. iconName: 'edit-pen',
  186. },
  187. {
  188. name: '地址',
  189. iconName: 'map',
  190. page: '/pages_mine/pages/selectAddress/index'
  191. },
  192. {
  193. name: '帮助与客服',
  194. iconName: 'kefu-ermai',
  195. },
  196. {
  197. name: '成为志愿者',
  198. iconName: 'account',
  199. operate: () => {
  200. uni.setStorageSync('userType', 2);
  201. uni.reLaunch({
  202. url: '/pages/index'
  203. });
  204. }
  205. }
  206. ]);
  207. const onLogin = () => {
  208. const token = getToken();
  209. !token && showConfirm('您还未登陆系统,是否前往登陆?').then(res => {
  210. if (res.confirm) {
  211. store.dispatch('LogOut').then(res => {
  212. uni.reLaunch({ url: '/pages/login' })
  213. })
  214. }
  215. })
  216. }
  217. const onLogou = () => {
  218. showConfirm('确认退出登陆吗?').then(res => {
  219. if (res.confirm) {
  220. store.dispatch('LogOut').then(res => {
  221. // uni.reLaunch({ url: '/pages/login' })
  222. uni.reLaunch({
  223. url: '/pages/index'
  224. });
  225. })
  226. }
  227. })
  228. }
  229. const onClick = (record) => {
  230. console.log('record', record, record.page);
  231. if (record.page) {
  232. uni.navigateTo({
  233. url: record.page
  234. })
  235. }
  236. if (record.operate) {
  237. record.operate()
  238. }
  239. if (record.switchPage && record.value) {
  240. const app = getApp();
  241. app.globalData.switchTabParams = {
  242. tabKey: record.value
  243. };
  244. // JS跳转
  245. uni.switchTab({
  246. url: record.switchPage
  247. });
  248. return;
  249. }
  250. }
  251. const getDetails = async () => {
  252. try {
  253. // const res = await getVolunteerAccount();
  254. // console.log('res',res);
  255. } catch (error) {
  256. console.log('error', error);
  257. }
  258. }
  259. const handLsetTing = () => {
  260. uni.navigateTo({
  261. url: '/pages_mine/pages/setupUser/index'
  262. })
  263. }
  264. const geUserInfo = () => {
  265. console.log(store.state.user, '>>>>99');
  266. userInfo.value = store.state.user;
  267. // store.dispatch('GetInfo').then((res) => {
  268. // userInfo.value = store.state.user
  269. // });
  270. }
  271. onShow(() => {
  272. const token = getToken();
  273. if (token) {
  274. geUserInfo();
  275. init();
  276. }
  277. })
  278. const init = async () => {
  279. try {
  280. // uni.hideLoading();
  281. uni.showLoading({
  282. title: '数据加载中...'
  283. });
  284. if (userType === 2) {
  285. const res1 = await getVolunteerAccountInfo();
  286. const res2 = await volunteerOrderStatistics();
  287. data.value = {
  288. ...res1.data,
  289. ...res2.data
  290. }
  291. console.log(11, res1, res2, data.value);
  292. }
  293. } catch (error) {
  294. console.log('error', error);
  295. uni.showToast({
  296. title: error.msg,
  297. icon: 'error',
  298. });
  299. } finally {
  300. uni.hideLoading();
  301. }
  302. }
  303. </script>
  304. <style lang="scss" scoped>
  305. .mine-container {
  306. position: fixed;
  307. left: 0;
  308. top: 0;
  309. right: 0;
  310. bottom: 150rpx;
  311. background: rgba(245, 245, 245, 1);
  312. overflow-y: auto;
  313. .mine-header {
  314. padding: 36rpx 44rpx;
  315. background: #fff;
  316. display: flex;
  317. .header-info {
  318. display: flex;
  319. // flex-direction: column;
  320. align-items: center;
  321. justify-content: space-between;
  322. margin-left: 36rpx;
  323. flex: 1;
  324. .info-name {
  325. font-size: 36rpx;
  326. font-weight: 400;
  327. line-height: 54rpx;
  328. color: rgba(51, 51, 51, 1);
  329. }
  330. .info-id {
  331. font-size: 28rpx;
  332. font-weight: 400;
  333. letter-spacing: 0rpx;
  334. line-height: 42rpx;
  335. color: rgba(153, 153, 153, 1);
  336. }
  337. .info-edit {
  338. font-size: 24rpx;
  339. font-weight: 400;
  340. letter-spacing: 0rpx;
  341. line-height: 36rpx;
  342. color: #3366ff;
  343. }
  344. }
  345. }
  346. .list-box {
  347. padding: 16rpx 40rpx;
  348. .price-card {
  349. display: flex;
  350. align-items: center;
  351. justify-content: space-between;
  352. .price-item {
  353. display: flex;
  354. align-items: center;
  355. flex-direction: column;
  356. .price-name {
  357. font-size: 28rpx;
  358. font-weight: 400;
  359. line-height: 42rpx;
  360. color: rgba(102, 102, 102, 1);
  361. }
  362. .price-data {
  363. font-size: 48rpx;
  364. font-weight: 400;
  365. line-height: 72rpx;
  366. color: rgba(51, 51, 51, 1);
  367. }
  368. .grid-min-price {
  369. font-size: 24rpx;
  370. font-weight: 400;
  371. line-height: 36rpx;
  372. color: rgba(153, 153, 153, 1);
  373. }
  374. }
  375. }
  376. .service-img {
  377. width: 60rpx;
  378. height: 60rpx;
  379. margin-bottom: 10rpx;
  380. }
  381. .service-list {
  382. padding-bottom: 12px;
  383. }
  384. .grid-text {
  385. font-size: 14px;
  386. color: #909399;
  387. padding: 10rpx 0 20rpx 0rpx;
  388. /* #ifndef APP-PLUS */
  389. box-sizing: border-box;
  390. /* #endif */
  391. }
  392. .grid-box {
  393. display: flex;
  394. align-items: center;
  395. justify-content: center;
  396. flex-direction: column;
  397. position: relative;
  398. .item-badge {
  399. position: absolute;
  400. }
  401. }
  402. .price-box {
  403. display: flex;
  404. align-content: center;
  405. justify-content: space-between;
  406. // padding: 12px;
  407. .price-item {
  408. width: 50%;
  409. padding: 12px;
  410. display: flex;
  411. flex-direction: column;
  412. align-items: center;
  413. justify-content: center;
  414. .price-name {
  415. font-size: 28rpx;
  416. font-weight: 400;
  417. line-height: 42rpx;
  418. color: rgba(102, 102, 102, 1);
  419. }
  420. .price-data {
  421. font-size: 48rpx;
  422. font-weight: 400;
  423. line-height: 72rpx;
  424. color: rgba(51, 51, 51, 1);
  425. }
  426. .grid-min-price {
  427. font-size: 24rpx;
  428. font-weight: 400;
  429. line-height: 36rpx;
  430. color: rgba(153, 153, 153, 1);
  431. }
  432. }
  433. }
  434. .status-card {
  435. display: grid;
  436. grid-template-columns: repeat(3, 1fr);
  437. gap: 48rpx;
  438. /* 网格项之间的间距 */
  439. .status-card-item {
  440. display: flex;
  441. align-items: center;
  442. justify-content: center;
  443. flex-direction: column;
  444. .grid-img-box {
  445. padding: 35rpx;
  446. border-radius: 50%;
  447. background: rgba(249, 250, 251, 1);
  448. display: flex;
  449. align-items: center;
  450. justify-content: center;
  451. margin-bottom: 12rpx;
  452. }
  453. .grid-text {
  454. font-size: 28rpx;
  455. font-weight: 400;
  456. line-height: 42rpx;
  457. color: rgba(51, 51, 51, 1);
  458. }
  459. }
  460. }
  461. .count-card {
  462. .count-list {
  463. display: grid;
  464. grid-template-columns: repeat(4, 1fr);
  465. /* 3 列,每列等宽 */
  466. gap: 32rpx;
  467. /* 网格项之间的间距 */
  468. .count-item {
  469. display: flex;
  470. flex-direction: column;
  471. align-items: center;
  472. justify-content: center;
  473. .count-item-text {
  474. font-size: 28rpx;
  475. font-weight: 400;
  476. line-height: 42rpx;
  477. color: rgba(102, 102, 102, 1);
  478. }
  479. }
  480. }
  481. }
  482. .rate-card {
  483. .rate-list {
  484. display: flex;
  485. align-items: center;
  486. .rate-box {
  487. display: flex;
  488. flex-direction: column;
  489. align-items: center;
  490. .rate-count {
  491. font-size: 64rpx;
  492. font-weight: 400;
  493. line-height: 96rpx;
  494. color: rgba(51, 51, 51, 1);
  495. }
  496. .rate-text {
  497. font-size: 28rpx;
  498. font-weight: 400;
  499. line-height: 42rpx;
  500. color: rgba(102, 102, 102, 1);
  501. }
  502. }
  503. }
  504. }
  505. }
  506. }
  507. .mine-card {
  508. border-radius: 24rpx;
  509. background: rgba(255, 255, 255, 1);
  510. box-shadow: 0rpx 0rpx 0rpx rgba(0, 0, 0, 0), 0rpx 0rpx 0rpx rgba(0, 0, 0, 0), 0rpx 4rpx 16rpx rgba(0, 0, 0, 0.05);
  511. margin-bottom: 16rpx;
  512. padding: 40rpx;
  513. }
  514. .count-title {
  515. font-size: 32rpx;
  516. font-weight: 400;
  517. line-height: 48rpx;
  518. color: rgba(51, 51, 51, 1);
  519. margin-bottom: 8rpx;
  520. }
  521. .status-card2 {
  522. margin-top: 24rpx;
  523. padding: 30rpx 30rpx;
  524. background-color: #fff;
  525. .status-card-item2 {
  526. // height: 88rpx;
  527. width: 100%;
  528. display: flex;
  529. align-items: center;
  530. justify-content: space-between;
  531. .status-card2-left {
  532. display: flex;
  533. align-items: center;
  534. .grid-img-box {
  535. margin-right: 12rpx;
  536. }
  537. }
  538. }
  539. }
  540. .logout-box {
  541. padding: 40rpx;
  542. .logout-btn {
  543. border-radius: 16rpx;
  544. background: rgba(221, 94, 69, 1);
  545. padding: 24rpx 0;
  546. text-align: center;
  547. font-size: 32rpx;
  548. font-weight: 400;
  549. line-height: 48rpx;
  550. color: rgba(255, 255, 255, 1);
  551. }
  552. }
  553. </style>