mine.vue 11 KB

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