mine.vue 12 KB

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