|
|
@ -19,8 +19,6 @@ |
|
|
|
</u-overlay> |
|
|
|
</view> |
|
|
|
<!-- 轮播图 --> |
|
|
|
|
|
|
|
|
|
|
|
<!-- #ifdef APP-PLUS --> |
|
|
|
<u-swiper class="swiper" :list="swiperList" @click="bannerClick" previousMargin="48rpx" nextMargin="80rpx" circular |
|
|
|
:autoplay="true" radius="32rpx" bgColor="rgba(0,0,0,0)" height="360rpx"> |
|
|
@ -60,9 +58,14 @@ |
|
|
|
<view class="steps"> |
|
|
|
<view class="content"> |
|
|
|
<view class="title">{{ i18n.TodaySteps }}</view> |
|
|
|
<view id="chart" :stepsNum="stepsNum" :stepTarget="stepTarget" :change:stepTarget="echarts.receive" |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<view id="chart" :stepsNum="stepsNum" :stepTarget="stepTarget" :change:stepTarget="echarts.stepTargetReceive" |
|
|
|
:change:stepsNum="echarts.receive" style="width: 280rpx;height:280rpx; font-size: 40rpx;"> |
|
|
|
</view> |
|
|
|
|
|
|
|
|
|
|
|
<!-- <canvas id="chart" ref="chart" style="width: 280rpx;height:280rpx; font-size: 40rpx;"></canvas> --> |
|
|
|
<u-button class="button" color="#00E8A2" @click="closeModalShow=true">{{ i18n.ReceiveEarnings }} |
|
|
|
</u-button> |
|
|
@ -88,20 +91,23 @@ |
|
|
|
<video class="video" v-show="videoShow" id="video" :enable-progress-gesture="false" autoplay="true" |
|
|
|
:src="videoUrl" controls x5-video-player-type="h5-page" @fullscreenchange="ifStopVideo"></video> |
|
|
|
<!-- 通知弹出层 --> |
|
|
|
<u-popup class="popup" v-if="popupShow" round="32rpx" mode="center" @close="popupShow = false" |
|
|
|
@open="popupShow = true" bgColor="#211F32" :customStyle="{ |
|
|
|
margin: 'auto 102rpx auto 118rpx', |
|
|
|
}"> |
|
|
|
<view class="content"> |
|
|
|
<scroll-view scroll-y="true" style="max-height: 288rpx;" scroll-with-animation="true" |
|
|
|
@touchmove.stop.prevent=""> |
|
|
|
<view class="" v-html="contentFirst"></view> |
|
|
|
</scroll-view> |
|
|
|
<u-button class="button" color="#00E8A2" @click="toRead" :throttleTime="500">OK</u-button> |
|
|
|
</view> |
|
|
|
</u-popup> |
|
|
|
<view class=""> |
|
|
|
<u-popup class="popup" :show="popupShow" round="32rpx" mode="center" @close="popupShow = false" |
|
|
|
@open="popupShow = true" bgColor="#211F32" :customStyle="{ |
|
|
|
margin: 'auto 102rpx auto 118rpx', |
|
|
|
}"> |
|
|
|
<view class="content"> |
|
|
|
<scroll-view scroll-y="true" style="max-height: 288rpx;" scroll-with-animation="true" |
|
|
|
@touchmove.stop.prevent=""> |
|
|
|
<view class="" v-html="contentFirst"></view> |
|
|
|
</scroll-view> |
|
|
|
<u-button class="button" color="#00E8A2" @click="toRead" :throttleTime="500">OK</u-button> |
|
|
|
</view> |
|
|
|
</u-popup> |
|
|
|
</view> |
|
|
|
|
|
|
|
|
|
|
|
<!-- <view class="" @click="startStep"> |
|
|
|
<!-- <view class="" @click="startStep"> |
|
|
|
开始记步 |
|
|
|
</view> |
|
|
|
<view class="" @click="startStep"> |
|
|
@ -122,7 +128,7 @@ |
|
|
|
// let videoPlayerObj = {}; |
|
|
|
let videoPlayer; |
|
|
|
let myChart; |
|
|
|
// let StepCounter = uni.requireNativePlugin('HF-Step-module'); |
|
|
|
let StepCounter = uni.requireNativePlugin('HF-Step-module'); |
|
|
|
export default { |
|
|
|
name: 'home', |
|
|
|
components: { |
|
|
@ -145,7 +151,7 @@ |
|
|
|
languageShow: false, |
|
|
|
langTrue: languageData[0].title || 'English', |
|
|
|
languageData, |
|
|
|
popupShow: true, |
|
|
|
popupShow: false, |
|
|
|
messageList: [], |
|
|
|
swiperList: [ |
|
|
|
|
|
|
@ -156,22 +162,18 @@ |
|
|
|
videoList: [], |
|
|
|
option: null, |
|
|
|
stepsNum: 0, // 当前步数 |
|
|
|
stepsNumString:'', // 传后台的步数 |
|
|
|
stepTarget: 10000, // 目标步数 |
|
|
|
stepTarget: 5000, // 目标步数 |
|
|
|
myChart: null, |
|
|
|
} |
|
|
|
}, |
|
|
|
onLoad() { |
|
|
|
this.stepsNum=uni.getStorageSync('coinTypeInfo').system_total_steps |
|
|
|
this.stepsNum=parseInt(this.stepsNum) |
|
|
|
this.stepsNumString=uni.getStorageSync('coinTypeInfo').system_total_steps |
|
|
|
this.baseURL = constant.BASE_URL |
|
|
|
this.getbanner(); |
|
|
|
this.noticeList(); |
|
|
|
this.getUserInfoBalance(); |
|
|
|
}, |
|
|
|
onShow() { |
|
|
|
// this.getSept() |
|
|
|
|
|
|
|
// 生成播放器队列对象 |
|
|
|
// this.videoList.forEach((item, index) => { |
|
|
|
// const VideoPlayer = uni.createVideoContext(`video-${index}`, this) |
|
|
@ -185,9 +187,17 @@ |
|
|
|
if (uni.getStorageSync('langTrue')) { |
|
|
|
this.langTrue = uni.getStorageSync('langTrue') |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// #ifdef APP-PLUS |
|
|
|
this.getSept() |
|
|
|
// this.startStep() |
|
|
|
// this.resStartStep() |
|
|
|
this.updateSteps(); |
|
|
|
// #endif |
|
|
|
// #ifdef H5 |
|
|
|
this.stepsNum=0; |
|
|
|
// #endif |
|
|
|
}, |
|
|
|
|
|
|
|
onHide() { |
|
|
|
this.stopAllVideoPlay() |
|
|
|
}, |
|
|
@ -197,6 +207,48 @@ |
|
|
|
} |
|
|
|
}, |
|
|
|
methods: { |
|
|
|
// 更新步数逻辑 |
|
|
|
updateSteps(){ |
|
|
|
var today=this.$index.formatyymmdd(new Date().getTime()); |
|
|
|
var stepsNum_date= uni.getStorageSync("stepsNum_date"); |
|
|
|
|
|
|
|
var isUpdate=false; |
|
|
|
console.log(today) |
|
|
|
console.log(uni.getStorageSync("stepsNum_date")) |
|
|
|
console.log(stepsNum_date) |
|
|
|
|
|
|
|
if(stepsNum_date){ |
|
|
|
if(today!=stepsNum_date.date){ |
|
|
|
uni.setStorageSync("stepsNum_date",null); |
|
|
|
|
|
|
|
}else{ |
|
|
|
if(this.stepsNum==0){ |
|
|
|
this.stepsNum=stepsNum_date.stepsNum; |
|
|
|
} |
|
|
|
if(parseInt(this.stepsNum)>parseInt(stepsNum_date.stepsNum)){ |
|
|
|
isUpdate=true; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
}else{ |
|
|
|
isUpdate=true; |
|
|
|
} |
|
|
|
|
|
|
|
if(isUpdate){ |
|
|
|
this.$api.updateSteps({ |
|
|
|
steps: this.stepsNum |
|
|
|
}).then(res => { |
|
|
|
console.log(res,'res更新') |
|
|
|
uni.setStorageSync("stepsNum_date",{ |
|
|
|
stepsNum:this.stepsNum, |
|
|
|
date:today |
|
|
|
}); |
|
|
|
}) |
|
|
|
} |
|
|
|
console.log(this.stepsNum) |
|
|
|
}, |
|
|
|
|
|
|
|
bannerClick(i){ |
|
|
|
// #ifdef APP-PLUS |
|
|
|
plus.runtime.openUrl(this.bannerList[i].adUrl) |
|
|
@ -215,42 +267,45 @@ |
|
|
|
}, |
|
|
|
// 捐步 |
|
|
|
closeConfirm() { |
|
|
|
this.$api.updateSteps({ |
|
|
|
steps: this.stepsNumString |
|
|
|
}).then(res => { |
|
|
|
this.$api.receivStepsAward().then(res => { |
|
|
|
uni.$u.toast(this.$t("markets").Succeeded) |
|
|
|
this.closeModalShow=false |
|
|
|
}) |
|
|
|
this.$api.receivStepsAward().then(res => { |
|
|
|
uni.$u.toast(this.$t("markets").Succeeded) |
|
|
|
this.closeModalShow=false |
|
|
|
}) |
|
|
|
|
|
|
|
}, |
|
|
|
// 开启计步服务 |
|
|
|
getSept() { |
|
|
|
//整个应用设置一次即可,停止计步后需重新调用,所有接口调用必须先开启计步服务 |
|
|
|
StepCounter.startStep((res) => { |
|
|
|
console.log(res, '步数res'); |
|
|
|
this.stepCount = res.stepCount |
|
|
|
//res.stepCount 当天累计步数 |
|
|
|
}, (res) => { |
|
|
|
console.log(res) |
|
|
|
let callback = res.callback |
|
|
|
if (callback == "stepStatus") { |
|
|
|
let status = res.status; |
|
|
|
if (1 == status) { |
|
|
|
//安卓gps定位服务未开 |
|
|
|
console.log('安卓gps定位服务未开') |
|
|
|
} else if (2 == status || 5 == status) { |
|
|
|
//权限被禁止 |
|
|
|
//this.gotoSettings() |
|
|
|
console.log('权限被禁止') |
|
|
|
} else if (3 == status) { |
|
|
|
//允许运动权限(处理安卓权限问题) |
|
|
|
//this.startStep() |
|
|
|
console.log('允许运动权限(处理安卓权限问题)') |
|
|
|
try{ |
|
|
|
//整个应用设置一次即可,停止计步后需重新调用,所有接口调用必须先开启计步服务 |
|
|
|
StepCounter.startStep((res) => { |
|
|
|
console.log(res, '步数res'); |
|
|
|
this.stepCount = res.stepCount |
|
|
|
this.stepsNum=res.stepCount; |
|
|
|
this.updateSteps(); |
|
|
|
//res.stepCount 当天累计步数 |
|
|
|
}, (res) => { |
|
|
|
console.log(res) |
|
|
|
let callback = res.callback |
|
|
|
if (callback == "stepStatus") { |
|
|
|
let status = res.status; |
|
|
|
if (1 == status) { |
|
|
|
//安卓gps定位服务未开 |
|
|
|
console.log('安卓gps定位服务未开') |
|
|
|
} else if (2 == status || 5 == status) { |
|
|
|
//权限被禁止 |
|
|
|
//this.gotoSettings() |
|
|
|
console.log('权限被禁止') |
|
|
|
} else if (3 == status) { |
|
|
|
//允许运动权限(处理安卓权限问题) |
|
|
|
//this.startStep() |
|
|
|
console.log('允许运动权限(处理安卓权限问题)') |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
}); |
|
|
|
}catch(e){ |
|
|
|
console.error("获取步数出错",e) |
|
|
|
} |
|
|
|
}, |
|
|
|
startStep() { |
|
|
|
//获取本次记录的步数,重启应用后需要重新开始记录 |
|
|
@ -258,9 +313,7 @@ |
|
|
|
//res.result == true 获取记录成功,否则错误 |
|
|
|
//res.stepCount 记录的步数 |
|
|
|
console.log(res.result) |
|
|
|
this.stepResult = res.result |
|
|
|
console.log(res.stepCount) |
|
|
|
this.stepResult = res.stepCount |
|
|
|
}); |
|
|
|
}, |
|
|
|
resStartStep() { |
|
|
@ -294,17 +347,15 @@ |
|
|
|
if (this.notice[i].isRead == 'no') { |
|
|
|
this.contentFirst = this.notice[i].content |
|
|
|
this.noticeId = this.notice[i].id |
|
|
|
this.popupShow = true |
|
|
|
} |
|
|
|
} |
|
|
|
// 如果循环都是已读的就关闭弹框 |
|
|
|
if (!this.noticeId) { |
|
|
|
this.popupShow = false |
|
|
|
} |
|
|
|
}, |
|
|
|
go(url) { |
|
|
|
uni.navigateTo({ |
|
|
|
url: url |
|
|
|
}) |
|
|
|
} |
|
|
|
}, |
|
|
|
// 读公告 |
|
|
|
toRead() { |
|
|
|
api.noticeRead({ |
|
|
|
noticeId: this.noticeId |
|
|
@ -315,10 +366,15 @@ |
|
|
|
console.log(res, '已经读了吗') |
|
|
|
}) |
|
|
|
}, |
|
|
|
go(url) { |
|
|
|
uni.navigateTo({ |
|
|
|
url: url |
|
|
|
}) |
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
// 公告 |
|
|
|
noticeList() { |
|
|
|
|
|
|
|
api.noticeList({}).then(res => { |
|
|
|
this.notice = res; |
|
|
|
for (var i = 0; i < res.length; i++) { |
|
|
@ -421,81 +477,7 @@ |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
initChart() { |
|
|
|
// let myChart = echarts.init(this.$refs.chart); |
|
|
|
// console.log(document); |
|
|
|
// console.log(this.$refs.chart); |
|
|
|
// this.myChart = echarts.init(document.getElementById('chart')); |
|
|
|
// this.myChart = echarts.init(this.$refs.chart); |
|
|
|
// myChart = echarts.init(document.getElementById('chart')) |
|
|
|
this.option = { |
|
|
|
title: { |
|
|
|
text: this.stepsNum, |
|
|
|
// 副标题 |
|
|
|
subtext: "", |
|
|
|
// 主副标题间距 |
|
|
|
itemGap: 0, |
|
|
|
left: 'center', |
|
|
|
top: 'center', |
|
|
|
// 主标题样式 |
|
|
|
textStyle: { |
|
|
|
fontSize: '20', |
|
|
|
color: '#fff' |
|
|
|
}, |
|
|
|
}, |
|
|
|
series: [{ |
|
|
|
name: '环形饼图', |
|
|
|
type: 'pie', |
|
|
|
radius: ['48%', '70%'], |
|
|
|
avoidLabelOverlap: false, |
|
|
|
label: { |
|
|
|
show: false, |
|
|
|
position: 'center' |
|
|
|
}, |
|
|
|
itemStyle: { |
|
|
|
// 设置扇形的阴影 |
|
|
|
shadowBlur: 30, |
|
|
|
shadowColor: '#15141F', |
|
|
|
shadowOffsetX: 'center', |
|
|
|
shadowOffsetY: 'center' |
|
|
|
|
|
|
|
}, |
|
|
|
data: [{ |
|
|
|
value: +this.stepsNum / this.stepTarget, |
|
|
|
name: '步数', |
|
|
|
itemStyle: { |
|
|
|
color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{ |
|
|
|
offset: .2, |
|
|
|
color: '#47BDFF' |
|
|
|
}, { |
|
|
|
offset: .5, |
|
|
|
color: '#34AEFF' |
|
|
|
}, { |
|
|
|
offset: 1, |
|
|
|
color: '#0589FF' |
|
|
|
}]), |
|
|
|
borderRadius: 800, |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
}, |
|
|
|
{ |
|
|
|
value: (this.stepTarget - this.stepsNum) / this.stepTarget, |
|
|
|
name: '剩余步数', |
|
|
|
itemStyle: { |
|
|
|
color: '#15141F', |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
] |
|
|
|
}] |
|
|
|
} |
|
|
|
|
|
|
|
// myChart.setOption(this.option, true); |
|
|
|
// window.addEventListener('resize', () => { |
|
|
|
// myChart.resize(); |
|
|
|
// }); |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
</script> |
|
|
@ -521,18 +503,24 @@ |
|
|
|
|
|
|
|
methods: { |
|
|
|
receive(newValue, oldValue, ownerVm, vm) { |
|
|
|
console.log('newValue', newValue) |
|
|
|
|
|
|
|
console.log(newValue,'变化') |
|
|
|
this.initEcharts() |
|
|
|
// if(!this.myChart){ |
|
|
|
// this.initEcharts() |
|
|
|
// }else{ |
|
|
|
// this.myChart.setOption(this.option) |
|
|
|
// } |
|
|
|
|
|
|
|
}, |
|
|
|
stepTargetReceive(newValue, oldValue, ownerVm, vm){ |
|
|
|
|
|
|
|
}, |
|
|
|
initEcharts() { |
|
|
|
this.initChart() |
|
|
|
myChart = echarts.init(document.getElementById('chart')) |
|
|
|
this.myChart = echarts.init(document.getElementById('chart')) |
|
|
|
// 观测更新的数据在 view 层可以直接访问到 |
|
|
|
myChart.setOption(this.option) |
|
|
|
}, |
|
|
|
updateEcharts(newValue, oldValue, ownerInstance, instance) { |
|
|
|
// 监听 service 层数据变更 |
|
|
|
myChart.setOption(newValue) |
|
|
|
this.myChart.setOption(this.option) |
|
|
|
// console.log('变化initEcharts') |
|
|
|
}, |
|
|
|
onClick(event, ownerInstance) { |
|
|
|
// 调用 service 层的方法 |
|
|
|