|
|
@ -23,70 +23,59 @@ Page({ |
|
|
|
effectiveFlag: Number, //打卡是否有效(0-否,1-是)
|
|
|
|
phraseList: [], //常用于列表
|
|
|
|
phraseId: "", //常用语id
|
|
|
|
ldata: false |
|
|
|
}, |
|
|
|
/** |
|
|
|
* 生命周期函数--监听页面加载 |
|
|
|
*/ |
|
|
|
onLoad: function(options) { |
|
|
|
var that = this; |
|
|
|
const qqmapsdk = new QQMapWX({ |
|
|
|
key: 'CMJBZ-4DECI-JXGGN-5B4WU-QLV2H-B5BEJ' |
|
|
|
}) |
|
|
|
|
|
|
|
if (options.currentUserStatus == "4") { //0-打卡
|
|
|
|
this.setData({ |
|
|
|
that.setData({ |
|
|
|
clockType: 0 |
|
|
|
}) |
|
|
|
} else { //更新打卡
|
|
|
|
this.setData({ |
|
|
|
that.setData({ |
|
|
|
clockType: 1 |
|
|
|
}) |
|
|
|
} |
|
|
|
this.setData({ |
|
|
|
that.setData({ |
|
|
|
qqmapsdk, |
|
|
|
id: options.id, |
|
|
|
effectiveFlag: 1 |
|
|
|
}) |
|
|
|
this.getPhraseList(); //常用语列表
|
|
|
|
this.getPosition(); |
|
|
|
this.clockAddressDetail(); |
|
|
|
}, |
|
|
|
getPhraseList() { |
|
|
|
let that = this; |
|
|
|
api.getPhraseList().then(function(res) { //常用语列表
|
|
|
|
console.log('常用语列表:' + JSON.stringify(res.data)) |
|
|
|
that.setData({ |
|
|
|
phraseList: res.data, |
|
|
|
}) |
|
|
|
}) |
|
|
|
}, |
|
|
|
toOperationDesc(phrase) { //常用于点击事件
|
|
|
|
// console.log(phrase.currentTarget.dataset.phrase)
|
|
|
|
this.setData({ |
|
|
|
operationDesc: this.data.operationDesc + phrase.currentTarget.dataset.phrase, |
|
|
|
phraseId: phrase.currentTarget.dataset.id |
|
|
|
}) |
|
|
|
// console.log(phrase.currentTarget.dataset.phrase)
|
|
|
|
that.getPhraseList(); //常用语列表
|
|
|
|
that.getPosition(); |
|
|
|
that.clockAddressDetail(); |
|
|
|
that.getPosition() |
|
|
|
}, |
|
|
|
//获取经纬度
|
|
|
|
getPosition() { |
|
|
|
var that = this; |
|
|
|
wx.showLoading({ |
|
|
|
title: '正在获取位置', |
|
|
|
}) |
|
|
|
wx.getLocation({ |
|
|
|
type: 'gcj02', |
|
|
|
success: (res) => { |
|
|
|
this.reverseGeocoder(res) |
|
|
|
this.setData({ |
|
|
|
location: { |
|
|
|
that.reverseGeocoder(res) |
|
|
|
that.setData({ |
|
|
|
ldata: false, |
|
|
|
locationLongitude: res.longitude, |
|
|
|
locationLatitude: res.latitude |
|
|
|
} |
|
|
|
}) |
|
|
|
}, |
|
|
|
fail: (res) => { |
|
|
|
wx.hideLoading(); |
|
|
|
that.setData({ |
|
|
|
ldata: true |
|
|
|
}) |
|
|
|
wx.showToast({ |
|
|
|
title: '位置获取失败,请开启手机GPS定位', |
|
|
|
title: '位置获取失败,请开启手机GPS定位或重新授权获取位置信息', |
|
|
|
icon: 'none', |
|
|
|
duration: 3000 |
|
|
|
}) |
|
|
@ -94,6 +83,30 @@ Page({ |
|
|
|
} |
|
|
|
}) |
|
|
|
}, |
|
|
|
handler: function(e) { |
|
|
|
var that = this; |
|
|
|
if (!e.detail.authSetting['scope.userLocation']) { |
|
|
|
that.setData({ |
|
|
|
ldata: true |
|
|
|
}) |
|
|
|
} else { |
|
|
|
that.setData({ |
|
|
|
ldata: false, |
|
|
|
}) |
|
|
|
wx.getLocation({ |
|
|
|
type: 'gcj02', |
|
|
|
success: function(res) { |
|
|
|
var latitude = res.latitude |
|
|
|
var longitude = res.longitude |
|
|
|
|
|
|
|
that.setData({ |
|
|
|
locationLongitude: longitude, |
|
|
|
locationLatitude: latitude |
|
|
|
}) |
|
|
|
} |
|
|
|
}) |
|
|
|
} |
|
|
|
}, |
|
|
|
// 逆地址解析
|
|
|
|
reverseGeocoder({ |
|
|
|
latitude, |
|
|
@ -115,8 +128,23 @@ Page({ |
|
|
|
} |
|
|
|
}) |
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
getPhraseList() { |
|
|
|
let that = this; |
|
|
|
api.getPhraseList().then(function(res) { //常用语列表
|
|
|
|
// console.log('常用语列表:' + JSON.stringify(res.data))
|
|
|
|
that.setData({ |
|
|
|
phraseList: res.data, |
|
|
|
}) |
|
|
|
}) |
|
|
|
}, |
|
|
|
toOperationDesc(phrase) { //常用于点击事件
|
|
|
|
// console.log(phrase.currentTarget.dataset.phrase)
|
|
|
|
this.setData({ |
|
|
|
operationDesc: this.data.operationDesc + phrase.currentTarget.dataset.phrase, |
|
|
|
phraseId: phrase.currentTarget.dataset.id |
|
|
|
}) |
|
|
|
// console.log(phrase.currentTarget.dataset.phrase)
|
|
|
|
}, |
|
|
|
// 上传图片
|
|
|
|
onChange(e) { |
|
|
|
// console.log('onChange', e)
|
|
|
@ -144,25 +172,19 @@ Page({ |
|
|
|
this.setData({ |
|
|
|
images: images |
|
|
|
}) |
|
|
|
|
|
|
|
// console.log("~~~~~~@@@@@@@@" + JSON.stringify(images))
|
|
|
|
|
|
|
|
}, |
|
|
|
onSuccess(e) { |
|
|
|
// console.log('onSuccess', e)
|
|
|
|
|
|
|
|
}, |
|
|
|
onFail(e) { |
|
|
|
// console.log('onFail', e)
|
|
|
|
|
|
|
|
}, |
|
|
|
// 上传完成
|
|
|
|
onComplete(e) { |
|
|
|
// console.log('onComplete', e)
|
|
|
|
wx.hideLoading() |
|
|
|
}, |
|
|
|
// 点击图片放大
|
|
|
|
onPreview(e) { |
|
|
|
// console.log('onPreview', e)
|
|
|
|
const { |
|
|
|
file, |
|
|
|
fileList |
|
|
@ -215,7 +237,7 @@ Page({ |
|
|
|
|
|
|
|
if (this.data.phraseId) { |
|
|
|
api.sagenumAddOne(this.data.phraseId).then(function(res) { |
|
|
|
console.log('常用语言:' + res) |
|
|
|
// console.log('常用语言:' + res)
|
|
|
|
}) |
|
|
|
} |
|
|
|
|
|
|
@ -223,9 +245,11 @@ Page({ |
|
|
|
const signinLatitude = this.data.signin.signinLatitude; //纬度
|
|
|
|
var clockLongitudeMy = 0; |
|
|
|
var clockLatitudeMy = 0; |
|
|
|
if (this.data.location && this.data.location.locationLatitude && this.data.location.locationLongitude) { |
|
|
|
clockLongitudeMy = this.data.location.locationLongitude; //经度
|
|
|
|
clockLatitudeMy = this.data.location.locationLatitude; //纬度
|
|
|
|
|
|
|
|
console.log(this.data.locationLatitude + '::::::::::::::' + this.data.locationLongitude) |
|
|
|
if (this.data.locationLatitude > 0 && this.data.locationLongitude > 0) { |
|
|
|
clockLongitudeMy = this.data.locationLongitude; //经度
|
|
|
|
clockLatitudeMy = this.data.locationLatitude; //纬度
|
|
|
|
|
|
|
|
// Lat1 Lung1 表示A点纬度和经度,Lat2 Lung2 表示B点纬度和经度;
|
|
|
|
// a = Lat1 – Lat2 为两点纬度之差 b = Lung1 - Lung2 为两点经度之差;
|
|
|
@ -234,13 +258,12 @@ Page({ |
|
|
|
var radLat2 = this.Rad(clockLatitudeMy); |
|
|
|
var a = radLat1 - radLat2; |
|
|
|
var b = this.Rad(signinLongitude) - this.Rad(clockLongitudeMy); |
|
|
|
var s = 2 * Math.asin(Math.sqrt(Math.pow(Math.sin(a / 2), 2) + |
|
|
|
Math.cos(radLat1) * Math.cos(radLat2) * Math.pow(Math.sin(b / 2), 2))); |
|
|
|
var s = 2 * Math.asin(Math.sqrt(Math.pow(Math.sin(a / 2), 2) + Math.cos(radLat1) * Math.cos(radLat2) * Math.pow(Math.sin(b / 2), 2))); |
|
|
|
s = s * 6378.137; // EARTH_RADIUS;
|
|
|
|
s = Math.round(s * 10000) / 10000 * 1000; |
|
|
|
//s=s.toFixed(4);
|
|
|
|
|
|
|
|
if (s > this.data.signin.clockRadius) { |
|
|
|
s = Math.round(s * 10000) / 10000; |
|
|
|
s = s.toFixed(4); |
|
|
|
console.log(s + "::::::::::::::::::" + this.data.signin.clockRadius) |
|
|
|
if (s * 1000 > this.data.signin.clockRadius) { |
|
|
|
this.setData({ |
|
|
|
effectiveFlag: 0 |
|
|
|
}) |
|
|
|