new_file.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515
  1. <template>
  2. <view>
  3. <template>
  4. <view class="Wrapper-grid">
  5. <view class="serve-title-Box" v-if="userType == 2">
  6. <view class="serve-content">
  7. <image src="/static/container.png" class="serve-content-img" mode="aspectFill"></image>
  8. <text class="serve-content-text">注册专区</text>
  9. </view>
  10. <view class="serve-content-box2">
  11. <text class="serve-content-text">认证资质专区</text>
  12. </view>
  13. </view>
  14. <up-grid :border="false" col="3">
  15. <up-grid-item v-for="(item, index) in serveiceList" :key="index" @click="handleGridClick(item)">
  16. <view class="grid-box">
  17. <view class="grid-image">
  18. <image :src="item.businessIcon" class="service-img" mode="aspectFit" />
  19. </view>
  20. <view class="grid-content">
  21. <text class="grid-text">{{ item.businessName }}</text>
  22. <text class="grid-text-bone">{{ item.businessDescribe }}</text>
  23. </view>
  24. </view>
  25. </up-grid-item>
  26. </up-grid>
  27. <up-toast ref="uToastRef" />
  28. <view class="paiBanSty" v-if="userType == 2">
  29. <!-- 背景图片 -->
  30. <!-- <image src="/static/img/14147@2x.png" class="background-image" mode="aspectFill" /> -->
  31. <!-- 左侧轮播图 -->
  32. <swiper class="zhiYuanZheSwiper" vertical circular autoplay :interval="4000" :duration="800"
  33. @change="onSwiperChange">
  34. <swiper-item v-for="(imgUrl, index) in volunteerImages" :key="index">
  35. <view class="swiper-item-container" :class="{ 'active-swiper': currentSwiperIndex === index }">
  36. <image :src="imgUrl" class="zhiYuanZhe" mode="aspectFill" />
  37. </view>
  38. </swiper-item>
  39. </swiper>
  40. <!-- 右侧内容区域 -->
  41. <view class="content-wrapper">
  42. <view class="title-button-row">
  43. <view class="paiBanTitle">我的排班</view>
  44. <button class="paiBanBtn" @click="DataInit">去管理排班</button>
  45. </view>
  46. <view class="paiBanDesc">管理排班时间,合理分配服务订单</view>
  47. </view>
  48. </view>
  49. </view>
  50. </template>
  51. <Calendar ref="calendar" class="uni-calendar--hook" :clear-date="false" :date="info.date" :insert="info.insert"
  52. :lunar="info.lunar" :range="info.range" @change="change" :clearDate="true" @confirm="confirm" :selected="selected"
  53. @delete="onDelete" />
  54. </view>
  55. </template>
  56. <script setup>
  57. import {
  58. ref,
  59. onMounted,
  60. watch,
  61. computed,
  62. provide
  63. } from 'vue';
  64. import {
  65. workDate,
  66. getDataTime,
  67. getVolunteerInfo
  68. } from '@/api/volunteer.js'
  69. import {
  70. volunteerSeachgetTreeList,
  71. volunteerVolunteerPicture
  72. } from "@/api/volunteerDetailsApi/details.js"
  73. import { getTreeList } from '@/api/volunteer'
  74. import Calendar from '../../components/uni-calendar/components/uni-calendar/uni-calendar.vue'
  75. import { getToken } from '@/utils/auth'
  76. const swiperList = ['integral', 'kefu-ermai', 'coupon', 'gift', 'scan', 'pause-circle', 'wifi', 'email', 'list'];
  77. // Toast 控制宫格
  78. const uToastRef = ref(null);
  79. const userType = uni.getStorageSync('userType') //读取本地存储
  80. // 用户/志愿者 识别标识
  81. const userOrWorker = uni.getStorageSync('storage_data').vuex_userOrWorker //读取本地存储
  82. const calendar = ref(null)
  83. const info = ref({
  84. lunar: true,
  85. range: true,
  86. insert: false,
  87. })
  88. const selected = ref([])
  89. const serveiceList = ref([]);
  90. // 志愿者图片
  91. const volunteerImages = ref([]);
  92. const getVolunteerImages = () => {
  93. volunteerVolunteerPicture({}).then(res => {
  94. if (Array.isArray(res)) {
  95. volunteerImages.value = res;
  96. } else if (res.code === 200 && res.data) {
  97. volunteerImages.value = res.data;
  98. }
  99. })
  100. }
  101. // 当前显示的轮播图索引
  102. const currentSwiperIndex = ref(0);
  103. // 轮播图切换事件
  104. const onSwiperChange = (e) => {
  105. currentSwiperIndex.value = e.detail.current;
  106. };
  107. // 宫格点击事件
  108. const handleGridClick = async (service) => {
  109. // 用户
  110. if (userType == 1) {
  111. // 动态获取 parentId
  112. const params = {
  113. parentId: service.id,
  114. }
  115. const res = await volunteerSeachgetTreeList(params)
  116. uni.navigateTo({
  117. url: `/pages_home/pages/client/details?dataList=${encodeURIComponent(JSON.stringify(res.data))}&serviceCategory=${service.id}`
  118. });
  119. }
  120. // 志愿者
  121. if (userType == 2) {
  122. const res = await getVolunteerInfo({
  123. serviceCategory: service.id
  124. });
  125. if (res.code === 200 && res.data) {
  126. //已有注册,跳转详情页面
  127. uni.navigateTo({
  128. url: `/pages_home/pages/details/index?data=${encodeURIComponent(JSON.stringify({ ...service, key: service.id }))}`
  129. })
  130. return
  131. }
  132. uni.navigateTo({
  133. url: `/pages_home/pages/register/index?data=${encodeURIComponent(JSON.stringify({ ...service, key: service.id }))}`
  134. })
  135. }
  136. };
  137. const change = (e) => {
  138. let dates = [{
  139. date: e.fulldate,
  140. info: `${e.time.startTime}~${e.time.endTime}`,
  141. time: e.time
  142. }]
  143. if (e.range.before && e.range.after) {
  144. dates = e.range.data.map(item => {
  145. return {
  146. date: item,
  147. info: `${e.time.startTime}~${e.time.endTime}`,
  148. time: e.time
  149. }
  150. })
  151. }
  152. selected.value = [...selected.value, ...dates]
  153. }
  154. const onDelete = (e) => {
  155. selected.value = selected.value.filter(item => {
  156. return item.date !== e.fulldate
  157. })
  158. }
  159. //排班时间去重处理
  160. const handleDates = computed(() => {
  161. const parmas = selected.value.map(item => {
  162. return {
  163. workDate: item.date,
  164. workStartTime: item.time.startTime,
  165. workEndTime: item.time.endTime
  166. }
  167. })
  168. return parmas.reduce((acc, current) => {
  169. const existing = acc.find(item => item.workDate === current.workDate);
  170. if (existing) {
  171. Object.assign(existing, current);
  172. } else {
  173. acc.push(current);
  174. }
  175. return acc;
  176. }, []);
  177. });
  178. const confirm = (e) => {
  179. const parmas = handleDates.value;
  180. workDate(parmas).then(res => {
  181. if (res.code == 200) {
  182. uni.showToast({
  183. title: '修改成功',
  184. icon: 'success',
  185. success: () => {
  186. setTimeout(() => {
  187. close();
  188. }, 1000)
  189. }
  190. })
  191. return;
  192. }
  193. uni.showToast({
  194. title: res.msg,
  195. icon: 'none'
  196. })
  197. })
  198. };
  199. const close = () => {
  200. calendar.value.close();
  201. }
  202. const init = () => {
  203. getTreeList({ parentId: '0' }).then(res => {
  204. serveiceList.value = res.data;
  205. })
  206. }
  207. const DataInit = () => {
  208. getDataTime().then(res => {
  209. if (res.code === 200) {
  210. selected.value = res.data.map(item => {
  211. return {
  212. date: item.workDate,
  213. info: `${item.workStartTime}~${item.workEndTime}`,
  214. time: {
  215. startTime: item.workStartTime,
  216. endTime: item.workEndTime
  217. }
  218. }
  219. })
  220. calendar.value.open();
  221. }
  222. })
  223. }
  224. onMounted(() => {
  225. init();
  226. const token = getToken();
  227. token && getVolunteerImages();
  228. });
  229. </script>
  230. <style scoped lang="scss">
  231. .serve-title-Box {
  232. display: flex;
  233. align-items: center;
  234. justify-content: space-between;
  235. margin-bottom: 10rpx;
  236. margin-top: 24rpx;
  237. .serve-content {
  238. display: flex;
  239. align-items: center;
  240. .serve-content-img {
  241. width: 36rpx;
  242. height: 36rpx;
  243. margin-left: 34rpx;
  244. }
  245. .serve-content-text {
  246. width: 136rpx;
  247. height: 40rpx;
  248. font-family: PingFang SC;
  249. font-size: 34rpx;
  250. font-weight: 500;
  251. line-height: 40rpx;
  252. letter-spacing: normal;
  253. color: rgba(0, 0, 0, 0.8);
  254. margin-left: 10rpx;
  255. }
  256. }
  257. .serve-content-box2 {
  258. .serve-content-text {
  259. width: 144rpx;
  260. height: 42rpx;
  261. font-family: Yuppy SC;
  262. font-size: 24rpx;
  263. font-weight: 500;
  264. line-height: 42rpx;
  265. text-align: right;
  266. letter-spacing: normal;
  267. color: #E58182;
  268. margin-right: 40rpx;
  269. }
  270. }
  271. }
  272. .grid-box {
  273. width: 226rpx;
  274. height: 116rpx;
  275. display: flex;
  276. flex-direction: row;
  277. align-items: center;
  278. justify-content: flex-start;
  279. margin-right: 5rpx;
  280. margin-left: 5rpx;
  281. background: #fff;
  282. border-radius: 14rpx;
  283. // background: red;
  284. background: linear-gradient(180deg, #FFF9F3 0%, #FFFFFF 100%);
  285. box-shadow: 0rpx 4rpx 10rpx 0rpx rgba(0, 0, 0, 0.04);
  286. margin-top: 10rpx;
  287. .grid-image {
  288. width: 64rpx;
  289. height: 68rpx;
  290. display: flex;
  291. align-items: center;
  292. justify-content: center;
  293. }
  294. }
  295. .grid-content {
  296. display: flex;
  297. flex-direction: column;
  298. align-items: flex-start;
  299. justify-content: center;
  300. .grid-text {
  301. width: 112rpx;
  302. height: 36rpx;
  303. font-family: PingFang SC;
  304. font-size: 28rpx;
  305. font-weight: 500;
  306. line-height: 36rpx;
  307. letter-spacing: normal;
  308. color: #313131;
  309. }
  310. .grid-text-bone {
  311. width: 130rpx;
  312. height: 28rpx;
  313. font-family: PingFang SC;
  314. font-size: 22rpx;
  315. font-weight: normal;
  316. line-height: 28rpx;
  317. letter-spacing: -0.02em;
  318. color: #818181;
  319. margin-left: 6rpx;
  320. margin-top: 10rpx;
  321. }
  322. }
  323. .paiBanSty {
  324. // position: relative;
  325. margin-top: 30rpx;
  326. display: flex;
  327. flex-direction: row;
  328. background: #FFFFFF;
  329. background-image: url('/static/img/14147@2x.png');
  330. background-size: cover;
  331. // background-position: center;
  332. border-radius: 20rpx;
  333. box-shadow: 0rpx 4rpx 10rpx 0rpx rgba(0, 0, 0, 0.04);
  334. overflow: hidden;
  335. height: 330rpx;
  336. .background-image {
  337. // position: absolute;
  338. width: 100%;
  339. height: 100%;
  340. object-fit: cover;
  341. // z-index: 0;
  342. }
  343. .zhiYuanZheSwiper {
  344. width: 196rpx;
  345. height: 240rpx;
  346. border-radius: 38rpx;
  347. overflow: hidden;
  348. margin: 30rpx;
  349. // z-index: 1;
  350. // position: relative;
  351. }
  352. .swiper-item-container {
  353. width: 100%;
  354. height: 100%;
  355. display: flex;
  356. align-items: center;
  357. justify-content: center;
  358. transition: all 0.3s;
  359. &.active-swiper {
  360. transform: scale(1);
  361. }
  362. }
  363. .zhiYuanZhe {
  364. width: 100%;
  365. height: 100%;
  366. border-radius: 38rpx;
  367. box-shadow: 0 8rpx 20rpx rgba(0, 0, 0, 0.1);
  368. }
  369. .content-wrapper {
  370. flex: 1;
  371. display: flex;
  372. flex-direction: column;
  373. justify-content: flex-start;
  374. // padding: 30rpx;
  375. // z-index: 1;
  376. // position: relative;
  377. }
  378. .title-button-row {
  379. display: flex;
  380. flex-direction: row;
  381. justify-content: space-between;
  382. align-items: center;
  383. margin-bottom: 12rpx;
  384. width: 100%;
  385. margin-top: 129rpx;
  386. margin-left: 0rpx;
  387. }
  388. .paiBanTitle {
  389. font-family: PingFang SC;
  390. font-size: 34rpx;
  391. font-weight: 600;
  392. line-height: 40rpx;
  393. letter-spacing: normal;
  394. color: rgba(0, 0, 0, 0.8);
  395. width: 136rpx;
  396. height: 25rpx;
  397. margin-top: 95rpx;
  398. margin-left: 33rpx;
  399. // position: relative;
  400. // left: -2rpx;
  401. // top: 17rpx;
  402. }
  403. .paiBanDesc {
  404. font-family: PingFang SC;
  405. font-size: 26rpx;
  406. font-weight: normal;
  407. line-height: 40rpx;
  408. color: rgba(0, 0, 0, 0.5);
  409. margin-top: 12rpx;
  410. margin-left: 33rpx;
  411. // position: relative;
  412. }
  413. .paiBanBtn {
  414. width: 200rpx;
  415. height: 70rpx;
  416. display: flex;
  417. justify-content: center;
  418. align-items: center;
  419. border-radius: 36rpx;
  420. background: #D94342;
  421. font-family: PingFang SC;
  422. font-size: 28rpx;
  423. font-weight: 500;
  424. line-height: 30rpx;
  425. color: #FFFFFF;
  426. border: none;
  427. padding: 0;
  428. margin-top: 55rpx;
  429. margin-left: 53rpx;
  430. // position: relative;
  431. // top: -20rpx;
  432. // left: 4rpx;
  433. }
  434. }
  435. .home-ranking {}
  436. @keyframes fadeIn {
  437. from {
  438. opacity: 0;
  439. transform: scale(0.9) translateY(10rpx);
  440. }
  441. to {
  442. opacity: 1;
  443. transform: scale(1) translateY(0);
  444. }
  445. }
  446. @keyframes fadeOut {
  447. from {
  448. opacity: 1;
  449. transform: scale(1) translateY(0);
  450. }
  451. to {
  452. opacity: 0.8;
  453. transform: scale(0.95) translateY(-10rpx);
  454. }
  455. }
  456. </style>