mine.vue 13 KB

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