|  | @@ -21,7 +21,7 @@ Component({
 | 
	
		
			
				|  |  |          contentHeight: 0, // 可用内容高度
 | 
	
		
			
				|  |  |          contentpadding: 0, //顶部padding高度
 | 
	
		
			
				|  |  |          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.order()
 | 
	
		
			
				|  |  |              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);
 | 
	
		
			
				|  |  |                      // 这里需要调用你的后端接口进行解密
 | 
	
		
			
				|  |  |                      // 假设你有一个解密函数 decryptData
 | 
	
		
			
				|  |  | -                    // this.decryptData(encryptedData, iv).then(steps => {
 | 
	
		
			
				|  |  | -                    //     this.setData({
 | 
	
		
			
				|  |  | -                    //         steps: `${steps}`
 | 
	
		
			
				|  |  | -                    //     });
 | 
	
		
			
				|  |  | -                    //     console.log('用户步数:', this.data.steps);
 | 
	
		
			
				|  |  | -                    // }).catch(err => {
 | 
	
		
			
				|  |  | -                    //     console.error('解密失败:', err);
 | 
	
		
			
				|  |  | -                    // });
 | 
	
		
			
				|  |  | -                    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) {
 | 
	
		
			
				|  |  | -            // return new Promise((resolve, reject) => {
 | 
	
		
			
				|  |  | -            //     // 发送请求到后端进行解密
 | 
	
		
			
				|  |  | -            //     wx.request({
 | 
	
		
			
				|  |  | -            //         url: '', // 替换为你的后端解密接口
 | 
	
		
			
				|  |  | -            //         method: 'POST',
 | 
	
		
			
				|  |  | -            //         data: {
 | 
	
		
			
				|  |  | -            //             encryptedData: encryptedData,
 | 
	
		
			
				|  |  | -            //             iv: iv,
 | 
	
		
			
				|  |  | -            //             // 需要传递 session_key,通常在用户登录时获取
 | 
	
		
			
				|  |  | -            //             session_key: wx.getStorageSync('session_key') // 假设你已经存储了 session_key
 | 
	
		
			
				|  |  | -            //         },
 | 
	
		
			
				|  |  | -            //         success: (res) => {
 | 
	
		
			
				|  |  | -            //             if (res.data && res.data.steps) {
 | 
	
		
			
				|  |  | -            //                 // resolve(res.data.steps); // 返回步数
 | 
	
		
			
				|  |  | -            //                 const steps = 123456
 | 
	
		
			
				|  |  | -            //                 resolve(steps);
 | 
	
		
			
				|  |  | -            //             } else {
 | 
	
		
			
				|  |  | -            //                 reject('解密返回数据格式错误');
 | 
	
		
			
				|  |  | -            //             }
 | 
	
		
			
				|  |  | -            //         },
 | 
	
		
			
				|  |  | -            //         fail: (err) => {
 | 
	
		
			
				|  |  | -            //             reject(err);
 | 
	
		
			
				|  |  | -            //         }
 | 
	
		
			
				|  |  | -            //     });
 | 
	
		
			
				|  |  | -            // });
 | 
	
		
			
				|  |  | -            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 && res.data.steps) {
 | 
	
		
			
				|  |  | +                        //     console.log(res.data.steps);
 | 
	
		
			
				|  |  | +                        //     // resolve(res.data.steps); // 返回步数
 | 
	
		
			
				|  |  | +                        //     // const steps = 123456
 | 
	
		
			
				|  |  | +                        //     resolve(steps);
 | 
	
		
			
				|  |  | +                        // } else {
 | 
	
		
			
				|  |  | +                        //     reject('解密返回数据格式错误');
 | 
	
		
			
				|  |  | +                        // }
 | 
	
		
			
				|  |  | +                        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); // 使用 isToday 函数判断是否是今天
 | 
	
		
			
				|  |  | +                            });
 | 
	
		
			
				|  |  | +                            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);
 | 
	
		
			
				|  |  |          },
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  })
 |