diff --git a/src/app.config.ts b/src/app.config.ts index bae1943..d609852 100644 --- a/src/app.config.ts +++ b/src/app.config.ts @@ -1,6 +1,7 @@ export default defineAppConfig({ pages: [ 'pages/index/index', + 'pages/login/login', 'pages/initiate/initiate', 'pages/entry/entry', 'pages/activity/activity', @@ -8,6 +9,7 @@ export default defineAppConfig({ "pages/shop/shop", "pages/user/user", "pages/userInfo/userInfo", + 'pages/userInfoDetail/userInfoDetail', "pages/register/register", 'pages/instrument/instrument', 'pages/privacyPolicy/privacyPolicy', diff --git a/src/app.less b/src/app.less index 24a1e07..2b6d1c0 100644 --- a/src/app.less +++ b/src/app.less @@ -117,6 +117,6 @@ page { .van-overlay { z-index: 10000 !important; } -.van-popup--center { +.van-popup { z-index: 10001 !important; } diff --git a/src/app.tsx b/src/app.tsx index 840be2b..b46b447 100644 --- a/src/app.tsx +++ b/src/app.tsx @@ -1,9 +1,9 @@ import { Component, PropsWithChildren } from "react"; import "./app.less"; -// html4 -import "@tarojs/taro/html.css"; -// html5 -import "@tarojs/taro/html5.css"; +// // html4 +// import "@tarojs/taro/html.css"; +// // html5 +// import "@tarojs/taro/html5.css"; import Taro from "@tarojs/taro"; import { go } from "./utils/traoAPI"; @@ -20,7 +20,7 @@ class App extends Component { // 对应 onLaunch onLaunch(options) { - console.log("onLaunch", options); + // console.log("onLaunch", options); if (options.scene == 1007 || options.scene == 1008) { return; } diff --git a/src/components/calendar/body/index.tsx b/src/components/calendar/body/index.tsx index dd764cb..079b376 100644 --- a/src/components/calendar/body/index.tsx +++ b/src/components/calendar/body/index.tsx @@ -36,13 +36,10 @@ const defaultProps: Partial = { // const events = new Events(); -export default class AtCalendarBody extends React.Component< - AtCalendarBodyProps, - Readonly -> { +export default class AtCalendarBody extends React.Component { static defaultProps: Partial = defaultProps; - public constructor(props: AtCalendarBodyProps) { + public constructor(props: any) { super(props); const { validDates, @@ -53,6 +50,7 @@ export default class AtCalendarBody extends React.Component< generateDate, selectedDate, selectedDates, + currentDate, } = props; this.generateFunc = generateCalendarGroup({ @@ -63,8 +61,8 @@ export default class AtCalendarBody extends React.Component< marks, selectedDates, }); - const listGroup = this.getGroups(generateDate, selectedDate); - + // const listGroup = this.getGroups(generateDate, selectedDate); + const listGroup = this.getGroups(currentDate, selectedDate); this.state = { listGroup, offsetSize: 0, @@ -269,6 +267,7 @@ export default class AtCalendarBody extends React.Component< : clientX - this.swipeStartPoint > 0; }; + // 收起展开改变界面 private onChangeFoldingCalendar = () => { let { isFolding, listGroup } = this.state; isFolding = !isFolding; @@ -324,23 +323,22 @@ export default class AtCalendarBody extends React.Component< this.props.onDayClick(item); } + // 修改日历-重新渲染 onSelectDataChange(value: any) { let { temporaryCalendar } = this.state; - let oldValueItem = temporaryCalendar.findIndex((ele) => ele.isSelected); - let newValueItem = temporaryCalendar.findIndex( - (ele) => ele.value === value - ); - - temporaryCalendar[oldValueItem].isSelected = false; - temporaryCalendar[oldValueItem].isSelectedHead = false; - temporaryCalendar[oldValueItem].isSelectedTail = false; - temporaryCalendar[newValueItem].isSelected = true; - temporaryCalendar[newValueItem].isSelectedHead = true; - temporaryCalendar[newValueItem].isSelectedTail = true; + let newDateValue = dayjs(value).valueOf(); + const listGroup = this.getGroups(newDateValue, { + start: newDateValue, + end: newDateValue, + }); + temporaryCalendar = JSON.parse(JSON.stringify(listGroup[1].list)); + this.setState({ listGroup, temporaryCalendar, isFolding: false }); - this.setState({ temporaryCalendar }); - this.props.onDayClick(temporaryCalendar[newValueItem]); + let newValueItemIndex = temporaryCalendar.findIndex( + (ele) => ele.value === value + ); + this.props.onDayClick(temporaryCalendar[newValueItemIndex]); } public render(): JSX.Element { @@ -374,6 +372,7 @@ export default class AtCalendarBody extends React.Component< onClick={this.onDayClick.bind(this)} onLongClick={this.props.onLongClick} /> */} + {/* 仅关注此处定制数据即可 */} diff --git a/src/components/calendar/controller/index.less b/src/components/calendar/controller/index.less new file mode 100644 index 0000000..7045ece --- /dev/null +++ b/src/components/calendar/controller/index.less @@ -0,0 +1,49 @@ +.toolbar { + // position: absolute; + // left: 0; + // right: 0; + background: #fff; + padding: 20rpx 30rpx; + z-index: 999; +} + +.toolbar .toolbar_title { + font-size: 36rpx; + font-weight: 600; + text-align: center; +} + +.toolbar .select_box .text { + color: #cccccc; + font-size: 24rpx; + margin-bottom: 20rpx; + margin-top: 40rpx; +} + +.toolbar .select_box .date { + color: #000; + font-size: 28rpx; + font-weight: 500; +} + +.btn_confirm { + height: 90rpx; + background: #000; + color: #fff; + text-align: center; + line-height: 90rpx; + font-size: 32rpx; + font-weight: 700; + margin: 0 30rpx 40rpx; + border-radius: 50rpx; +} + +.van-picker__toolbar { + display: none; +} + +.popup-date-close { + position: absolute; + right: 50rpx; + top: 50rpx; +} diff --git a/src/components/calendar/controller/index.tsx b/src/components/calendar/controller/index.tsx index 009e4f9..406407b 100644 --- a/src/components/calendar/controller/index.tsx +++ b/src/components/calendar/controller/index.tsx @@ -1,20 +1,58 @@ import classnames from "classnames"; import dayjs, { Dayjs } from "dayjs"; import React from "react"; -import { Picker, Text, View } from "@tarojs/components"; +import { Text, View, Block } from "@tarojs/components"; +import { DatetimePicker, Popup } from "@antmjs/vantui"; import { AtCalendarControllerProps, AtCalendarControllerState, } from "../../../../types/calendar"; -export default class AtCalendarController extends React.Component< - AtCalendarControllerProps, - AtCalendarControllerState -> { +import "./index.less"; + +export default class AtCalendarController extends React.Component { + public constructor(props: any) { + super(props); + this.state = { + showDatePicker: false, + selectDate: 0, + curDate: 0, + }; + } + + onChangeDate = (e) => { + e.stopPropagation(); + }; + + onInput = (e) => { + this.setState({ curDate: e.detail }); + }; + + onClickStop = (e) => { + e.stopPropagation(); + }; + + onSelectDate = () => { + let { curDate } = this.state; + this.props.onSelectDate(curDate); + this.onPopupClose(); + }; + + onPopupClose = () => { + this.setState({ showDatePicker: false }); + }; + public render(): JSX.Element { - const { generateDate, minDate, maxDate, monthFormat, hideArrow } = - this.props; + const { + generateDate, + minDate, + maxDate, + monthFormat, + hideArrow, + currentDate, + } = this.props; + const dayjsDate: Dayjs = dayjs(generateDate); const dayjsMinDate: Dayjs | boolean = !!minDate && dayjs(minDate); const dayjsMaxDate: Dayjs | boolean = !!maxDate && dayjs(maxDate); @@ -32,49 +70,71 @@ export default class AtCalendarController extends React.Component< ? dayjsMaxDate.format("YYYY-MM") : ""; + let { showDatePicker, selectDate, curDate } = this.state; + return ( - - {hideArrow ? null : ( + + + {hideArrow ? null : ( + + )} - )} - - this.setState({ showDatePicker: true })} > {/* */} {/* {dayjsDate.format(monthFormat)} */} {dayjsDate.format("YYYY.MM.DD")} - - + + + - - {/* {hideArrow ? null : ( - + + + 选择日期 + + + + 已选择日期 + {currentDate} + + + - )} */} - + + 确定 + + + ); } } diff --git a/src/components/calendar/index.less b/src/components/calendar/index.less index 885fa38..7565b7a 100644 --- a/src/components/calendar/index.less +++ b/src/components/calendar/index.less @@ -1,4 +1,4 @@ .flex-justify-sb { display: flex; - justify-content: space-between; + justify-content: space-between !important; } diff --git a/src/components/calendar/index.tsx b/src/components/calendar/index.tsx index fdb0a23..752b2c2 100644 --- a/src/components/calendar/index.tsx +++ b/src/components/calendar/index.tsx @@ -67,7 +67,6 @@ export default class AtCalendar extends React.Component< private getSingleSelectdState = (value: Dayjs): Partial => { const { generateDate } = this.state; - console.log("generateDate", generateDate); const stateValue: Partial = { selectedDate: this.getSelectedDate(value.valueOf()), }; @@ -152,7 +151,6 @@ export default class AtCalendar extends React.Component< end = cEnd ? dayjs(cEnd).startOf("day").valueOf() : start; } else { const dayjsStart = dayjs(currentDate as Calendar.DateArg); - start = dayjsStart.startOf("day").valueOf(); // generateDateValue = dayjsStart.startOf("month").valueOf(); // 初始化选择器时间为每月第一天 generateDateValue = dayjsStart.startOf("day").valueOf(); @@ -213,8 +211,8 @@ export default class AtCalendar extends React.Component< }; // picker 选择时间改变时触发 - private handleSelectDate = (e: BaseEventOrig<{ value: string }>): void => { - const { value } = e.detail; + private handleSelectDate = (e: any): void => { + const value = e; const _generateDate: Dayjs = dayjs(value); const _generateDateValue: number = _generateDate.valueOf(); @@ -226,16 +224,13 @@ export default class AtCalendar extends React.Component< generateDate: _generateDateValue, }); - Taro.eventCenter.trigger( - "onSelectDataChange", - dayjs(_generateDateValue).format("YYYY-MM-DD") - ); + let newValue = dayjs(_generateDateValue).format("YYYY-MM-DD"); + Taro.eventCenter.trigger("onSelectDataChange", newValue); - console.log("this.state", this.state); + this.props.onTimeChange(newValue); }; private handleDayClick = (item: Calendar.Item): void => { - console.log("handleDayClick", item); const { isMultiSelect } = this.props; const { isDisabled, value } = item; @@ -297,8 +292,8 @@ export default class AtCalendar extends React.Component< isVertical, monthFormat, selectedDates, + currentDate, } = this.props as AtCalendarPropsWithDefaults; - return ( + list: Calendar.List; - onClick?: (item: Calendar.Item) => void + onClick?: (item: Calendar.Item) => void; - onLongClick?: (item: Calendar.Item) => void + onLongClick?: (item: Calendar.Item) => void; } export default class AtCalendarList extends React.Component { private handleClick = (item: Calendar.Item): void => { - if (typeof this.props.onClick === 'function') { - this.props.onClick(item) + if (typeof this.props.onClick === "function") { + this.props.onClick(item); } - } + }; private handleLongClick = (item: Calendar.Item): void => { - if (typeof this.props.onLongClick === 'function') { - this.props.onLongClick(item) + if (typeof this.props.onLongClick === "function") { + this.props.onLongClick(item); } - } + }; public render(): JSX.Element | null { - const { list } = this.props - if (!list || list.length === 0) return null + const { list } = this.props; + if (!list || list.length === 0) return null; return ( - + {list.map((item: Calendar.Item) => ( - - {item.text} + + {item.text} - + {item.marks && item.marks.length > 0 ? ( - + {item.marks.map((mark, key) => ( - + {mark.value} ))} @@ -75,6 +75,6 @@ export default class AtCalendarList extends React.Component { ))} - ) + ); } } diff --git a/src/components/calendar2/calendar2.less b/src/components/calendar2/calendar2.less new file mode 100644 index 0000000..6a87e32 --- /dev/null +++ b/src/components/calendar2/calendar2.less @@ -0,0 +1,334 @@ +.infobox1 { + position: relative; + background: #fff; + border-radius: 0 0 30rpx 30rpx; + padding: 19rpx 29rpx 44rpx 29rpx; + box-shadow: -2.6rpx 0 11rpx 0.5rpx rgba(129, 129, 129, 0.05); + transition: all 0.3s; +} +.infobox1 .selectbox { + margin-top: 38rpx; +} +.infobox1 .selectbox .block { + position: relative; +} +.infobox1 .selectbox .block picker, +.infobox1 .selectbox .block picker view { + position: absolute; + left: 0; + top: 0; + right: 0; + bottom: 0; + z-index: 99; + opacity: 0; +} +.infobox1 .selectbox .block .title { + font-size: 36rpx; + font-weight: 500; + color: #000000; + font-family: Poppins; +} +.infobox1 .selectbox .block .icon { + width: 30rpx; + height: 30rpx; + margin-left: 35rpx; +} + +.right_icon { + width: 10rpx; + height: 20rpx; + margin-left: 14rpx; +} + +.calendar_view { + margin-top: 44rpx; + font-size: 24rpx; + font-weight: 500; + color: #666666; + justify-content: center; +} + +.calendar_views { + font-size: 24rpx; + font-weight: 500; + color: #000; + justify-content: center; +} + +.calendar_view > view, +.calendar_views > view { + text-align: center; + color: #666666; + font-size: 24rpx; + font-weight: 500; + width: 98rpx; + height: 60rpx; + position: relative; +} +.calendar_views .block { + text-align: center; + width: 49rpx; + height: 49rpx; + border-radius: 50%; + color: #000000; + font-weight: 500; + font-size: 24rpx; + line-height: 49rpx; +} + +.calendar_views .blockstatus1 { + width: 6rpx; + height: 6rpx; + background: #e9cd9e; + border-radius: 50%; + position: absolute; + left: 50%; + bottom: 14rpx; + margin-left: -3rpx; +} + +.statubox { + justify-content: flex-end; + padding: 0 0 14rpx 0; + border-bottom: 1rpx solid rgba(105, 100, 96, 0.1); +} +.statubox .status1 { +} +.statubox .status1 .block { + width: 18rpx; + height: 18rpx; + border-radius: 50%; + background: #f1ece6; +} +.statubox .status1 .title { + font-size: 22rpx; + color: #202020; + margin-left: 12rpx; +} +.statubox .status2 { + margin-left: 26rpx; +} +.statubox .status2 .block { + width: 6rpx; + height: 6rpx; + border-radius: 50%; + background: #e9cd9e; +} +.statubox .status2 .title { + font-size: 22rpx; + color: #202020; + margin-left: 12rpx; + display: flex; + align-items: center; + justify-content: center; +} + +.calendar_views .status1 { + border: 2rpx solid #eecda1; + border-radius: 50%; +} + +.calendar_views .cur_day { + background: linear-gradient(0deg, #fff0da, #ffe4c0); + border-radius: 50%; +} + +.calendar_views .status4 { + border: 2rpx solid #f2f2f2; + border-radius: 50%; +} + +.calendar_views .no_cur_month { + color: #cccccc; +} + +.menubox { + color: #202020; + font-size: 24rpx; + font-weight: bold; + margin-top: 44rpx; +} +.menubox .record { + background: #e2c6a3; + border-radius: 22rpx; + color: #202020; + font-size: 24rpx; + height: 44rpx; + line-height: 44rpx; + width: 120rpx; + text-align: center; +} + +.van-tabs__scroll--line { + background: transparent !important; +} + +image { + width: 100%; + height: 100%; + display: flex; + border-radius: 0; +} + +.color { + color: #f1ab15; +} + +.ellipsis2 { + overflow: hidden; + text-overflow: ellipsis; + display: -webkit-box; + -webkit-line-clamp: 2; + -webkit-box-orient: vertical; +} + +.nodata { + color: #666666; + text-align: center; + margin-top: 50rpx; + font-size: 28rpx; +} + +.MT30 { + margin-top: 30rpx; +} + +.submitbtn { + position: absolute; + bottom: 100rpx; + width: 400rpx; + left: 50%; + margin-left: -200rpx; +} +.submitbtn .btn { + position: absolute; + top: 20rpx; + color: #fff; + font-weight: bold; + font-size: 32rpx; + text-align: center; + width: 100%; + bottom: 0; +} + +.avatar-wrapper { + position: absolute; + bottom: 0; + width: 100%; + height: 100%; + left: 0; + right: 0; + top: 0; + z-index: 99; + opacity: 0; +} + +.flex { + display: flex; +} +.aitems { + align-items: center; +} +.jcenter { + justify-content: center; +} +.sb { + justify-content: space-between; +} +.sa { + justify-content: space-around; +} +.wrap { + flex-wrap: wrap; +} + +.echartsboxs { + font-size: 24rpx; + font-weight: 500; + color: #666; + display: flex; + justify-content: center; +} + +.echartsboxs .blockbox { + width: 98rpx; + height: 60rpx; +} + +.echartsboxs .blockbox .title { + font-weight: 500; + text-align: center; + color: #000000; + font-size: 24rpx; + margin: 20rpx auto 0; + width: 49rpx; + height: 49rpx; + line-height: 49rpx; + border-radius: 50%; +} + +.echartsboxs .blockbox .cur_day { + background: linear-gradient(0deg, #fff0da, #ffe4c0); +} + +.echartsboxs .blockbox .status1 { + border: 2rpx solid #eecda1; +} + +.echartsboxs .blockbox .status4 { + border: 2rpx solid #f2f2f2; +} + +.arrow_box { + position: absolute; + left: 50%; + bottom: 0; + transform: translate(-50%); + /*width: 100%;*/ + height: 13rpx; + padding: 40rpx 80rpx 14rpx; +} + +.arrow { + transform: rotate(180deg); + transition-property: all; + transition-duration: 0.5s; + width: 24rpx; + height: 100%; + margin: 0 auto; +} + +.toolbar { + padding: 30rpx; +} + +.toolbar .toolbar_title { + font-size: 36rpx; + font-weight: 600; + text-align: center; +} + +.toolbar .select_box .text { + color: #cccccc; + font-size: 24rpx; + margin-bottom: 20rpx; + margin-top: 40rpx; +} + +.toolbar .select_box .date { + color: #000; + font-size: 28rpx; + font-weight: 500; +} + +.btn_confirm { + height: 90rpx; + background: #000; + color: #fff; + text-align: center; + line-height: 90rpx; + font-size: 32rpx; + font-weight: 700; + margin: 0 30rpx 40rpx; + border-radius: 50rpx; +} diff --git a/src/components/calendar2/calendar2.tsx b/src/components/calendar2/calendar2.tsx new file mode 100644 index 0000000..e40fdf6 --- /dev/null +++ b/src/components/calendar2/calendar2.tsx @@ -0,0 +1,355 @@ +import { Component } from "react"; +import Taro from "@tarojs/taro"; +import classnames from "classnames"; + +import { go } from "../../utils/traoAPI"; +import { date, getdates } from "../../utils/util"; +import { PunchingCardListIOT } from "../../utils/Interface"; + +import "./calendar2.less"; +import { Block, View, Image } from "@tarojs/components"; +import { DatetimePicker, Popup } from "@antmjs/vantui"; + +export default class Calendar2 extends Component { + constructor(props) { + super(props); + + this.state = { + name: "时间组件", + days: [], + weeklist: [], + year: new Date().getFullYear(), + month: String(new Date().getMonth() + 1).padStart(2, "0"), + day: String(new Date().getDate()).padStart(2, "0"), + consyear: new Date().getFullYear(), + consmonth: String(new Date().getMonth() + 1).padStart(2, "0"), + constday: String(new Date().getDate()).padStart(2, "0"), + week: "", + monthtext: new Date().getMonth() + 1 + "月", + selectlist: [ + { + name: "每月", + id: 2, + }, + { + name: "每周", + id: 1, + }, + ], + selectlistindex: 1, + curMonthDate: + String(new Date().getFullYear()) + + "-" + + String(new Date().getMonth() + 1).padStart(2, "0"), + curDate: new Date().getTime(), + selectDate: date(), + temDate: null, + today: date().replace(/\-/g, "."), + maxDate: new Date().getTime(), + yearlist: [], + monthlist: [], + totalcount: 0, + showDatePicker: false, + }; + } + + async onLoad() { + // // 状态栏高度 + } + componentDidMount() {} + + componentWillUnmount() {} + + componentDidShow() {} + + componentDidHide() {} + + onChangeDate = async (event) => { + const { showDatePicker, curDate, temDate } = this.state; + if (showDatePicker && event.type !== "close") { + if (curDate !== temDate) { + this.setState({ + selectDate: getdates(temDate), + curDate: temDate, + curMonthDate: getdates(temDate).slice(0, 7), + }); + await this.PunchingCardListIOT(); + } + } + // this.getTabBar().setState({ + // showBar: showDatePicker + // }) + this.setState({ showDatePicker: !showDatePicker }); + }; + onInput = (event) => { + this.setState({ temDate: event.detail }); + }; + gourl = (e) => { + const { url } = e.currentTarget.dataset; + if (!this.state.userInfo.mobile) { + //未注册授权 + // showModal({ + // t2: '暂未授权注册,请点击注册', + // btn1show: false + // }).then(res => { + // Taro.navigateTo({ + // url: '/pages/register/register', + // }) + // }) + return false; + } + go(url); + }; + onChangeCalendar = () => { + const { selectlistindex } = this.state; + if (!selectlistindex) { + this.setState({ selectlistindex: 1 }); + } else { + this.setState({ selectlistindex: 0 }); + } + this.PunchingCardListIOT(); + console.log(this.state.curMonthDate); + }; + PunchingCardListIOT = async () => { + Taro.showLoading({ + title: "加载中", + }); + let { data } = await PunchingCardListIOT({ + type: this.state.selectlist[this.state.selectlistindex].id, + times: this.state.selectDate + " 00:00:01", + }); + if (data.code === 200) { + if (this.state.selectlist[this.state.selectlistindex].id === 2) { + data.data.list = data.data.list.map((item) => ({ + ...item, + date: parseInt(item.addtime.slice(-2)), + month: item.addtime.slice(0, 7), + curDate: item.addtime.replace(/-/g, "."), + })); + this.setState({ + days: data.data.list, + }); + } + if (this.state.selectlist[this.state.selectlistindex].id === 1) { + let totalcount = 0; + let week: any = new Date().getDay(); + if (week === 1) week = "周一"; + else if (week === 2) week = "周二"; + else if (week === 3) week = "周三"; + else if (week === 4) week = "周四"; + else if (week === 5) week = "周五"; + else if (week === 6) week = "周六"; + else week = "周日"; + let now = Date.now(); + data.data.list.map((item, index) => { + item.week2 = week; + item.day = parseInt(item.addtime.substring(8, 10)); + item.curDate = item.addtime.replace(/-/g, "."); + if (item.times) { + item.fen = item.times.substring(0, item.times.indexOf(":")); + item.miao = item.times.substring( + item.times.indexOf(":") + 1, + item.times.length + ); + item.total = + Number(item.fen * 60) + Number(item.miao) > 980 + ? 980 + : Number(item.fen * 60) + Number(item.miao); + item.totals = Number(item.fen * 60) + Number(item.miao); + let yu = 3.4; + item.height = item.total / yu; + if (now > new Date(item.addtime.replace(/-/g, "/")).getTime()) { + item.bgcolor = "#E8D3B1"; + item.textcolor = ""; + totalcount += item.totals; + } else { + if (item.c_status) { + item.bgcolor = "#F2F2F2"; + item.textcolor = "#202020"; + } + } + if (Number(item.fen) > 1440) { + item.times = "1440:00"; + } + } else { + item.height = 0; + } + }); + this.setState({ + weeklist: data.data.list, + atotalcount: this.s_to_hs(totalcount), + }); + } + } + Taro.hideLoading(); + }; + s_to_hs = (s) => { + //计算分钟 + //算法:将秒数除以60,然后下舍入,既得到分钟数 + let h; + h = Math.floor(s / 60); + //计算秒 + //算法:取得秒%60的余数,既得到秒数 + s = s % 60; + //将变量转换为字符串 + h += ""; + s += ""; + //如果只有一位数,前面增加一个0 + h = h.length === 1 ? "0" + h : h; + s = s.length === 1 ? "0" + s : s; + return h + "分" + s + "秒"; + }; + + render() { + let { + selectlist, + selectlistindex, + today, + days, + curMonthDate, + weeklist, + showDatePicker, + selectDate, + curDate, + maxDate, + } = this.state; + return ( + + + + + {today} + + + + + + 护理记录 + + + + + {selectlist[selectlistindex].id === 2 && ( + + + + + + + + + + + + + {days.map((item, index) => { + return ( + + {/* {{item.curDate === today ? 'cur_day' : item.status === 1 || item.status === 2 ? 'status1' : item.month !== curMonthDate ? 'no_cur_month' : item.status === 4 ? 'status4' : ''}} */} + + {item.date} + + + ); + })} + + + )} + + {selectlist[selectlistindex].id === 1 && ( + + + + + + + + + + + + {weeklist.map((item, index) => { + return ( + + + {item.day} + + + ); + })} + + + )} + + + + + + + + + 选择日期 + + 已选择日期 + {selectDate} + + + + + 确定 + + + + ); + } +} diff --git a/src/components/modal/modal.config.js b/src/components/modal/modal.config.js deleted file mode 100644 index fd50080..0000000 --- a/src/components/modal/modal.config.js +++ /dev/null @@ -1,3 +0,0 @@ -export default { - component: true, -}; diff --git a/src/components/modal/modal.less b/src/components/modal/modal.less deleted file mode 100644 index 55fd392..0000000 --- a/src/components/modal/modal.less +++ /dev/null @@ -1 +0,0 @@ -@import "~taro-ui/dist/style/components/modal.scss"; diff --git a/src/components/modal/modal.tsx b/src/components/modal/modal.tsx deleted file mode 100644 index af8820e..0000000 --- a/src/components/modal/modal.tsx +++ /dev/null @@ -1,13 +0,0 @@ -import { AtModal, AtModalHeader, AtModalContent, AtModalAction } from "taro-ui"; - -{ - /* - 标题 - - 这里是正文内容,欢迎加入京东凹凸实验室 - 这里是正文内容,欢迎加入京东凹凸实验室 - 这里是正文内容,欢迎加入京东凹凸实验室 - - - */ -} diff --git a/src/components/modal/registerModal/registerModal.less b/src/components/modal/registerModal/registerModal.less new file mode 100644 index 0000000..e69de29 diff --git a/src/components/modal/registerModal/registerModal.tsx b/src/components/modal/registerModal/registerModal.tsx new file mode 100644 index 0000000..9fe92f3 --- /dev/null +++ b/src/components/modal/registerModal/registerModal.tsx @@ -0,0 +1,95 @@ +import { Component } from "react"; + +import { Dialog } from "@antmjs/vantui"; +const Dialog_ = Dialog.createOnlyDialog(); + +/*** redux ***/ +import { connect } from "react-redux"; +import { setColor, resetColor } from "../../../store/features/navigation"; +import { userRefresh } from "../../../store/features/userInfo"; +/*** redux end ***/ + +import "./registerModal.less"; +import { Block } from "@tarojs/components"; +import { go } from "../../../utils/traoAPI"; + +class RegisterModal extends Component { + constructor(props) { + super(props); + + this.state = { + name: "导航组件", + statusBarHeight: 40, // 状态栏高度 + navigationBarHeight: 0, // 导航栏高度 + navHeight: 40, + }; + this.initData(); + } + + async onLoad() { + // // 状态栏高度 + } + componentDidMount() {} + + componentWillUnmount() {} + + componentDidShow() {} + + componentDidHide() {} + + async initData() { + this.alertRegister(); + } + + public alertRegister = () => { + if (!this.props.mobile) { + this.setColor("#4C4C4C"); + setTimeout(() => { + Dialog_.alert({ + title: "提示", + message: "暂未授权注册,请点击注册", + }).then((value) => { + this.resetColor(); + this.goRegister(); + }); + }, 300); + } else { + go("/pages/instrument/instrument"); + } + }; + + setColor = (color) => { + this.props.setColor(color); + }; + resetColor = () => { + this.props.resetColor(); + }; + + goRegister() { + go("/pages/register/register"); + } + + render() { + return ( + + + + ); + } +} + +const mapStateToProps = (state) => ({ + mobile: state.userInfo.mobile, +}); +const mapDispatchToProps = (dispatch) => ({ + setColor(color) { + dispatch(setColor(color)); + }, + resetColor() { + dispatch(resetColor()); + }, + userRefresh(data) { + dispatch(userRefresh(data)); + }, +}); +export default connect(mapStateToProps, mapDispatchToProps)(RegisterModal); diff --git a/src/components/navbar/navbar.less b/src/components/navbar/navbar.less index c669de0..2103eb3 100644 --- a/src/components/navbar/navbar.less +++ b/src/components/navbar/navbar.less @@ -16,12 +16,21 @@ // } .nav_box { + position: fixed; + top: 0; + left: 0; + right: 0; display: flex; justify-content: center; background: #fff; + z-index: 99; .logo { display: inline-flex; align-items: center; width: 220rpx; } } + +.nav_top_padding { + position: relative; +} diff --git a/src/components/navbar/navbar.tsx b/src/components/navbar/navbar.tsx index c0df8f4..048032e 100644 --- a/src/components/navbar/navbar.tsx +++ b/src/components/navbar/navbar.tsx @@ -13,11 +13,29 @@ export default class Navbar extends Component { name: "导航组件", statusBarHeight: 40, // 状态栏高度 navigationBarHeight: 0, // 导航栏高度 + navHeight: 40, }; + this.initData(); + } + + async onLoad() { + // // 状态栏高度 + } + componentDidMount() {} + + componentWillUnmount() {} + + componentDidShow() {} + + componentDidHide() {} + + async initData() { + this.setStatusBar(); + } - const that = this; + setStatusBar() { Taro.getSystemInfoAsync({ - success(res) { + success: (res) => { const statusBarHeight = res.statusBarHeight || 0; // 获取微信胶囊的位置信息 width,height,top,right,left,bottom const custom = Taro.getMenuButtonBoundingClientRect(); @@ -25,33 +43,22 @@ export default class Navbar extends Component { const navigationBarHeight = custom.height + (custom.top - statusBarHeight) * 2; // 总体高度 = 状态栏高度 + 导航栏高度 - // const navHeight = navigationBarHeight + statusBarHeight; + const navHeight = navigationBarHeight + statusBarHeight; - that.setState({ + this.setState({ statusBarHeight, navigationBarHeight, + navHeight, }); }, }); } - async onLoad() { - // // 状态栏高度 - } - componentDidMount() {} - - componentWillUnmount() {} - - componentDidShow() {} - - componentDidHide() {} - - async initData() {} - render() { - let { statusBarHeight, navigationBarHeight } = this.state; + let { statusBarHeight, navigationBarHeight, navHeight } = this.state; const statusBarHeightRpx = statusBarHeight * 2; const navigationBarHeightRpx = navigationBarHeight * 2; + const navHeightRpx = navHeight * 2; return ( { + {/* diff --git a/src/components/popup/popup-privacy.tsx b/src/components/popup/popup-privacy.tsx index 5c89a6e..5378c83 100644 --- a/src/components/popup/popup-privacy.tsx +++ b/src/components/popup/popup-privacy.tsx @@ -35,7 +35,7 @@ export default class PopupPrivacy extends Component { componentWillUnmount() {} componentDidShow() { - console.log("isShowPrivacyPopup show", this.state); + // console.log("isShowPrivacyPopup show", this.state); // 是否已授权隐私 // if (Taro.getStorageSync("isPrivacyPopup") !== "true") { // // this.setState({ @@ -75,6 +75,10 @@ export default class PopupPrivacy extends Component { this.props.closePrivacy(); }; + onClickStop = (e) => { + e.stopPropagation(); + }; + render() { // let { isShowPrivacyPopup } = this.state; return ( @@ -87,6 +91,7 @@ export default class PopupPrivacy extends Component { round overlayStyle="width: 100vw;padding: 0;" onClose={this.onClose} + onClick={this.onClickStop} > 用户隐私保护提示 diff --git a/src/custom-tab-bar/index.config.js b/src/custom-tab-bar/index.config.js index fd50080..f5f4a32 100644 --- a/src/custom-tab-bar/index.config.js +++ b/src/custom-tab-bar/index.config.js @@ -1,3 +1,4 @@ export default { component: true, + lazyCodeLoading: "requiredComponents", }; diff --git a/src/custom-tab-bar/index.tsx b/src/custom-tab-bar/index.tsx index dcffeeb..3a11454 100644 --- a/src/custom-tab-bar/index.tsx +++ b/src/custom-tab-bar/index.tsx @@ -55,7 +55,6 @@ export default class Index extends Component { } setSelected(idx: number) { - console.log("setSelected", idx); this.setState({ selected: idx, }); diff --git a/src/pages/activity/activity.tsx b/src/pages/activity/activity.tsx index 99ce9a4..3306364 100644 --- a/src/pages/activity/activity.tsx +++ b/src/pages/activity/activity.tsx @@ -26,9 +26,7 @@ export default class Activity extends Component { }; } - async onLoad() { - console.log("app", app); - } + async onLoad() {} componentDidMount() {} componentWillUnmount() {} diff --git a/src/pages/detect/detect.tsx b/src/pages/detect/detect.tsx index a5133c2..f2b3f74 100644 --- a/src/pages/detect/detect.tsx +++ b/src/pages/detect/detect.tsx @@ -26,9 +26,7 @@ export default class Detect extends Component { }; } - async onLoad() { - console.log("app", app); - } + async onLoad() {} componentDidMount() {} componentWillUnmount() {} diff --git a/src/pages/entry/entry.tsx b/src/pages/entry/entry.tsx index 0a3b226..b0729db 100644 --- a/src/pages/entry/entry.tsx +++ b/src/pages/entry/entry.tsx @@ -48,7 +48,6 @@ export default class Entry extends Component { } async onLoad() { - console.log("app", app); const menu = Taro.getMenuButtonBoundingClientRect(); this.setState({ menu }); @@ -63,20 +62,18 @@ export default class Entry extends Component { componentDidHide() {} async intData() { - const { data } = await MpSplashDetail({ - pageNum: 1, - pageSize: 5, - type: 2, - }); - if (data.code === 200) { - let welcomeList = data.rows.map((item) => { + let MpSplashDetail_type1 = + Taro.getStorageSync("MpSplashDetail_type1") || undefined; + if (MpSplashDetail_type1) { + let detail = JSON.parse(MpSplashDetail_type1); + let list = detail.filter((item: any) => item.fileSuffix === "page"); + let welcomeList = list.map((item) => { return { image: item.fileUrl, title: item.title, desc: item.content, }; }); - welcomeList = [].concat(welcomeList, welcomeList); this.setState({ welcomeList }); } } @@ -159,8 +156,7 @@ export default class Entry extends Component { diff --git a/src/pages/errorpage/errorpage.tsx b/src/pages/errorpage/errorpage.tsx index 664eada..bfe2645 100644 --- a/src/pages/errorpage/errorpage.tsx +++ b/src/pages/errorpage/errorpage.tsx @@ -24,9 +24,7 @@ export default class Index extends Component { }; } - async onLoad() { - console.log("app", app); - } + async onLoad() {} componentDidMount() {} componentWillUnmount() {} diff --git a/src/pages/index/index.tsx b/src/pages/index/index.tsx index 73e4105..8e6b862 100644 --- a/src/pages/index/index.tsx +++ b/src/pages/index/index.tsx @@ -5,12 +5,9 @@ import { Component, PropsWithChildren } from "react"; import { Block, View, Text, Image, PageMeta, Button } from "@tarojs/components"; /*** redux ***/ -// import { connect } from "react-redux"; -// import navigation from "../../store/features/navigation"; -import { setColor, resetColor } from "../../store/features/navigation"; - import { connect } from "react-redux"; -import { addNumber } from "../../store/features/counter"; +import { setColor, resetColor } from "../../store/features/navigation"; +import { userRefresh } from "../../store/features/userInfo"; /*** redux end ***/ /** 自定义组件 **/ @@ -23,7 +20,7 @@ import Navbar from "../../components/navbar/navbar"; import { Dialog } from "@antmjs/vantui"; const Dialog_ = Dialog.createOnlyDialog(); -import { UserInfo, GetUserMobile } from "../../utils/Interface"; +import { GetUserMobile, RefreshWxUserInfo } from "../../utils/Interface"; import { setGlobalData } from "../../utils/global"; // css引入 @@ -31,8 +28,6 @@ import "taro-ui/rn/style/components/calendar.scss"; import "./index.less"; import { go } from "../../utils/traoAPI"; -const app = Taro.getApp(); - // PropsWithChildren class Index extends Component { pageCtx = Taro.getCurrentInstance().page; @@ -42,7 +37,9 @@ class Index extends Component { this.state = { isShowPrivacyPopup: false, // imgUrl: this.app.globalData.imgUrl, - userinfo: {}, + userinfo: { + mobile: this.props.mobile, + }, connectInstrument: {}, yiqiinfo: {}, titleHeight: "", @@ -58,7 +55,7 @@ class Index extends Component { versioninfo: {}, //仪器版本号, info: {}, // 护理推荐点击参与活动的信息 weekinfo: undefined, - today: dayjs().format("YYYY-MM-DD"), + currentDate: dayjs().format("YYYY-MM-DD"), }; } @@ -66,12 +63,13 @@ class Index extends Component { const menu = Taro.getMenuButtonBoundingClientRect(); this.setState({ menu }); - console.log("this.props", this); + const isFirst = Taro.getStorageSync("isWelcome"); + if (isFirst) { + this.RefreshWxUserInfo(); + } } - componentDidMount() { - console.log("app", app); - } + componentDidMount() {} componentWillUnmount() {} @@ -82,6 +80,15 @@ class Index extends Component { componentDidHide() {} + getUserInfo() {} + + RefreshWxUserInfo = async () => { + let res = await RefreshWxUserInfo(); + if (res.data.code === 200) { + this.props.userRefresh(res.data.data); + } + }; + setColor = (color) => { this.props.setColor(color); }; @@ -89,71 +96,50 @@ class Index extends Component { this.props.resetColor(); }; - /****获取用户数据****/ - UserInfo = async (code: string) => { - // this.showPrivacy(); - - let { data } = await GetUserMobile({ code }); - console.log("data", data); - // let that = this; - // let { data } = await UserInfo(); - // if (data.code == 200) { - // setGlobalData("userinfo", data.data); - // // app.globalData.userinfo = data.data; - // this.setState({ - // userinfo: data.data, - // }); - // Taro.downloadFile({ - // url: data.data.headimg, - // success: function (res) { - // that.setState({ - // headimg: res.tempFilePath, - // }); - // }, - // }); - // } - }; - /****获取用户数据 END****/ - goRegister() { - console.log("gourl"); go("/pages/register/register"); } + addNewDevice = () => { - console.log("addNewDevice"); let mobile = Taro.getStorageSync("mobile"); + console.log("mobile", mobile); if (!mobile) { - console.log("未登录注册!"); this.alertRegister(); } }; showPrivacy = () => { - console.log("showPrivacy"); this.setState({ isShowPrivacyPopup: true }); }; closePrivacy = () => { - console.log("closePrivacy"); this.setState({ isShowPrivacyPopup: false }); }; public alertRegister = () => { - this.setColor("#4C4C4C"); - setTimeout(() => { - Dialog_.alert({ - title: "提示", - message: "暂未授权注册,请点击注册", - }).then((value) => { - this.resetColor(); - this.goRegister(); - console.log("dialog result", value); - }); - }, 300); + if (!this.props.mobile) { + this.setColor("#4C4C4C"); + setTimeout(() => { + Dialog_.alert({ + title: "提示", + message: "暂未授权注册,请点击注册", + }).then((value) => { + this.resetColor(); + this.goRegister(); + }); + }, 300); + } else { + go("/pages/instrument/instrument"); + } + }; + + onTimeChange = (value) => { + console.log("onTimeChange", value); + this.setState({ currentDate: value }); }; render() { - let { today, isShowPrivacyPopup } = this.state; + let { currentDate, isShowPrivacyPopup } = this.state; return ( @@ -168,7 +154,14 @@ class Index extends Component { - + {/* */} + @@ -207,6 +200,7 @@ class Index extends Component { const mapStateToProps = (state) => ({ background: state.navigation.background, + mobile: state.userInfo.mobile, }); const mapDispatchToProps = (dispatch) => ({ setColor(color) { @@ -215,5 +209,8 @@ const mapDispatchToProps = (dispatch) => ({ resetColor() { dispatch(resetColor()); }, + userRefresh(data) { + dispatch(userRefresh(data)); + }, }); export default connect(mapStateToProps, mapDispatchToProps)(Index); diff --git a/src/pages/initiate/initiate.tsx b/src/pages/initiate/initiate.tsx index 0e423e4..9202d86 100644 --- a/src/pages/initiate/initiate.tsx +++ b/src/pages/initiate/initiate.tsx @@ -12,15 +12,18 @@ import { SwiperItem, } from "@tarojs/components"; +/*** redux ***/ +import { connect } from "react-redux"; +import { setMobile } from "../../store/features/userInfo"; +/*** redux end ***/ + import "taro-ui/dist/style/components/button.scss"; // 按需引入 import "./initiate.less"; import { go } from "../../utils/traoAPI"; import { getGlobalData, setGlobalData } from "../../utils/global"; -const app = Taro.getApp(); - -export default class Index extends Component { +class Initiate extends Component { constructor(props) { super(props); this.state = { @@ -45,16 +48,19 @@ export default class Index extends Component { }, }); - console.log("app", app); - if (!getGlobalData("token")) await this.WCUserLogin(); const menu = Taro.getMenuButtonBoundingClientRect(); this.setState({ menu }); - Taro.setStorageSync("isWelcome", true); - await this.intData(); - } - componentDidMount() { - console.log("this.state", this.state); + + if (!getGlobalData("token")) { + await this.WCUserLogin(); + Taro.setStorageSync("isWelcome", true); + await this.initData(); + } else { + // this.setBg(); + go("/pages/entry/entry"); + } } + componentDidMount() {} componentWillUnmount() {} @@ -62,47 +68,52 @@ export default class Index extends Component { componentDidHide() {} - async intData() { + async initData() { const { data } = await MpSplashDetail({ pageNum: 1, pageSize: 5, type: 1, }); - console.log("data", data); if (data.code === 200) { let url = ""; if (data.rows.length) { - url = data.rows[0].fileUrl; + Taro.setStorageSync("MpSplashDetail_type1", JSON.stringify(data.rows)); + } + + let bgObj = data.rows.find((item: any) => item.fileSuffix === "video"); + if (bgObj) { + url = bgObj.filePath; + this.setState({ url }); } - this.setState({ url }); } } + + setBg() { + let bgData = Taro.getStorageSync("MpSplashDetail_type1"); + bgData = JSON.parse(bgData); + let bgObj = bgData.find((item: any) => item.fileSuffix === "video"); + if (bgObj) { + this.setState({ url: bgObj.filePath }); + } + } + async WCUserLogin() { const { code } = await Taro.login(); - console.log("code", typeof code); const { data } = await WCUserLogin({ code }); if (data.code === 200) { setGlobalData("token", data.data.token); + // Taro.setStorageSync("mobile", data.data.mobile); + this.props.setMobile(data.data.mobile); } } touchstart(event) { - console.log("touchstart", event); const { clientX, clientY } = event.changedTouches[0]; this.setState({ touchX: clientX, touchY: clientY }); } touchend(event) { - console.log("touchstart", event); const { clientX, clientY } = event.changedTouches[0]; const { touchX, touchY } = this.state; - - console.log("clientX - touchX", clientX - touchX, clientX, touchX); - console.log( - "clientX - touchX < -30 && Math.abs(clientY - touchY) > 30", - clientX - touchX < -30, - Math.abs(clientY - touchY) < 30, - Math.abs(clientY - touchY) - ); if (clientX - touchX < -30 && Math.abs(clientY - touchY) < 30) { this.onEnded(); } @@ -116,7 +127,7 @@ export default class Index extends Component { }; render() { - let { menu } = this.state; + let { menu, url } = this.state; return ( {