mine.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564
  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. <custom-tab-bar :page="3"/>
  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. import CustomTabBar from '@/components/CustomTabBar/index.vue'
  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. switchPage: '/pages/classify',
  101. value: 0
  102. }
  103. ]
  104. const orderList = ref([{
  105. name: '预约单',
  106. key: 'reservationCount',
  107. switchPage:'/pages/classify',
  108. value:1
  109. },
  110. {
  111. name: '进行单',
  112. key: 'doingCount',
  113. switchPage:'/pages/classify',
  114. value:2
  115. },
  116. {
  117. name: '完成单',
  118. key: 'finishedCount',
  119. switchPage:'/pages/classify',
  120. value:3
  121. },
  122. {
  123. name: '取消单',
  124. key: 'cancelCount',
  125. switchPage:'/pages/classify',
  126. value:4
  127. }
  128. ]);
  129. const userType = uni.getStorageSync('userType') //读取本地存储
  130. const adminList = ref(
  131. [
  132. {
  133. name: '差评申述',
  134. iconName: 'chat',
  135. page: '/pages_mine/pages/bad/index'
  136. },
  137. {
  138. name: '帮助与客服',
  139. iconName: 'kefu-ermai',
  140. },
  141. {
  142. name: '用户端',
  143. iconName: 'account',
  144. operate:()=>{
  145. uni.reLaunch({
  146. url: '/pages/UserSelection'
  147. });
  148. }
  149. },
  150. ]);
  151. const userList = ref(
  152. [{
  153. name: '待服务',
  154. iconName: 'clock',
  155. page: '/pages/classify',
  156. value: 1
  157. },
  158. {
  159. name: '进行中',
  160. iconName: 'car',
  161. page: '/pages/classify',
  162. value: 2
  163. },
  164. {
  165. name: '已完成',
  166. iconName: 'car-fill',
  167. page: '/pages/classify',
  168. value: 3
  169. },
  170. {
  171. name: '评论',
  172. iconName: 'edit-pen',
  173. },
  174. {
  175. name: '钱包',
  176. iconName: 'rmb-circle',
  177. page: '/pages_mine/pages/wallet/index'
  178. },
  179. {
  180. name: '浏览记录',
  181. iconName: 'eye',
  182. },
  183. {
  184. name: '收藏',
  185. iconName: 'star',
  186. },
  187. {
  188. name: '帮助与客服',
  189. iconName: 'kefu-ermai',
  190. },
  191. {
  192. name: '地址',
  193. iconName: 'map',
  194. page: '/pages_mine/pages/selectAddress/index'
  195. },
  196. {
  197. name: '志愿者',
  198. iconName: 'account',
  199. operate:()=>{
  200. uni.reLaunch({
  201. url: '/pages/UserSelection'
  202. });
  203. }
  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.operate){
  214. record.operate()
  215. }
  216. if (record.switchPage && record.value ) {
  217. const app = getApp();
  218. app.globalData.switchTabParams = {
  219. tabKey: record.value
  220. };
  221. // JS跳转
  222. uni.switchTab({
  223. url: record.switchPage
  224. });
  225. return;
  226. }
  227. }
  228. const getDetails = async () => {
  229. try {
  230. // const res = await getVolunteerAccount();
  231. // console.log('res',res);
  232. } catch (error) {
  233. console.log('error', error);
  234. }
  235. }
  236. const handLsetTing = () => {
  237. uni.navigateTo({
  238. url: '/pages_mine/pages/setupUser/index'
  239. })
  240. }
  241. const geUserInfo = () => {
  242. console.log(store.state, '>>>>99');
  243. store.dispatch('GetInfo').then((res) => {
  244. userInfo.value = store.state.user
  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: 150rpx;
  283. background: rgba(245, 245, 245, 1);
  284. overflow-y: auto;
  285. .mine-header {
  286. padding: 36rpx 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: 12rpx;
  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: 8rpx;
  489. }
  490. </style>