feat: init project with miniprogram, cloud functions and admin console
这个提交包含在:
@@ -0,0 +1,57 @@
|
||||
var http = require('../../utils/request')
|
||||
var ble = require('../../services/ble')
|
||||
var app = getApp()
|
||||
|
||||
Page({
|
||||
data: {
|
||||
sessionId: '',
|
||||
regions: 0,
|
||||
duration: 0,
|
||||
avgPd: 0,
|
||||
durationText: '',
|
||||
regionNames: [],
|
||||
syncing: false,
|
||||
synced: false
|
||||
},
|
||||
|
||||
onLoad: function (options) {
|
||||
var durationMs = parseInt(options.duration) || 0
|
||||
var mins = Math.floor(durationMs / 60000)
|
||||
var secs = Math.floor((durationMs % 60000) / 1000)
|
||||
|
||||
this.setData({
|
||||
sessionId: options.session_id || '',
|
||||
regions: parseInt(options.regions) || 0,
|
||||
duration: durationMs,
|
||||
avgPd: options.avg_pd || 0,
|
||||
durationText: mins + '分' + secs + '秒',
|
||||
regionNames: ble.getRegionName(parseInt(options.regions) || 0)
|
||||
})
|
||||
|
||||
this.syncRecord()
|
||||
},
|
||||
|
||||
syncRecord: function () {
|
||||
var self = this
|
||||
self.setData({ syncing: true })
|
||||
|
||||
http.post('/api/v1/treatment/sync', {
|
||||
session_id: self.data.sessionId,
|
||||
device_id: ble.getDeviceId(),
|
||||
start_time: new Date(Date.now() - self.data.duration).toISOString(),
|
||||
end_time: new Date().toISOString(),
|
||||
regions: self.data.regions,
|
||||
total_duration_ms: self.data.duration,
|
||||
mode: 0,
|
||||
avg_pd: self.data.avgPd
|
||||
}).then(function () {
|
||||
self.setData({ syncing: false, synced: true })
|
||||
}).catch(function () {
|
||||
self.setData({ syncing: false, synced: false })
|
||||
})
|
||||
},
|
||||
|
||||
onBackHome: function () {
|
||||
wx.switchTab({ url: '/pages/index/index' })
|
||||
}
|
||||
})
|
||||
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"navigationBarTitleText": "护理完成"
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
<view class="container">
|
||||
<view class="card text-center">
|
||||
<view class="done-icon">✓</view>
|
||||
<view class="section-title">护理完成</view>
|
||||
</view>
|
||||
|
||||
<view class="card">
|
||||
<view class="flex-between mb-20">
|
||||
<text>护理时长</text>
|
||||
<text>{{durationText}}</text>
|
||||
</view>
|
||||
<view class="flex-between mb-20">
|
||||
<text>护理区域</text>
|
||||
<text class="text-muted">{{regionNames.join('、')}}</text>
|
||||
</view>
|
||||
<view class="flex-between">
|
||||
<text>平均光功率密度</text>
|
||||
<text>{{avgPd}}</text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="card text-center">
|
||||
<view wx:if="{{syncing}}" class="text-muted">
|
||||
<view class="spinner-sm"></view>
|
||||
<text>正在同步记录...</text>
|
||||
</view>
|
||||
<view wx:elif="{{synced}}" class="text-success">记录已同步</view>
|
||||
<view wx:else class="text-error">同步失败,可稍后在护理记录中重试</view>
|
||||
</view>
|
||||
|
||||
<view class="btn-area-fixed">
|
||||
<view class="btn-primary" bindtap="onBackHome">返回首页</view>
|
||||
</view>
|
||||
</view>
|
||||
@@ -0,0 +1,25 @@
|
||||
.done-icon {
|
||||
width: 120rpx;
|
||||
height: 120rpx;
|
||||
border-radius: 50%;
|
||||
background-color: #52c41a;
|
||||
color: #ffffff;
|
||||
font-size: 72rpx;
|
||||
line-height: 120rpx;
|
||||
text-align: center;
|
||||
margin: 40rpx auto;
|
||||
}
|
||||
|
||||
.spinner-sm {
|
||||
width: 40rpx;
|
||||
height: 40rpx;
|
||||
border: 4rpx solid #eeeeee;
|
||||
border-top-color: #333333;
|
||||
border-radius: 50%;
|
||||
animation: spin 0.8s linear infinite;
|
||||
margin: 0 auto 12rpx;
|
||||
}
|
||||
|
||||
@keyframes spin {
|
||||
to { transform: rotate(360deg); }
|
||||
}
|
||||
在新工单中引用
屏蔽一个用户