mine.vue 12 KB

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