new_file.vue 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422
  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. console.log('res', res);
  81. if (Array.isArray(res)) {
  82. volunteerImages.value = res;
  83. } else if (res.code === 200 && res.data) {
  84. volunteerImages.value = res.data;
  85. }
  86. })
  87. }
  88. // 当前显示的轮播图索引
  89. const currentSwiperIndex = ref(0);
  90. // 轮播图切换事件
  91. const onSwiperChange = (e) => {
  92. currentSwiperIndex.value = e.detail.current;
  93. };
  94. // 宫格点击事件
  95. const handleGridClick = async (service) => {
  96. // 用户
  97. if (userType == 1) {
  98. // 动态获取 parentId
  99. const params = {
  100. parentId: service.id,
  101. }
  102. const res = await volunteerSeachgetTreeList(params)
  103. uni.navigateTo({
  104. url: `/pages_home/pages/client/details?dataList=${encodeURIComponent(JSON.stringify(res.data))}&serviceCategory=${service.id}`
  105. });
  106. }
  107. // 志愿者
  108. if (userType == 2) {
  109. const res = await getVolunteerInfo({
  110. serviceCategory: service.id
  111. });
  112. if (res.code === 200 && res.data) {
  113. //已有注册,跳转详情页面
  114. uni.navigateTo({
  115. url: `/pages_home/pages/details/index?data=${encodeURIComponent(JSON.stringify({ ...service, key: service.id }))}`
  116. })
  117. return
  118. }
  119. uni.navigateTo({
  120. url: `/pages_home/pages/register/index?data=${encodeURIComponent(JSON.stringify({ ...service, key: service.id }))}`
  121. })
  122. }
  123. };
  124. const change = (e) => {
  125. console.log('change', e);
  126. let dates = [{
  127. date: e.fulldate,
  128. info: `${e.time.startTime}~${e.time.endTime}`,
  129. time: e.time
  130. }]
  131. if (e.range.before && e.range.after) {
  132. dates = e.range.data.map(item => {
  133. return {
  134. date: item,
  135. info: `${e.time.startTime}~${e.time.endTime}`,
  136. time: e.time
  137. }
  138. })
  139. }
  140. selected.value = [...selected.value, ...dates]
  141. }
  142. const onDelete = (e) => {
  143. selected.value = selected.value.filter(item => {
  144. console.log('item.fulldate !== e.date', item.date, e.fulldate);
  145. return item.date !== e.fulldate
  146. })
  147. console.log(e, selected.value);
  148. }
  149. //排班时间去重处理
  150. const handleDates = computed(() => {
  151. const parmas = selected.value.map(item => {
  152. return {
  153. workDate: item.date,
  154. workStartTime: item.time.startTime,
  155. workEndTime: item.time.endTime
  156. }
  157. })
  158. return parmas.reduce((acc, current) => {
  159. const existing = acc.find(item => item.workDate === current.workDate);
  160. if (existing) {
  161. Object.assign(existing, current);
  162. } else {
  163. acc.push(current);
  164. }
  165. return acc;
  166. }, []);
  167. });
  168. const confirm = (e) => {
  169. const parmas = handleDates.value;
  170. console.log('确定', parmas);
  171. workDate(parmas).then(res => {
  172. if (res.code == 200) {
  173. uni.showToast({
  174. title: '修改成功',
  175. icon: 'success',
  176. success: () => {
  177. setTimeout(() => {
  178. close();
  179. }, 1000)
  180. }
  181. })
  182. return;
  183. }
  184. uni.showToast({
  185. title: res.msg,
  186. icon: 'none'
  187. })
  188. })
  189. };
  190. const close = () => {
  191. calendar.value.close();
  192. }
  193. const init = () => {
  194. getTreeList({ parentId: '0' }).then(res => {
  195. console.log("TCL: init -> res", res)
  196. serveiceList.value = res.data;
  197. })
  198. }
  199. const DataInit = () => {
  200. getDataTime().then(res => {
  201. console.log('res', res);
  202. if (res.code === 200) {
  203. selected.value = res.data.map(item => {
  204. return {
  205. date: item.workDate,
  206. info: `${item.workStartTime}~${item.workEndTime}`,
  207. time: {
  208. startTime: item.workStartTime,
  209. endTime: item.workEndTime
  210. }
  211. }
  212. })
  213. calendar.value.open();
  214. }
  215. })
  216. }
  217. onMounted(() => {
  218. init();
  219. const token = getToken();
  220. token && getVolunteerImages();
  221. });
  222. </script>
  223. <style scoped lang="scss">
  224. .grid-box {
  225. width: 226rpx;
  226. height: 116rpx;
  227. display: flex;
  228. flex-direction: row;
  229. align-items: center;
  230. justify-content: flex-start;
  231. margin-right: 5rpx;
  232. margin-left: 5rpx;
  233. background: #fff;
  234. border-radius: 14rpx;
  235. // background: red;
  236. background: linear-gradient(180deg, #FFF9F3 0%, #FFFFFF 100%);
  237. box-shadow: 0rpx 4rpx 10rpx 0rpx rgba(0, 0, 0, 0.04);
  238. margin-top: 10rpx;
  239. .grid-image {
  240. width: 64rpx;
  241. height: 68rpx;
  242. display: flex;
  243. align-items: center;
  244. justify-content: center;
  245. }
  246. }
  247. .grid-content {
  248. display: flex;
  249. flex-direction: column;
  250. align-items: flex-start;
  251. justify-content: center;
  252. .grid-text {
  253. width: 112rpx;
  254. height: 36rpx;
  255. font-family: PingFang SC;
  256. font-size: 28rpx;
  257. font-weight: 500;
  258. line-height: 36rpx;
  259. letter-spacing: normal;
  260. color: #313131;
  261. }
  262. .grid-text-bone {
  263. width: 130rpx;
  264. height: 28rpx;
  265. font-family: PingFang SC;
  266. font-size: 22rpx;
  267. font-weight: normal;
  268. line-height: 28rpx;
  269. letter-spacing: -0.02em;
  270. color: #818181;
  271. margin-left: 6rpx;
  272. margin-top: 10rpx;
  273. }
  274. }
  275. .paiBanSty {
  276. .paiBanTitle {
  277. width: 136rpx;
  278. height: 40rpx;
  279. font-family: PingFang SC;
  280. font-size: 34rpx;
  281. font-weight: 600;
  282. line-height: 40rpx;
  283. letter-spacing: normal;
  284. color: rgba(0, 0, 0, 0.8);
  285. position: absolute;
  286. top: 1072rpx;
  287. left: 278rpx;
  288. }
  289. .paiBanDesc {
  290. width: 390rpx;
  291. height: 40rpx;
  292. font-family: PingFang SC;
  293. font-size: 26rpx;
  294. font-weight: normal;
  295. line-height: 40rpx;
  296. letter-spacing: normal;
  297. color: rgba(0, 0, 0, 0.5);
  298. position: absolute;
  299. top: 1136rpx;
  300. left: 278rpx;
  301. }
  302. .paiBanBtn {
  303. width: 200rpx;
  304. height: 60rpx;
  305. display: flex;
  306. justify-content: center;
  307. align-items: center;
  308. border-radius: 36rpx;
  309. background: #D94342;
  310. font-family: PingFang SC;
  311. font-size: 28rpx;
  312. font-weight: 600;
  313. line-height: 30rpx;
  314. letter-spacing: normal;
  315. color: #FFF9F3;
  316. position: absolute;
  317. top: 1035rpx;
  318. left: 472rpx;
  319. }
  320. .images {
  321. width: 750rpx;
  322. }
  323. .zhiYuanZheSwiper {
  324. width: 205rpx;
  325. height: 298rpx;
  326. position: absolute;
  327. top: 876rpx;
  328. left: 43rpx;
  329. border-radius: 38rpx;
  330. overflow: hidden;
  331. }
  332. .swiper-item-container {
  333. width: 100%;
  334. height: 100%;
  335. display: flex;
  336. justify-content: center;
  337. align-items: center;
  338. transition: all 0.5s ease;
  339. opacity: 0.8;
  340. transform: scale(0.95);
  341. &.active-swiper {
  342. opacity: 1;
  343. transform: scale(1);
  344. animation: fadeIn 0.8s ease forwards;
  345. }
  346. }
  347. .zhiYuanZhe {
  348. width: 100%;
  349. height: 100%;
  350. border-radius: 38rpx;
  351. transition: all 0.5s ease;
  352. box-shadow: 0 8rpx 20rpx rgba(0, 0, 0, 0.1);
  353. display: block; /* 确保没有额外的空间 */
  354. }
  355. }
  356. .home-ranking{
  357. }
  358. @keyframes fadeIn {
  359. from {
  360. opacity: 0;
  361. transform: scale(0.9) translateY(10rpx);
  362. }
  363. to {
  364. opacity: 1;
  365. transform: scale(1) translateY(0);
  366. }
  367. }
  368. @keyframes fadeOut {
  369. from {
  370. opacity: 1;
  371. transform: scale(1) translateY(0);
  372. }
  373. to {
  374. opacity: 0.8;
  375. transform: scale(0.95) translateY(-10rpx);
  376. }
  377. }
  378. </style>