mine.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642
  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. store.dispatch('GetInfo').then((res) => {
  164. userInfo.value = store.state.user;
  165. uni.reLaunch({
  166. url: '/pages/index'
  167. });
  168. });
  169. }
  170. },
  171. ]);
  172. const userList = ref([
  173. {
  174. name: '钱包',
  175. iconName: 'rmb-circle',
  176. page: '/pages_mine/pages/wallet/index'
  177. },
  178. {
  179. name: '浏览记录',
  180. iconName: 'eye',
  181. },
  182. {
  183. name: '收藏',
  184. iconName: 'star',
  185. },
  186. {
  187. name: '评论',
  188. iconName: 'edit-pen',
  189. },
  190. {
  191. name: '地址',
  192. iconName: 'map',
  193. page: '/pages_mine/pages/selectAddress/index'
  194. },
  195. {
  196. name: '帮助与客服',
  197. iconName: 'kefu-ermai',
  198. },
  199. {
  200. name: '成为志愿者',
  201. iconName: 'account',
  202. operate: () => {
  203. uni.setStorageSync('userType', 2);
  204. store.dispatch('GetInfo').then((res) => {
  205. userInfo.value = store.state.user;
  206. uni.reLaunch({
  207. url: '/pages/index'
  208. });
  209. });
  210. }
  211. }
  212. ]);
  213. const onLogin = () => {
  214. const token = getToken();
  215. !token && showConfirm('您还未登陆系统,是否前往登陆?').then(res => {
  216. if (res.confirm) {
  217. store.dispatch('LogOut').then(res => {
  218. uni.reLaunch({ url: '/pages/login' })
  219. })
  220. }
  221. })
  222. }
  223. const onLogou = () => {
  224. showConfirm('确认退出登陆吗?').then(res => {
  225. if (res.confirm) {
  226. store.dispatch('LogOut').then(res => {
  227. // uni.reLaunch({ url: '/pages/login' })
  228. uni.reLaunch({
  229. url: '/pages/index'
  230. });
  231. })
  232. }
  233. })
  234. }
  235. const onClick = (record) => {
  236. console.log('record', record, record.page);
  237. if (record.page) {
  238. uni.navigateTo({
  239. url: record.page
  240. })
  241. }
  242. if (record.operate) {
  243. record.operate()
  244. }
  245. if (record.switchPage && record.value) {
  246. const app = getApp();
  247. app.globalData.switchTabParams = {
  248. tabKey: record.value
  249. };
  250. // JS跳转
  251. uni.switchTab({
  252. url: record.switchPage
  253. });
  254. return;
  255. }
  256. }
  257. const getDetails = async () => {
  258. try {
  259. // const res = await getVolunteerAccount();
  260. // console.log('res',res);
  261. } catch (error) {
  262. console.log('error', error);
  263. }
  264. }
  265. const handLsetTing = () => {
  266. uni.navigateTo({
  267. url: '/pages_mine/pages/setupUser/index'
  268. })
  269. }
  270. const geUserInfo = () => {
  271. console.log(store.state.user, '>>>>99');
  272. userInfo.value = store.state.user;
  273. // store.dispatch('GetInfo').then((res) => {
  274. // userInfo.value = store.state.user
  275. // });
  276. }
  277. onShow(() => {
  278. const token = getToken();
  279. if (token) {
  280. geUserInfo();
  281. init();
  282. }
  283. })
  284. const init = async () => {
  285. try {
  286. // uni.hideLoading();
  287. uni.showLoading({
  288. title: '数据加载中...'
  289. });
  290. if (userType === 2) {
  291. const res1 = await getVolunteerAccountInfo();
  292. const res2 = await volunteerOrderStatistics();
  293. data.value = {
  294. ...res1.data,
  295. ...res2.data
  296. }
  297. console.log(11, res1, res2, data.value);
  298. }
  299. } catch (error) {
  300. console.log('error', error);
  301. uni.showToast({
  302. title: error.msg,
  303. icon: 'error',
  304. });
  305. } finally {
  306. uni.hideLoading();
  307. }
  308. }
  309. </script>
  310. <style lang="scss" scoped>
  311. .mine-container {
  312. position: fixed;
  313. left: 0;
  314. top: 0;
  315. right: 0;
  316. bottom: 150rpx;
  317. background: rgba(245, 245, 245, 1);
  318. overflow-y: auto;
  319. .mine-header {
  320. padding: 36rpx 44rpx;
  321. background: #fff;
  322. display: flex;
  323. .header-info {
  324. display: flex;
  325. // flex-direction: column;
  326. align-items: center;
  327. justify-content: space-between;
  328. margin-left: 36rpx;
  329. flex: 1;
  330. .info-name {
  331. font-size: 36rpx;
  332. font-weight: 400;
  333. line-height: 54rpx;
  334. color: rgba(51, 51, 51, 1);
  335. }
  336. .info-id {
  337. font-size: 28rpx;
  338. font-weight: 400;
  339. letter-spacing: 0rpx;
  340. line-height: 42rpx;
  341. color: rgba(153, 153, 153, 1);
  342. }
  343. .info-edit {
  344. font-size: 24rpx;
  345. font-weight: 400;
  346. letter-spacing: 0rpx;
  347. line-height: 36rpx;
  348. color: #3366ff;
  349. }
  350. }
  351. }
  352. .list-box {
  353. padding: 16rpx 40rpx;
  354. .price-card {
  355. display: flex;
  356. align-items: center;
  357. justify-content: space-between;
  358. .price-item {
  359. display: flex;
  360. align-items: center;
  361. flex-direction: column;
  362. .price-name {
  363. font-size: 28rpx;
  364. font-weight: 400;
  365. line-height: 42rpx;
  366. color: rgba(102, 102, 102, 1);
  367. }
  368. .price-data {
  369. font-size: 48rpx;
  370. font-weight: 400;
  371. line-height: 72rpx;
  372. color: rgba(51, 51, 51, 1);
  373. }
  374. .grid-min-price {
  375. font-size: 24rpx;
  376. font-weight: 400;
  377. line-height: 36rpx;
  378. color: rgba(153, 153, 153, 1);
  379. }
  380. }
  381. }
  382. .service-img {
  383. width: 60rpx;
  384. height: 60rpx;
  385. margin-bottom: 10rpx;
  386. }
  387. .service-list {
  388. padding-bottom: 12px;
  389. }
  390. .grid-text {
  391. font-size: 14px;
  392. color: #909399;
  393. padding: 10rpx 0 20rpx 0rpx;
  394. /* #ifndef APP-PLUS */
  395. box-sizing: border-box;
  396. /* #endif */
  397. }
  398. .grid-box {
  399. display: flex;
  400. align-items: center;
  401. justify-content: center;
  402. flex-direction: column;
  403. position: relative;
  404. .item-badge {
  405. position: absolute;
  406. }
  407. }
  408. .price-box {
  409. display: flex;
  410. align-content: center;
  411. justify-content: space-between;
  412. // padding: 12px;
  413. .price-item {
  414. width: 50%;
  415. padding: 12px;
  416. display: flex;
  417. flex-direction: column;
  418. align-items: center;
  419. justify-content: center;
  420. .price-name {
  421. font-size: 28rpx;
  422. font-weight: 400;
  423. line-height: 42rpx;
  424. color: rgba(102, 102, 102, 1);
  425. }
  426. .price-data {
  427. font-size: 48rpx;
  428. font-weight: 400;
  429. line-height: 72rpx;
  430. color: rgba(51, 51, 51, 1);
  431. }
  432. .grid-min-price {
  433. font-size: 24rpx;
  434. font-weight: 400;
  435. line-height: 36rpx;
  436. color: rgba(153, 153, 153, 1);
  437. }
  438. }
  439. }
  440. .status-card {
  441. display: grid;
  442. grid-template-columns: repeat(3, 1fr);
  443. gap: 48rpx;
  444. /* 网格项之间的间距 */
  445. .status-card-item {
  446. display: flex;
  447. align-items: center;
  448. justify-content: center;
  449. flex-direction: column;
  450. .grid-img-box {
  451. padding: 35rpx;
  452. border-radius: 50%;
  453. background: rgba(249, 250, 251, 1);
  454. display: flex;
  455. align-items: center;
  456. justify-content: center;
  457. margin-bottom: 12rpx;
  458. }
  459. .grid-text {
  460. font-size: 28rpx;
  461. font-weight: 400;
  462. line-height: 42rpx;
  463. color: rgba(51, 51, 51, 1);
  464. }
  465. }
  466. }
  467. .count-card {
  468. .count-list {
  469. display: grid;
  470. grid-template-columns: repeat(4, 1fr);
  471. /* 3 列,每列等宽 */
  472. gap: 32rpx;
  473. /* 网格项之间的间距 */
  474. .count-item {
  475. display: flex;
  476. flex-direction: column;
  477. align-items: center;
  478. justify-content: center;
  479. .count-item-text {
  480. font-size: 28rpx;
  481. font-weight: 400;
  482. line-height: 42rpx;
  483. color: rgba(102, 102, 102, 1);
  484. }
  485. }
  486. }
  487. }
  488. .rate-card {
  489. .rate-list {
  490. display: flex;
  491. align-items: center;
  492. .rate-box {
  493. display: flex;
  494. flex-direction: column;
  495. align-items: center;
  496. .rate-count {
  497. font-size: 64rpx;
  498. font-weight: 400;
  499. line-height: 96rpx;
  500. color: rgba(51, 51, 51, 1);
  501. }
  502. .rate-text {
  503. font-size: 28rpx;
  504. font-weight: 400;
  505. line-height: 42rpx;
  506. color: rgba(102, 102, 102, 1);
  507. }
  508. }
  509. }
  510. }
  511. }
  512. }
  513. .mine-card {
  514. border-radius: 24rpx;
  515. background: rgba(255, 255, 255, 1);
  516. 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);
  517. margin-bottom: 16rpx;
  518. padding: 40rpx;
  519. }
  520. .count-title {
  521. font-size: 32rpx;
  522. font-weight: 400;
  523. line-height: 48rpx;
  524. color: rgba(51, 51, 51, 1);
  525. margin-bottom: 8rpx;
  526. }
  527. .status-card2 {
  528. margin-top: 24rpx;
  529. padding: 30rpx 30rpx;
  530. background-color: #fff;
  531. .status-card-item2 {
  532. // height: 88rpx;
  533. width: 100%;
  534. display: flex;
  535. align-items: center;
  536. justify-content: space-between;
  537. .status-card2-left {
  538. display: flex;
  539. align-items: center;
  540. .grid-img-box {
  541. margin-right: 12rpx;
  542. }
  543. }
  544. }
  545. }
  546. .logout-box {
  547. padding: 40rpx;
  548. .logout-btn {
  549. border-radius: 16rpx;
  550. background: rgba(221, 94, 69, 1);
  551. padding: 24rpx 0;
  552. text-align: center;
  553. font-size: 32rpx;
  554. font-weight: 400;
  555. line-height: 48rpx;
  556. color: rgba(255, 255, 255, 1);
  557. }
  558. }
  559. </style>