This commit is contained in:
2024-01-31 14:45:23 +08:00
parent faf4664e4d
commit 2941522404
10 changed files with 301 additions and 21 deletions

View File

@ -30,4 +30,4 @@
text-align: justify;
color: #000000;
}
</style>
</style>

View File

@ -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'),
},
})
}

View File

@ -681,6 +681,13 @@
"navigationBarTitleText": "复诊记录",
"enablePullDownRefresh": false
}
}, {
"path" : "wxSport/wxSport",
"style" :
{
"navigationBarTitleText" : "微信运动",
"enablePullDownRefresh" : false
}
}
]
}, {
@ -810,4 +817,4 @@
}
]
}
}
}

View File

@ -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() {

View File

@ -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 @@
<style lang="scss">
@import "./login.scss";
</style>
</style>

View File

@ -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();
}
},
//

View File

@ -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;

View File

@ -15,6 +15,9 @@
<view class="Exchangerecords" @tap="goexchange" :style="region!=2?'bottom:15%':''">
兑换记录
</view>
<view class="wxSport" @tap="gowxSport" :style="region!=2?'bottom:15%':''">
微信运动
</view>
</view>
<view class="bottomitem">
<view class="PointsRecord">
@ -90,6 +93,11 @@
this.total = res.total
})
},
gowxSport() {
uni.navigateTo({
url: "/pagesC/wxSport/wxSport"
})
},
goexchange() {
uni.navigateTo({
url: '/pagesB/exchangerecords/exchangerecords'

BIN
pagesC/images/sport.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

164
pagesC/wxSport/wxSport.vue Normal file
View File

@ -0,0 +1,164 @@
<template>
<view class="app">
<view class="item" v-for="item in list" :key="item.date">
<view class="left">
<image mode="" :src="require('@/pagesC/images/sport.png')" @tap="goconsultationplatform"></image>
<view class="time">
{{item.date}}
</view>
</view>
<view class="right">
<view class="number">
{{item.step}}
</view>
<view class="text">
步数
</view>
</view>
</view>
</view>
</template>
<script>
import {
wxSportDecrypt,
wxsportadd
} from '@/api/pages/homepage/homepage.js'
export default {
data() {
return {
list: undefined,
userinfo: undefined,
};
},
onShow() {
this.userinfo = uni.getStorageSync('userinfo')
this.getStepInfo();
},
methods: {
wxSport(res, resp) {
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');
let obj = {
code: res.code,
encryptedData: resp.encryptedData,
iv: resp.iv
}
wxSportDecrypt(obj).then(Sportres => {
this.list = Sportres.data
if (wxsportaddtime != time) {
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);
}
})
}
}
})
},
getStepInfo() {
let that = this
wx.getSetting({
success: function(res) {
//
if (!res.authSetting['scope.werun']) {
wx.showModal({
title: '提示',
content: '获取微信运动步数,需要开启计步权限',
success: function(resp) {
if (resp.confirm) {
//
wx.openSetting({
success: function(respp) {}
})
}
}
})
} else {
wx.login({
success: function(loginres) {
if (loginres.code) {
wx.getWeRunData({
success: function(WeRunDatares) {
that.wxSport(loginres, WeRunDatares)
}
});
}
},
fail: function(err) {
wx.showModal({
title: '提示',
content: '未开通微信运动,请关注“微信运动”公众号后重试',
showCancel: false,
confirmText: '知道了'
})
}
});
}
}
})
},
}
}
</script>
<style lang="scss">
.app {
width: 100%;
padding-bottom: 50rpx;
.item {
width: 96%;
margin: 20rpx auto;
height: 200rpx;
background-color: #fff;
display: flex;
align-items: center;
border-radius: 10rpx;
.right {
width: 44%;
height: 160rpx;
margin: 20rpx 0;
font-weight: bold;
color: #333333;
text-align: center;
.text {
line-height: 60rpx;
}
.number {
line-height: 100rpx;
font-size: 56rpx;
}
}
.left {
width: 54%;
display: flex;
align-items: center;
height: 160rpx;
margin: 20rpx 0;
border-right: 2rpx solid #DBDBDB;
image {
width: 90rpx;
height: 90rpx;
}
.time {
font-size: 32rpx;
color: #999999;
}
}
}
}
</style>