studentCheckIn: function () {
console.log("執行簽到程序");
var student;
var stuId = this.data.studentId;
var courseId = this.data.courseId;
var idKey = wx.getStorageSync('idKey');
console.log('stuId', stuId, 'courseId', courseId, 'idKey', idKey);
var long;
var lati;
wx.getSetting({
success: function (res) {
console.log('getSetting...', res)
if (res.authSetting["scope.userLocation"] == true) {
console.log("用戶已開啟定位授權");
} else {
wx.showModal({
title: '位置信息授權',
content: '位置授權暫未開啟,無法完成簽到',
confirmText: '開啟授權',
confirmColor: '#345391',
cancelText: '仍然拒絕',
cancelColor: '#999999',
success: function (res) {
if (res.confirm) {
wx.openSetting({
fail: function () {
console.log('openSetting.failed')
}
})
}
if (res.cancel) {
wx.showModal({
title: '簽到失敗',
content: '無法使用定位權限,簽到失敗',
confirmText: '太遺憾了',
confirmColor: '#345391',
showCancel: false
})
}
}
})
}
}
})
wx.getLocation({
success: function (res) {
console.log(res);
long = res.longitude
lati = res.latitude
console.log("簽到成功,等待服務器反饋")
console.log('stuId', stuId, 'courseId', courseId, 'idKey', idKey, 'longitude', long, 'latitude', lati);
},
fail: function () {
wx.showModal({
title: '簽到失敗',
content: '拒絕授權,獲取位置信息失敗',
confirmText: '授權開啟',
cancelText: '我知道了',
})
}
})
},