new_file.vue 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421
  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. const swiperList = ['integral', 'kefu-ermai', 'coupon', 'gift', 'scan', 'pause-circle', 'wifi', 'email', 'list'];
  62. // Toast 控制宫格
  63. const uToastRef = ref(null);
  64. const userType = uni.getStorageSync('userType') //读取本地存储
  65. // 用户/志愿者 识别标识
  66. const userOrWorker = uni.getStorageSync('storage_data').vuex_userOrWorker //读取本地存储
  67. const calendar = ref(null)
  68. const info = ref({
  69. lunar: true,
  70. range: true,
  71. insert: false,
  72. })
  73. const selected = ref([])
  74. const serveiceList = ref([]);
  75. // 志愿者图片
  76. const volunteerImages = ref([]);
  77. const getVolunteerImages = () => {
  78. volunteerVolunteerPicture({}).then(res => {
  79. console.log('res', 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. console.log('change', e);
  125. let dates = [{
  126. date: e.fulldate,
  127. info: `${e.time.startTime}~${e.time.endTime}`,
  128. time: e.time
  129. }]
  130. if (e.range.before && e.range.after) {
  131. dates = e.range.data.map(item => {
  132. return {
  133. date: item,
  134. info: `${e.time.startTime}~${e.time.endTime}`,
  135. time: e.time
  136. }
  137. })
  138. }
  139. selected.value = [...selected.value, ...dates]
  140. }
  141. const onDelete = (e) => {
  142. selected.value = selected.value.filter(item => {
  143. console.log('item.fulldate !== e.date', item.date, e.fulldate);
  144. return item.date !== e.fulldate
  145. })
  146. console.log(e, selected.value);
  147. }
  148. //排班时间去重处理
  149. const handleDates = computed(() => {
  150. const parmas = selected.value.map(item => {
  151. return {
  152. workDate: item.date,
  153. workStartTime: item.time.startTime,
  154. workEndTime: item.time.endTime
  155. }
  156. })
  157. return parmas.reduce((acc, current) => {
  158. const existing = acc.find(item => item.workDate === current.workDate);
  159. if (existing) {
  160. Object.assign(existing, current);
  161. } else {
  162. acc.push(current);
  163. }
  164. return acc;
  165. }, []);
  166. });
  167. const confirm = (e) => {
  168. const parmas = handleDates.value;
  169. console.log('确定', parmas);
  170. workDate(parmas).then(res => {
  171. if (res.code == 200) {
  172. uni.showToast({
  173. title: '修改成功',
  174. icon: 'success',
  175. success: () => {
  176. setTimeout(() => {
  177. close();
  178. }, 1000)
  179. }
  180. })
  181. return;
  182. }
  183. uni.showToast({
  184. title: res.msg,
  185. icon: 'none'
  186. })
  187. })
  188. };
  189. const close = () => {
  190. calendar.value.close();
  191. }
  192. const init = () => {
  193. getTreeList({ parentId: '0' }).then(res => {
  194. console.log("TCL: init -> res", res)
  195. serveiceList.value = res.data;
  196. })
  197. }
  198. const DataInit = () => {
  199. getDataTime().then(res => {
  200. console.log('res', 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. getVolunteerImages();
  219. });
  220. </script>
  221. <style scoped lang="scss">
  222. .grid-box {
  223. width: 226rpx;
  224. height: 116rpx;
  225. display: flex;
  226. flex-direction: row;
  227. align-items: center;
  228. justify-content: flex-start;
  229. margin-right: 5rpx;
  230. margin-left: 5rpx;
  231. background: #fff;
  232. border-radius: 14rpx;
  233. // background: red;
  234. background: linear-gradient(180deg, #FFF9F3 0%, #FFFFFF 100%);
  235. box-shadow: 0rpx 4rpx 10rpx 0rpx rgba(0, 0, 0, 0.04);
  236. margin-top: 10rpx;
  237. .grid-image {
  238. width: 64rpx;
  239. height: 68rpx;
  240. display: flex;
  241. align-items: center;
  242. justify-content: center;
  243. }
  244. }
  245. .grid-content {
  246. display: flex;
  247. flex-direction: column;
  248. align-items: flex-start;
  249. justify-content: center;
  250. .grid-text {
  251. width: 112rpx;
  252. height: 36rpx;
  253. font-family: PingFang SC;
  254. font-size: 28rpx;
  255. font-weight: 500;
  256. line-height: 36rpx;
  257. letter-spacing: normal;
  258. color: #313131;
  259. }
  260. .grid-text-bone {
  261. width: 130rpx;
  262. height: 28rpx;
  263. font-family: PingFang SC;
  264. font-size: 22rpx;
  265. font-weight: normal;
  266. line-height: 28rpx;
  267. letter-spacing: -0.02em;
  268. color: #818181;
  269. margin-left: 6rpx;
  270. margin-top: 10rpx;
  271. }
  272. }
  273. .paiBanSty {
  274. .paiBanTitle {
  275. width: 136rpx;
  276. height: 40rpx;
  277. font-family: PingFang SC;
  278. font-size: 34rpx;
  279. font-weight: 600;
  280. line-height: 40rpx;
  281. letter-spacing: normal;
  282. color: rgba(0, 0, 0, 0.8);
  283. position: absolute;
  284. top: 1072rpx;
  285. left: 278rpx;
  286. }
  287. .paiBanDesc {
  288. width: 390rpx;
  289. height: 40rpx;
  290. font-family: PingFang SC;
  291. font-size: 26rpx;
  292. font-weight: normal;
  293. line-height: 40rpx;
  294. letter-spacing: normal;
  295. color: rgba(0, 0, 0, 0.5);
  296. position: absolute;
  297. top: 1136rpx;
  298. left: 278rpx;
  299. }
  300. .paiBanBtn {
  301. width: 200rpx;
  302. height: 60rpx;
  303. display: flex;
  304. justify-content: center;
  305. align-items: center;
  306. border-radius: 36rpx;
  307. background: #D94342;
  308. font-family: PingFang SC;
  309. font-size: 28rpx;
  310. font-weight: 600;
  311. line-height: 30rpx;
  312. letter-spacing: normal;
  313. color: #FFF9F3;
  314. position: absolute;
  315. top: 1035rpx;
  316. left: 472rpx;
  317. }
  318. .images {
  319. width: 750rpx;
  320. }
  321. .zhiYuanZheSwiper {
  322. width: 205rpx;
  323. height: 298rpx;
  324. position: absolute;
  325. top: 876rpx;
  326. left: 43rpx;
  327. border-radius: 38rpx;
  328. overflow: hidden;
  329. }
  330. .swiper-item-container {
  331. width: 100%;
  332. height: 100%;
  333. display: flex;
  334. justify-content: center;
  335. align-items: center;
  336. transition: all 0.5s ease;
  337. opacity: 0.8;
  338. transform: scale(0.95);
  339. &.active-swiper {
  340. opacity: 1;
  341. transform: scale(1);
  342. animation: fadeIn 0.8s ease forwards;
  343. }
  344. }
  345. .zhiYuanZhe {
  346. width: 100%;
  347. height: 100%;
  348. border-radius: 38rpx;
  349. transition: all 0.5s ease;
  350. box-shadow: 0 8rpx 20rpx rgba(0, 0, 0, 0.1);
  351. display: block; /* 确保没有额外的空间 */
  352. }
  353. }
  354. .home-ranking{
  355. }
  356. @keyframes fadeIn {
  357. from {
  358. opacity: 0;
  359. transform: scale(0.9) translateY(10rpx);
  360. }
  361. to {
  362. opacity: 1;
  363. transform: scale(1) translateY(0);
  364. }
  365. }
  366. @keyframes fadeOut {
  367. from {
  368. opacity: 1;
  369. transform: scale(1) translateY(0);
  370. }
  371. to {
  372. opacity: 0.8;
  373. transform: scale(0.95) translateY(-10rpx);
  374. }
  375. }
  376. </style>