From 3d7a6f1bb7f8a20c7ff138f6c4c5993979f00e1f Mon Sep 17 00:00:00 2001
From: wupengfei <834520024@qq.com>
Date: 星期一, 20 十月 2025 16:36:59 +0800
Subject: [PATCH] fix: bug
---
apps/cMiniApp/src/pages/home/index.vue | 114 +++++++++++++++++++++++++++-----------------------------
1 files changed, 55 insertions(+), 59 deletions(-)
diff --git a/apps/cMiniApp/src/pages/home/index.vue b/apps/cMiniApp/src/pages/home/index.vue
index 62093b5..d0097eb 100644
--- a/apps/cMiniApp/src/pages/home/index.vue
+++ b/apps/cMiniApp/src/pages/home/index.vue
@@ -8,43 +8,46 @@
<div class="home-header">
<div class="home-searchbar-wrapper">
<div class="searchbar-container">
- <BlSearchbar v-model.trim="searchValue" placeholder="鎼滅储浠诲姟"></BlSearchbar>
+ <BlSearchbar
+ v-model.trim="searchValue"
+ placeholder="鎼滅储浠诲姟"
+ @search="handleSearch"
+ @change="handleSearch"
+ ></BlSearchbar>
</div>
<div class="city-btn" @click="goCitySelect">
- <Location2 :size="16" />
+ <img :src="IconLocaltion" class="city-btn-icon" />
<div class="city-btn-text">{{ locationCity }}</div>
</div>
</div>
- <div class="home-banner-wrapper">
+ <!-- <div class="home-banner-wrapper">
<nut-swiper :auto-play="3000">
<nut-swiper-item v-for="(item, index) in list" :key="index">
<img :src="item" class="banner-img" draggable="false" />
</nut-swiper-item>
</nut-swiper>
- </div>
+ </div> -->
</div>
<ProTabs
v-model="queryState.orderType"
name="home-tab"
:showPaneContent="false"
+ :showSmile="false"
class="home-tabs"
isTransparent
- title-gutter="12"
+ title-gutter="8"
title-scroll
>
<ProTabPane :title="`鎺ㄨ崘`" :pane-key="HomeOrderType.Recommend"></ProTabPane>
<ProTabPane :title="`鏈�鏂癭" :pane-key="HomeOrderType.LastShelfTime"></ProTabPane>
<template #right>
<Menu>
- <MenuItem
- v-model="queryState.orderByProperty"
- title="绛涢��"
- ref="selectItem"
- :options="[
- { text: '鎺掑簭', value: 'userId' },
- { text: '鎸夊叧娉ㄦ椂闂�', value: 'creationTime' },
- ]"
- />
+ <MenuItem title="绛涢��" ref="selectItem">
+ <HomeQueryMenuView
+ v-model:query="queryMenuState"
+ @close="handleMenuSelectClose"
+ ></HomeQueryMenuView>
+ </MenuItem>
</Menu>
</template>
</ProTabs>
@@ -54,7 +57,7 @@
:key="queryState.orderType"
>
<template #renderItem="{ item }">
- <TaskCard />
+ <TaskCard @click="goTaskDetail(item)" v-bind="item" />
</template>
</InfiniteLoading>
</PageLayoutWithBg>
@@ -62,37 +65,32 @@
<script setup lang="ts">
import { useUser } from '@/hooks';
-import { useUserStore } from '@/stores/modules/user';
-import { RectDown, Location2 } from '@nutui/icons-vue-taro';
import Taro from '@tarojs/taro';
-import { LocationUtils, trim } from '@12333/utils';
+import { setLocationCity } from '@/utils';
import _ from 'lodash';
import IconLogo from '@/assets/home/icon-logo.png';
-import { useInfiniteLoading } from '@12333/hooks';
-import { OrderInputType } from '@12333/constants';
-import * as orderServices from '@12333/services/api/Order';
import { TaskCard, ProTabs, ProTabPane } from '@12333/components';
-import { HomeOrderType } from './constants';
+import HomeQueryMenuView from './HomeQueryMenuView.vue';
+import IconLocaltion from '@/assets/task/icon-localtion.png';
+import { useAllAreaList, useTaskList, HomeOrderType } from '@12333/hooks';
+import { useAccessLogin } from '@/hooks';
const { locationCity } = useUser();
-Taro.usePageScroll(() => {
- console.log('11', 11);
+const { findAreaCodeFromName } = useAllAreaList();
+
+const { searchValue, queryState, handleSearch, infiniteLoadingProps, queryMenuState } = useTaskList(
+ {
+ cityCode: computed(() => findAreaCodeFromName(locationCity.value)),
+ enabled: computed(() => !!findAreaCodeFromName(locationCity.value)),
+ }
+);
+
+onMounted(async () => {
+ try {
+ await setLocationCity();
+ } catch (error) {}
});
-
-const searchValue = ref('');
-
-const queryState = reactive({
- searchValueTrim: '',
- orderType: HomeOrderType.Recommend,
- orderByProperty: 'userId',
-});
-
-const handleSearch = _.debounce(function () {
- queryState.searchValueTrim = trim(searchValue.value);
-}, 300);
-
-const userStore = useUserStore();
function goCitySelect() {
Taro.navigateTo({
@@ -107,28 +105,21 @@
'https://storage.360buyimg.com/jdc-article/fristfabu.jpg',
]);
-const { infiniteLoadingProps } = useInfiniteLoading(
- ({ pageParam }) => {
- let params: API.FrontOrderListInput = {
- pageModel: {
- rows: 20,
- page: pageParam,
- orderInput: [
- queryState.orderType === HomeOrderType.Recommend
- ? { property: 'isRecommend', order: OrderInputType.Desc }
- : { property: 'lastShelfTime', order: OrderInputType.Desc },
- ],
- },
- };
+const selectItem = ref();
- return orderServices.getFrontOrderList(params, {
- showLoading: false,
- });
- },
- {
- queryKey: ['orderServices/getFrontOrderList', queryState],
- }
-);
+function handleMenuSelectClose() {
+ selectItem.value?.toggle?.();
+}
+
+function goTaskDetail(item: API.GetTaskInfosQueryResultItem) {
+ Taro.navigateTo({
+ url: `${RouterPath.taskDetail}?id=${item.id}&from=apply`,
+ });
+}
+
+const goTaskApply = useAccessLogin((item: API.GetTaskInfosQueryResultItem) => {
+ console.log('item: ', item);
+});
</script>
<style lang="scss">
@@ -159,6 +150,11 @@
padding-left: 36px;
color: boleGetCssVar('text-color', 'primary');
+ .city-btn-icon {
+ width: 40px;
+ height: 40px;
+ }
+
.city-btn-text {
max-width: 200px;
@include ellipsis;
--
Gitblit v1.9.1