new_file.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537
  1. <template>
  2. <view>
  3. <!-- 服务选择 -->
  4. <template v-if="userType == 1">
  5. <view class="Wrapper-grid">
  6. <up-grid :border="false" col="4" @click="handleGridClick">
  7. <up-grid-item v-for="(item, index) in serviceList1" :key="index"
  8. :custom-style="{ padding: '20rpx' }">
  9. <!-- 图标 -->
  10. <image :src="item.icon" class="service-img" mode="aspectFit" />
  11. <!-- 文本 -->
  12. <text class="grid-text">{{ item.name }}</text>
  13. </up-grid-item>
  14. </up-grid>
  15. <up-toast ref="uToastRef" />
  16. </view>
  17. </template>
  18. <template v-else-if="userType == 2">
  19. <view class="Wrapper-grid">
  20. <up-grid :border="false" col="4" @click="handleGridClick">
  21. <up-grid-item v-for="(item, index) in serviceList2" :key="index" :custom-style="custmoStyle">
  22. <view class="grid-box">
  23. <!-- 图标 -->
  24. <view class="grid-icon">
  25. <image :src="item.icon" class="service-img" mode="aspectFit" />
  26. </view>
  27. <!-- 文本 -->
  28. <text class="grid-text">{{ item.name }}</text>
  29. </view>
  30. </up-grid-item>
  31. </up-grid>
  32. <up-toast ref="uToastRef" />
  33. </view>
  34. </template>
  35. <Calendar ref="calendar" class="uni-calendar--hook" :clear-date="false" :date="info.date" :insert="info.insert"
  36. :lunar="info.lunar" :range="info.range" @change="change" :clearDate="true" @confirm="confirm"
  37. :selected="selected" @delete="onDelete" />
  38. </view>
  39. </template>
  40. <script setup>
  41. import {
  42. ref,
  43. onMounted,
  44. watch,
  45. computed,
  46. provide
  47. } from 'vue';
  48. // import {
  49. // typeOptionSelect
  50. // } from "@/api/volunteerDetailsApi/details.js"
  51. import {
  52. workDate,
  53. <<<<<<< HEAD
  54. <<<<<<< HEAD
  55. getDataTime,
  56. getVolunteerInfo
  57. =======
  58. getDataTime
  59. >>>>>>> 3e2be9f (fetch:详情tabs/用户新增地址)
  60. =======
  61. getDataTime,
  62. getVolunteerInfo
  63. >>>>>>> 8343935 (fix: 代码合并)
  64. } from '@/api/volunteer.js'
  65. import {
  66. volunteerSeachgetTreeList,
  67. } from "@/api/volunteerDetailsApi/details.js"
  68. import Calendar from '../../components/uni-calendar/components/uni-calendar/uni-calendar.vue'
  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. <<<<<<< HEAD
  82. // 普通用户
  83. const serviceList1 = ref([{
  84. icon: '/static/img/统一知识平台-营运@1x.png',
  85. name: '孩子陪护',
  86. key: 2,
  87. },
  88. {
  89. icon: '/static/img/编组.png',
  90. name: '陪伴陪聊',
  91. key: 1,
  92. },
  93. {
  94. icon: '/static/img/清空.png',
  95. name: '家庭助理',
  96. key: 3,
  97. },
  98. {
  99. icon: '/static/img/构建.png',
  100. name: '健康管理',
  101. key: 4,
  102. },
  103. {
  104. icon: '/static/img/报事报修@6x.png',
  105. name: '家庭清洁',
  106. key: 5,
  107. },
  108. {
  109. icon: '/static/img/报事报修@6x.png',
  110. name: '家务帮手',
  111. key: 6,
  112. },
  113. {
  114. icon: '/static/img/报事报修@6x.png',
  115. name: '资讯与服务',
  116. key: 7,
  117. },
  118. ]);
  119. //志愿者
  120. const serviceList2 = ref([
  121. {
  122. icon: '/static/serverImg/home/icon/icon2.png',
  123. name: '陪伴陪聊',
  124. key: 1,
  125. },
  126. {
  127. icon: '/static/serverImg/home/icon/icon4.png',
  128. name: '孩子陪护',
  129. key: 2,
  130. },
  131. {
  132. icon: '/static/serverImg/home/icon/icon1.png',
  133. name: '家庭助理',
  134. key: 3,
  135. },
  136. {
  137. icon: '/static/serverImg/home/icon/icon6.png',
  138. name: '健康管理',
  139. key: 4
  140. },
  141. {
  142. icon: '/static/serverImg/home/icon/icon2.png',
  143. name: '家庭清洁',
  144. key: 5
  145. },
  146. {
  147. icon: '/static/serverImg/home/icon/icon5.png',
  148. name: '家务帮手',
  149. key: 6
  150. },
  151. {
  152. icon: '/static/serverImg/home/icon/icon7.png',
  153. name: '咨询服务',
  154. key: 8
  155. },
  156. {
  157. icon: '/static/serverImg/home/icon/icon8.png',
  158. name: '排班管理',
  159. key: 7
  160. },
  161. ]);
  162. <<<<<<< HEAD
  163. =======
  164. >>>>>>> 3e2be9f (fetch:详情tabs/用户新增地址)
  165. const parentIdMap = {
  166. '孩子陪护': 2,
  167. '陪伴陪聊': 1,
  168. '家庭助理': 3,
  169. '健康管理': 4,
  170. '家庭清洁': 5,
  171. '家务帮手': 6,
  172. '资讯与服务': 7,
  173. };
  174. const getParentId = (service) => parentIdMap[service.name] || 1;
  175. <<<<<<< HEAD
  176. // 宫格点击事件
  177. const handleGridClick = async (index) => {
  178. const service = serviceList1.value[index]; // 获取点击的服务条目
  179. // 用户
  180. if (userType == 1) {
  181. // 动态获取 parentId
  182. const parentId = getParentId(service); // 通过服务条目动态获取 parentId
  183. const params = {
  184. parentId: parentId
  185. }
  186. const res = await volunteerSeachgetTreeList(params)
  187. console.log(res, '>>>>>dictSort = null')
  188. // 只有第一条和第二条可以跳转
  189. if (index === 0 || index === 1) {
  190. uni.navigateTo({
  191. url: `/pages_home/pages/client/details?dataList=${encodeURIComponent(JSON.stringify(res.data))}`
  192. });
  193. } else {
  194. // 其他条目提示“敬请期待”
  195. uni.showToast({
  196. title: '敬请期待',
  197. icon: 'none'
  198. });
  199. }
  200. }
  201. // 志愿者
  202. if (userType == 2 && uToastRef.value) {
  203. // pages_home/pages
  204. =======
  205. // 普通用户
  206. const serviceList1 = ref([{
  207. icon: '/static/img/统一知识平台-营运@1x.png',
  208. name: '孩子陪护',
  209. key: 2,
  210. },
  211. {
  212. icon: '/static/img/编组.png',
  213. name: '陪伴陪聊',
  214. key: 1,
  215. },
  216. {
  217. icon: '/static/img/清空.png',
  218. name: '家庭助理',
  219. key: 3,
  220. },
  221. {
  222. icon: '/static/img/构建.png',
  223. name: '健康管理',
  224. key: 4,
  225. },
  226. {
  227. icon: '/static/img/报事报修@6x.png',
  228. name: '家庭清洁',
  229. key: 5,
  230. },
  231. {
  232. icon: '/static/img/报事报修@6x.png',
  233. name: '家务帮手',
  234. key: 6,
  235. },
  236. {
  237. icon: '/static/img/报事报修@6x.png',
  238. name: '资讯与服务',
  239. key: 7,
  240. },
  241. ]);
  242. //志愿者
  243. const serviceList2 = ref([{
  244. icon: '/static/img/统一知识平台-营运@1x.png',
  245. name: '孩子陪护注册',
  246. key: 2,
  247. },
  248. {
  249. icon: '/static/img/编组.png',
  250. name: '陪伴陪聊注册',
  251. key: 1,
  252. },
  253. {
  254. icon: '/static/img/清空.png',
  255. name: '家庭助理注册',
  256. key: 3,
  257. },
  258. {
  259. icon: '/static/img/构建.png',
  260. name: '健康管理注册',
  261. key: 4
  262. },
  263. {
  264. icon: '/static/img/报事报修@6x.png',
  265. name: '家庭清洁注册',
  266. key: 5
  267. },
  268. {
  269. icon: '/static/img/报事报修@6x.png',
  270. name: '家务帮手注册',
  271. key: 6
  272. },
  273. {
  274. icon: '/static/img/清空.png',
  275. name: '排班管理',
  276. key: 7
  277. },
  278. ]);
  279. >>>>>>> 3e2be9f (fetch:详情tabs/用户新增地址)
  280. =======
  281. >>>>>>> 8343935 (fix: 代码合并)
  282. const parentIdMap = {
  283. '孩子陪护': 2,
  284. '陪伴陪聊': 1,
  285. '家庭助理': 3,
  286. '健康管理': 4,
  287. '家庭清洁': 5,
  288. '家务帮手': 6,
  289. '资讯与服务': 7,
  290. };
  291. const getParentId = (service) => parentIdMap[service.name] || 1;
  292. // 宫格点击事件
  293. const handleGridClick = async (index) => {
  294. const service = serviceList1.value[index]; // 获取点击的服务条目
  295. // 用户
  296. if (userType == 1) {
  297. // 动态获取 parentId
  298. const parentId = getParentId(service); // 通过服务条目动态获取 parentId
  299. const params = {
  300. parentId: parentId
  301. }
  302. const res = await volunteerSeachgetTreeList(params)
  303. console.log(res, '>>>>>dictSort = null')
  304. // 只有第一条和第二条可以跳转
  305. if (index === 0 || index === 1) {
  306. uni.navigateTo({
  307. url: `/pages_home/pages/client/details?dataList=${encodeURIComponent(JSON.stringify(res.data))}`
  308. });
  309. } else {
  310. // 其他条目提示“敬请期待”
  311. uni.showToast({
  312. title: '敬请期待',
  313. icon: 'none'
  314. });
  315. }
  316. }
  317. // 志愿者
  318. if (userType == 2 && uToastRef.value) {
  319. // pages_home/pages
  320. const data = serviceList2.value[index]
  321. if (data.key !== 7) {
  322. const res = await getVolunteerInfo({ serviceCategory: data.key });
  323. if (res.code === 200 && res.data) {
  324. //已有注册,跳转详情页面
  325. uni.navigateTo({
  326. url: `/pages_home/pages/details/index?data=${encodeURIComponent(JSON.stringify(data))}`
  327. })
  328. return
  329. }
  330. data.key === 1 || data.key === 2 ? uni.navigateTo({
  331. url: `/pages_home/pages/register/index?data=${encodeURIComponent(JSON.stringify(data))}`
  332. }) : uni.showToast({
  333. title: '敬请期待',
  334. icon: 'none'
  335. })
  336. return;
  337. }
  338. <<<<<<< HEAD
  339. <<<<<<< HEAD
  340. init();
  341. }
  342. =======
  343. >>>>>>> 3e2be9f (fetch:详情tabs/用户新增地址)
  344. =======
  345. init();
  346. }
  347. >>>>>>> 8343935 (fix: 代码合并)
  348. };
  349. const change = (e) => {
  350. console.log('change', e);
  351. let dates = [{
  352. date: e.fulldate,
  353. info: `${e.time.startTime}~${e.time.endTime}`,
  354. time: e.time
  355. }]
  356. if (e.range.before && e.range.after) {
  357. dates = e.range.data.map(item => {
  358. return {
  359. date: item,
  360. info: `${e.time.startTime}~${e.time.endTime}`,
  361. time: e.time
  362. }
  363. })
  364. }
  365. selected.value = [...selected.value, ...dates]
  366. }
  367. const onDelete = (e) => {
  368. selected.value = selected.value.filter(item => {
  369. console.log('item.fulldate !== e.date', item.date, e.fulldate);
  370. return item.date !== e.fulldate
  371. })
  372. console.log(e, selected.value);
  373. }
  374. //排班时间去重处理
  375. const handleDates = computed(() => {
  376. const parmas = selected.value.map(item => {
  377. return {
  378. workDate: item.date,
  379. workStartTime: item.time.startTime,
  380. workEndTime: item.time.endTime
  381. }
  382. })
  383. return parmas.reduce((acc, current) => {
  384. const existing = acc.find(item => item.workDate === current.workDate);
  385. if (existing) {
  386. Object.assign(existing, current);
  387. } else {
  388. acc.push(current);
  389. }
  390. return acc;
  391. }, []);
  392. });
  393. const confirm = (e) => {
  394. const parmas = handleDates.value;
  395. console.log('确定', parmas);
  396. workDate(parmas).then(res => {
  397. if (res.code == 200) {
  398. uni.showToast({
  399. title: '修改成功',
  400. icon: 'success',
  401. success: () => {
  402. setTimeout(() => {
  403. close();
  404. }, 1000)
  405. }
  406. })
  407. return;
  408. }
  409. uni.showToast({
  410. title: res.msg,
  411. icon: 'none'
  412. })
  413. })
  414. };
  415. const close = () => {
  416. calendar.value.close();
  417. }
  418. const init = () => {
  419. <<<<<<< HEAD
  420. <<<<<<< HEAD
  421. getDataTime().then(res => {
  422. console.log('res', res);
  423. if (res.code === 200) {
  424. =======
  425. getDataTime().then(res => {
  426. console.log('res', res);
  427. >>>>>>> 3e2be9f (fetch:详情tabs/用户新增地址)
  428. =======
  429. getDataTime().then(res => {
  430. console.log('res', res);
  431. if (res.code === 200) {
  432. >>>>>>> 8343935 (fix: 代码合并)
  433. selected.value = res.data.map(item => {
  434. return {
  435. date: item.workDate,
  436. info: `${item.workStartTime}~${item.workEndTime}`,
  437. time: {
  438. startTime: item.workStartTime,
  439. endTime: item.workEndTime
  440. }
  441. }
  442. })
  443. calendar.value.open();
  444. }
  445. })
  446. }
  447. onMounted(() => {
  448. // init();
  449. });
  450. </script>
  451. <style scoped>
  452. .Wrapper-grid {
  453. /* margin-top: 170rpx; */
  454. margin-top: 36rpx;
  455. }
  456. /* 图标样式 */
  457. .service-img {
  458. /* width: 80rpx;
  459. height: 80rpx; */
  460. /* margin-bottom: 15rpx; */
  461. }
  462. /* 文本样式 */
  463. .grid-text {
  464. font-size: 24rpx;
  465. color: #333;
  466. text-align: center;
  467. margin-top: 18rpx;
  468. }
  469. .grid-box {
  470. display: flex;
  471. align-items: center;
  472. justify-content: center;
  473. flex-direction: column;
  474. margin-bottom: 48rpx;
  475. }
  476. .grid-icon {
  477. width: 96rpx;
  478. height: 96rpx;
  479. opacity: 1;
  480. border-radius: 8rpx;
  481. background: rgba(0, 122, 255, 0.1);
  482. display: flex;
  483. align-items: center;
  484. justify-content: center;
  485. }
  486. .service-img {
  487. width: 48rpx;
  488. height: 48rpx;
  489. }
  490. </style>