mine.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597
  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. <up-icon name="setting-fill" size="25" @click="handLsetTing" v-if="userType == 1"></up-icon>
  8. <!-- <text class="info-edit" @click="handLsetTing" v-if="userType == 1">设置></text> -->
  9. </view>
  10. </view>
  11. <view class="status-card2" v-if="userType == 1">
  12. <view v-for="(listItem, listIndex) in userList" :key="listIndex"
  13. @click="onClick(listItem)">
  14. <view class="status-card-item2">
  15. <view class="status-card2-left">
  16. <view class="grid-img-box">
  17. <up-icon :name="listItem.iconName" :size="22"></up-icon>
  18. </view>
  19. <text class="grid-text">{{ listItem.name }}</text>
  20. </view>
  21. <up-icon name="arrow-right"></up-icon>
  22. </view>
  23. <up-divider v-if="listIndex !== userList.length -1"></up-divider>
  24. </view>
  25. </view>
  26. <view class="list-box" v-if="userType == 2">
  27. <view class="mine-card price-card" >
  28. <view v-for="(item, index) in priceList" :key="item.key" class="price-item"
  29. :style="{ alignItems: index === 0 ? 'flex-start' : 'flex-end' }" @click="onClick(item)">
  30. <view class="price-name flex-center"> {{ item.name }} </view>
  31. <view class="price-data flex-center">
  32. {{ index === 0 ? '¥' : '' }}<up-count-to :startVal="0" :endVal="data[item.key]"
  33. :decimals="item.decimals"></up-count-to>
  34. </view>
  35. <text class="grid-min-price" v-if="item.key === 'balance'">待入账 ¥{{ data[item.balance] }}</text>
  36. </view>
  37. </view>
  38. <!-- 志愿者 -->
  39. <view class="mine-card status-card" >
  40. <view class="status-card-item" v-for="(listItem, listIndex) in adminList" :key="listIndex"
  41. @click="onClick(listItem)">
  42. <view class="grid-img-box">
  43. <up-icon :name="listItem.iconName" color="rgba(51, 51, 51, 1)" size="25"></up-icon>
  44. </view>
  45. <text class="grid-text">{{ listItem.name }}</text>
  46. </view>
  47. </view>
  48. <!-- 用户端 -->
  49. <!-- <view class="mine-card status-card" v-if="userType == 1">
  50. <view class="status-card-item" v-for="(listItem, listIndex) in userList" :key="listIndex"
  51. @click="onClick(listItem)">
  52. <view class="grid-img-box">
  53. <up-icon :name="listItem.iconName" :size="22"></up-icon>
  54. </view>
  55. <text class="grid-text">{{ listItem.name }}</text>
  56. </view>
  57. </view> -->
  58. <view class="mine-card count-card" >
  59. <view class="count-title">订单统计</view>
  60. <view class="count-list">
  61. <view class="count-item" v-for="(item, index) in orderList" :key="index" @click="onClick(item)">
  62. <up-count-to :startVal="0" :endVal="data[item.key]"
  63. :color="data[item.key] > 0 && 'rgba(221, 94, 69, 1)'"></up-count-to>
  64. <text class="count-item-text">{{ item.name }}</text>
  65. </view>
  66. </view>
  67. </view>
  68. <view class="mine-card rate-card" >
  69. <view class="count-title">好评率</view>
  70. <view class="rate-list">
  71. <view class="rate-box">
  72. <label class="rate-count">{{ rateValue }}</label>
  73. <text class="rate-text">优秀</text>
  74. </view>
  75. <up-rate v-model="rateValue" active-color="rgba(255, 87, 4, 1)" inactive-color="#b2b2b2" gutter="20"
  76. readonly></up-rate>
  77. </view>
  78. </view>
  79. </view>
  80. <custom-tab-bar page="mine" />
  81. </view>
  82. </template>
  83. <script setup>
  84. import { onMounted, ref } from 'vue';
  85. import {
  86. onLoad,
  87. onShow
  88. } from '@dcloudio/uni-app';
  89. import store from "@/store"
  90. import { getVolunteerAccountInfo, volunteerOrderStatistics } from "@/api/mine";
  91. import CustomTabBar from '@/components/CustomTabBar/index.vue'
  92. const userInfo = ref({
  93. avatar: '/static/serverImg/mine/user.png'
  94. })
  95. const data = ref({
  96. balance: 0.0,
  97. reservationCount: 0,
  98. doingCount: 0,
  99. finishedCount: 0,
  100. cancelCount: 0,
  101. orderCount: 0,
  102. orderFrozenBalance: 0
  103. });
  104. const rateValue = ref(3)
  105. const priceList = [{
  106. name: '账户余额',
  107. key: 'balance',
  108. decimals: 2,
  109. balance: 'orderFrozenBalance',
  110. page: '/pages_mine/pages/wallet/index'
  111. },
  112. {
  113. name: '订单总数',
  114. key: 'orderCount',
  115. decimals: 0,
  116. switchPage: '/pages/classify',
  117. value: 0
  118. }
  119. ]
  120. const orderList = ref([{
  121. name: '预约单',
  122. key: 'reservationCount',
  123. switchPage: '/pages/classify',
  124. value: 1
  125. },
  126. {
  127. name: '进行单',
  128. key: 'doingCount',
  129. switchPage: '/pages/classify',
  130. value: 2
  131. },
  132. {
  133. name: '完成单',
  134. key: 'finishedCount',
  135. switchPage: '/pages/classify',
  136. value: 3
  137. },
  138. {
  139. name: '取消单',
  140. key: 'cancelCount',
  141. switchPage: '/pages/classify',
  142. value: 4
  143. }
  144. ]);
  145. const userType = uni.getStorageSync('userType') //读取本地存储
  146. const adminList = ref(
  147. [
  148. {
  149. name: '差评申述',
  150. iconName: 'chat',
  151. page: '/pages_mine/pages/bad/index'
  152. },
  153. // {
  154. // name: '资质申请',
  155. // iconName: 'chat',
  156. // page: '/pages_home/pages/qualifications/index'
  157. // },
  158. {
  159. name: '帮助与客服',
  160. iconName: 'kefu-ermai',
  161. },
  162. {
  163. name: '用户端',
  164. iconName: 'account',
  165. operate: () => {
  166. uni.setStorageSync('userType', 1);
  167. uni.reLaunch({
  168. url: '/pages/index'
  169. });
  170. }
  171. },
  172. ]);
  173. const userList = ref([
  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: 'edit-pen',
  190. },
  191. {
  192. name: '地址',
  193. iconName: 'map',
  194. page: '/pages_mine/pages/selectAddress/index'
  195. },
  196. {
  197. name: '帮助与客服',
  198. iconName: 'kefu-ermai',
  199. },
  200. {
  201. name: '成为志愿者',
  202. iconName: 'account',
  203. operate: () => {
  204. uni.setStorageSync('userType', 2);
  205. uni.reLaunch({
  206. url: '/pages/index'
  207. });
  208. }
  209. }
  210. ]);
  211. const onClick = (record) => {
  212. console.log('record', record, record.page);
  213. if (record.page) {
  214. uni.navigateTo({
  215. url: record.page
  216. })
  217. }
  218. if (record.operate) {
  219. record.operate()
  220. }
  221. if (record.switchPage && record.value) {
  222. const app = getApp();
  223. app.globalData.switchTabParams = {
  224. tabKey: record.value
  225. };
  226. // JS跳转
  227. uni.switchTab({
  228. url: record.switchPage
  229. });
  230. return;
  231. }
  232. }
  233. const getDetails = async () => {
  234. try {
  235. // const res = await getVolunteerAccount();
  236. // console.log('res',res);
  237. } catch (error) {
  238. console.log('error', error);
  239. }
  240. }
  241. const handLsetTing = () => {
  242. uni.navigateTo({
  243. url: '/pages_mine/pages/setupUser/index'
  244. })
  245. }
  246. const geUserInfo = () => {
  247. console.log(store.state, '>>>>99');
  248. store.dispatch('GetInfo').then((res) => {
  249. userInfo.value = store.state.user
  250. });
  251. }
  252. onShow(() => {
  253. geUserInfo();
  254. init();
  255. })
  256. const init = async () => {
  257. try {
  258. // uni.hideLoading();
  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: 150rpx;
  289. background: rgba(245, 245, 245, 1);
  290. overflow-y: auto;
  291. .mine-header {
  292. padding: 36rpx 44rpx;
  293. background: #fff;
  294. display: flex;
  295. .header-info {
  296. display: flex;
  297. // flex-direction: column;
  298. align-items: center;
  299. justify-content: space-between;
  300. margin-left: 36rpx;
  301. flex: 1;
  302. .info-name {
  303. font-size: 36rpx;
  304. font-weight: 400;
  305. line-height: 54rpx;
  306. color: rgba(51, 51, 51, 1);
  307. }
  308. .info-id {
  309. font-size: 28rpx;
  310. font-weight: 400;
  311. letter-spacing: 0rpx;
  312. line-height: 42rpx;
  313. color: rgba(153, 153, 153, 1);
  314. }
  315. .info-edit {
  316. font-size: 24rpx;
  317. font-weight: 400;
  318. letter-spacing: 0rpx;
  319. line-height: 36rpx;
  320. color: #3366ff;
  321. }
  322. }
  323. }
  324. .list-box {
  325. padding: 16rpx 40rpx;
  326. .price-card {
  327. display: flex;
  328. align-items: center;
  329. justify-content: space-between;
  330. .price-item {
  331. display: flex;
  332. align-items: center;
  333. flex-direction: column;
  334. .price-name {
  335. font-size: 28rpx;
  336. font-weight: 400;
  337. line-height: 42rpx;
  338. color: rgba(102, 102, 102, 1);
  339. }
  340. .price-data {
  341. font-size: 48rpx;
  342. font-weight: 400;
  343. line-height: 72rpx;
  344. color: rgba(51, 51, 51, 1);
  345. }
  346. .grid-min-price {
  347. font-size: 24rpx;
  348. font-weight: 400;
  349. line-height: 36rpx;
  350. color: rgba(153, 153, 153, 1);
  351. }
  352. }
  353. }
  354. .service-img {
  355. width: 60rpx;
  356. height: 60rpx;
  357. margin-bottom: 10rpx;
  358. }
  359. .service-list {
  360. padding-bottom: 12px;
  361. }
  362. .grid-text {
  363. font-size: 14px;
  364. color: #909399;
  365. padding: 10rpx 0 20rpx 0rpx;
  366. /* #ifndef APP-PLUS */
  367. box-sizing: border-box;
  368. /* #endif */
  369. }
  370. .grid-box {
  371. display: flex;
  372. align-items: center;
  373. justify-content: center;
  374. flex-direction: column;
  375. position: relative;
  376. .item-badge {
  377. position: absolute;
  378. }
  379. }
  380. .price-box {
  381. display: flex;
  382. align-content: center;
  383. justify-content: space-between;
  384. // padding: 12px;
  385. .price-item {
  386. width: 50%;
  387. padding: 12px;
  388. display: flex;
  389. flex-direction: column;
  390. align-items: center;
  391. justify-content: center;
  392. .price-name {
  393. font-size: 28rpx;
  394. font-weight: 400;
  395. line-height: 42rpx;
  396. color: rgba(102, 102, 102, 1);
  397. }
  398. .price-data {
  399. font-size: 48rpx;
  400. font-weight: 400;
  401. line-height: 72rpx;
  402. color: rgba(51, 51, 51, 1);
  403. }
  404. .grid-min-price {
  405. font-size: 24rpx;
  406. font-weight: 400;
  407. line-height: 36rpx;
  408. color: rgba(153, 153, 153, 1);
  409. }
  410. }
  411. }
  412. .status-card {
  413. display: grid;
  414. grid-template-columns: repeat(3, 1fr);
  415. gap: 48rpx;
  416. /* 网格项之间的间距 */
  417. .status-card-item {
  418. display: flex;
  419. align-items: center;
  420. justify-content: center;
  421. flex-direction: column;
  422. .grid-img-box {
  423. padding: 35rpx;
  424. border-radius: 50%;
  425. background: rgba(249, 250, 251, 1);
  426. display: flex;
  427. align-items: center;
  428. justify-content: center;
  429. margin-bottom: 12rpx;
  430. }
  431. .grid-text {
  432. font-size: 28rpx;
  433. font-weight: 400;
  434. line-height: 42rpx;
  435. color: rgba(51, 51, 51, 1);
  436. }
  437. }
  438. }
  439. .count-card {
  440. .count-list {
  441. display: grid;
  442. grid-template-columns: repeat(4, 1fr);
  443. /* 3 列,每列等宽 */
  444. gap: 32rpx;
  445. /* 网格项之间的间距 */
  446. .count-item {
  447. display: flex;
  448. flex-direction: column;
  449. align-items: center;
  450. justify-content: center;
  451. .count-item-text {
  452. font-size: 28rpx;
  453. font-weight: 400;
  454. line-height: 42rpx;
  455. color: rgba(102, 102, 102, 1);
  456. }
  457. }
  458. }
  459. }
  460. .rate-card {
  461. .rate-list {
  462. display: flex;
  463. align-items: center;
  464. .rate-box {
  465. display: flex;
  466. flex-direction: column;
  467. align-items: center;
  468. .rate-count {
  469. font-size: 64rpx;
  470. font-weight: 400;
  471. line-height: 96rpx;
  472. color: rgba(51, 51, 51, 1);
  473. }
  474. .rate-text {
  475. font-size: 28rpx;
  476. font-weight: 400;
  477. line-height: 42rpx;
  478. color: rgba(102, 102, 102, 1);
  479. }
  480. }
  481. }
  482. }
  483. }
  484. }
  485. .mine-card {
  486. border-radius: 24rpx;
  487. background: rgba(255, 255, 255, 1);
  488. 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);
  489. margin-bottom: 16rpx;
  490. padding: 40rpx;
  491. }
  492. .count-title {
  493. font-size: 32rpx;
  494. font-weight: 400;
  495. line-height: 48rpx;
  496. color: rgba(51, 51, 51, 1);
  497. margin-bottom: 8rpx;
  498. }
  499. .status-card2 {
  500. margin-top: 24rpx;
  501. padding: 30rpx 30rpx;
  502. background-color: #fff;
  503. .status-card-item2{
  504. // height: 88rpx;
  505. width: 100%;
  506. display: flex;
  507. align-items: center;
  508. justify-content: space-between;
  509. .status-card2-left {
  510. display: flex;
  511. align-items: center;
  512. .grid-img-box {
  513. margin-right: 12rpx;
  514. }
  515. }
  516. }
  517. }
  518. </style>