flat: 添加定位

This commit is contained in:
Apcallover
2024-06-05 14:30:33 +08:00
parent f3eef9f396
commit 21835e52c1
7 changed files with 867 additions and 773 deletions

View File

@@ -24,6 +24,7 @@
this.$store.dispatch('startRefreshTokenTimer')
this.$store.dispatch('startRefreshNewsTimer')
this.$store.dispatch('refreshAuthState')
this.$store.dispatch('getUserLocation')
}
// #ifdef H5
// 企业定制

View File

@@ -36,7 +36,7 @@
</view> -->
<view style="display: flex;align-items: center;position:absolute;right:0;">
<image src="../../static/img/location_new.png" style="width: 30rpx;height: 30rpx;" mode=""></image>
<view>--km</view>
<view>{{distance(companyitem)}}</view>
</view>
</view>
<view class="comment" v-if='comment' @tap.stop="goComment(companyitem.missionNo)">
@@ -59,7 +59,10 @@
dateFormat
} from "../../untils/format.js";
import dictionary from '@/common/textdata.js';
import {
addZeroPrefix,
getDistanceFromLatLonInKm
} from '@/untils/tools.js'
export default {
beforeCreate: function() {},
props: {
@@ -80,6 +83,9 @@
near: {
type: Boolean,
default: false
},
position: {
default: null
}
},
data() {
@@ -92,10 +98,32 @@
},
computed: {
skillNames() {
return this.companyitem.skillNames.split(',')
if (this.companyitem.skillNames) {
return this.companyitem.skillNames.split(',')
} else {
return []
}
}
},
methods: {
distance(item) {
const {
lon,
lat
} = item
if (this.position && lon) {
const {
longitude,
latitude
} = this.position
const {
m,
km
} = getDistanceFromLatLonInKm(lat, lon, latitude, longitude)
return m > 1000 ? `${km.toFixed(2)}km` : `${m.toFixed(2)}m`
}
return '--km'
},
goComment: function(no) {
uni.navigateTo({
url: `../../pageMy/mycomment/mycomment?missionNo=${encodeURIComponent(no)}`

View File

@@ -43,7 +43,7 @@
</view> -->
<view style="display: flex;align-items: center;position:absolute;right:0;">
<image src="../../static/img/location_new.png" style="width: 30rpx;height: 30rpx;" mode=""></image>
<view>--km</view>
<view>{{distance(companyitem)}}</view>
</view>
</view>
<view class="comment" v-if='comment' @tap.stop="goComment(companyitem.missionNo)">
@@ -66,7 +66,10 @@
dateFormat
} from "../../untils/format.js";
import dictionary from '@/common/textdata.js';
import {
addZeroPrefix,
getDistanceFromLatLonInKm
} from '@/untils/tools.js'
export default {
beforeCreate: function() {},
props: {
@@ -99,10 +102,32 @@
},
computed: {
skillNames() {
return this.companyitem.skillNames.split(',')
if (this.companyitem.skillNames) {
return this.companyitem.skillNames.split(',')
} else {
return []
}
}
},
methods: {
distance(item) {
const {
lon,
lat
} = item
if (this.position && lon) {
const {
longitude,
latitude
} = this.position
const {
m,
km
} = getDistanceFromLatLonInKm(lat, lon, latitude, longitude)
return m > 1000 ? `${km.toFixed(2)}km` : `${m.toFixed(2)}m`
}
return '--km'
},
goComment: function(no) {
uni.navigateTo({
url: `../../pageMy/mycomment/mycomment?missionNo=${encodeURIComponent(no)}`

View File

@@ -1,12 +1,12 @@
<template>
<view style="background-color: #fefefe;">
<view class="titles">
添加职业技能
</view>
<view class="slo">
添加职业技能获得个性化的职位推荐
</view>
<!-- <view class="jobcontent" @click="goAddind">
<view style="background-color: #fefefe;">
<view class="titles">
添加职业技能
</view>
<view class="slo">
添加职业技能获得个性化的职位推荐
</view>
<!-- <view class="jobcontent" @click="goAddind">
<view class="jobinfo">
<view class="jobAddress">
我所属的行业
@@ -16,277 +16,277 @@
</view>
<image src="../../../static/img/right.svg" mode=""></image>
</view> -->
<view class="border"></view>
<view class="jobcontent" @click="skill">
<view class="jobinfo">
<view class="jobAddress">
零工工种
</view>
<view v-if="worktypesName" class="jobText">{{ worktypesName }}</view>
<view v-else class="jobText nochoose">请选择</view>
</view>
<image src="../../../static/img/right.svg" mode=""></image>
</view>
<view class="border"></view>
<view class="jobcontent" @click="skillLevel">
<view class="jobinfo">
<view class="jobAddress">
岗位工种
</view>
<view v-if="skillsName" class="jobText">{{ skillsName }}</view>
<view v-else class="jobText nochoose">请选择</view>
</view>
<image src="../../../static/img/right.svg" mode=""></image>
</view>
<view class="border"></view>
<view class="btn">
<view v-if="skillsName" class="bottombtn" @click="submit">确定</view>
<view v-else class="bottombtn disabledBtn">确定</view>
</view>
</view>
<view class="border"></view>
<view class="jobcontent" @click="skill">
<view class="jobinfo">
<view class="jobAddress">
第一技能
</view>
<view v-if="worktypesName" class="jobText">{{ worktypesName }}</view>
<view v-else class="jobText nochoose">请选择</view>
</view>
<image src="../../../static/img/right.svg" mode=""></image>
</view>
<view class="border"></view>
<view class="jobcontent" @click="skillLevel">
<view class="jobinfo">
<view class="jobAddress">
第二技能
</view>
<view v-if="skillsName" class="jobText">{{ skillsName }}</view>
<view v-else class="jobText nochoose">请选择</view>
</view>
<image src="../../../static/img/right.svg" mode=""></image>
</view>
<view class="border"></view>
<view class="btn">
<view v-if="skillsName" class="bottombtn" @click="submit">确定</view>
<view v-else class="bottombtn disabledBtn">确定</view>
</view>
</view>
</template>
<script>
import {
addSkills
} from '@/api/resume.js'
import {
addSkills
} from '@/api/resume.js'
export default {
data() {
return {
tradeId: '',
tradeName: '',
worktypesId: '',
worktypesName: '',
skillsId: '',
skillsName: '',
}
},
onLoad(query) {
uni.$off('setInd')
uni.$on('setInd', ({
id,
name
}) => {
this.tradeId = id
this.tradeName = name
this.worktypesId = ''
this.worktypesName = ''
this.skillsId = ''
this.skillsName = ''
})
uni.$off('setworkTypes')
uni.$on('setworkTypes', ({
detail
}) => {
console.log(detail, "id,name");
// this.worktypesId = id
this.worktypesName = detail.parentLabel + "-" + detail.label
// this.skillsId = ''
// this.skillsName = ''
})
uni.$off('setSkill')
uni.$on('setSkill', ({
detail
}) => {
console.log('detail,', detail)
// this.skillsId = id
this.skillsName = `${detail.parentLabel}-${detail.parentTwoLabel}-${detail.label}`
})
},
methods: {
goAddind: function () {
uni.navigateTo({
url: './addInd?id=' + this.tradeId
})
},
skill: function () {
// if (this.tradeId) {
uni.navigateTo({
url: `./skill?id=${this.worktypesId}&tradeId=${this.tradeId}&maxLayer=2&type=1`
})
// } else {
// uni.showToast({
// title: '请先选择从事的行业',
// icon: 'none'
// });
// }
},
skillLevel: function () {
export default {
data() {
return {
tradeId: '',
tradeName: '',
worktypesId: '',
worktypesName: '',
skillsId: '',
skillsName: '',
}
},
onLoad(query) {
uni.$off('setInd')
uni.$on('setInd', ({
id,
name
}) => {
this.tradeId = id
this.tradeName = name
this.worktypesId = ''
this.worktypesName = ''
this.skillsId = ''
this.skillsName = ''
})
uni.$off('setworkTypes')
uni.$on('setworkTypes', ({
detail
}) => {
console.log(detail, "id,name");
// this.worktypesId = id
this.worktypesName = detail.parentLabel + "-" + detail.label
// this.skillsId = ''
// this.skillsName = ''
})
uni.$off('setSkill')
uni.$on('setSkill', ({
detail
}) => {
console.log('detail,', detail)
// this.skillsId = id
this.skillsName = `${detail.parentLabel}-${detail.parentTwoLabel}-${detail.label}`
})
},
methods: {
goAddind: function() {
uni.navigateTo({
url: './addInd?id=' + this.tradeId
})
},
skill: function() {
// if (this.tradeId) {
uni.navigateTo({
url: `./skill?id=${this.worktypesId}&tradeId=${this.tradeId}&maxLayer=2&type=1`
})
// } else {
// uni.showToast({
// title: '请先选择从事的行业',
// icon: 'none'
// });
// }
},
skillLevel: function() {
uni.navigateTo({
url: `./skillLevel?id=${this.skillsId}&worktypesId=${this.worktypesId}&maxLayer=3&type=2`
})
},
submit: async function () {
// console.log(this.tradeName, this.worktypesName, this.skillsName);
let result = this.worktypesName.split('-');
let result1 = this.skillsName.split('-');
uni.navigateTo({
url: `./skillLevel?id=${this.skillsId}&worktypesId=${this.worktypesId}&maxLayer=3&type=2`
})
},
submit: async function() {
// console.log(this.tradeName, this.worktypesName, this.skillsName);
let result = this.worktypesName.split('-');
let result1 = this.skillsName.split('-');
// 工种
await addSkills(this.tradeName, result[0], result[1], 0)
// 岗位
await addSkills(this.tradeName, `${result1[0]}${result1[1]}`, result1[2], 1)
uni.navigateBack()
}
}
}
// 工种
await addSkills(this.tradeName, result[0], result[1], 0)
// 岗位
await addSkills(this.tradeName, `${result1[0]}${result1[1]}`, result1[2], 1)
uni.navigateBack()
}
}
}
</script>
<style>
.slo {
font-family: PingFangSC-Regular;
font-size: 28rpx;
color: #999999;
.slo {
font-family: PingFangSC-Regular;
font-size: 28rpx;
color: #999999;
padding: 0 30rpx;
padding-top: 10rpx;
}
padding: 0 30rpx;
padding-top: 10rpx;
}
.titles {
font-family: PingFangSC-Medium;
font-size: 36rpx;
color: #333333;
padding: 0 30rpx;
padding-top: 30rpx;
}
.titles {
font-family: PingFangSC-Medium;
font-size: 36rpx;
color: #333333;
padding: 0 30rpx;
padding-top: 30rpx;
}
.border {
margin-left: 30rpx;
width: 720rpx;
border-bottom: 2rpx solid #ddd;
opacity: 0.6;
}
.border {
margin-left: 30rpx;
width: 720rpx;
border-bottom: 2rpx solid #ddd;
opacity: 0.6;
}
.jobText {
font-family: PingFangSC-Regular;
font-size: 32rpx;
color: #666666;
}
.jobText {
font-family: PingFangSC-Regular;
font-size: 32rpx;
color: #666666;
}
.nochoose {
color: #ccc;
}
.nochoose {
color: #ccc;
}
.jobAddress {
font-family: PingFangSC-Regular;
font-size: 32rpx;
color: #999999;
}
.jobAddress {
font-family: PingFangSC-Regular;
font-size: 32rpx;
color: #999999;
}
.jobcontent {
padding: 30rpx;
.jobcontent {
padding: 30rpx;
background: #fefefe;
display: flex;
/* align-items: center; */
align-items: flex-end;
justify-content: space-between;
line-height: 63rpx;
}
background: #fefefe;
display: flex;
/* align-items: center; */
align-items: flex-end;
justify-content: space-between;
line-height: 63rpx;
}
.jobcontent image {
width: 40rpx;
height: 40rpx;
margin-bottom: 5px;
.jobcontent image {
width: 40rpx;
height: 40rpx;
margin-bottom: 5px;
}
}
.listBody {}
.listBody {}
.list_text {
font-family: PingFangSC-Regular;
font-size: 32rpx;
color: #666666;
}
.list_text {
font-family: PingFangSC-Regular;
font-size: 32rpx;
color: #666666;
}
.list image {
width: 40rpx;
height: 40rpx;
margin-left: auto;
}
.list image {
width: 40rpx;
height: 40rpx;
margin-left: auto;
}
.list {
padding: 0 30rpx;
height: 126rpx;
background: #fefefe;
display: flex;
align-items: center;
justify-content: space-between;
}
.list {
padding: 0 30rpx;
height: 126rpx;
background: #fefefe;
display: flex;
align-items: center;
justify-content: space-between;
}
.title image {
width: 40rpx;
height: 40rpx;
}
.title image {
width: 40rpx;
height: 40rpx;
}
.title {
font-family: PingFangSC-Regular;
font-size: 28rpx;
color: #999999;
display: flex;
padding: 10rpx 30rpx;
background-color: #fefefe;
align-items: center;
justify-content: space-between;
}
.title {
font-family: PingFangSC-Regular;
font-size: 28rpx;
color: #999999;
display: flex;
padding: 10rpx 30rpx;
background-color: #fefefe;
align-items: center;
justify-content: space-between;
}
.userInfo {
font-family: PingFangSC-Regular;
font-size: 24rpx;
color: #999999;
}
.userInfo {
font-family: PingFangSC-Regular;
font-size: 24rpx;
color: #999999;
}
.name {
margin-left: 20rpx;
font-family: PingFangSC-Medium;
font-size: 36rpx;
color: #333333;
line-height: 50rpx;
}
.name {
margin-left: 20rpx;
font-family: PingFangSC-Medium;
font-size: 36rpx;
color: #333333;
line-height: 50rpx;
}
.head image:last-child {
width: 40rpx;
height: 40rpx;
margin-left: auto;
}
.head image:last-child {
width: 40rpx;
height: 40rpx;
margin-left: auto;
}
.head image {
width: 100rpx;
height: 100rpx;
}
.head image {
width: 100rpx;
height: 100rpx;
}
.head {
padding: 30rpx;
width: 690rpx;
background-color: #fefefe;
display: flex;
align-items: center;
justify-content: flex-start;
}
.head {
padding: 30rpx;
width: 690rpx;
background-color: #fefefe;
display: flex;
align-items: center;
justify-content: flex-start;
}
.bottombtn {
background-color: #1b66ff;
color: #fff;
text-align: center;
border-radius: 10rpx;
font-family: PingFangSC-Medium;
font-size: 32rpx;
height: 90rpx;
line-height: 90rpx;
}
.bottombtn {
background-color: #1b66ff;
color: #fff;
text-align: center;
border-radius: 10rpx;
font-family: PingFangSC-Medium;
font-size: 32rpx;
height: 90rpx;
line-height: 90rpx;
}
.btn {
background-color: #fefefe;
width: 690rpx;
padding: 30rpx;
padding-bottom: 80rpx;
position: fixed;
bottom: 0;
left: 0;
}
.btn {
background-color: #fefefe;
width: 690rpx;
padding: 30rpx;
padding-bottom: 80rpx;
position: fixed;
bottom: 0;
left: 0;
}
.disabledBtn {
background-color: #c8c9cc;
}
.disabledBtn {
background-color: #c8c9cc;
}
</style>

View File

@@ -35,7 +35,7 @@
<block v-if="activeTab == 0">
<view v-if="newList.length > 0" style="padding-bottom: 20rpx;">
<block v-for="(item, index) in newList" :key="index">
<companyList :companyitem="item"></companyList>
<companyList :companyitem="item" :position="userLocation"></companyList>
</block>
</view>
<view v-else>
@@ -125,7 +125,9 @@
getcoder
} from "@/api/map.js";
import verticalMenu from '@/components/vertical-menu/vertical-menu.vue';
import {
mapGetters
} from 'vuex'
export default {
components: {
vTabs,
@@ -134,7 +136,9 @@
workList,
userrecruitList
},
computed: {
...mapGetters(['userLocation']),
},
data() {
return {
policyContentList: [],
@@ -180,6 +184,7 @@
},
onLoad: function() {
this.getData()
console.log('userLocation', this.userLocation)
// this.getPolicy()
},
onShow: function() {
@@ -398,7 +403,8 @@
return
}
if (this.activeTab === 2) {
if (this.policyPage.current <= Math.ceil(this.policyPage.total / this.policyPage.size)) {
if (this.policyPage.current <= Math.ceil(this.policyPage.total / this.policyPage
.size)) {
if (this.isSearch) {
this.getPolicySearch()
} else {
@@ -527,7 +533,8 @@
this.policyPage.current += 1;
this.policyPage.total = res.data.data.total;
if (res.data.data && res.data.data.records.length) {
this.policyContentList = this.policyContentList.concat(res.data.data.records);
this.policyContentList = this.policyContentList.concat(res.data.data
.records);
}
})

View File

@@ -1,18 +1,20 @@
const getters = {
language: state => state.common.language,
website: state => state.common.website,
userInfo: state => state.user.userInfo,
userChecked:state=>state.user.userChecked,
area: state => state.area,
news: state=> state.news,
auth: state => state.auth,
authPass: (state,getters) => getters.auth.laborState && getters.auth.realNameState && getters.auth.bankCardState && getters.auth.insureState,
authInfo: state => state.auth.authInfo,
face: state => state.face,
realName: state => state.authentication.realName,
bankCard: state => state.authentication.bankCard,
autograph: state => state.authentication.autograph,
sendTimes:state => state.user.sendTimes,//接收短信的次数
language: state => state.common.language,
website: state => state.common.website,
userInfo: state => state.user.userInfo,
userChecked: state => state.user.userChecked,
area: state => state.area,
news: state => state.news,
auth: state => state.auth,
authPass: (state, getters) => getters.auth.laborState && getters.auth.realNameState && getters.auth
.bankCardState && getters.auth.insureState,
authInfo: state => state.auth.authInfo,
face: state => state.face,
realName: state => state.authentication.realName,
bankCard: state => state.authentication.bankCard,
autograph: state => state.authentication.autograph,
sendTimes: state => state.user.sendTimes, //接收短信的次数
userLocation: state => state.user.userLocation, //用户位置
}
export default getters

View File

@@ -64,8 +64,36 @@ const user = {
seeEnterprise: getStore({ //用户发送短信次数
name: 'enterprise'
}) || 0, // 0 个体招工 企业招工
userLocation: null
},
actions: {
getUserLocation({
commit,
dispatch
}) {
console.log('getUserLocation null1')
commit('setLocation', {
latitude: 31.133980,
longitude: 104.404419,
})
// uni.getLocation({
// type: 'gcj02',
// success: function(res) {
// const {
// longitude,
// latitude
// } = res
// commit('setLocation', {
// longitude,
// latitude
// })
// },
// fail: function(err) {
// commit('setLocation', null)
// },
// complete: function(e) {}
// })
},
//用户点击radio按钮
UserCheckedBtn({
commit
@@ -186,6 +214,9 @@ const user = {
},
},
mutations: {
setLocation(state, val) {
state.userLocation = val
},
setEnterprise(state, val) { // 0 个体招工 企业招工
state.seeEnterprise = val;
setStore({