mine.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587
  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. },
  216. {
  217. name: '志愿者',
  218. iconName: 'kefu-ermai',
  219. },
  220. ]);
  221. const onClick = (record) => {
  222. console.log('record', record, record.page);
  223. if(record.page){
  224. uni.navigateTo({
  225. url: record.page
  226. })
  227. }
  228. if(record.operate){
  229. record.operate()
  230. }
  231. if (record.switchPage && record.value ) {
  232. const app = getApp();
  233. app.globalData.switchTabParams = {
  234. tabKey: record.value
  235. };
  236. // JS跳转
  237. uni.switchTab({
  238. url: record.switchPage
  239. });
  240. return;
  241. }
  242. }
  243. const getDetails = async () => {
  244. try {
  245. // const res = await getVolunteerAccount();
  246. // console.log('res',res);
  247. } catch (error) {
  248. console.log('error', error);
  249. }
  250. }
  251. const handLsetTing = () => {
  252. console.log('123')
  253. uni.navigateTo({
  254. url: '/pages_mine/pages/setupUser/index'
  255. })
  256. }
  257. const geUserInfo = () => {
  258. console.log(store.state, '>>>>99');
  259. // userInfo.value = store.state.user
  260. store.dispatch('GetInfo').then((res) => {
  261. userInfo.value = store.state.user
  262. console.log(userInfo.value , '>>>>99');
  263. //设置默认头像
  264. });
  265. }
  266. onShow(() => {
  267. geUserInfo();
  268. init();
  269. })
  270. const init = async() => {
  271. try {
  272. uni.showLoading({
  273. title: '数据加载中...'
  274. });
  275. if(userType === 2){
  276. const res1 = await getVolunteerAccountInfo();
  277. const res2 = await volunteerOrderStatistics();
  278. data.value = {
  279. ...res1.data,
  280. ...res2.data
  281. }
  282. console.log(11,res1,res2,data.value);
  283. }
  284. } catch (error) {
  285. console.log('error', error);
  286. uni.showToast({
  287. title: error.msg,
  288. icon: 'error',
  289. });
  290. } finally {
  291. uni.hideLoading();
  292. }
  293. }
  294. </script>
  295. <style lang="scss" scoped>
  296. .mine-container {
  297. position: fixed;
  298. left: 0;
  299. top: 0;
  300. right: 0;
  301. bottom: 0;
  302. background: rgba(245, 245, 245, 1);
  303. overflow-y: auto;
  304. .mine-header {
  305. padding: 42rpx 44rpx;
  306. background: #fff;
  307. display: flex;
  308. .header-info {
  309. display: flex;
  310. flex-direction: column;
  311. margin-left: 36rpx;
  312. .info-name {
  313. font-size: 36rpx;
  314. font-weight: 400;
  315. line-height: 54rpx;
  316. color: rgba(51, 51, 51, 1);
  317. }
  318. .info-id {
  319. font-size: 28rpx;
  320. font-weight: 400;
  321. letter-spacing: 0rpx;
  322. line-height: 42rpx;
  323. color: rgba(153, 153, 153, 1);
  324. }
  325. .info-edit {
  326. font-size: 24rpx;
  327. font-weight: 400;
  328. letter-spacing: 0rpx;
  329. line-height: 36rpx;
  330. color: #3366ff;
  331. }
  332. }
  333. }
  334. .list-box {
  335. padding: 16rpx 40rpx;
  336. .price-card {
  337. display: flex;
  338. align-items: center;
  339. justify-content: space-between;
  340. .price-item {
  341. display: flex;
  342. align-items: center;
  343. flex-direction: column;
  344. .price-name {
  345. font-size: 28rpx;
  346. font-weight: 400;
  347. line-height: 42rpx;
  348. color: rgba(102, 102, 102, 1);
  349. }
  350. .price-data {
  351. font-size: 48rpx;
  352. font-weight: 400;
  353. line-height: 72rpx;
  354. color: rgba(51, 51, 51, 1);
  355. }
  356. .grid-min-price {
  357. font-size: 24rpx;
  358. font-weight: 400;
  359. line-height: 36rpx;
  360. color: rgba(153, 153, 153, 1);
  361. }
  362. }
  363. }
  364. .service-img {
  365. width: 60rpx;
  366. height: 60rpx;
  367. margin-bottom: 10rpx;
  368. }
  369. .service-list {
  370. padding-bottom: 12px;
  371. }
  372. .grid-text {
  373. font-size: 14px;
  374. color: #909399;
  375. padding: 10rpx 0 20rpx 0rpx;
  376. /* #ifndef APP-PLUS */
  377. box-sizing: border-box;
  378. /* #endif */
  379. }
  380. .grid-box {
  381. display: flex;
  382. align-items: center;
  383. justify-content: center;
  384. flex-direction: column;
  385. position: relative;
  386. .item-badge {
  387. position: absolute;
  388. }
  389. }
  390. .price-box {
  391. display: flex;
  392. align-content: center;
  393. justify-content: space-between;
  394. // padding: 12px;
  395. .price-item {
  396. width: 50%;
  397. padding: 12px;
  398. display: flex;
  399. flex-direction: column;
  400. align-items: center;
  401. justify-content: center;
  402. .price-name {
  403. font-size: 28rpx;
  404. font-weight: 400;
  405. line-height: 42rpx;
  406. color: rgba(102, 102, 102, 1);
  407. }
  408. .price-data {
  409. font-size: 48rpx;
  410. font-weight: 400;
  411. line-height: 72rpx;
  412. color: rgba(51, 51, 51, 1);
  413. }
  414. .grid-min-price {
  415. font-size: 24rpx;
  416. font-weight: 400;
  417. line-height: 36rpx;
  418. color: rgba(153, 153, 153, 1);
  419. }
  420. }
  421. }
  422. .status-card {
  423. display: grid;
  424. grid-template-columns: repeat(3, 1fr);
  425. gap: 48rpx;
  426. /* 网格项之间的间距 */
  427. .status-card-item {
  428. display: flex;
  429. align-items: center;
  430. justify-content: center;
  431. flex-direction: column;
  432. .grid-img-box {
  433. padding: 35rpx;
  434. border-radius: 50%;
  435. background: rgba(249, 250, 251, 1);
  436. display: flex;
  437. align-items: center;
  438. justify-content: center;
  439. margin-bottom: 18rpx;
  440. }
  441. .grid-text {
  442. font-size: 28rpx;
  443. font-weight: 400;
  444. line-height: 42rpx;
  445. color: rgba(51, 51, 51, 1);
  446. }
  447. }
  448. }
  449. .count-card {
  450. .count-list {
  451. display: grid;
  452. grid-template-columns: repeat(4, 1fr);
  453. /* 3 列,每列等宽 */
  454. gap: 32rpx;
  455. /* 网格项之间的间距 */
  456. .count-item {
  457. display: flex;
  458. flex-direction: column;
  459. align-items: center;
  460. justify-content: center;
  461. .count-item-text {
  462. font-size: 28rpx;
  463. font-weight: 400;
  464. line-height: 42rpx;
  465. color: rgba(102, 102, 102, 1);
  466. }
  467. }
  468. }
  469. }
  470. .rate-card {
  471. .rate-list {
  472. display: flex;
  473. align-items: center;
  474. .rate-box {
  475. display: flex;
  476. flex-direction: column;
  477. align-items: center;
  478. .rate-count {
  479. font-size: 64rpx;
  480. font-weight: 400;
  481. line-height: 96rpx;
  482. color: rgba(51, 51, 51, 1);
  483. }
  484. .rate-text {
  485. font-size: 28rpx;
  486. font-weight: 400;
  487. line-height: 42rpx;
  488. color: rgba(102, 102, 102, 1);
  489. }
  490. }
  491. }
  492. }
  493. }
  494. }
  495. .mine-card {
  496. border-radius: 24rpx;
  497. background: rgba(255, 255, 255, 1);
  498. 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);
  499. margin-bottom: 16rpx;
  500. padding: 40rpx;
  501. }
  502. .count-title {
  503. font-size: 32rpx;
  504. font-weight: 400;
  505. line-height: 48rpx;
  506. color: rgba(51, 51, 51, 1);
  507. margin-bottom: 32rpx;
  508. }
  509. </style>