mine.vue 11 KB

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