mine.vue 12 KB

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