|
@@ -1,4 +1,6 @@
|
|
// nova-werun/components/home/index.js
|
|
// nova-werun/components/home/index.js
|
|
|
|
+const Parse = getApp().Parse;
|
|
|
|
+const company = getApp().globalData.company;
|
|
Component({
|
|
Component({
|
|
/**
|
|
/**
|
|
* 组件的属性列表
|
|
* 组件的属性列表
|
|
@@ -33,7 +35,7 @@ Component({
|
|
image: 'https://file-cloud.fmode.cn/qpFbRRSZrO/20241102/mcu488041343362.png?imageView2/1/w/200/h/200',
|
|
image: 'https://file-cloud.fmode.cn/qpFbRRSZrO/20241102/mcu488041343362.png?imageView2/1/w/200/h/200',
|
|
text: '转发分享',
|
|
text: '转发分享',
|
|
url: '../../pages/home/share/index'
|
|
url: '../../pages/home/share/index'
|
|
-
|
|
|
|
|
|
+
|
|
},
|
|
},
|
|
{
|
|
{
|
|
image: 'https://file-cloud.fmode.cn/qpFbRRSZrO/20241102/pqln61041343428.png?imageView2/1/w/200/h/200',
|
|
image: 'https://file-cloud.fmode.cn/qpFbRRSZrO/20241102/pqln61041343428.png?imageView2/1/w/200/h/200',
|
|
@@ -44,14 +46,14 @@ Component({
|
|
image: 'https://file-cloud.fmode.cn/qpFbRRSZrO/20241102/9crt85041343498.png?imageView2/1/w/200/h/200',
|
|
image: 'https://file-cloud.fmode.cn/qpFbRRSZrO/20241102/9crt85041343498.png?imageView2/1/w/200/h/200',
|
|
text: '步行',
|
|
text: '步行',
|
|
url: '../../pages/home/sport/sport-home/index',
|
|
url: '../../pages/home/sport/sport-home/index',
|
|
-
|
|
|
|
|
|
+
|
|
},
|
|
},
|
|
|
|
|
|
{
|
|
{
|
|
image: 'https://file-cloud.fmode.cn/qpFbRRSZrO/20241102/71svpg041343669.png?imageView2/1/w/200/h/200',
|
|
image: 'https://file-cloud.fmode.cn/qpFbRRSZrO/20241102/71svpg041343669.png?imageView2/1/w/200/h/200',
|
|
text: '跑步',
|
|
text: '跑步',
|
|
url: '../../pages/home/sport/sport-home/index',
|
|
url: '../../pages/home/sport/sport-home/index',
|
|
- active:1
|
|
|
|
|
|
+ active: 1
|
|
},
|
|
},
|
|
{
|
|
{
|
|
image: 'https://file-cloud.fmode.cn/qpFbRRSZrO/20241102/uk13u1041343733.png?imageView2/1/w/200/h/200',
|
|
image: 'https://file-cloud.fmode.cn/qpFbRRSZrO/20241102/uk13u1041343733.png?imageView2/1/w/200/h/200',
|
|
@@ -63,7 +65,9 @@ Component({
|
|
text: '积分',
|
|
text: '积分',
|
|
url: '../../pages/home/integral/index'
|
|
url: '../../pages/home/integral/index'
|
|
},
|
|
},
|
|
- ]
|
|
|
|
|
|
+ ],
|
|
|
|
+ target: 0
|
|
|
|
+
|
|
},
|
|
},
|
|
lifetimes: {
|
|
lifetimes: {
|
|
|
|
|
|
@@ -91,6 +95,7 @@ Component({
|
|
contentpadding
|
|
contentpadding
|
|
});
|
|
});
|
|
console.log('123', contentpadding);
|
|
console.log('123', contentpadding);
|
|
|
|
+ this.gettarget()
|
|
},
|
|
},
|
|
},
|
|
},
|
|
|
|
|
|
@@ -102,17 +107,50 @@ Component({
|
|
gourl(e) {
|
|
gourl(e) {
|
|
const url = e.currentTarget.dataset.url
|
|
const url = e.currentTarget.dataset.url
|
|
const active = e.currentTarget.dataset.active
|
|
const active = e.currentTarget.dataset.active
|
|
- if(active){
|
|
|
|
|
|
+ if (active) {
|
|
wx.navigateTo({
|
|
wx.navigateTo({
|
|
- url: `${url}?id=`+active // 目标页面的路径
|
|
|
|
|
|
+ url: `${url}?id=` + active // 目标页面的路径
|
|
});
|
|
});
|
|
console.log(active);
|
|
console.log(active);
|
|
- }else{
|
|
|
|
|
|
+ } else {
|
|
wx.navigateTo({
|
|
wx.navigateTo({
|
|
url: `${url}` // 目标页面的路径
|
|
url: `${url}` // 目标页面的路径
|
|
});
|
|
});
|
|
}
|
|
}
|
|
|
|
|
|
},
|
|
},
|
|
|
|
+ async gettarget() {
|
|
|
|
+ const currentUser = Parse.User.current();
|
|
|
|
+ let userquery = new Parse.Query('_User');
|
|
|
|
+ userquery.equalTo('company', company);
|
|
|
|
+ userquery.equalTo('objectId', currentUser.id);
|
|
|
|
+ userquery.notEqualTo('isDeleted', true)
|
|
|
|
+ let user = await userquery.find();
|
|
|
|
+ let num = user.map(item => item.toJSON());
|
|
|
|
+ if (num[0].num) {
|
|
|
|
+ this.setData({
|
|
|
|
+ target: num[0].num
|
|
|
|
+ })
|
|
|
|
+ console.log('当前步数',this.data.target);
|
|
|
|
+ } else {
|
|
|
|
+ const currentUser2 = Parse.User.current();
|
|
|
|
+ let userquery2 = new Parse.Query('_User');
|
|
|
|
+ userquery2.equalTo('company', company);
|
|
|
|
+ userquery2.equalTo('objectId', currentUser2.id);
|
|
|
|
+ userquery2.notEqualTo('isDeleted', true)
|
|
|
|
+ let user2 = await userquery2.first();
|
|
|
|
+ user2.set('num', 5000)
|
|
|
|
+ try {
|
|
|
|
+ let saveDate2 = await user2.save();
|
|
|
|
+ console.log(saveDate2);
|
|
|
|
+ this.setData({
|
|
|
|
+ target: 5000
|
|
|
|
+ })
|
|
|
|
+ console.log("目标步数更改成功");
|
|
|
|
+ } catch (error) {
|
|
|
|
+ console.error("保存数据时出现错误:", error);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ },
|
|
}
|
|
}
|
|
})
|
|
})
|