diff --git a/common/config.js b/common/config.js
index 32d0c66..78de38b 100644
--- a/common/config.js
+++ b/common/config.js
@@ -1,7 +1,7 @@
module.exports = {
// baseUrl: 'http://3fl8266127.qicp.vip'
- // baseUrl:"https://employadmin.hhlm1688.com"
- baseUrl:"http://augcl.natapp1.cc", //测试环境
+ baseUrl:"https://employadmin.hhlm1688.com"
+ // baseUrl:"http://augcl.natapp1.cc", //测试环境
// https://employadmin.hhlm1688.com/employ-api
}
diff --git a/pages/home/component/enterprise.vue b/pages/home/component/enterprise.vue
index 2a6efda..82c825f 100644
--- a/pages/home/component/enterprise.vue
+++ b/pages/home/component/enterprise.vue
@@ -46,7 +46,7 @@
{{items.sex_dictText}}-汉族
-
+
{{items.categoryTwo_dictText}}
@@ -59,7 +59,10 @@
09月23日 16:20
-->
- {{items.brief}}
+
+ {{items.brief}}
+
+
联系他
diff --git a/pages/home/component/master.vue b/pages/home/component/master.vue
index a31966a..dd365fa 100644
--- a/pages/home/component/master.vue
+++ b/pages/home/component/master.vue
@@ -49,14 +49,14 @@
-
-
-
- 100km
- {{items.address}}
+
+
+ {{items.latitude,items.longitude | getDistance}}km
+
+ {{items.address}}
- {{items.createTime}}
+ {{items.createTime | formatTime}}
立即接单
@@ -102,6 +102,66 @@
defaultIndex:[0,0]
}
},
+
+ filters:{
+ formatTime(time) {
+ const timestamp = new Date(time).getTime();
+ const currentTime = new Date().getTime();
+ console.info("currentTime",currentTime)
+ const diff = (currentTime - timestamp) / 1000; // 时间差,单位:秒
+
+ // 计算月差,判断是否超过一个月
+ const oneMonthInSeconds = 30 * 24 * 60 * 60;
+ if (diff > oneMonthInSeconds) {
+ let date = new Date(timestamp);
+ let year = date.getFullYear();
+ let month = date.getMonth() + 1;
+ let day = date.getDate();
+
+ if (month < 10) month = "0" + month;
+ if (day < 10) day = "0" + day;
+
+ return `${year}-${month}-${day}`;
+ } else {
+ // 计算秒、分钟、小时的差值
+ if (diff < 60) {
+ return `${Math.floor(diff)}秒钟前`;
+ } else if (diff < 60 * 60) {
+ return `${Math.floor(diff / 60)}分钟前`;
+ } else if (diff < 60 * 60 * 24) {
+ return `${Math.floor(diff / 60 / 60)}小时前`;
+ } else {
+ // 显示天数
+ return `${Math.floor(diff / 60 / 60 / 24)}天前`;
+ }
+ }
+ },
+ formDate(date){
+ return dayjs(date).format("YYYY-MM-DD").fromNow();
+ },
+ getDistance(lat1, lng1) {
+ let lng2 = uni.getStorageSync("longitude")
+ let lat2 = uni.getStorageSync("latitude")
+ if(!lng2 && !lat2){
+ return "请授权"
+ }
+ const R = 6371; // 地球半径,单位:km
+ const radLat1 = (lat1 * Math.PI) / 180;
+ const radLat2 = (lat2 * Math.PI) / 180;
+ const deltaLat = radLat2 - radLat1;
+ const deltaLng = ((lng2 - lng1) * Math.PI) / 180;
+
+ const a =
+ Math.sin(deltaLat / 2) * Math.sin(deltaLat / 2) +
+ Math.cos(radLat1) *
+ Math.cos(radLat2) *
+ Math.sin(deltaLng / 2) *
+ Math.sin(deltaLng / 2);
+
+ const c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a));
+ return (R * c).toFixed(2); // 返回保留两位小数的公里数
+ }
+ },
methods:{
onSelected(res){
console.info(res)
diff --git a/pages/home/index.vue b/pages/home/index.vue
index 70ad9e6..b31387b 100644
--- a/pages/home/index.vue
+++ b/pages/home/index.vue
@@ -114,6 +114,9 @@
}
},
mounted() {
+
+ },
+ onShow() {
this.onBannerList()
this.onTaskList()
this.onRolelist()
@@ -177,7 +180,7 @@
uni.setStorageSync("longitude",res.longitude)
uni.setStorageSync("latitude",res.latitude)
const qqmapsdk = new QQMapWX({
- key: 'TT7BZ-Z3LW4-KOAUB-KWHOA-SBJJ6-Y5B6R' // 必填
+ key: 'BJKBZ-W46K3-6S43C-OFLJB-FW6FQ-RMBYP' // 必填
});
qqmapsdk.reverseGeocoder({
location: {
@@ -217,12 +220,12 @@
pageNo:this.tpageNo,
pageSize:this.tpageSize
}).then(response=>{
+ console.info("response",response.result.records)
if(this.tpageNo==1){
this.tList = response.result.records
}else{
this.tList = this.tList.concat(response.result.records)
}
-
console.info("taskList",response)
}).catch(error=>{
diff --git a/pages_subpack/work-detail/index.vue b/pages_subpack/work-detail/index.vue
index 025cf4e..9566b1b 100644
--- a/pages_subpack/work-detail/index.vue
+++ b/pages_subpack/work-detail/index.vue
@@ -30,7 +30,7 @@
工作地址
-
+
{{items.address}}
@@ -94,6 +94,35 @@
}).catch(error=>{
})
+ },
+ openAddress(){
+ let that = this
+ // wx.openLocation({
+ // latitude: that.items.latitude.toFixed(2),
+ // longitude: that.items.longitude.toFixed(2),
+ // name: that.items.title,
+ // address: that.items.address,
+ // scale: 12,
+ // success: function(res) {
+ // console.log(JSON.stringify(res));
+ // },
+ // fail: function(res) {
+ // console.log(`openLocation fail:${JSON.stringify(res)}`);
+ // }
+ // })
+ uni.openLocation({
+ latitude: 30.492121,
+ longitude: 114.410324,
+ name: "保利国际中心",
+ address: "武汉市洪山区关山大道",
+ scale: 12,
+ success: function(res) {
+ console.log(JSON.stringify(res));
+ },
+ fail: function(res) {
+ console.log(`openLocation fail:${JSON.stringify(res)}`);
+ }
+ })
}
}
}
diff --git a/util/request/responseInterceptors.js b/util/request/responseInterceptors.js
index 4f4b125..88ded7b 100644
--- a/util/request/responseInterceptors.js
+++ b/util/request/responseInterceptors.js
@@ -42,14 +42,14 @@ module.exports = (vm) => {
}, (response) => {
const data = response.data
console.info('responseresponse',data)
- // if(data.code === 401){
- // uni.removeStorageSync('token')
- // uni.removeStorageSync('userInfo')
- // uni.navigateTo({
- // url:"/pages/auth/index"
- // })
- // return;
- // }
- // return Promise.reject(response)
+ if(data.code === 401){
+ uni.removeStorageSync('token')
+ uni.removeStorageSync('userInfo')
+ uni.navigateTo({
+ url:"/pages/auth/index"
+ })
+ return;
+ }
+ return Promise.reject(response)
})
}
\ No newline at end of file