优化发布职位选择定位按钮

This commit is contained in:
冯辉
2025-11-14 12:08:45 +08:00
parent 70aa72930d
commit 9cda4eacb3
4 changed files with 110 additions and 5 deletions

21
.gitignore vendored
View File

@@ -3,3 +3,24 @@
/docs/
/.qoder/
/.idea/
.DS_Store
/dist/
/build/
.vscode/
*.log
*.tmp
*.swp
.env
.env.*
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
/coverage/
/.nyc_output/
/.turbo/
/cache/
/output/
/hs_err_pid*
*.local
yarn.lock

View File

@@ -0,0 +1,52 @@
<!-- #ifdef H5 -->
<template>
<view></view>
</template>
<script>
// #ifdef H5
export default {
name: 'Keypress',
props: {
disable: {
type: Boolean,
default: false
}
},
mounted () {
const keyNames = {
esc: ['Esc', 'Escape'],
tab: 'Tab',
enter: 'Enter',
space: [' ', 'Spacebar'],
up: ['Up', 'ArrowUp'],
left: ['Left', 'ArrowLeft'],
right: ['Right', 'ArrowRight'],
down: ['Down', 'ArrowDown'],
delete: ['Backspace', 'Delete', 'Del']
}
const listener = ($event) => {
if (this.disable) {
return
}
const keyName = Object.keys(keyNames).find(key => {
const keyName = $event.key
const value = keyNames[key]
return value === keyName || (Array.isArray(value) && value.includes(keyName))
})
if (keyName) {
// 避免和其他按键事件冲突
setTimeout(() => {
this.$emit(keyName, {})
}, 0)
}
}
document.addEventListener('keyup', listener)
// this.$once('hook:beforeDestroy', () => {
// document.removeEventListener('keyup', listener)
// })
}
}
// #endif
</script>
<!-- #endif -->

View File

@@ -117,8 +117,8 @@
placeholder="请输入具体工作地址"
v-model="formData.jobLocation"
/>
<view class="location-btn" @click="chooseLocation">
<text class="location-btn-text">选择位置</text>
<view class="location-icon-btn" @click="chooseLocation">
<uni-icons type="location" size="20" color="#256BFA"></uni-icons>
</view>
</view>
</view>
@@ -226,6 +226,7 @@ import { storeToRefs } from 'pinia';
import { createRequest } from '@/utils/request';
import useDictStore from '@/stores/useDictStore';
import useUserStore from '@/stores/useUserStore';
import UniIcons from '@/uni_modules/uni-icons/components/uni-icons/uni-icons.vue';
const userStore = useUserStore();
const cachedUserInfo = uni.getStorageSync('userInfo') || {};
// 表单数据
@@ -790,6 +791,37 @@ const validateForm = () => {
border-top: 8rpx solid #999;
}
}
// 工作地点输入容器样式
.location-input-container {
display: flex;
align-items: center;
position: relative;
.location-input {
flex: 1;
padding-right: 80rpx;
}
.location-icon-btn {
position: absolute;
right: -3px;
top: 20%;
transform: translateY(-50%);
width: 80rpx;
height: 80rpx;
display: flex;
align-items: center;
justify-content: center;
background: transparent;
border: none;
border-radius: 8rpx;
z-index: 99;
&:active {
background: #f0f0f0;
}
}
}
}
// 企业选择器样式

View File

@@ -30,12 +30,12 @@ const useLocationStore = defineStore("location", () => {
if (config.UsingSimulatedPositioning) { // 使用模拟定位
longitudeVal.value = resd.longitude
latitudeVal.value = resd.latitude
msg('用户位置获取成功')
// msg('用户位置获取成功')
resole(resd)
} else {
longitudeVal.value = res.longitude
latitudeVal.value = res.latitude
msg('用户位置获取成功')
// msg('用户位置获取成功')
resole(res)
}
},