mine.vue 11 KB

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