123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402 |
- <template>
- <view>
- <!-- 服务选择 -->
- <template v-if="userType == 1">
- <view class="Wrapper-grid">
- <!-- 横向滚动容器 -->
- <scroll-view scroll-x class="grid-scroll-view" shows-horizontal-scroll-indicator="false">
- <up-grid :border="false" col="5" @click="handleGridClick" class="grid-container">
- <up-grid-item v-for="(item, index) in serviceList1" :key="index"
- :custom-style="{ padding: '20rpx' }">
- <!-- 图标 -->
- <image :src="item.icon" class="service-img" mode="aspectFit" />
-
- <!-- 文本 -->
- <text class="grid-text">{{ item.name }}</text>
- </up-grid-item>
- </up-grid>
- </scroll-view>
-
- <up-toast ref="uToastRef" />
- </view>
- </template>
- <template v-else-if="userType == 2">
- <view class="Wrapper-grid">
- <up-grid :border="false" col="4" @click="handleGridClick">
- <up-grid-item v-for="(item, index) in serviceList2" :key="index" :custom-style="custmoStyle">
- <view class="grid-box">
- <!-- 图标 -->
- <view class="grid-icon">
- <image :src="item.icon" class="service-img" mode="aspectFit" />
- </view>
- <!-- 文本 -->
- <text class="grid-text">{{ item.name }}</text>
- </view>
- </up-grid-item>
- </up-grid>
- <up-toast ref="uToastRef" />
- </view>
- </template>
- <Calendar ref="calendar" class="uni-calendar--hook" :clear-date="false" :date="info.date" :insert="info.insert"
- :lunar="info.lunar" :range="info.range" @change="change" :clearDate="true" @confirm="confirm"
- :selected="selected" @delete="onDelete" />
- </view>
- </template>
- <script setup>
- import {
- ref,
- onMounted,
- watch,
- computed,
- provide
- } from 'vue';
- // import {
- // typeOptionSelect
- // } from "@/api/volunteerDetailsApi/details.js"
- import {
- workDate,
- getDataTime,
- getVolunteerInfo
- } from '@/api/volunteer.js'
- import {
- volunteerSeachgetTreeList,
- } from "@/api/volunteerDetailsApi/details.js"
- import Calendar from '../../components/uni-calendar/components/uni-calendar/uni-calendar.vue'
- // Toast 控制宫格
- const uToastRef = ref(null);
- const userType = uni.getStorageSync('userType') //读取本地存储
- // 用户/志愿者 识别标识
- const userOrWorker = uni.getStorageSync('storage_data').vuex_userOrWorker //读取本地存储
- const calendar = ref(null)
- const info = ref({
- lunar: true,
- range: true,
- insert: false,
- })
- const selected = ref([])
- // 普通用户
- const serviceList1 = ref([{
- icon: '/static/Tioimages/1 妇女儿童权益保护服务.png',
- name: '孩子陪伴',
- key: 2,
- },
- {
- icon: '/static/Tioimages/家庭保洁.png',//换
- name: '家庭保洁',
- key: 1,
- },
- {
- icon: '/static/Tioimages/临时帮手.png',
- name: '临时帮手',
- key: 3,
- },
- {
- icon: '/static/Tioimages/专家服务.png',
- name: '专家服务',
- key: 4,
- },
- {
- icon: '/static/Tioimages/家电维修.png',
- name: '家电维护',
- key: 5,
- },
- {
- icon: '/static/Tioimages/1v专业指导.png',
- name: '陪伴陪聊',
- key: 6,
- },
- {
- icon: '/static/Tioimages/旅游服务.png',
- name: '旅游服务',
- key: 7,
- },
- {
- icon: '/static/Tioimages/健康管理.png',//换
- name: '健康管理',
- key: 8,
- },
- {
- icon: '/static/Tioimages/交友.png',
- name: '交友专区',
- key: 9,
- },
- {
- icon: '/static/Tioimages/购物商城.png',
- name: '商城购物',
- key: 10,
- },
- {
- icon: '/static/Tioimages/本地生活.png',
- name: '本地生活',
- key: 11,
- },
- ]);
-
- //志愿者
- const serviceList2 = ref([
- {
- icon: '/static/serverImg/home/icon/icon2.png',
- name: '陪伴陪聊',
- key: 1,
- },
- {
- icon: '/static/serverImg/home/icon/icon4.png',
- name: '孩子陪护',
- key: 2,
- },
- {
- icon: '/static/serverImg/home/icon/icon1.png',
- name: '家庭助理',
- key: 3,
- },
- {
- icon: '/static/serverImg/home/icon/icon6.png',
- name: '健康管理',
- key: 4
- },
- {
- icon: '/static/serverImg/home/icon/icon3.png',
- name: '家庭清洁',
- key: 5
- },
- {
- icon: '/static/serverImg/home/icon/icon5.png',
- name: '家务帮手',
- key: 6
- },
- {
- icon: '/static/serverImg/home/icon/icon7.png',
- name: '咨询服务',
- key: 8
- },
- {
- icon: '/static/serverImg/home/icon/icon8.png',
- name: '排班管理',
- key: 7
- },
- ]);
- const parentIdMap = {
- '孩子陪护': 2,
- '陪伴陪聊': 1,
- '家庭助理': 3,
- '健康管理': 4,
- '家庭清洁': 5,
- '家务帮手': 6,
- '资讯与服务': 7,
- };
- const getParentId = (service) => parentIdMap[service.name] || 1;
- // 宫格点击事件
- const handleGridClick = async (index) => {
- const service = serviceList1.value[index]; // 获取点击的服务条目
- // 用户
- if (userType == 1) {
- // 动态获取 parentId
- const parentId = getParentId(service); // 通过服务条目动态获取 parentId
- const params = {
- parentId: parentId
- }
- const res = await volunteerSeachgetTreeList(params)
- console.log(res, '>>>>>dictSort = null')
-
- // 只有第一条和第二条可以跳转
- if (index === 0 || index === 1) {
- uni.navigateTo({
- url: `/pages_home/pages/client/details?dataList=${encodeURIComponent(JSON.stringify(res.data))}`
- });
- } else {
- // 其他条目提示“敬请期待”
- uni.showToast({
- title: '敬请期待',
- icon: 'none'
- });
- }
- }
- // 志愿者
- if (userType == 2 && uToastRef.value) {
- // pages_home/pages
- const data = serviceList2.value[index]
- if (data.key !== 7) {
- const res = await getVolunteerInfo({ serviceCategory: data.key });
- if (res.code === 200 && res.data) {
- //已有注册,跳转详情页面
- uni.navigateTo({
- url: `/pages_home/pages/details/index?data=${encodeURIComponent(JSON.stringify(data))}`
- })
- return
- }
- data.key === 1 || data.key === 2 ? uni.navigateTo({
- url: `/pages_home/pages/register/index?data=${encodeURIComponent(JSON.stringify(data))}`
- }) : uni.showToast({
- title: '敬请期待',
- icon: 'none'
- })
- return;
- }
- init();
- }
- };
- const change = (e) => {
- console.log('change', e);
- let dates = [{
- date: e.fulldate,
- info: `${e.time.startTime}~${e.time.endTime}`,
- time: e.time
- }]
- if (e.range.before && e.range.after) {
- dates = e.range.data.map(item => {
- return {
- date: item,
- info: `${e.time.startTime}~${e.time.endTime}`,
- time: e.time
- }
- })
- }
- selected.value = [...selected.value, ...dates]
- }
- const onDelete = (e) => {
- selected.value = selected.value.filter(item => {
- console.log('item.fulldate !== e.date', item.date, e.fulldate);
- return item.date !== e.fulldate
- })
- console.log(e, selected.value);
- }
- //排班时间去重处理
- const handleDates = computed(() => {
- const parmas = selected.value.map(item => {
- return {
- workDate: item.date,
- workStartTime: item.time.startTime,
- workEndTime: item.time.endTime
- }
- })
- return parmas.reduce((acc, current) => {
- const existing = acc.find(item => item.workDate === current.workDate);
- if (existing) {
- Object.assign(existing, current);
- } else {
- acc.push(current);
- }
- return acc;
- }, []);
- });
- const confirm = (e) => {
- const parmas = handleDates.value;
- console.log('确定', parmas);
- workDate(parmas).then(res => {
- if (res.code == 200) {
- uni.showToast({
- title: '修改成功',
- icon: 'success',
- success: () => {
- setTimeout(() => {
- close();
- }, 1000)
- }
- })
- return;
- }
- uni.showToast({
- title: res.msg,
- icon: 'none'
- })
- })
- };
- const close = () => {
- calendar.value.close();
- }
- const init = () => {
- getDataTime().then(res => {
- console.log('res', res);
- if (res.code === 200) {
- selected.value = res.data.map(item => {
- return {
- date: item.workDate,
- info: `${item.workStartTime}~${item.workEndTime}`,
- time: {
- startTime: item.workStartTime,
- endTime: item.workEndTime
- }
- }
- })
- calendar.value.open();
- }
- })
- }
- onMounted(() => {
- // init();
- });
- </script>
- <style scoped>
- .Wrapper-grid {
- /* margin-top: 170rpx; */
- margin-top: 36rpx;
- }
- /* 图标样式 */
- .service-img {
- /* width: 80rpx;
- height: 80rpx; */
- /* margin-bottom: 15rpx; */
- }
- /* 文本样式 */
- .grid-text {
- font-size: 24rpx;
- color: #333;
- text-align: center;
- margin-top: 18rpx;
- }
- .grid-box {
- display: flex;
- align-items: center;
- justify-content: center;
- flex-direction: column;
- margin-bottom: 48rpx;
- }
- .grid-icon {
- width: 96rpx;
- height: 96rpx;
- opacity: 1;
- border-radius: 8rpx;
- background: rgba(251, 229, 225, 1);
- display: flex;
- align-items: center;
- justify-content: center;
- }
- .service-img {
- width: 48rpx;
- height: 48rpx;
- }
- </style>
|