mine.vue 11 KB

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