diff --git a/App.vue b/App.vue
index 52cb185..c0f94d7 100644
--- a/App.vue
+++ b/App.vue
@@ -30,4 +30,4 @@
text-align: justify;
color: #000000;
}
-
+
\ No newline at end of file
diff --git a/api/pages/homepage/homepage.js b/api/pages/homepage/homepage.js
index 45d91e5..be70248 100644
--- a/api/pages/homepage/homepage.js
+++ b/api/pages/homepage/homepage.js
@@ -43,3 +43,22 @@ export function checkSignApply(identity) {
},
})
}
+// 获取微信运动步数接口
+export function wxSportDecrypt(data) {
+ return request({
+ url: `/applet/register/wxSportDecrypt`,
+ method: 'post',
+ data,
+ })
+}
+
+// 微信运动自动添加积分接口
+export function wxsportadd(identity) {
+ return request({
+ url: `/applet/score/record/wxsport/add/${identity}/WX_SPORT_STEP_NUM`,
+ method: 'get',
+ header: {
+ region: uni.getStorageSync('region'),
+ },
+ })
+}
\ No newline at end of file
diff --git a/pages.json b/pages.json
index f81e6da..577957a 100644
--- a/pages.json
+++ b/pages.json
@@ -681,6 +681,13 @@
"navigationBarTitleText": "复诊记录",
"enablePullDownRefresh": false
}
+ }, {
+ "path" : "wxSport/wxSport",
+ "style" :
+ {
+ "navigationBarTitleText" : "微信运动",
+ "enablePullDownRefresh" : false
+ }
}
]
}, {
@@ -810,4 +817,4 @@
}
]
}
-}
\ No newline at end of file
+}
diff --git a/pages/homepage/homepage.vue b/pages/homepage/homepage.vue
index fcc1d5f..5480bfd 100644
--- a/pages/homepage/homepage.vue
+++ b/pages/homepage/homepage.vue
@@ -90,7 +90,9 @@
import {
getOpenId,
detail,
- checkSignApply
+ checkSignApply,
+ wxSportDecrypt,
+ wxsportadd
} from '@/api/pages/homepage/homepage.js'
import {
mapActions
@@ -116,15 +118,69 @@
this.openid = uni.getStorageSync('openid');
this.region = Number(uni.getStorageSync('region'))
if (this.userinfo && this.region != 3) {
+ this.checkSignApplyinfo();
+ }
+ if (uni.getStorageSync('userinfo')) {
+ this.wxSportDecryptinfo();
+ }
+ },
+ methods: {
+ wxSportDecryptinfo() {
+ let that = this
+ let currentDate = new Date();
+ let year = currentDate.getFullYear();
+ let month = currentDate.getMonth() + 1;
+ let day = currentDate.getDate();
+ month >= 1 && month <= 9 ? (month = "0" + month) : "";
+ day >= 0 && day <= 9 ? (day = "0" + day) : "";
+ let time = `${year}-${month}-${day}`
+ let wxsportaddtime = uni.getStorageSync('wxsportaddtime');
+ if (wxsportaddtime != time) {
+ wx.getSetting({
+ success: function(res) {
+ // 开启微信运动授权
+ if (res.authSetting['scope.werun']) {
+ // 在小程序中获取微信步数
+ wx.login({
+ success: function(res) {
+ if (res.code) {
+ wx.getWeRunData({
+ success: function(resp) {
+ that.wxSport(res, resp)
+ }
+ });
+ }
+ }
+ });
+ }
+ }
+ })
+ }
+ },
+ wxSport(res, resp) {
+ let obj = {
+ code: res.code,
+ encryptedData: resp.encryptedData,
+ iv: resp.iv
+ }
+ wxSportDecrypt(obj).then(Sportres => {
+ if (Sportres.data && Sportres.data[0].step >= 5000) {
+ wxsportadd(this.userinfo.cardNo).then(sportaddres => {
+ if (sportaddres.code == 200) {
+ uni.setStorageSync('wxsportaddtime', Sportres.data[0].date);
+ }
+ })
+ }
+ })
+ },
+ checkSignApplyinfo() {
checkSignApply(this.userinfo.cardNo).then(res => {
if (res.data) {
this.checkSign = res.data.code
this.infotitle = res.data.info
}
})
- } else {}
- },
- methods: {
+ },
...mapActions(["openPopup"]),
//跳转选择地址
city() {
diff --git a/pages/login/login.vue b/pages/login/login.vue
index 4b50a6e..a08b1a0 100644
--- a/pages/login/login.vue
+++ b/pages/login/login.vue
@@ -45,6 +45,7 @@
} from '../../api/pages/login/index.js'
import {
getCurrentUser,
+ wxSportDecrypt
} from '@/api/pages/homepage/homepage.js'
import {
createMobileToken
@@ -71,9 +72,15 @@
if (!uni.getStorageSync('location') || !uni.getStorageSync('region')) {
this.getAddress()
}
+ this.sportinfo();
this.phonecode = undefined
},
methods: {
+ sportinfo() {
+ wx.getWeRunData({
+ success: function(res) {}
+ });
+ },
nologin() {
this.$refs.uToast.show({
title: '请先阅读并同意《用户协议与隐私政策》',
@@ -231,4 +238,4 @@
+
\ No newline at end of file
diff --git a/pages/myinformation/myinformation.vue b/pages/myinformation/myinformation.vue
index f5d85e6..9398f50 100644
--- a/pages/myinformation/myinformation.vue
+++ b/pages/myinformation/myinformation.vue
@@ -503,15 +503,21 @@
},
//行为积分
goBehaviorpoints() {
- if (uni.getStorageSync('region') == 3) {
- this.$refs.uToast.show({
- title: '当前地区不支持,请选择其它地区',
- type: 'error',
- })
+ const value = uni.getStorageSync('userinfo');
+ const value2 = uni.getStorageSync('patientId');
+ if (value && value2) {
+ if (uni.getStorageSync('region') == 3) {
+ this.$refs.uToast.show({
+ title: '当前地区不支持,请选择其它地区',
+ type: 'error',
+ })
+ } else {
+ uni.navigateTo({
+ url: '/pagesB/Behaviorpoints/Behaviorpoints'
+ })
+ }
} else {
- uni.navigateTo({
- url: '/pagesB/Behaviorpoints/Behaviorpoints'
- })
+ this.gologin();
}
},
// 切换家庭成员
diff --git a/pagesB/Behaviorpoints/Behaviorpoints.scss b/pagesB/Behaviorpoints/Behaviorpoints.scss
index f227180..8a231c7 100644
--- a/pagesB/Behaviorpoints/Behaviorpoints.scss
+++ b/pagesB/Behaviorpoints/Behaviorpoints.scss
@@ -14,29 +14,42 @@
width: 100%;
height: 500rpx;
}
-
- .Exchangerecords {
- width: 180rpx;
+ .wxSport{
+ width: 25%;
height: 54rpx;
background: #00785C;
border-radius: 24rpx;
position: absolute;
bottom: 0%;
- right: 15%;
+ right: 6%;
+ color: #fff;
+ text-align: center;
+ border: 2rpx solid #00785C;
+ line-height: 54rpx;
+ }
+ .Exchangerecords {
+ width: 25%;
+ height: 54rpx;
+ background: #00785C;
+ border-radius: 24rpx;
+ position: absolute;
+ bottom: 0%;
+ left: 50%;
+ transform: translateX(-50%);
color: #fff;
text-align: center;
border: 2rpx solid #00785C;
line-height: 54rpx;
}
.PointsMall {
- width: 180rpx;
+ width: 25%;
height: 54rpx;
border: 2rpx solid #00785C;
background: #00785C;
border-radius: 24rpx;
position: absolute;
bottom: 0%;
- left: 15%;
+ left: 6%;
color: #fff;
text-align: center;
line-height: 54rpx;
diff --git a/pagesB/Behaviorpoints/Behaviorpoints.vue b/pagesB/Behaviorpoints/Behaviorpoints.vue
index 7f871c3..a1910b4 100644
--- a/pagesB/Behaviorpoints/Behaviorpoints.vue
+++ b/pagesB/Behaviorpoints/Behaviorpoints.vue
@@ -15,6 +15,9 @@
兑换记录
+
+ 微信运动
+
@@ -90,6 +93,11 @@
this.total = res.total
})
},
+ gowxSport() {
+ uni.navigateTo({
+ url: "/pagesC/wxSport/wxSport"
+ })
+ },
goexchange() {
uni.navigateTo({
url: '/pagesB/exchangerecords/exchangerecords'
diff --git a/pagesC/images/sport.png b/pagesC/images/sport.png
new file mode 100644
index 0000000..9a86518
Binary files /dev/null and b/pagesC/images/sport.png differ
diff --git a/pagesC/wxSport/wxSport.vue b/pagesC/wxSport/wxSport.vue
new file mode 100644
index 0000000..e3ea52a
--- /dev/null
+++ b/pagesC/wxSport/wxSport.vue
@@ -0,0 +1,164 @@
+
+
+
+
+
+
+ {{item.date}}
+
+
+
+
+ {{item.step}}
+
+
+ 步数
+
+
+
+
+
+
+
+
+
\ No newline at end of file