new_file.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516
  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(['/static/serverImg/home/zyz_pb.png']);
  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. console.log("TCL: handleGridClick -> res", res)
  117. uni.navigateTo({
  118. url: `/pages_home/pages/client/details?dataList=${encodeURIComponent(JSON.stringify(res.data))}&serviceCategory=${service.id}`
  119. });
  120. }
  121. // 志愿者
  122. if (userType == 2) {
  123. const res = await getVolunteerInfo({
  124. serviceCategory: service.id
  125. });
  126. if (res.code === 200 && res.data) {
  127. //已有注册,跳转详情页面
  128. uni.navigateTo({
  129. url: `/pages_home/pages/details/index?data=${encodeURIComponent(JSON.stringify({ ...service, key: service.id }))}`
  130. })
  131. return
  132. }
  133. uni.navigateTo({
  134. url: `/pages_home/pages/register/index?data=${encodeURIComponent(JSON.stringify({ ...service, key: service.id }))}`
  135. })
  136. }
  137. };
  138. const change = (e) => {
  139. let dates = [{
  140. date: e.fulldate,
  141. info: `${e.time.startTime}~${e.time.endTime}`,
  142. time: e.time
  143. }]
  144. if (e.range.before && e.range.after) {
  145. dates = e.range.data.map(item => {
  146. return {
  147. date: item,
  148. info: `${e.time.startTime}~${e.time.endTime}`,
  149. time: e.time
  150. }
  151. })
  152. }
  153. selected.value = [...selected.value, ...dates]
  154. }
  155. const onDelete = (e) => {
  156. selected.value = selected.value.filter(item => {
  157. return item.date !== e.fulldate
  158. })
  159. }
  160. //排班时间去重处理
  161. const handleDates = computed(() => {
  162. const parmas = selected.value.map(item => {
  163. return {
  164. workDate: item.date,
  165. workStartTime: item.time.startTime,
  166. workEndTime: item.time.endTime
  167. }
  168. })
  169. return parmas.reduce((acc, current) => {
  170. const existing = acc.find(item => item.workDate === current.workDate);
  171. if (existing) {
  172. Object.assign(existing, current);
  173. } else {
  174. acc.push(current);
  175. }
  176. return acc;
  177. }, []);
  178. });
  179. const confirm = (e) => {
  180. const parmas = handleDates.value;
  181. workDate(parmas).then(res => {
  182. if (res.code == 200) {
  183. uni.showToast({
  184. title: '修改成功',
  185. icon: 'success',
  186. success: () => {
  187. setTimeout(() => {
  188. close();
  189. }, 1000)
  190. }
  191. })
  192. return;
  193. }
  194. uni.showToast({
  195. title: res.msg,
  196. icon: 'none'
  197. })
  198. })
  199. };
  200. const close = () => {
  201. calendar.value.close();
  202. }
  203. const init = () => {
  204. getTreeList({ parentId: '0' }).then(res => {
  205. serveiceList.value = res.data;
  206. })
  207. }
  208. const DataInit = () => {
  209. getDataTime().then(res => {
  210. if (res.code === 200) {
  211. selected.value = res.data.map(item => {
  212. return {
  213. date: item.workDate,
  214. info: `${item.workStartTime}~${item.workEndTime}`,
  215. time: {
  216. startTime: item.workStartTime,
  217. endTime: item.workEndTime
  218. }
  219. }
  220. })
  221. calendar.value.open();
  222. }
  223. })
  224. }
  225. onMounted(() => {
  226. init();
  227. const token = getToken();
  228. token && getVolunteerImages();
  229. });
  230. </script>
  231. <style scoped lang="scss">
  232. .serve-title-Box {
  233. display: flex;
  234. align-items: center;
  235. justify-content: space-between;
  236. margin-bottom: 10rpx;
  237. margin-top: 24rpx;
  238. .serve-content {
  239. display: flex;
  240. align-items: center;
  241. .serve-content-img {
  242. width: 36rpx;
  243. height: 36rpx;
  244. margin-left: 34rpx;
  245. }
  246. .serve-content-text {
  247. width: 136rpx;
  248. height: 40rpx;
  249. font-family: PingFang SC;
  250. font-size: 34rpx;
  251. font-weight: 500;
  252. line-height: 40rpx;
  253. letter-spacing: normal;
  254. color: rgba(0, 0, 0, 0.8);
  255. margin-left: 10rpx;
  256. }
  257. }
  258. .serve-content-box2 {
  259. .serve-content-text {
  260. width: 144rpx;
  261. height: 42rpx;
  262. font-family: Yuppy SC;
  263. font-size: 24rpx;
  264. font-weight: 500;
  265. line-height: 42rpx;
  266. text-align: right;
  267. letter-spacing: normal;
  268. color: #E58182;
  269. margin-right: 40rpx;
  270. }
  271. }
  272. }
  273. .grid-box {
  274. width: 226rpx;
  275. height: 116rpx;
  276. display: flex;
  277. flex-direction: row;
  278. align-items: center;
  279. justify-content: flex-start;
  280. margin-right: 5rpx;
  281. margin-left: 5rpx;
  282. background: #fff;
  283. border-radius: 14rpx;
  284. // background: red;
  285. background: linear-gradient(180deg, #FFF9F3 0%, #FFFFFF 100%);
  286. box-shadow: 0rpx 4rpx 10rpx 0rpx rgba(0, 0, 0, 0.04);
  287. margin-top: 10rpx;
  288. .grid-image {
  289. width: 64rpx;
  290. height: 68rpx;
  291. display: flex;
  292. align-items: center;
  293. justify-content: center;
  294. }
  295. }
  296. .grid-content {
  297. display: flex;
  298. flex-direction: column;
  299. align-items: flex-start;
  300. justify-content: center;
  301. .grid-text {
  302. width: 112rpx;
  303. height: 36rpx;
  304. font-family: PingFang SC;
  305. font-size: 28rpx;
  306. font-weight: 500;
  307. line-height: 36rpx;
  308. letter-spacing: normal;
  309. color: #313131;
  310. }
  311. .grid-text-bone {
  312. width: 130rpx;
  313. height: 28rpx;
  314. font-family: PingFang SC;
  315. font-size: 22rpx;
  316. font-weight: normal;
  317. line-height: 28rpx;
  318. letter-spacing: -0.02em;
  319. color: #818181;
  320. margin-left: 6rpx;
  321. margin-top: 10rpx;
  322. }
  323. }
  324. .paiBanSty {
  325. // position: relative;
  326. margin-top: 30rpx;
  327. display: flex;
  328. flex-direction: row;
  329. background: #FFFFFF;
  330. background-image: url('/static/img/14147@2x.png');
  331. background-size: cover;
  332. // background-position: center;
  333. border-radius: 20rpx;
  334. box-shadow: 0rpx 4rpx 10rpx 0rpx rgba(0, 0, 0, 0.04);
  335. overflow: hidden;
  336. height: 330rpx;
  337. .background-image {
  338. // position: absolute;
  339. width: 100%;
  340. height: 100%;
  341. object-fit: cover;
  342. // z-index: 0;
  343. }
  344. .zhiYuanZheSwiper {
  345. width: 196rpx;
  346. height: 240rpx;
  347. border-radius: 38rpx;
  348. overflow: hidden;
  349. margin: 30rpx;
  350. // z-index: 1;
  351. // position: relative;
  352. }
  353. .swiper-item-container {
  354. width: 100%;
  355. height: 100%;
  356. display: flex;
  357. align-items: center;
  358. justify-content: center;
  359. transition: all 0.3s;
  360. &.active-swiper {
  361. transform: scale(1);
  362. }
  363. }
  364. .zhiYuanZhe {
  365. width: 100%;
  366. height: 100%;
  367. border-radius: 38rpx;
  368. box-shadow: 0 8rpx 20rpx rgba(0, 0, 0, 0.1);
  369. }
  370. .content-wrapper {
  371. flex: 1;
  372. display: flex;
  373. flex-direction: column;
  374. justify-content: flex-start;
  375. // padding: 30rpx;
  376. // z-index: 1;
  377. // position: relative;
  378. }
  379. .title-button-row {
  380. display: flex;
  381. flex-direction: row;
  382. justify-content: space-between;
  383. align-items: center;
  384. margin-bottom: 12rpx;
  385. width: 100%;
  386. margin-top: 129rpx;
  387. margin-left: 0rpx;
  388. }
  389. .paiBanTitle {
  390. font-family: PingFang SC;
  391. font-size: 34rpx;
  392. font-weight: 600;
  393. line-height: 40rpx;
  394. letter-spacing: normal;
  395. color: rgba(0, 0, 0, 0.8);
  396. width: 136rpx;
  397. height: 25rpx;
  398. margin-top: 95rpx;
  399. margin-left: 33rpx;
  400. // position: relative;
  401. // left: -2rpx;
  402. // top: 17rpx;
  403. }
  404. .paiBanDesc {
  405. font-family: PingFang SC;
  406. font-size: 26rpx;
  407. font-weight: normal;
  408. line-height: 40rpx;
  409. color: rgba(0, 0, 0, 0.5);
  410. margin-top: 12rpx;
  411. margin-left: 33rpx;
  412. // position: relative;
  413. }
  414. .paiBanBtn {
  415. width: 200rpx;
  416. height: 70rpx;
  417. display: flex;
  418. justify-content: center;
  419. align-items: center;
  420. border-radius: 36rpx;
  421. background: #D94342;
  422. font-family: PingFang SC;
  423. font-size: 28rpx;
  424. font-weight: 500;
  425. line-height: 30rpx;
  426. color: #FFFFFF;
  427. border: none;
  428. padding: 0;
  429. margin-top: 55rpx;
  430. margin-left: 53rpx;
  431. // position: relative;
  432. // top: -20rpx;
  433. // left: 4rpx;
  434. }
  435. }
  436. .home-ranking {}
  437. @keyframes fadeIn {
  438. from {
  439. opacity: 0;
  440. transform: scale(0.9) translateY(10rpx);
  441. }
  442. to {
  443. opacity: 1;
  444. transform: scale(1) translateY(0);
  445. }
  446. }
  447. @keyframes fadeOut {
  448. from {
  449. opacity: 1;
  450. transform: scale(1) translateY(0);
  451. }
  452. to {
  453. opacity: 0.8;
  454. transform: scale(0.95) translateY(-10rpx);
  455. }
  456. }
  457. </style>