|
@@ -21,7 +21,7 @@ Component({
|
|
|
contentHeight: 0,
|
|
|
contentpadding: 0,
|
|
|
navheight: 0,
|
|
|
- percentage:0,
|
|
|
+ percentage: 0,
|
|
|
|
|
|
rows: [{
|
|
|
image: 'https://file-cloud.fmode.cn/qpFbRRSZrO/20241225/r5j1uc041211788.png',
|
|
@@ -78,9 +78,9 @@ Component({
|
|
|
todayList: [],
|
|
|
changetitle: 'today',
|
|
|
|
|
|
- isclick:false,
|
|
|
+ isclick: false,
|
|
|
|
|
|
- rank:'up'
|
|
|
+ rank: 'up'
|
|
|
},
|
|
|
lifetimes: {
|
|
|
|
|
@@ -115,7 +115,7 @@ Component({
|
|
|
|
|
|
this.Getlocation()
|
|
|
this.gettoday()
|
|
|
-
|
|
|
+
|
|
|
},
|
|
|
},
|
|
|
|
|
@@ -256,55 +256,79 @@ Component({
|
|
|
|
|
|
const encryptedData = res.encryptedData;
|
|
|
const iv = res.iv;
|
|
|
- console.log('encryptedData',encryptedData);
|
|
|
- console.log('iv',iv);
|
|
|
+ console.log('encryptedData', encryptedData);
|
|
|
+ console.log('iv', iv);
|
|
|
+ const userInfo = wx.getStorageSync('userInfo');
|
|
|
+ const session_key = userInfo.session_key
|
|
|
+ console.log('session_key', session_key);
|
|
|
|
|
|
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- const steps = this.decryptData(encryptedData, iv)
|
|
|
- console.log(steps);
|
|
|
- this.updatetoday(steps)
|
|
|
+ this.decryptData(encryptedData, iv, session_key).then(steps => {
|
|
|
+ this.setData({
|
|
|
+ steps: steps
|
|
|
+ });
|
|
|
+ console.log('用户步数:', this.data.steps);
|
|
|
+ this.updatetoday(steps)
|
|
|
+ }).catch(err => {
|
|
|
+ console.error('解密失败:', err);
|
|
|
+ });
|
|
|
},
|
|
|
fail: (err) => {
|
|
|
console.error('获取运动数据失败:', err);
|
|
|
}
|
|
|
});
|
|
|
},
|
|
|
- decryptData(encryptedData, iv) {
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- const steps = 1200
|
|
|
- return steps
|
|
|
+
|
|
|
+ decryptData(encryptedData, iv, session_key) {
|
|
|
+ return new Promise((resolve, reject) => {
|
|
|
+
|
|
|
+ wx.request({
|
|
|
+ url: 'https://server.fmode.cn/api/wxapp/decrypt_phone',
|
|
|
+ method: 'get',
|
|
|
+ data: {
|
|
|
+ encryptedData: encryptedData,
|
|
|
+ iv: iv,
|
|
|
+ appId: 'wxe6ecc0193c09696c',
|
|
|
+ sessionKey: session_key
|
|
|
+ },
|
|
|
+ success: (res) => {
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ if (res.data.data) {
|
|
|
+ const stepInfoList = res.data.data.stepInfoList
|
|
|
+ console.log(stepInfoList);
|
|
|
+ const todaylist = stepInfoList.filter(item => {
|
|
|
+ console.log(this.isToday(item));
|
|
|
+ return this.isToday(item);
|
|
|
+ });
|
|
|
+ const steps = todaylist[0].step;
|
|
|
+ resolve(steps);
|
|
|
+ console.log('今日步数', steps);
|
|
|
+ } else {
|
|
|
+ reject('解密返回数据格式错误');
|
|
|
+ }
|
|
|
+
|
|
|
+ },
|
|
|
+ fail: (err) => {
|
|
|
+ reject(err);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ });
|
|
|
+ },
|
|
|
+
|
|
|
+ isToday(item) {
|
|
|
+ const today = new Date();
|
|
|
+ const date = new Date(item.timestamp * 1000);
|
|
|
+
|
|
|
+ return date.getFullYear() === today.getFullYear() &&
|
|
|
+ date.getMonth() === today.getMonth() &&
|
|
|
+ date.getDate() === today.getDate();
|
|
|
},
|
|
|
|
|
|
async updatetoday(steps) {
|
|
@@ -359,7 +383,7 @@ Component({
|
|
|
console.error("保存数据时出现错误:", error);
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
},
|
|
|
|
|
|
change() {
|
|
@@ -372,19 +396,19 @@ Component({
|
|
|
});
|
|
|
if (this.data.changetitle == 'today') {
|
|
|
this.setData({
|
|
|
- rank:'up'
|
|
|
+ rank: 'up'
|
|
|
})
|
|
|
this.gettoday()
|
|
|
}
|
|
|
if (this.data.changetitle == 'weekdday') {
|
|
|
this.setData({
|
|
|
- rank:'up'
|
|
|
+ rank: 'up'
|
|
|
})
|
|
|
console.log('weekdday');
|
|
|
}
|
|
|
if (this.data.changetitle == 'month') {
|
|
|
this.setData({
|
|
|
- rank:'up'
|
|
|
+ rank: 'up'
|
|
|
})
|
|
|
console.log('month');
|
|
|
}
|
|
@@ -439,14 +463,14 @@ Component({
|
|
|
}
|
|
|
},
|
|
|
|
|
|
- changeup(){
|
|
|
- if(this.data.rank=='up'){
|
|
|
+ changeup() {
|
|
|
+ if (this.data.rank == 'up') {
|
|
|
this.setData({
|
|
|
- rank:'down'
|
|
|
+ rank: 'down'
|
|
|
})
|
|
|
if (this.data.changetitle == 'today') {
|
|
|
this.setData({
|
|
|
- todayList:this.data.todayList.reverse(),
|
|
|
+ todayList: this.data.todayList.reverse(),
|
|
|
})
|
|
|
console.log('逆序');
|
|
|
}
|
|
@@ -456,13 +480,13 @@ Component({
|
|
|
if (this.data.changetitle == 'month') {
|
|
|
console.log('month逆序');
|
|
|
}
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
this.setData({
|
|
|
- rank:'up'
|
|
|
+ rank: 'up'
|
|
|
})
|
|
|
if (this.data.changetitle == 'today') {
|
|
|
this.setData({
|
|
|
- todayList:this.data.todayList.reverse(),
|
|
|
+ todayList: this.data.todayList.reverse(),
|
|
|
})
|
|
|
console.log('顺序');
|
|
|
}
|
|
@@ -483,9 +507,9 @@ Component({
|
|
|
percentage = 100;
|
|
|
}
|
|
|
this.setData({
|
|
|
- percentage:`conic-gradient(from 0deg, #015EEA ${percentage}%, white 0%)`,
|
|
|
+ percentage: `conic-gradient(from 0deg, #015EEA ${percentage}%, white 0%)`,
|
|
|
})
|
|
|
- console.log('百分比',this.data.percentage);
|
|
|
+ console.log('百分比', this.data.percentage);
|
|
|
},
|
|
|
}
|
|
|
})
|