From 7acb0415dd0ab0427ec5bd651fc9730c34a7bd6c Mon Sep 17 00:00:00 2001 From: zhengyiming <540361168@qq.com> Date: 星期五, 08 八月 2025 15:25:54 +0800 Subject: [PATCH] fix: 任务详情 --- apps/cMiniApp/src/subpackages/task/taskDetail/InnerPage.vue | 19 +++++++-- packages/utils/location.ts | 7 ++- packages/components/src/Card/TaskCard.vue | 49 +++++++++++++++++++++--- apps/cMiniApp/src/pages/home/index.vue | 15 ++++++- apps/bMiniApp/src/subpackages/task/publishTask/InnerPage.vue | 2 packages/services/apiV2/typings.d.ts | 2 + packages/components/src/Card/TaskPrice.vue | 2 apps/cMiniApp/src/hooks/task.ts | 10 +++-- 8 files changed, 84 insertions(+), 22 deletions(-) diff --git a/apps/bMiniApp/src/subpackages/task/publishTask/InnerPage.vue b/apps/bMiniApp/src/subpackages/task/publishTask/InnerPage.vue index dbb88a9..db4237e 100644 --- a/apps/bMiniApp/src/subpackages/task/publishTask/InnerPage.vue +++ b/apps/bMiniApp/src/subpackages/task/publishTask/InnerPage.vue @@ -202,7 +202,7 @@ benefits: [] as string[], ageMinLimit: 0, ageMaxLimit: 0, - genderLimit: '' as any as EnumUserGender, + genderLimit: 0 as any as EnumUserGender, credentialLimits: [] as string[], // address: '', beginTime: '', diff --git a/apps/cMiniApp/src/hooks/task.ts b/apps/cMiniApp/src/hooks/task.ts index bdb6b3a..fe9dc25 100644 --- a/apps/cMiniApp/src/hooks/task.ts +++ b/apps/cMiniApp/src/hooks/task.ts @@ -18,11 +18,12 @@ } type UseTaskListOptions = { - cityName?: MaybeRef<string>; + cityCode?: MaybeRef<string>; + enabled?: MaybeRef<boolean>; }; export function useTaskList(options: UseTaskListOptions = {}) { - const { cityName = '' } = options; + const { cityCode = '', enabled = true } = options; const searchValue = ref(''); @@ -55,7 +56,7 @@ ], }, keywords: queryState.searchValueTrim, - // cityCode: 'string', + cityCode: unref(cityCode), settlementCycle: queryMenuState.settlementCycle, benefitCodes: [queryMenuState.benefitCodes].filter(Boolean), genderLimit: queryMenuState.genderLimit, @@ -68,7 +69,8 @@ }); }, { - queryKey: ['taskServices/getTaskInfos', queryState, queryMenuState, cityName], + queryKey: ['taskServices/getTaskInfos', queryState, queryMenuState, cityCode], + enabled: enabled, } ); diff --git a/apps/cMiniApp/src/pages/home/index.vue b/apps/cMiniApp/src/pages/home/index.vue index 3fb5639..e08f524 100644 --- a/apps/cMiniApp/src/pages/home/index.vue +++ b/apps/cMiniApp/src/pages/home/index.vue @@ -57,7 +57,7 @@ :key="queryState.orderType" > <template #renderItem="{ item }"> - <TaskCard @click="goTaskDetail(item)" v-bind="item" /> + <TaskCard @click="goTaskDetail(item)" v-bind="item" @apply="goTaskApply(item)" /> </template> </InfiniteLoading> </PageLayoutWithBg> @@ -74,13 +74,18 @@ import { TaskCard, ProTabs, ProTabPane } from '@12333/components'; import HomeQueryMenuView from './HomeQueryMenuView.vue'; import IconLocaltion from '@/assets/task/icon-localtion.png'; +import { useAllAreaList } from '@12333/hooks'; +import { useAccessLogin } from '@/hooks'; const { locationCity } = useUser(); -const userStore = useUserStore(); +const { findAreaCodeFromName } = useAllAreaList(); const { searchValue, queryState, handleSearch, infiniteLoadingProps, queryMenuState } = useTaskList( - { cityName: locationCity } + { + cityCode: computed(() => findAreaCodeFromName(locationCity.value)), + enabled: computed(() => !!findAreaCodeFromName(locationCity.value)), + } ); onMounted(async () => { @@ -113,6 +118,10 @@ url: `${RouterPath.taskDetail}?id=${item.id}`, }); } + +const goTaskApply = useAccessLogin((item: API.GetTaskInfosQueryResultItem) => { + console.log('item: ', item); +}); </script> <style lang="scss"> diff --git a/apps/cMiniApp/src/subpackages/task/taskDetail/InnerPage.vue b/apps/cMiniApp/src/subpackages/task/taskDetail/InnerPage.vue index b599bbe..ce816ca 100644 --- a/apps/cMiniApp/src/subpackages/task/taskDetail/InnerPage.vue +++ b/apps/cMiniApp/src/subpackages/task/taskDetail/InnerPage.vue @@ -22,7 +22,7 @@ </div> --> </div> <TaskPrice - :value="detail.serviceFee ?? 0" + :value="toThousand(detail.serviceFee ?? 0)" :unit="BillingMethodEnumUnit[detail.billingMethod]" /> </div> @@ -101,7 +101,12 @@ openType="share" ></PageFooterAction> <PageFooterAction :icon="IconPhone" text="鎵嬫満" :isFlex="false"></PageFooterAction> - <PageFooterBtn type="primary">鎶ュ悕锛�5浜哄凡鎶ュ悕锛�</PageFooterBtn> + <PageFooterBtn v-if="detail.releaseStatus === EnumTaskReleaseStatus.InProcess" type="primary" + >鎶ュ悕锛�5浜哄凡鎶ュ悕锛�</PageFooterBtn + > + <PageFooterBtn v-if="detail.releaseStatus === EnumTaskReleaseStatus.Stopped" color="#999999" + >宸插仠姝�</PageFooterBtn + > </PageFooter> </LoadingLayout> </template> @@ -122,8 +127,12 @@ import './taskDetail.scss'; import CompanyDesc from '../components/CompanyDesc.vue'; import dayjs from 'dayjs'; -import { TaskUtils } from '@12333/utils'; -import { EnumSettlementCycleText, BillingMethodEnumUnit } from '@12333/constants'; +import { TaskUtils, toThousand } from '@12333/utils'; +import { + EnumSettlementCycleText, + BillingMethodEnumUnit, + EnumTaskReleaseStatus, +} from '@12333/constants'; import { useAccessLogin } from '@/hooks'; defineOptions({ @@ -131,7 +140,7 @@ }); /** - * TODO 缂哄皯宸叉姤鍚嶄汉鏁� 鎵嬫満 鎶曡瘔涓炬姤鎺ュ彛 + * TODO 缂哄皯宸叉姤鍚嶄汉鏁� 鎵嬫満 鎶曡瘔涓炬姤鎺ュ彛 鎶ュ悕鎺ュ彛 */ const router = Taro.useRouter(); diff --git a/packages/components/src/Card/TaskCard.vue b/packages/components/src/Card/TaskCard.vue index 098b45c..687f7f6 100644 --- a/packages/components/src/Card/TaskCard.vue +++ b/packages/components/src/Card/TaskCard.vue @@ -3,7 +3,10 @@ <div class="task-card-title-wrapper"> <div class="task-card-title">{{ name }}</div> <slot name="title-right"> - <TaskPrice :value="serviceFee ?? 0" :unit="BillingMethodEnumUnit[billingMethod]" /> + <TaskPrice + :value="toThousand(serviceFee ?? 0)" + :unit="BillingMethodEnumUnit[billingMethod]" + /> </slot> </div> <slot> @@ -12,7 +15,14 @@ {{ EnumSettlementCycleText[settlementCycle] }} </div> <div class="task-card-welfare-list-item">{{ TaskUtils.getGenderText(genderLimit) }}</div> - <div class="task-card-welfare-list-item">鍖呬笁椁�</div> + <div + class="task-card-welfare-list-item" + v-if="benefits?.length > 0" + v-for="item in benefits" + :key="item.benefitCode" + > + {{ item.benefitContent }} + </div> </div> <div class="task-card-time"> {{ dayjs(beginTime).format('YYYY骞碝M鏈圖D鏃�') }}鑷硔{ @@ -23,11 +33,16 @@ <div class="task-card-footer"> <div class="task-card-left"> <div class="task-card-footer-tag">H</div> - <div class="task-card-footer-address">{{ 'address' }}</div> + <div class="task-card-footer-address">{{ addressName }}</div> </div> <div class="task-card-actions" v-if="showActions"> <slot name="actions"> - <nut-button type="primary" @click.stop="handleSign">鎶ュ悕</nut-button> + <nut-button + v-if="releaseStatus === EnumTaskReleaseStatus.InProcess" + type="primary" + @click.stop="emit('apply', id)" + >鎶ュ悕</nut-button + > </slot> </div> </div> @@ -52,7 +67,7 @@ import TaskPrice from './TaskPrice.vue'; import { CommonTaskCardProps } from './card'; import dayjs from 'dayjs'; -import { TaskUtils } from '@12333/utils'; +import { TaskUtils, toThousand } from '@12333/utils'; defineOptions({ name: 'TaskCard', @@ -70,7 +85,27 @@ /** 鏈嶅姟璐� */ serviceFee?: number; settlementCycle?: EnumSettlementCycle; + /** 绂忓埄 */ + benefits?: API.GetTaskInfoQueryResultBenefit[]; genderLimit?: EnumUserGender; + /** 璧勬牸璇佷功绫诲瀷 */ + credentialLimits?: API.GetTaskInfoQueryResultCredentialLimit[]; + /** 浠诲姟鍦扮偣鎵�灞炵渷浠界紪鍙� */ + provinceCode?: string; + /** 浠诲姟鍦扮偣鎵�灞炵渷浠� */ + provinceContent?: string; + /** 浠诲姟鍦扮偣鎵�灞炲煄甯傜紪鍙� */ + cityCode?: string; + /** 浠诲姟鍦扮偣鎵�灞炲煄甯� */ + cityContent?: string; + /** 浠诲姟鍦扮偣鍚嶇О */ + addressName?: string; + /** 浠诲姟鍦扮偣璇︾粏鍦板潃 */ + addressDetail?: string; + /** 缁忓害 */ + longitude?: number; + /** 绾害 */ + latitude?: number; /** 鎶ュ悕浜烘暟 */ userCount?: number; status?: EnumTaskStatus; @@ -90,7 +125,9 @@ showActions: true, }); -function handleSign() {} +const emit = defineEmits<{ + (e: 'apply', id: string): void; +}>(); </script> <style lang="scss"> diff --git a/packages/components/src/Card/TaskPrice.vue b/packages/components/src/Card/TaskPrice.vue index 922f437..3e8d8a2 100644 --- a/packages/components/src/Card/TaskPrice.vue +++ b/packages/components/src/Card/TaskPrice.vue @@ -11,7 +11,7 @@ }); type Props = { - value?: number; + value?: number | string; unit?: string; }; diff --git a/packages/services/apiV2/typings.d.ts b/packages/services/apiV2/typings.d.ts index 5324984..dc7dd0d 100644 --- a/packages/services/apiV2/typings.d.ts +++ b/packages/services/apiV2/typings.d.ts @@ -1197,6 +1197,8 @@ createdTime?: string; /** 鏄惁宸叉敹钘� */ isCollected?: boolean; + status?: EnumTaskStatus; + releaseStatus?: EnumTaskReleaseStatus; } interface GetTaskInfoQueryResultBenefit { diff --git a/packages/utils/location.ts b/packages/utils/location.ts index 69bf88e..dec2f88 100644 --- a/packages/utils/location.ts +++ b/packages/utils/location.ts @@ -26,7 +26,7 @@ static currentProvinceName: string; - static blackList = ['姹熻タ鐪�']; + static blackList = []; static async getLocation() { if (!this.wxLocation) { @@ -87,7 +87,10 @@ static getLocationByIp() { return axios .get<LocationResponse>( - `https://apis.map.qq.com/ws/location/v1/ip?key=HH7BZ-5L2KI-TN3GW-U5HKU-MK5H3-VOBZH` + `https://apis.map.qq.com/ws/location/v1/ip?key=HH7BZ-5L2KI-TN3GW-U5HKU-MK5H3-VOBZH`, + { + timeout: 3000, + } ) .then((res) => res.data); } -- Gitblit v1.9.1