Commit c7306330 by 穆启卓

canvas和image切换法解决canvas真机层级问题

parent 91a97b7b
...@@ -16,6 +16,7 @@ Page({ ...@@ -16,6 +16,7 @@ Page({
scene: 1001, scene: 1001,
progressCanvasContext: '', progressCanvasContext: '',
progressCanvasRate: '', progressCanvasRate: '',
progressCanvasImage: '',
}, },
onShow() { onShow() {
...@@ -65,7 +66,20 @@ Page({ ...@@ -65,7 +66,20 @@ Page({
context.arc(-245 * rate, 0, 7 * rate, 0, 2 * Math.PI, false); context.arc(-245 * rate, 0, 7 * rate, 0, 2 * Math.PI, false);
context.fill(); context.fill();
// 画 // 画
context.draw(); context.draw(false, drawRes => {
if (drawRes.errMsg === 'drawCanvas:ok') {
wx.canvasToTempFilePath({
canvasId: 'progressCanvas',
success:(ImageRes) => {
this.setData({
progressCanvasImage: ImageRes.tempFilePath
});
}
});
} else {
// 重画
}
});
}, },
getPageData() { getPageData() {
...@@ -277,9 +291,10 @@ Page({ ...@@ -277,9 +291,10 @@ Page({
setData.currentSteps = (resData.step_data && resData.step_data[0]) ? resData.step_data[0].step : 0; setData.currentSteps = (resData.step_data && resData.step_data[0]) ? resData.step_data[0].step : 0;
} }
this.setData(setData); this.setData(setData);
wx.hideLoading();
this.showToast(); this.showToast();
}, },
complete: () => { fail: () => {
wx.hideLoading(); wx.hideLoading();
} }
}); });
...@@ -364,7 +379,20 @@ Page({ ...@@ -364,7 +379,20 @@ Page({
context.arc(-245 * rate, 0, 7 * rate, 0, 2 * Math.PI, false); context.arc(-245 * rate, 0, 7 * rate, 0, 2 * Math.PI, false);
context.fill(); context.fill();
// 画 // 画
context.draw(); context.draw(false, drawRes => {
if (drawRes.errMsg === 'drawCanvas:ok') {
wx.canvasToTempFilePath({
canvasId: 'progressCanvas',
success:(ImageRes) => {
this.setData({
progressCanvasImage: ImageRes.tempFilePath
});
}
});
} else {
this.drawProgressCanvas();
}
});
}, },
// 获取微信步数失败处理,包括未授权、设备不支持等 // 获取微信步数失败处理,包括未授权、设备不支持等
...@@ -501,7 +529,6 @@ Page({ ...@@ -501,7 +529,6 @@ Page({
}); });
}, },
// 暂留================================================================== // 暂留==================================================================
// 通过code2session方式拿unionid // 通过code2session方式拿unionid
......
...@@ -7,7 +7,8 @@ ...@@ -7,7 +7,8 @@
<view>说明</view> <view>说明</view>
</view> </view>
<view class="today-step-info" bindtap="clickStepData"> <view class="today-step-info" bindtap="clickStepData">
<canvas class="progress-canvas" canvas-id="progressCanvas"></canvas> <image class="progress-canvas" src="{{progressCanvasImage}}" wx:if="{{activityExplainShow || showGetUserInfo}}"></image>
<canvas class="progress-canvas" canvas-id="progressCanvas" hidden="{{activityExplainShow || showGetUserInfo}}"></canvas>
<block wx:if="{{stepAuth}}"> <block wx:if="{{stepAuth}}">
<view class="info-title">今日步数</view> <view class="info-title">今日步数</view>
<view class="today-step-num">{{currentSteps}}</view> <view class="today-step-num">{{currentSteps}}</view>
...@@ -35,7 +36,7 @@ ...@@ -35,7 +36,7 @@
</view> </view>
</view> </view>
<!-- 活动说明弹窗 --> <!-- 活动说明弹窗 -->
<view class="activity-explain-popup-bg" wx:if="{{activityExplainShow}}"> <view class="activity-explain-popup-bg" catchtouchmove wx:if="{{activityExplainShow}}">
<view class="activity-explain-popup-container"> <view class="activity-explain-popup-container">
<view class="popup-title">活动说明</view> <view class="popup-title">活动说明</view>
<view class="popup-explain">本小程序仅用于记录您的步数明细数据,获取步数数据成功后,返回报名页面,即打卡成功</view> <view class="popup-explain">本小程序仅用于记录您的步数明细数据,获取步数数据成功后,返回报名页面,即打卡成功</view>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment