mine.vue 11 KB

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