new_file.vue 10 KB

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