mine.vue 11 KB

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