From 3ee4341aaacb800920f1af4ab9032b3bb656f54a Mon Sep 17 00:00:00 2001 From: qsj <731458905@qq.com> Date: Wed, 13 Mar 2024 11:10:54 +0800 Subject: [PATCH] =?UTF-8?q?bug=E4=BF=AE=E6=94=B9bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/face_report/face_report.less | 108 +++++++++ src/pages/face_report/face_report.tsx | 246 +++++++++++++++++++- src/pages/index/index.tsx | 13 +- src/pages/instrumentClickinUpload/index.tsx | 15 +- src/pages/recording/recording.tsx | 102 ++++++-- src/utils/util.js | 3 +- 6 files changed, 447 insertions(+), 40 deletions(-) diff --git a/src/pages/face_report/face_report.less b/src/pages/face_report/face_report.less index b968567..2dbd436 100644 --- a/src/pages/face_report/face_report.less +++ b/src/pages/face_report/face_report.less @@ -66,6 +66,114 @@ page { margin: 48rpx 0 34rpx; } +.van-popup { + border-radius: 30rpx; + .popBox { + box-sizing: border-box; + width: 670rpx; + height: 840rpx; + background: #ffffff; + border-radius: 30rpx; + position: relative; + padding: 42rpx 30rpx 0; + .close_icon { + position: absolute; + width: 50rpx; + height: 50rpx; + top: 34rpx; + right: 34rpx; + } + .popTitle { + font-size: 36rpx; + text-align: center; + font-family: PingFang SC; + font-weight: bold; + } + .popSubtitle { + display: flex; + justify-content: center; + align-items: flex-end; + font-size: 28rpx; + text-align: center; + margin-top: 50rpx; + .bold { + font-size: 38rpx; + font-weight: bold; + } + } + .img_box { + margin: 58rpx 0 37rpx 0; + display: flex; + flex-wrap: wrap; + + .img { + position: relative; + margin-right: 35rpx; + .closeImg { + position: absolute; + top: 10rpx; + right: 10rpx; + width: 30rpx; + } + } + .img:last-child { + margin-right: 0; + } + .addBox { + width: 180rpx; + height: 180rpx; + background: #ffffff; + border: 1px solid #dddddd; + border-radius: 20rpx; + display: flex; + justify-content: center; + align-items: center; + Image { + width: 40rpx; + } + } + .showImg { + width: 180rpx; + height: 180rpx; + border-radius: 20rpx; + } + } + .info4 { + position: relative; + textarea { + padding: 28rpx 30rpx; + width: 610rpx; + height: 186rpx; + background: #ffffff; + border: 1px solid #dddddd; + border-radius: 3rpx; + box-sizing: border-box; + } + .tip { + position: absolute; + right: 20rpx; + bottom: 22rpx; + font-size: 22rpx; + font-family: PingFang SC; + font-weight: 500; + color: #cccccc; + } + } + .btn1 { + font-style: normal; + width: 270rpx; + height: 90rpx; + line-height: 90rpx; + background: #000000; + text-align: center; + border-radius: 45rpx; + font-size: 32rpx; + font-weight: bold; + margin-top: 55rpx; + color: #ffffff; + } + } +} .footer { position: fixed; z-index: 99; diff --git a/src/pages/face_report/face_report.tsx b/src/pages/face_report/face_report.tsx index e6ec885..7785e9a 100644 --- a/src/pages/face_report/face_report.tsx +++ b/src/pages/face_report/face_report.tsx @@ -2,8 +2,11 @@ import Taro from "@tarojs/taro"; import classnames from "classnames"; import { Component, PropsWithChildren, useEffect, useState } from "react"; import { Progress } from "@antmjs/vantui"; - -import { Block, View, Text, Image, Input, Button } from "@tarojs/components"; +import { showModal } from "../../utils/traoAPI.js"; +import { Tab, Tabs, Dialog, Popup } from "@antmjs/vantui"; +import { + Block, View, Text, Image, Input, Button, Textarea, +} from "@tarojs/components"; import { date, getdates, previewImage } from "../../utils/util"; /** 自定义组件 **/ @@ -22,13 +25,38 @@ export default class Index extends Component { statistics: {}, recordList: [], recordData: {}, + year: new Date().getFullYear(), + show: false, + clockStatistics: [], + punchInInfo: { + clockImageList: [], + clockContent: "", + }, + monthTime: [ + { month: 1, time: 0 }, + { month: 2, time: 0 }, + { month: 3, time: 0 }, + { month: 4, time: 0 }, + { month: 5, time: 0 }, + { month: 6, time: 0 }, + { month: 7, time: 0 }, + { month: 8, time: 0 }, + { month: 9, time: 0 }, + { month: 10, time: 0 }, + { month: 11, time: 0 }, + { month: 12, time: 0 }, + ], }; } - componentDidMount() {} + componentDidMount() { } - componentWillUnmount() {} + componentWillUnmount() { } + // 打开/关闭弹窗 + setShow(show: boolean) { + this.setState({ show }); + } // 查询用户护理记录的当月统计信息 async getStatistics(id) { let data = {}; @@ -67,7 +95,142 @@ export default class Index extends Component { }); } } + // 文本框输入文字 + handleTextareaInput = (e) => { + const punchInInfo = this.state.punchInInfo; + this.setState({ punchInInfo: { ...punchInInfo, clockContent: e.detail.value } }); + }; + async submit() { + let punchInInfo = this.state.punchInInfo || {}; + if (!punchInInfo.clockImageList.length) { + Taro.showToast({ + title: "请上传图片", + icon: "none", + }); + return; + } + if (!punchInInfo.clockContent) { + Taro.showToast({ + title: "请输入打卡心得", + icon: "none", + }); + return; + } + InstrumentInfo.apiClock.postInsertClockLog(punchInInfo).then((res) => { + showModal({ + t2: "您已完成今日打卡", + btn1show: false, + }).then(() => { + let data = new Date + Taro.setStorageSync('DayTime', data.toISOString()) + this.setState({ + clockShow: true + }) + this.getClockStatistics(); + this.setShow(false); + + }); + }); + } + /**分页获取用户的打卡记录 page size*/ + async getClockStatistics(year = this.state.year) { + let res = await InstrumentInfo.apiClock.getClockStatistics({ year }); + console.log(res,'查看返回',year); + + if (res.data.code === 200) { + res.data.data.reverse(); + if (res.data.data.length > 0) { + res.data.data.map((item, index) => { + item.isMore = false; + item.detail = []; + if (index === 0) { + item.isMore = true; + this.getList(item.id, item.year, item.month); + } + this.state.monthTime.map((monthItem) => { + if (monthItem.month == item.month) { + monthItem.time = item.clockNum; + } + }); + }); + this.setState({ monthTime: this.state.monthTime }); + } else { + let monthTime = [ + { month: 1, time: 0 }, + { month: 2, time: 0 }, + { month: 3, time: 0 }, + { month: 4, time: 0 }, + { month: 5, time: 0 }, + { month: 6, time: 0 }, + { month: 7, time: 0 }, + { month: 8, time: 0 }, + { month: 9, time: 0 }, + { month: 10, time: 0 }, + { month: 11, time: 0 }, + { month: 12, time: 0 }, + ]; + this.setState({ monthTime }); + } + this.setState({ clockStatistics: res.data.data }); + } + } + // 获取当月打卡记录 + async getList(id, year, month) { + let data = { + year, + month, + }; + let res = await InstrumentInfo.apiClock.getList(data); + if (res.data.code === 200) { + console.log(this.state.clockStatistics, 88888); + + this.state.clockStatistics.map((item) => { + if (item.id === id) { + item.detail = res.data.data; + item.detail.map((obj) => { + obj.updateTime = getdates(obj.updateTime).replace(/-/g, "."); + }); + } + }); + this.setState({ clockStatistics: this.state.clockStatistics }); + } + } +// 上传图片 +handleChooseImage() { + Taro.chooseMedia({ + count: 1, + mediaType: ["image"], + sourceType: ["album", "camera"], + success: (res) => { + const tempFilePaths = res.tempFiles.map((item) => item.tempFilePath); + tempFilePaths?.forEach((item) => { + // eslint-disable-next-line @typescript-eslint/no-shadow + InstrumentInfo.apiClock + .clockFileUpload({ clockImg: item }) + .then((res) => { + const currentImage = res.data.url; + const newImageList = + this.state.punchInInfo.clockImageList.length >= 3 + ? this.state.punchInInfo.clockImageList + : [...this.state.punchInInfo.clockImageList, currentImage]; + const punchInInfo = this.state.punchInInfo; + punchInInfo.clockImageList = newImageList; + this.setState({ punchInInfo }); + }); + }); + }, + fail: (err) => { + console.info("err", err); + }, + }); +} +// 删除打卡图片 +delImg(i) { + const punchInInfo = this.state.punchInInfo; + punchInInfo.clockImageList.splice(i, 1); + this.setState({ punchInInfo }); +} getRouteId() { const searchParams = new URLSearchParams(window.location.search); const id = searchParams.get("id"); @@ -89,20 +252,21 @@ export default class Index extends Component { } async onLoad() { this.getRouteId(); + this.getClockStatistics() } - componentDidShow() {} + componentDidShow() { } - componentDidHide() {} + componentDidHide() { } - async initData() {} + async initData() { } GoIndex = () => { Taro.switchTab({ url: "/pages/index/index" }); }; render() { - let { name, statistics, recordList, recordData } = this.state; + let { name, statistics, recordList, recordData, show,clockStatistics,punchInInfo,monthTime } = this.state; return ( @@ -223,7 +387,7 @@ export default class Index extends Component { - 前往打卡 + 前往打卡 跳过 { > + this.setState({ show: false })}> + + + 今日打卡 + + 本月您已打卡 + {clockStatistics[0]?.clockNum}{" "} + 天,超越 + + {(clockStatistics[0]?.percentage * 100).toFixed(1)}% + + 花至用户 + + + {punchInInfo.clockImageList.map((item, index) => ( + + + + + ))} + {punchInInfo.clockImageList.length < 3 && ( + + + + )} + + + + + + + {"(" + (punchInInfo.clockContent.length || 0) + "/120)"} + + + + + 确认提交 + + + + ); } diff --git a/src/pages/index/index.tsx b/src/pages/index/index.tsx index ccb37ee..c1274ce 100644 --- a/src/pages/index/index.tsx +++ b/src/pages/index/index.tsx @@ -108,6 +108,7 @@ class Index extends Component { BeforeBindingErrorText: "", // 绑定前校验错误文本 instrumentList: [], // 仪器列表 + ViewAddInstrument: true, // 查看是否添加有仪器 unbindingInstrumentList: [], // 未绑定仪器列表 instrumentInfo: { // 扫码获得的序列号仪器 @@ -407,7 +408,9 @@ class Index extends Component { // 护理记录 toNursingRecords = () => { - go("/pages/recording/recording"); + let { ViewAddInstrument } = this.state; + // go(`/pages/recording/recording?param1=${param1Value}`); + go(`/pages/recording/recording?param=${ViewAddInstrument}`); }; gourl = (e) => { @@ -473,8 +476,13 @@ class Index extends Component { mask: true, }); let { data: res } = await InstrumentInfo.bindingInstrumentList(); - Taro.hideLoading(); + console.log(res,'查看绑定的设备'); + + // Taro.hideLoading(); if (res.code === 200) { + if(res.data.length === 0){ + this.setState({ ViewAddInstrument: false }); + } this.setState({ instrumentList: res.data }); } else { // 仪器列表失败todo @@ -951,6 +959,7 @@ class Index extends Component { isExchangeBinding, instrumentInfo, instrumentList, + ViewAddInstrument, showEquipment, // 升级弹窗 diff --git a/src/pages/instrumentClickinUpload/index.tsx b/src/pages/instrumentClickinUpload/index.tsx index 9d2b6d3..b75b3e7 100644 --- a/src/pages/instrumentClickinUpload/index.tsx +++ b/src/pages/instrumentClickinUpload/index.tsx @@ -55,7 +55,7 @@ export default class InstrumentClickInUpload extends Component { secondClockImg: null, thirdClockImg: null, }, - clockcontents: "", + // 现在选中的数据 currentInfo: { modeVideo: "", @@ -122,6 +122,7 @@ export default class InstrumentClickInUpload extends Component { }; // 获取最新一条打卡记录 getLatestClockRecord = async () => { + let { punchInInfo } = this.state; let res = await InstrumentInfo.apiClock.getLatestClockRecord(); if (res.data.code === 200) { @@ -260,8 +261,10 @@ export default class InstrumentClickInUpload extends Component { videoLoadedMetaData = async () => {}; - handleTextareaInput = async (e) => { - this.setState({ punchInInfo: { clockContent: e.detail.value } }); + handleTextareaInput = (e) => { + const punchInInfo = this.state.punchInInfo; + this.setState({ punchInInfo: { ...punchInInfo,clockContent: e.detail.value } }); + }; onModeLockOpen = async () => { @@ -292,7 +295,7 @@ export default class InstrumentClickInUpload extends Component { punchInInfo, isTipShow, currentInfo, - clockcontents, + clockcontent, modeInfo, nurseInfo, isModeLock, @@ -304,7 +307,6 @@ export default class InstrumentClickInUpload extends Component { stepIndex, autoPlay, sysInfo, - clockContent, } = this.state; return ( @@ -476,7 +478,7 @@ export default class InstrumentClickInUpload extends Component { placeholder-className="placeh和给g'holder" maxlength={100} onInput={this.handleTextareaInput} - value={clockcontents} + value={punchInInfo.clockContent} placeholder="请记录一下今天打卡的心得吧~" > {/* {tipshow && ( @@ -488,6 +490,7 @@ export default class InstrumentClickInUpload extends Component { )} */} {punchInInfo.clockContent.length}/100 + {/* {punchInInfo.clockContent.length}/100 */} diff --git a/src/pages/recording/recording.tsx b/src/pages/recording/recording.tsx index 66f5516..793d860 100644 --- a/src/pages/recording/recording.tsx +++ b/src/pages/recording/recording.tsx @@ -32,9 +32,11 @@ export default class Recording extends Component { this.state = { name: "护理历程", current: 0, + ViewAddInstrument:false, //用来记录有没有添加设备 array: [1, 2, 3, 4, 5], recordList: [], bindingInstrumentList: [], + clockShow: false, curIndex: null, clockStatistics: [], statistics: [], @@ -62,9 +64,9 @@ export default class Recording extends Component { }; } - componentDidMount() {} + componentDidMount() { } - componentWillUnmount() {} + componentWillUnmount() { } // 格式化时间 getTime(time) { const hour = time.slice(0, 2); @@ -86,15 +88,21 @@ export default class Recording extends Component { } // 获取护理历程 async getRecord(id) { + let data = {}; if (id != null) { data["instrumentId"] = id; } let res = await InstrumentInfo.apiNursingLog.getRecord(data); + + if (res.data.code === 200) { res.data.rows.map((item) => { item.nursingTime = this.getTime(item.nursingTime); - item.createTime = getdates(item.createTime).replace(/-/g, "."); + let createTime = getdates(item.createTime) + + + item.createTime = createTime&& createTime.replace(/-/g, "."); }); this.setState({ recordList: res.data.rows }); } @@ -133,7 +141,9 @@ export default class Recording extends Component { /**分页获取用户的打卡记录 page size*/ async getClockStatistics(year = this.state.year) { let res = await InstrumentInfo.apiClock.getClockStatistics({ year }); + if (res.data.code === 200) { + res.data.data.reverse(); if (res.data.data.length > 0) { res.data.data.map((item, index) => { @@ -172,7 +182,8 @@ export default class Recording extends Component { } // 文本框输入文字 handleTextareaInput = (e) => { - this.setState({ punchInInfo: { clockContent: e.detail.value } }); + const punchInInfo = this.state.punchInInfo; + this.setState({ punchInInfo: { ...punchInInfo, clockContent: e.detail.value } }); }; // 打开/关闭弹窗 setShow(show: boolean) { @@ -205,32 +216,68 @@ export default class Recording extends Component { }; let res = await InstrumentInfo.apiClock.getList(data); if (res.data.code === 200) { - console.log(this.state.clockStatistics, 88888); + console.log(res, 88888,this.state.clockStatistics,id); this.state.clockStatistics.map((item) => { if (item.id === id) { item.detail = res.data.data; item.detail.map((obj) => { - obj.updateTime = getdates(obj.updateTime).replace(/-/g, "."); + + let updateTime =getdates(obj.updateTime) + + obj.updateTime = updateTime && updateTime.replace(/-/g, "."); }); } }); this.setState({ clockStatistics: this.state.clockStatistics }); } } + async DayTime() { + let storedData = Taro.getStorageSync('DayTime') + const day = new Date(); + if (storedData === undefined || storedData === "") { + + this.setState({ + clockShow: false + }) + + } else { + + const storedDate = new Date(storedData); + const currentDate = new Date(day.toISOString()); + + const isSameDate = storedDate.toDateString() === currentDate.toDateString(); + if (isSameDate) { + this.setState({ + clockShow: true + }) + } else { + this.setState({ + clockShow: false + }) + } + } + - async onLoad() { + } + async onLoad(options) { + const ViewAddInstrument = options.param; + this.setState({ + ViewAddInstrument: ViewAddInstrument + }) + this.getRecord(null); this.getBindingInstrumentList(); this.getLatestClockRecord(); this.getClockStatistics(); + this.DayTime() } - componentDidShow() {} + componentDidShow() { } - componentDidHide() {} + componentDidHide() { } - async initData() {} + async initData() { } // 选择年份 onChangeYear(event) { this.setState({ year: event.detail.value }); @@ -304,7 +351,14 @@ export default class Recording extends Component { t2: "您已完成今日打卡", btn1show: false, }).then(() => { + let data = new Date + Taro.setStorageSync('DayTime', data.toISOString()) + this.setState({ + clockShow: true + }) + this.getClockStatistics(); this.setShow(false); + }); }); } @@ -319,7 +373,9 @@ export default class Recording extends Component { array, name, recordList, + ViewAddInstrument, bindingInstrumentList, + clockShow, curIndex, clockStatistics, statistics, @@ -328,7 +384,6 @@ export default class Recording extends Component { monthTime, show, punchInInfo, - clockContent, } = this.state; return ( @@ -433,10 +488,10 @@ export default class Recording extends Component { tag_active: item.online === 2, })} > - {item.online ? "在线" : "离线"} + {item.online === 1 ? "在线" : "离线"} - {item.instrumentType === 2 && ( + {item.instrumentType === 1 && ( { ))} - 小紫弹智能射频仪、花至抗老射频仪PRO{" "} + {/* 小紫弹智能射频仪、花至抗老射频仪PRO{" "} */} + {obj.instrumentName === null ? "" : obj.instrumentName} {obj.clockContent} @@ -601,14 +657,18 @@ export default class Recording extends Component { )} - - - 前往打卡 - - + { + !clockShow && ViewAddInstrument === "true" && ( + + + 前往打卡 + + {/* 跳过 > - - + */} + + ) + } this.setState({ show: false })}> diff --git a/src/utils/util.js b/src/utils/util.js index 7870dee..ded5ecb 100644 --- a/src/utils/util.js +++ b/src/utils/util.js @@ -94,14 +94,13 @@ const date = () => { }; const getdates = (date) => { - date = date.replace(/-/g, "/"); // 部分iphone new Date不兼容[2023-01-01]格式,需要转换 + date = date && date.replace(/-/g, "/"); // 部分iphone new Date不兼容[2023-01-01]格式,需要转换 const year = new Date(date).getFullYear(); const month = new Date(date).getMonth() + 1; const day = new Date(date).getDate(); const hour = new Date(date).getHours(); const minute = new Date(date).getMinutes(); const second = new Date(date).getSeconds(); - // return `${[year, month, day].map(formatNumber).join('-')} ${[hour, minute, second].map(formatNumber).join(':')}` return `${[year, month, day].map(formatNumber).join("-")}`; };