|
@ -10,33 +10,33 @@ Page({ |
|
|
*/ |
|
|
*/ |
|
|
data: { |
|
|
data: { |
|
|
BASEURL: BASEURL(), |
|
|
BASEURL: BASEURL(), |
|
|
qqmapsdk:"", |
|
|
qqmapsdk: "", |
|
|
signin: {},//活动打卡地点详情
|
|
|
signin: {}, //活动打卡地点详情
|
|
|
actId: "",//活动ID
|
|
|
actId: "", //活动ID
|
|
|
operationDesc: "",//打卡描述
|
|
|
operationDesc: "", //打卡描述
|
|
|
operationDesc_:"", |
|
|
operationDesc_: "", |
|
|
locationLongitude: Number,//打卡位置经度
|
|
|
locationLongitude: Number, //打卡位置经度
|
|
|
locationLatitude: Number,// 打卡位置纬度
|
|
|
locationLatitude: Number, // 打卡位置纬度
|
|
|
operationAddress:"",//打卡地址
|
|
|
operationAddress: "", //打卡地址
|
|
|
images: [],//图片
|
|
|
images: [], //图片
|
|
|
clockType: Number,//打卡类型(0-打卡,1-更新打卡)
|
|
|
clockType: Number, //打卡类型(0-打卡,1-更新打卡)
|
|
|
effectiveFlag: Number,//打卡是否有效(0-否,1-是)
|
|
|
effectiveFlag: Number, //打卡是否有效(0-否,1-是)
|
|
|
phraseList:[],//常用于列表
|
|
|
phraseList: [], //常用于列表
|
|
|
phraseId:"",//常用语id
|
|
|
phraseId: "", //常用语id
|
|
|
}, |
|
|
}, |
|
|
/** |
|
|
/** |
|
|
* 生命周期函数--监听页面加载 |
|
|
* 生命周期函数--监听页面加载 |
|
|
*/ |
|
|
*/ |
|
|
onLoad: function (options) { |
|
|
onLoad: function(options) { |
|
|
const qqmapsdk = new QQMapWX({ |
|
|
const qqmapsdk = new QQMapWX({ |
|
|
key: 'CMJBZ-4DECI-JXGGN-5B4WU-QLV2H-B5BEJ' |
|
|
key: 'CMJBZ-4DECI-JXGGN-5B4WU-QLV2H-B5BEJ' |
|
|
}) |
|
|
}) |
|
|
|
|
|
|
|
|
if (options.currentUserStatus == "4") {//0-打卡
|
|
|
if (options.currentUserStatus == "4") { //0-打卡
|
|
|
this.setData({ |
|
|
this.setData({ |
|
|
clockType: 0 |
|
|
clockType: 0 |
|
|
}) |
|
|
}) |
|
|
}else{//更新打卡
|
|
|
} else { //更新打卡
|
|
|
this.setData({ |
|
|
this.setData({ |
|
|
clockType: 1 |
|
|
clockType: 1 |
|
|
}) |
|
|
}) |
|
@ -44,22 +44,22 @@ Page({ |
|
|
this.setData({ |
|
|
this.setData({ |
|
|
qqmapsdk, |
|
|
qqmapsdk, |
|
|
id: options.id, |
|
|
id: options.id, |
|
|
effectiveFlag:1 |
|
|
effectiveFlag: 1 |
|
|
}) |
|
|
}) |
|
|
this.getPhraseList();//常用语列表
|
|
|
this.getPhraseList(); //常用语列表
|
|
|
this.getPosition(); |
|
|
this.getPosition(); |
|
|
this.clockAddressDetail(); |
|
|
this.clockAddressDetail(); |
|
|
}, |
|
|
}, |
|
|
getPhraseList(){ |
|
|
getPhraseList() { |
|
|
let that = this; |
|
|
let that = this; |
|
|
api.getPhraseList().then(function (res) {//常用语列表
|
|
|
api.getPhraseList().then(function(res) { //常用语列表
|
|
|
console.log('常用语列表:' + JSON.stringify(res.data)) |
|
|
console.log('常用语列表:' + JSON.stringify(res.data)) |
|
|
that.setData({ |
|
|
that.setData({ |
|
|
phraseList: res.data, |
|
|
phraseList: res.data, |
|
|
}) |
|
|
}) |
|
|
}) |
|
|
}) |
|
|
}, |
|
|
}, |
|
|
toOperationDesc(phrase){//常用于点击事件
|
|
|
toOperationDesc(phrase) { //常用于点击事件
|
|
|
// console.log(phrase.currentTarget.dataset.phrase)
|
|
|
// console.log(phrase.currentTarget.dataset.phrase)
|
|
|
this.setData({ |
|
|
this.setData({ |
|
|
operationDesc: this.data.operationDesc + phrase.currentTarget.dataset.phrase, |
|
|
operationDesc: this.data.operationDesc + phrase.currentTarget.dataset.phrase, |
|
@ -78,8 +78,8 @@ Page({ |
|
|
this.reverseGeocoder(res) |
|
|
this.reverseGeocoder(res) |
|
|
this.setData({ |
|
|
this.setData({ |
|
|
location: { |
|
|
location: { |
|
|
locationLongitude: res.latitude, |
|
|
locationLongitude: res.longitude, |
|
|
locationLatitude: res.longitude |
|
|
locationLatitude: res.latitude |
|
|
} |
|
|
} |
|
|
}) |
|
|
}) |
|
|
}, |
|
|
}, |
|
@ -95,7 +95,10 @@ Page({ |
|
|
}) |
|
|
}) |
|
|
}, |
|
|
}, |
|
|
// 逆地址解析
|
|
|
// 逆地址解析
|
|
|
reverseGeocoder({ latitude, longitude }) { |
|
|
reverseGeocoder({ |
|
|
|
|
|
latitude, |
|
|
|
|
|
longitude |
|
|
|
|
|
}) { |
|
|
var that = this; |
|
|
var that = this; |
|
|
that.data.qqmapsdk.reverseGeocoder({ |
|
|
that.data.qqmapsdk.reverseGeocoder({ |
|
|
location: { |
|
|
location: { |
|
@ -201,7 +204,7 @@ Page({ |
|
|
return false |
|
|
return false |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
if (this.data.images.length==0){ |
|
|
if (this.data.images.length == 0) { |
|
|
wx.showToast({ |
|
|
wx.showToast({ |
|
|
title: '请上传打卡图片', |
|
|
title: '请上传打卡图片', |
|
|
icon: 'none', |
|
|
icon: 'none', |
|
@ -211,63 +214,71 @@ Page({ |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
if (this.data.phraseId) { |
|
|
if (this.data.phraseId) { |
|
|
api.sagenumAddOne(this.data.phraseId).then(function (res) { |
|
|
api.sagenumAddOne(this.data.phraseId).then(function(res) { |
|
|
console.log('常用语言:' + res) |
|
|
console.log('常用语言:' + res) |
|
|
}) |
|
|
}) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
const signinLongitude = this.data.signin.signinLongitude;//经度
|
|
|
const signinLongitude = this.data.signin.signinLongitude; //经度
|
|
|
const signinLatitude = this.data.signin.signinLatitude;//纬度
|
|
|
const signinLatitude = this.data.signin.signinLatitude; //纬度
|
|
|
|
|
|
var clockLongitudeMy = 0; |
|
|
const clockLongitude = this.data.location.locationLatitude;//经度
|
|
|
var clockLatitudeMy = 0; |
|
|
const clockLatitude = this.data.location.locationLongitude;//纬度
|
|
|
if (this.data.location && this.data.location.locationLatitude && this.data.location.locationLongitude) { |
|
|
|
|
|
clockLongitudeMy = this.data.location.locationLongitude; //经度
|
|
|
// console.log("signinLongitude" + signinLongitude + "signinLatitude" + signinLatitude)
|
|
|
clockLatitudeMy = this.data.location.locationLatitude; //纬度
|
|
|
// console.log("clockLongitude" + clockLongitude + "clockLatitude" + clockLatitude)
|
|
|
|
|
|
|
|
|
|
|
|
// Lat1 Lung1 表示A点纬度和经度,Lat2 Lung2 表示B点纬度和经度;
|
|
|
// Lat1 Lung1 表示A点纬度和经度,Lat2 Lung2 表示B点纬度和经度;
|
|
|
// a = Lat1 – Lat2 为两点纬度之差 b = Lung1 - Lung2 为两点经度之差;
|
|
|
// a = Lat1 – Lat2 为两点纬度之差 b = Lung1 - Lung2 为两点经度之差;
|
|
|
// 6378.137为地球半径,单位为公里;计算出来的结果单位为公里;
|
|
|
// 6378.137为地球半径,单位为公里;计算出来的结果单位为公里;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var radLat1 = this.Rad(signinLatitude); |
|
|
var radLat1 = this.Rad(signinLatitude); |
|
|
var radLat2 = this.Rad(clockLatitude); |
|
|
var radLat2 = this.Rad(clockLatitudeMy); |
|
|
var a = radLat1 - radLat2; |
|
|
var a = radLat1 - radLat2; |
|
|
var b = this.Rad(signinLongitude) - this.Rad(clockLongitude); |
|
|
var b = this.Rad(signinLongitude) - this.Rad(clockLongitudeMy); |
|
|
var s = 2 * Math.asin(Math.sqrt(Math.pow(Math.sin(a / 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))); |
|
|
Math.cos(radLat1) * Math.cos(radLat2) * Math.pow(Math.sin(b / 2), 2))); |
|
|
s = s * 6378.137;// EARTH_RADIUS;
|
|
|
s = s * 6378.137; // EARTH_RADIUS;
|
|
|
s = Math.round(s * 10000) / 10000 *1000; |
|
|
s = Math.round(s * 10000) / 10000 * 1000; |
|
|
//s=s.toFixed(4);
|
|
|
//s=s.toFixed(4);
|
|
|
|
|
|
|
|
|
if (s > this.data.signin.clockRadius){ |
|
|
if (s > this.data.signin.clockRadius) { |
|
|
this.setData({ |
|
|
this.setData({ |
|
|
effectiveFlag:0 |
|
|
effectiveFlag: 0 |
|
|
}) |
|
|
}) |
|
|
}else{ |
|
|
} else { |
|
|
this.setData({ |
|
|
this.setData({ |
|
|
effectiveFlag: 1 |
|
|
effectiveFlag: 1 |
|
|
}) |
|
|
}) |
|
|
} |
|
|
} |
|
|
const params={ |
|
|
} else { |
|
|
|
|
|
this.setData({ |
|
|
|
|
|
clockLongitudeMy: 0, |
|
|
|
|
|
clockLatitudeMy: 0, |
|
|
|
|
|
effectiveFlag: 0 |
|
|
|
|
|
}) |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const params = { |
|
|
actId: this.data.id, |
|
|
actId: this.data.id, |
|
|
clockDesc: this.data.operationDesc.substring(0, 500), |
|
|
clockDesc: this.data.operationDesc.substring(0, 500), |
|
|
clockLongitude: this.data.location.locationLongitude, |
|
|
clockLongitude: clockLongitudeMy, //打卡位置经度
|
|
|
clockLatitude: this.data.location.locationLatitude, |
|
|
clockLatitude: clockLatitudeMy, //打卡位置纬度
|
|
|
clockAddress: this.data.operationAddress, |
|
|
clockAddress: this.data.operationAddress, |
|
|
images: this.data.images, |
|
|
images: this.data.images, |
|
|
clockType: this.data.clockType,//打卡类型(0-打卡,1-更新打卡)
|
|
|
clockType: this.data.clockType, //打卡类型(0-打卡,1-更新打卡)
|
|
|
effectiveFlag: this.data.effectiveFlag//打卡是否有效(0-否,1-是)
|
|
|
effectiveFlag: this.data.effectiveFlag //打卡是否有效(0-否,1-是)
|
|
|
} |
|
|
} |
|
|
// console.log('~~~~~~~":::::' + JSON.stringify(params))
|
|
|
// console.log('~~~~~~~":::::' + JSON.stringify(params))
|
|
|
api.clock(params).then(function (res) { |
|
|
api.clock(params).then(function(res) { |
|
|
if (res.code == 0) { |
|
|
if (res.code == 0) { |
|
|
wx.showToast({ |
|
|
wx.showToast({ |
|
|
title: '打卡成功', |
|
|
title: '打卡成功', |
|
|
icon: 'none', |
|
|
icon: 'none', |
|
|
duration: 3000, |
|
|
duration: 3000, |
|
|
complete: function () { |
|
|
complete: function() { |
|
|
setTimeout(function () { |
|
|
setTimeout(function() { |
|
|
wx.navigateBack() |
|
|
wx.navigateBack() |
|
|
}, 1000); |
|
|
}, 1000); |
|
|
} |
|
|
} |
|
@ -276,14 +287,14 @@ Page({ |
|
|
|
|
|
|
|
|
}) |
|
|
}) |
|
|
}, |
|
|
}, |
|
|
Rad(d) {//经纬度转换成三角函数中度分表形式。
|
|
|
Rad(d) { //经纬度转换成三角函数中度分表形式。
|
|
|
return d * Math.PI / 180.0; |
|
|
return d * Math.PI / 180.0; |
|
|
}, |
|
|
}, |
|
|
clockAddressDetail() {//活动打卡地点详情
|
|
|
clockAddressDetail() { //活动打卡地点详情
|
|
|
let that = this; |
|
|
let that = this; |
|
|
const id = that.data.id; |
|
|
const id = that.data.id; |
|
|
|
|
|
|
|
|
api.clockAddressDetail(id).then(function (res) { |
|
|
api.clockAddressDetail(id).then(function(res) { |
|
|
if (res.code == 0) { |
|
|
if (res.code == 0) { |
|
|
that.setData({ |
|
|
that.setData({ |
|
|
signin: res.data |
|
|
signin: res.data |
|
@ -295,49 +306,49 @@ Page({ |
|
|
/** |
|
|
/** |
|
|
* 生命周期函数--监听页面初次渲染完成 |
|
|
* 生命周期函数--监听页面初次渲染完成 |
|
|
*/ |
|
|
*/ |
|
|
onReady: function () { |
|
|
onReady: function() { |
|
|
|
|
|
|
|
|
}, |
|
|
}, |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* 生命周期函数--监听页面显示 |
|
|
* 生命周期函数--监听页面显示 |
|
|
*/ |
|
|
*/ |
|
|
onShow: function () { |
|
|
onShow: function() { |
|
|
|
|
|
|
|
|
}, |
|
|
}, |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* 生命周期函数--监听页面隐藏 |
|
|
* 生命周期函数--监听页面隐藏 |
|
|
*/ |
|
|
*/ |
|
|
onHide: function () { |
|
|
onHide: function() { |
|
|
|
|
|
|
|
|
}, |
|
|
}, |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* 生命周期函数--监听页面卸载 |
|
|
* 生命周期函数--监听页面卸载 |
|
|
*/ |
|
|
*/ |
|
|
onUnload: function () { |
|
|
onUnload: function() { |
|
|
|
|
|
|
|
|
}, |
|
|
}, |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* 页面相关事件处理函数--监听用户下拉动作 |
|
|
* 页面相关事件处理函数--监听用户下拉动作 |
|
|
*/ |
|
|
*/ |
|
|
onPullDownRefresh: function () { |
|
|
onPullDownRefresh: function() { |
|
|
|
|
|
|
|
|
}, |
|
|
}, |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* 页面上拉触底事件的处理函数 |
|
|
* 页面上拉触底事件的处理函数 |
|
|
*/ |
|
|
*/ |
|
|
onReachBottom: function () { |
|
|
onReachBottom: function() { |
|
|
|
|
|
|
|
|
}, |
|
|
}, |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* 用户点击右上角分享 |
|
|
* 用户点击右上角分享 |
|
|
*/ |
|
|
*/ |
|
|
onShareAppMessage: function () { |
|
|
onShareAppMessage: function() { |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
}) |
|
|
}) |