Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
089e0eb081 |
@@ -98,7 +98,8 @@ Page({
|
||||
_id: item._id,
|
||||
patientName: item.patient?.name || '',
|
||||
patientSexText: SEX_MAP[item.patient?.sex] || '',
|
||||
patientAge: item.patient?.age || 0,
|
||||
patientBirth: item.patient?.birth || '',
|
||||
patientAge: this.calcAge(item.patient?.birth),
|
||||
patientWeight: item.patient?.weight || 0,
|
||||
patientHeight: item.patient?.height || 0,
|
||||
patientMobile: item.patient?.mobile || '',
|
||||
@@ -137,6 +138,18 @@ Page({
|
||||
}
|
||||
},
|
||||
|
||||
// 根据出生年月(YYYY-MM-DD)计算年龄
|
||||
calcAge(birth) {
|
||||
if (!birth) return 0
|
||||
const d = new Date(birth)
|
||||
if (isNaN(d.getTime())) return 0
|
||||
const now = new Date()
|
||||
let age = now.getFullYear() - d.getFullYear()
|
||||
const m = now.getMonth() - d.getMonth()
|
||||
if (m < 0 || (m === 0 && now.getDate() < d.getDate())) age--
|
||||
return age > 0 ? age : 0
|
||||
},
|
||||
|
||||
formatDate(dateStr) {
|
||||
const d = new Date(dateStr)
|
||||
const year = d.getFullYear()
|
||||
@@ -206,12 +219,15 @@ Page({
|
||||
|
||||
onEditPatientInfo() {
|
||||
const record = this.data.record
|
||||
const now = new Date()
|
||||
const today = `${now.getFullYear()}-${String(now.getMonth() + 1).padStart(2, '0')}-${String(now.getDate()).padStart(2, '0')}`
|
||||
this.setData({
|
||||
today,
|
||||
editingPatient: true,
|
||||
editPatient: {
|
||||
name: record.patientName || '',
|
||||
sex: record.patientSexText === '男' ? 'male' : record.patientSexText === '女' ? 'female' : '',
|
||||
age: record.patientAge ? String(record.patientAge) : '',
|
||||
birth: record.patientBirth || '',
|
||||
weight: record.patientWeight ? String(record.patientWeight) : '',
|
||||
height: record.patientHeight ? String(record.patientHeight) : '',
|
||||
mobile: record.patientMobile || '',
|
||||
@@ -220,6 +236,10 @@ Page({
|
||||
})
|
||||
},
|
||||
|
||||
onPatientBirthChange(e) {
|
||||
this.setData({ 'editPatient.birth': e.detail.value })
|
||||
},
|
||||
|
||||
onPatientInfoInput(e) {
|
||||
const field = e.currentTarget.dataset.field
|
||||
const value = e.detail.value
|
||||
@@ -254,7 +274,7 @@ Page({
|
||||
API.escort.updateRecord(this.data.recordId, {
|
||||
'patient.name': patient.name.trim(),
|
||||
'patient.sex': patient.sex,
|
||||
'patient.age': parseInt(patient.age) || 0,
|
||||
'patient.birth': patient.birth || '',
|
||||
'patient.weight': parseFloat(patient.weight) || 0,
|
||||
'patient.height': parseFloat(patient.height) || 0,
|
||||
'patient.mobile': patient.mobile.trim(),
|
||||
|
||||
@@ -63,8 +63,10 @@
|
||||
</view>
|
||||
</view>
|
||||
<view class="edit-row">
|
||||
<text class="edit-label">年龄</text>
|
||||
<input class="edit-input" type="number" value="{{editPatient.age}}" placeholder="请输入年龄" data-field="age" bindinput="onPatientInfoInput" />
|
||||
<text class="edit-label">出生年月</text>
|
||||
<picker mode="date" value="{{editPatient.birth}}" end="{{today}}" bindchange="onPatientBirthChange">
|
||||
<view class="edit-input {{editPatient.birth ? '' : 'placeholder'}}">{{editPatient.birth || '请选择出生日期'}}</view>
|
||||
</picker>
|
||||
</view>
|
||||
<view class="edit-row">
|
||||
<text class="edit-label">体重(kg)</text>
|
||||
|
||||
+1
-1
@@ -212,7 +212,7 @@ Page({
|
||||
wx.login({
|
||||
success: (res) => {
|
||||
if (res.code) {
|
||||
API.user.wxSignin({ phoneNumber, code: res.code })
|
||||
API.user.wxSignin({ phoneNumber, phoneCode, code: res.code })
|
||||
.then((data) => {
|
||||
if (data.code == 0) {
|
||||
const app = getApp()
|
||||
|
||||
Reference in New Issue
Block a user