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('startRefreshTokenTimer')
this.$store.dispatch('startRefreshNewsTimer') this.$store.dispatch('startRefreshNewsTimer')
this.$store.dispatch('refreshAuthState') this.$store.dispatch('refreshAuthState')
this.$store.dispatch('getUserLocation')
} }
// #ifdef H5 // #ifdef H5
// 企业定制 // 企业定制

View File

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

View File

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

View File

@@ -20,7 +20,7 @@
<view class="jobcontent" @click="skill"> <view class="jobcontent" @click="skill">
<view class="jobinfo"> <view class="jobinfo">
<view class="jobAddress"> <view class="jobAddress">
零工工种 第一技能
</view> </view>
<view v-if="worktypesName" class="jobText">{{ worktypesName }}</view> <view v-if="worktypesName" class="jobText">{{ worktypesName }}</view>
<view v-else class="jobText nochoose">请选择</view> <view v-else class="jobText nochoose">请选择</view>
@@ -31,7 +31,7 @@
<view class="jobcontent" @click="skillLevel"> <view class="jobcontent" @click="skillLevel">
<view class="jobinfo"> <view class="jobinfo">
<view class="jobAddress"> <view class="jobAddress">
岗位工种 第二技能
</view> </view>
<view v-if="skillsName" class="jobText">{{ skillsName }}</view> <view v-if="skillsName" class="jobText">{{ skillsName }}</view>
<view v-else class="jobText nochoose">请选择</view> <view v-else class="jobText nochoose">请选择</view>

View File

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

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

View File

@@ -64,8 +64,36 @@ const user = {
seeEnterprise: getStore({ //用户发送短信次数 seeEnterprise: getStore({ //用户发送短信次数
name: 'enterprise' name: 'enterprise'
}) || 0, // 0 个体招工 企业招工 }) || 0, // 0 个体招工 企业招工
userLocation: null
}, },
actions: { 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按钮 //用户点击radio按钮
UserCheckedBtn({ UserCheckedBtn({
commit commit
@@ -186,6 +214,9 @@ const user = {
}, },
}, },
mutations: { mutations: {
setLocation(state, val) {
state.userLocation = val
},
setEnterprise(state, val) { // 0 个体招工 企业招工 setEnterprise(state, val) { // 0 个体招工 企业招工
state.seeEnterprise = val; state.seeEnterprise = val;
setStore({ setStore({