From 24dc7ec489cc2206c69ad26b4c931905ad81bd8a Mon Sep 17 00:00:00 2001
From: zhengyiming <540361168@qq.com>
Date: 星期一, 17 二月 2025 14:31:52 +0800
Subject: [PATCH] fix: b端
---
apps/cMiniApp/config/staging.js | 4
apps/cMiniApp/src/pages/home/index.vue | 13 +++-
apps/cMiniApp/src/utils/common/localtion.ts | 12 ++++
apps/cMiniApp/src/hooks/task.ts | 11 +++
apps/cMiniApp/src/utils/index.ts | 1
apps/cMiniApp/src/stores/modules/user.ts | 13 +--
apps/cMiniApp/src/subpackages/city/citySelect/citySelect.vue | 49 +++++++++++++++-
apps/cMiniApp/src/utils/common/index.ts | 1
apps/bMiniApp/src/hooks/user.ts | 14 ----
apps/bMiniApp/src/stores/modules/user.ts | 16 ++--
apps/bMiniApp/src/utils/common/index.ts | 1
apps/cMiniApp/src/hooks/user.ts | 14 ----
apps/bMiniApp/src/utils/common/localtion.ts | 12 ++++
apps/bMiniApp/src/utils/index.ts | 1
apps/bMiniApp/src/assets/home/icon-logo.png | 0
apps/bMiniApp/src/pages/home/index.vue | 11 +++
16 files changed, 119 insertions(+), 54 deletions(-)
diff --git a/apps/bMiniApp/src/assets/home/icon-logo.png b/apps/bMiniApp/src/assets/home/icon-logo.png
index ec03de3..7d4d5f2 100644
--- a/apps/bMiniApp/src/assets/home/icon-logo.png
+++ b/apps/bMiniApp/src/assets/home/icon-logo.png
Binary files differ
diff --git a/apps/bMiniApp/src/hooks/user.ts b/apps/bMiniApp/src/hooks/user.ts
index f104353..1f9b943 100644
--- a/apps/bMiniApp/src/hooks/user.ts
+++ b/apps/bMiniApp/src/hooks/user.ts
@@ -67,20 +67,8 @@
const router = Taro.useRouter();
Taro.useReady(async () => {
- let res;
- try {
- res = await LocationUtils.getLocation();
- } catch (error) {}
if (isLogin.value && userStore.firstGetUserDetail) {
- userStore.firstGetUserDetail = false;
- if (LocationUtils.isProvinceChange(userStore.locationProvince)) {
- userStore.resetState();
- } else {
- userStore.getCurrentUserInfo();
- }
- }
- if (res?.result?.ad_info?.city && userStore.firstSetLocation) {
- userStore.setLocationCity(res.result.ad_info.city, res.result.ad_info.province);
+ userStore.getCurrentUserInfo();
}
if (needAuth && !isLogin.value) {
Taro.navigateTo({
diff --git a/apps/bMiniApp/src/pages/home/index.vue b/apps/bMiniApp/src/pages/home/index.vue
index 4c9777e..0d5207e 100644
--- a/apps/bMiniApp/src/pages/home/index.vue
+++ b/apps/bMiniApp/src/pages/home/index.vue
@@ -8,12 +8,12 @@
<div class="home-header">
<div class="home-searchbar-wrapper">
<div class="city-btn-wrapper">
- <div class="city-btn" @click="goCitySelect">
+ <div class="city-btn">
<img :src="IconLocaltion" class="city-btn-icon" />
<div class="city-btn-text">{{ locationCity }}</div>
</div>
</div>
- <div class="reset-localtion">閲嶆柊瀹氫綅</div>
+ <div class="reset-localtion" @click="resetLocation">閲嶆柊瀹氫綅</div>
</div>
<div class="home-banner-wrapper">
<nut-swiper :auto-play="3000">
@@ -80,6 +80,7 @@
import HomeQueryMenuView from './HomeQueryMenuView.vue';
import HomeQueryPositionMenuView from './HomeQueryPositionMenuView.vue';
import IconLocaltion from '@/assets/home/icon-localtion.png';
+import { setLocationCity } from '@/utils';
const { locationCity } = useUser();
@@ -150,6 +151,12 @@
url: `${RouterPath.flexJobDetail}?id=${item.id}`,
});
}
+
+async function resetLocation() {
+ try {
+ await setLocationCity();
+ } catch (error) {}
+}
</script>
<style lang="scss">
diff --git a/apps/bMiniApp/src/stores/modules/user.ts b/apps/bMiniApp/src/stores/modules/user.ts
index 7e52ace..9425112 100644
--- a/apps/bMiniApp/src/stores/modules/user.ts
+++ b/apps/bMiniApp/src/stores/modules/user.ts
@@ -293,14 +293,14 @@
this.locationProvince = provinceName;
this.firstSetLocation = false;
setStorageLocationCity({ city: cityName, province: provinceName });
- if (LocationUtils.isProvinceChange(provinceName)) {
- this.resetState();
- myClient.removeQueries();
- globalEventEmitter.trigger('logout/refresh');
- // myClient.invalidateQueries({
- // queryKey: ['logout/refresh'],
- // });
- }
+ // if (LocationUtils.isProvinceChange(provinceName)) {
+ // this.resetState();
+ // myClient.removeQueries();
+ // globalEventEmitter.trigger('logout/refresh');
+ // // myClient.invalidateQueries({
+ // // queryKey: ['logout/refresh'],
+ // // });
+ // }
LocationUtils.currentProvinceName = provinceName;
},
},
diff --git a/apps/bMiniApp/src/utils/common/index.ts b/apps/bMiniApp/src/utils/common/index.ts
new file mode 100644
index 0000000..8c712ab
--- /dev/null
+++ b/apps/bMiniApp/src/utils/common/index.ts
@@ -0,0 +1 @@
+export * from './localtion';
diff --git a/apps/bMiniApp/src/utils/common/localtion.ts b/apps/bMiniApp/src/utils/common/localtion.ts
new file mode 100644
index 0000000..55cdb3c
--- /dev/null
+++ b/apps/bMiniApp/src/utils/common/localtion.ts
@@ -0,0 +1,12 @@
+import { LocationUtils } from '@12333/utils';
+import { useUserStoreWithOut } from '@/stores/modules/user';
+
+export async function setLocationCity() {
+ try {
+ let res = await LocationUtils.getLocation();
+ if (res?.result?.ad_info?.city) {
+ const userStore = useUserStoreWithOut();
+ userStore.setLocationCity(res.result.ad_info.city, res.result.ad_info.province);
+ }
+ } catch (error) {}
+}
diff --git a/apps/bMiniApp/src/utils/index.ts b/apps/bMiniApp/src/utils/index.ts
index ccae4b4..b030767 100644
--- a/apps/bMiniApp/src/utils/index.ts
+++ b/apps/bMiniApp/src/utils/index.ts
@@ -1,2 +1,3 @@
export * from './storage';
export * from './page';
+export * from './common';
diff --git a/apps/cMiniApp/config/staging.js b/apps/cMiniApp/config/staging.js
index 0dfad2c..3da68a7 100644
--- a/apps/cMiniApp/config/staging.js
+++ b/apps/cMiniApp/config/staging.js
@@ -1,7 +1,7 @@
module.exports = {
env: {
- BASE_URL: '"https://testrlywx.boleyuma.com"',
- // BASE_URL: '"https://api.81812333.com"',
+ // BASE_URL: '"https://testrlywx.boleyuma.com"',
+ BASE_URL: '"https://api.81812333.com"',
BASE_URL_JX: '"https://api.jx818.com"',
OSS_URL: '"https://waterdroptest2.oss-cn-hangzhou.aliyuncs.com/"',
diff --git a/apps/cMiniApp/src/hooks/task.ts b/apps/cMiniApp/src/hooks/task.ts
index 36970be..0082d1d 100644
--- a/apps/cMiniApp/src/hooks/task.ts
+++ b/apps/cMiniApp/src/hooks/task.ts
@@ -3,13 +3,20 @@
import * as orderServices from '@12333/services/api/Order';
import _ from 'lodash';
import { trim } from '@12333/utils';
+import { MaybeRef } from 'vue';
export enum HomeOrderType {
Recommend = 'Recommend',
LastShelfTime = 'LastShelfTime',
}
-export function useTaskList() {
+type UseTaskListOptions = {
+ cityName?: MaybeRef<string>;
+};
+
+export function useTaskList(options: UseTaskListOptions = {}) {
+ const { cityName = '' } = options;
+
const searchValue = ref('');
const queryMenuState = reactive({
@@ -45,7 +52,7 @@
});
},
{
- queryKey: ['orderServices/getFrontOrderList', queryState, queryMenuState],
+ queryKey: ['orderServices/getFrontOrderList', queryState, queryMenuState, cityName],
}
);
diff --git a/apps/cMiniApp/src/hooks/user.ts b/apps/cMiniApp/src/hooks/user.ts
index f104353..1f9b943 100644
--- a/apps/cMiniApp/src/hooks/user.ts
+++ b/apps/cMiniApp/src/hooks/user.ts
@@ -67,20 +67,8 @@
const router = Taro.useRouter();
Taro.useReady(async () => {
- let res;
- try {
- res = await LocationUtils.getLocation();
- } catch (error) {}
if (isLogin.value && userStore.firstGetUserDetail) {
- userStore.firstGetUserDetail = false;
- if (LocationUtils.isProvinceChange(userStore.locationProvince)) {
- userStore.resetState();
- } else {
- userStore.getCurrentUserInfo();
- }
- }
- if (res?.result?.ad_info?.city && userStore.firstSetLocation) {
- userStore.setLocationCity(res.result.ad_info.city, res.result.ad_info.province);
+ userStore.getCurrentUserInfo();
}
if (needAuth && !isLogin.value) {
Taro.navigateTo({
diff --git a/apps/cMiniApp/src/pages/home/index.vue b/apps/cMiniApp/src/pages/home/index.vue
index 8ec5e32..6f60143 100644
--- a/apps/cMiniApp/src/pages/home/index.vue
+++ b/apps/cMiniApp/src/pages/home/index.vue
@@ -68,7 +68,7 @@
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 { TaskCard, ProTabs, ProTabPane } from '@12333/components';
@@ -79,8 +79,15 @@
const userStore = useUserStore();
-const { searchValue, queryState, handleSearch, infiniteLoadingProps, queryMenuState } =
- useTaskList();
+const { searchValue, queryState, handleSearch, infiniteLoadingProps, queryMenuState } = useTaskList(
+ { cityName: locationCity }
+);
+
+onMounted(async () => {
+ try {
+ await setLocationCity();
+ } catch (error) {}
+});
function goCitySelect() {
Taro.navigateTo({
diff --git a/apps/cMiniApp/src/stores/modules/user.ts b/apps/cMiniApp/src/stores/modules/user.ts
index 7e52ace..31de28b 100644
--- a/apps/cMiniApp/src/stores/modules/user.ts
+++ b/apps/cMiniApp/src/stores/modules/user.ts
@@ -293,14 +293,11 @@
this.locationProvince = provinceName;
this.firstSetLocation = false;
setStorageLocationCity({ city: cityName, province: provinceName });
- if (LocationUtils.isProvinceChange(provinceName)) {
- this.resetState();
- myClient.removeQueries();
- globalEventEmitter.trigger('logout/refresh');
- // myClient.invalidateQueries({
- // queryKey: ['logout/refresh'],
- // });
- }
+ // if (LocationUtils.isProvinceChange(provinceName)) {
+ // this.resetState();
+ // myClient.removeQueries();
+ // globalEventEmitter.trigger('logout/refresh');
+ // }
LocationUtils.currentProvinceName = provinceName;
},
},
diff --git a/apps/cMiniApp/src/subpackages/city/citySelect/citySelect.vue b/apps/cMiniApp/src/subpackages/city/citySelect/citySelect.vue
index 2d20cbc..f5bd9aa 100644
--- a/apps/cMiniApp/src/subpackages/city/citySelect/citySelect.vue
+++ b/apps/cMiniApp/src/subpackages/city/citySelect/citySelect.vue
@@ -6,10 +6,10 @@
<div class="city-btn-wrapper">
<div class="city-btn">
<img :src="IconLocaltion" class="city-btn-icon" />
- <div class="city-btn-text">{{ locationCity }}</div>
+ <div class="city-btn-text">褰撳墠瀹氫綅锛歿{ locationCity }}</div>
</div>
</div>
- <div class="reset-localtion">閲嶆柊瀹氫綅</div>
+ <div class="reset-localtion" @click="resetLocation">閲嶆柊瀹氫綅</div>
</div>
<Elevator :index-list="elevatorData" :height="'100%'" @click-item="clickItem" />
</ContentView>
@@ -24,7 +24,8 @@
import { groupBy, sortBy } from 'lodash';
import { useUserStore } from '@/stores/modules/user';
import { Elevator } from '@12333/components';
-import IconLocaltion from '@/assets/home/icon-localtion.png';
+import IconLocaltion from '@/assets/task/icon-localtion.png';
+import { setLocationCity } from '@/utils';
defineOptions({
name: 'citySelect',
@@ -66,12 +67,54 @@
console.log('item: ', item, getAreaByAreaCode(item.parentId).areaName);
userStore.setLocationCity(item.name, getAreaByAreaCode(item.parentId).areaName);
};
+
+async function resetLocation() {
+ try {
+ await setLocationCity();
+ } catch (error) {}
+}
</script>
<style lang="scss">
@import '@/styles/common.scss';
.citySelect-page-wrapper {
+ .home-searchbar-wrapper {
+ padding: 32px 0 28px;
+ display: flex;
+ align-items: center;
+
+ .city-btn-wrapper {
+ flex: 1;
+ min-width: 0;
+
+ .city-btn {
+ display: flex;
+ align-items: center;
+ padding-right: 36px;
+ color: boleGetCssVar('text-color', 'primary');
+
+ .city-btn-icon {
+ width: 40px;
+ height: 40px;
+ }
+
+ .city-btn-text {
+ @include ellipsis;
+ margin-left: 12px;
+ font-size: 30px;
+ }
+ }
+ }
+
+ .reset-localtion {
+ font-weight: 400;
+ font-size: 24px;
+ color: boleGetCssVar('color', 'primary');
+ line-height: 28px;
+ }
+ }
+
.current-city {
padding: 20px 0;
color: boleGetCssVar('text-color', 'primary');
diff --git a/apps/cMiniApp/src/utils/common/index.ts b/apps/cMiniApp/src/utils/common/index.ts
new file mode 100644
index 0000000..8c712ab
--- /dev/null
+++ b/apps/cMiniApp/src/utils/common/index.ts
@@ -0,0 +1 @@
+export * from './localtion';
diff --git a/apps/cMiniApp/src/utils/common/localtion.ts b/apps/cMiniApp/src/utils/common/localtion.ts
new file mode 100644
index 0000000..55cdb3c
--- /dev/null
+++ b/apps/cMiniApp/src/utils/common/localtion.ts
@@ -0,0 +1,12 @@
+import { LocationUtils } from '@12333/utils';
+import { useUserStoreWithOut } from '@/stores/modules/user';
+
+export async function setLocationCity() {
+ try {
+ let res = await LocationUtils.getLocation();
+ if (res?.result?.ad_info?.city) {
+ const userStore = useUserStoreWithOut();
+ userStore.setLocationCity(res.result.ad_info.city, res.result.ad_info.province);
+ }
+ } catch (error) {}
+}
diff --git a/apps/cMiniApp/src/utils/index.ts b/apps/cMiniApp/src/utils/index.ts
index ccae4b4..b030767 100644
--- a/apps/cMiniApp/src/utils/index.ts
+++ b/apps/cMiniApp/src/utils/index.ts
@@ -1,2 +1,3 @@
export * from './storage';
export * from './page';
+export * from './common';
--
Gitblit v1.9.1