new_file.vue 9.6 KB

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