mine.vue 15 KB

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