new_file.vue 10.0 KB

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