Commit 51b33414 authored by 王炽's avatar 王炽

代码合并生长工具

parents d123482c 998a14ac
......@@ -17,8 +17,9 @@ const {
// 通常可以吧 baseUrl 单独放在一个 js 文件了
// const baseUrl = "http://172.16.224.178:7777/pmall";
// const baseUrl = "https://momclub-uat.feihe.com/pmall";//测试环境
// const baseUrl = "https://momclub.feihe.com/pmall";//生产环境
const baseUrl = "https://feihe.m.duibatest.com.cn/pmall";//测试环境
// let baseUrl = "https://momclub.feihe.com/pmall";//生产环境
// const baseUrl = "https://docs.dui88.com/mock/1956/api";//mock
const baseUrl = "https://feihe.m.duibatest.com.cn/pmall"
const request = (options = {}) => {
// 在这里可以对请求头进行一些设置
......@@ -27,8 +28,9 @@ const request = (options = {}) => {
// "Content-Type": "application/x-www-form-urlencoded"
// }
// if(options.url == '/c/ai/chat/query'){
// baseUrl = "https://docs.dui88.com/mock/1956";
// baseUrl = "https://docs.dui88.com/mock/1956";
// }
return new Promise((resolve, reject) => {
uni
.request({
......@@ -41,7 +43,6 @@ const request = (options = {}) => {
},
})
.then((data) => {
// console.log('request data ===>', data);
if (data.statusCode !== HTTP_STATUS.SUCCESS) {
uni.showToast({
title: data.errMsg,
......@@ -49,14 +50,16 @@ const request = (options = {}) => {
});
reject(data);
globalStore.setIsShowLoading(false);
} else if (!data.data?.ok) {
}
else if (!data.data?.ok) {
uni.showToast({
title: data.data?.message,
icon: 'none'
});
reject(data.data);
globalStore.setIsShowLoading(false);
} else {
}
else {
resolve(data.data);
}
})
......@@ -75,6 +78,7 @@ const get = (url, data, options = {}) => {
};
const post = (url, data, options = {}) => {
options.type = "POST";
options.data = data;
options.url = url;
......
import requestModule from './request.js';
const {
api
} = requestModule;
/**
* 获取首页信息
* @returns
*/
export const growthHome = (babyId) => api.post('/c/growth/home', { babyId });
export const guideCompleted = () => api.post('/c/growth/guide/Completed');
export const assessmentSave = (data) => api.post('/c/growth/assessment/save', data);
export const getGrowthCurveData = (babyData) => api.post('/c/growth/curve/data', babyData);
export const getGrowthHistoryList = () => api.post('/c/growth/history/list');
// export const fetchHomeJSON = () => api.get('/c/front/content',{type:'home'});
\ No newline at end of file
<template>
<view v-if="visible" class="popup-overlay">
<view class="popup-content" @click.stop>
<!-- 喂养方式列表 -->
<view class="feed-list">
<view
v-for="(item, index) in feedOptions"
:key="index"
class="feed-item"
:class="{ selected: selectedIndex === index }"
@click="selectFeed(index)"
>
<!-- 选中背景 -->
<image
v-if="selectedIndex === index"
class="feed-item-bg"
src="/static/shengzhangTool/changeFeed/itemBg.png"
mode="aspectFit"
/>
<!-- 喂养方式文本 -->
<text class="feed-text">{{ item.name }}</text>
</view>
</view>
<!-- 底部按钮 -->
<view class="bottom-buttons">
<image
class="cancel-btn"
:class="{'cancel-btn-active': isCancelPressed}"
src="/static/shengzhangTool/changeFeed/cancelBtn.png"
@touchstart="handleCancelTouchStart"
@touchend="handleCancelTouchEnd"
mode="aspectFit"
/>
<image
class="ok-btn"
:class="{'ok-btn-active': isOkPressed}"
src="/static/shengzhangTool/changeFeed/okBtn.png"
@touchstart="handleOkTouchStart"
@touchend="handleOkTouchEnd"
mode="aspectFit"
/>
</view>
</view>
</view>
</template>
<script setup>
import { ref, defineEmits, defineProps } from 'vue'
const props = defineProps({
visible: {
type: Boolean,
default: false
},
selectedIndex: {
type: Number,
default: 0
}
})
const emit = defineEmits(['update:visible', 'update:selectedIndex', 'change'])
// 喂养方式选项
const feedOptions = ref([
{ name: '纯母乳', value: 'pure_breast' },
{ name: '母乳+奶粉混合喂养', value: 'mixed_feeding' },
{ name: '纯奶粉', value: 'pure_formula' },
{ name: '奶粉+辅食', value: 'formula_food' },
{ name: '母乳+辅食', value: 'breast_food' }
])
const selectIndex = ref(props.selectedIndex)
// 按钮状态
const isCancelPressed = ref(false)
const isOkPressed = ref(false)
// 添加加载状态
const isLoadingFeed = ref(false)
// 喂养方式相关数据
const showFeedSwitchPopup = ref(false)
const currentFeedIndex = ref(1) // 默认选中"母乳+奶粉混合喂养"
const selectedFeedText = ref('母乳+奶粉混合喂养')
// 选择喂养方式
const selectFeed = (index) => {
selectIndex.value = index
emit('update:selectedIndex', index)
}
// 取消按钮事件
const handleCancelTouchStart = () => {
isCancelPressed.value = true
}
const handleCancelTouchEnd = () => {
isCancelPressed.value = false
closePopup()
}
// 确认按钮事件
const handleOkTouchStart = () => {
isOkPressed.value = true
}
const handleOkTouchEnd = () => {
isOkPressed.value = false
const index = selectIndex.value
const selectedFeed = feedOptions.value[index]
// 发送事件通知主页面
emit('change', selectedFeed, index)//只能传一个参数
closePopup()
}
// 点击喂养方式选择
const openFeedSelector = () => {
console.log('打开喂养方式选择器')
showFeedSwitchPopup.value = true
}
// 处理喂养方式选择变化
const onFeedChange = (feedOption, index) => {
isLoadingFeed.value = true
console.log('选择了喂养方式:', feedOption, index)
selectedFeedText.value = feedOption.name
currentFeedIndex.value = index
// 模拟保存数据
setTimeout(() => {
isLoadingFeed.value = false
}, 300)
}
const closePopup = () => {
emit('update:visible', false)
}
</script>
<style lang="less" scoped>
.popup-overlay {
position: fixed;
top: 0;
left: 0;
right: 0;
bottom: 0;
background-color: rgba(0, 0, 0, 0.7);
z-index: 9999;
.popup-content {
position: absolute;
width: 750rpx;
height: 897rpx;
background-color: #f6f8fa;
overflow: hidden;
border-top-left-radius: 32rpx;
border-top-right-radius: 32rpx;
bottom: 0rpx;
padding-top: 50rpx;
.feed-list {
flex: 1;
overflow-y: auto;
padding-left: 30rpx;
padding-right: 30rpx;
.feed-item {
position: relative;
display: flex;
align-items: center;
justify-content: center;
height: 106rpx;
margin-bottom: 20rpx;
border-radius: 16rpx;
background-color: #fff;
&.selected {
background-color: transparent;
}
.feed-item-bg {
position: absolute;
width: 689rpx;
height: 108rpx;
z-index: 1;
}
.feed-text {
position: relative;
z-index: 2;
font-size: 28rpx;
color: #1d1e26;
font-weight: 400;
}
}
}
.bottom-buttons {
display: flex;
justify-content: space-between;
align-items: center;
padding-top: 20rpx;
padding-left: 30rpx;
padding-right: 30rpx;
.cancel-btn {
width: 334rpx;
height: 97rpx;
transition: transform 0.1s ease-out;
&.cancel-btn-active {
transform: scale(0.95);
}
}
.ok-btn {
width: 334rpx;
height: 97rpx;
transition: transform 0.1s ease-out;
&.ok-btn-active {
transform: scale(0.95);
}
}
}
}
}
.feeding-select {
display: flex;
align-items: center;
cursor: pointer; // 添加手型光标
.feeding-value {
font-size: 28rpx;
color: #666;
margin-right: 8rpx;
}
.dropdown-icon {
width: 20rpx;
height: 20rpx;
transition: transform 0.3s ease; // 添加旋转动画
}
// 可选:添加点击反馈效果
&:active {
opacity: 0.7;
}
}
</style>
<template>
<view v-if="visible" class="popup-overlay">
<view class="popup-content" @click.stop>
<!-- 弹窗头部 -->
<view class="popup-header">
<text class="popup-title">切换宝宝</text>
<image
class="close-btn"
src="/static/shengzhangTool/changeBaby/closeBtn.png"
mode="aspectFit"
@click="closePopup"
/>
</view>
<!-- 宝宝列表 -->
<view class="baby-list">
<view
v-for="(baby, index) in babyList"
:key="index"
class="baby-item"
:class="{ selected: selectedIndex === index }"
@click="selectBaby(index)"
>
<!-- 选中背景 -->
<image
v-if="selectedIndex === index"
class="baby-item-bg"
src="/static/shengzhangTool/changeBaby/babyItemBg.png"
mode="aspectFit"
/>
<!-- 宝宝头像 -->
<image
class="baby-avatar"
:src="baby.avatar || '/static/shengzhangTool/avatar.png'"
mode="aspectFill"
/>
<!-- 宝宝信息 -->
<view class="baby-info">
<view class="baby-name-row">
<text class="baby-name">{{ baby.name }}</text>
<image
class="gender-icon"
:src="baby.gender === 1 ? '/static/shengzhangTool/sex1.png' : '/static/shengzhangTool/sex0.png'"
mode="aspectFit"
/>
</view>
<text class="baby-birthday">宝宝生日: {{ baby.birthday }}</text>
</view>
</view>
</view>
<image
class="ok-btn"
:class="{'ok-btn-active': isOkPressed}"
src="/static/shengzhangTool/changeBaby/okBtn.png"
@touchstart="handleOkTouchStart"
@touchend="handleOkTouchEnd"
mode="aspectFit"
></image>
</view>
</view>
</template>
<script setup>
import { ref, defineEmits, defineProps } from 'vue'
const props = defineProps({
visible: {
type: Boolean,
default: false
},
babyList: {
type: Array,
default: () => []
},
selectedIndex: {
type: Number,
default: 0
}
})
const emit = defineEmits(['update:visible', 'update:selectedIndex', 'change'])
const selectHandle = () => {
}
const isOkPressed = ref(false)
const handleOkTouchStart = () => {
isOkPressed.value = true
}
const handleOkTouchEnd = () => {
isOkPressed.value = false
const index = selectIndex.value;
// 发送事件 通知主页面
emit('change', props.babyList[index], index)
closePopup();
}
const closePopup = () => {
emit('update:visible', false)
}
const selectIndex = ref(0)
const selectBaby = (index) => {
selectIndex.value = index;
emit('update:selectedIndex', index);
}
</script>
<style lang="less" scoped>
.popup-overlay {
position: fixed;
top: 0;
left: 0;
right: 0;
bottom: 0;
background-color: rgba(0, 0, 0, 0.7);
z-index: 9999;
// display: flex;
// align-items: center;
// justify-content: center;
.popup-content {
position: absolute;
width: 750rpx;
height: 719rpx;
background-color: #f6f8fa;
overflow: hidden;
border-top-left-radius: 32rpx;
border-top-right-radius: 32rpx;
bottom: 0rpx;
.popup-header {
display: flex;
align-items: center;
justify-content: space-between;
padding: 40rpx 30rpx 20rpx;
.popup-title {
font-size: 32rpx;
font-weight: bold;
color: #333;
}
.close-btn {
width: 40rpx;
height: 40rpx;
}
}
.baby-list {
flex: 1;
padding-left: 31rpx;
padding-right: 31rpx;
padding-top: 20rpx;
// padding-bottom: 20rpx;
height: 360rpx;
overflow-y: auto;
.baby-item {
position: relative;
display: flex;
align-items: center;
padding-left: 30rpx;
margin-bottom: 20rpx;
height: 129rpx;
border-radius: 16rpx;
background-color: #fff;
&.selected {
background-color: transparent;
}
.baby-item-bg {
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
width: 100%;
height: 100%;
z-index: 1;
}
.baby-avatar {
position: relative;
z-index: 2;
width: 80rpx;
height: 80rpx;
border-radius: 50%;
margin-right: 20rpx;
}
.baby-info {
position: relative;
z-index: 2;
flex: 1;
.baby-name-row {
display: flex;
align-items: center;
margin-bottom: 8rpx;
.baby-name {
font-size: 28rpx;
font-weight: bold;
color: #333;
margin-right: 10rpx;
}
.gender-icon {
width: 24rpx;
height: 24rpx;
}
}
.baby-birthday {
font-size: 24rpx;
color: #666;
}
}
}
}
.ok-btn {
position: absolute;
width: 681rpx;
height: 98rpx;
margin-left: 35rpx;
margin-top: 0rpx;
&.ok-btn-active {
transform: scale(0.95);
}
}
}
}
</style>
\ No newline at end of file
<template>
<view v-if="visible" class="popup-overlay">
<view class="popup-content" @click.stop>
<!-- 问号图标 -->
<view class="question-icon">
<image class="icon" src="/static/shengzhangTool/tipsPopIcon.png" mode="aspectFit"></image>
</view>
<!-- 提示内容区域 -->
<view class="tips-content">
<rich-text class="rich-content" :nodes="tipsContent"></rich-text>
</view>
<!-- 底部按钮 -->
<view class="bottom-buttons">
<image
class="ok-btn"
:class="{'ok-btn-active': isOkPressed}"
src="/static/shengzhangTool/tipsOkBtn.png"
@touchstart="handleOkTouchStart"
@touchend="handleOkTouchEnd"
mode="aspectFit"
/>
</view>
</view>
</view>
</template>
<script setup>
import { ref, defineEmits, defineProps } from 'vue'
const props = defineProps({
visible: {
type: Boolean,
default: false
}
})
const emit = defineEmits(['update:visible'])
// 按钮状态
const isOkPressed = ref(false)
// 富文本内容
const tipsContent = ref(`
<div style="padding: 20rpx; line-height: 1.6;">
<div style="font-size: 32rpx; font-weight: bold; color: #d3a358;">头围测量</div>
<div style="font-size: 28rpx; font-weight: 300; color: #000000;">将软尺固定于小儿眉毛上缘,软尺紧贴头皮绕过后脑最高点即为头围的长度。</div>
<br>
<div style="font-size: 32rpx; font-weight: bold; color: #d3a358;">身高测量</div>
<div style="font-size: 28rpx; font-weight: 300; color: #000000;">3岁以下的小儿躺着测身长,让小儿躺在桌上或木板床上,按直小儿的双膝,使两下肢伸直,用软尺量取头顶到脚底(注意不是足尖)的长度,3岁以上的小儿可站着测身高。</div>
<br>
<div style="font-size: 32rpx; font-weight: bold; color: #d3a358;">体重测量</div>
<div style="font-size: 28rpx; font-weight: 300; color: #000000;">1)先用小被单将孩子兜住,用称称重,然后减去小被单及包括尿布在内的一切衣物重量,即为婴儿体重;</div>
<div style="font-size: 28rpx; font-weight: 300; color: #000000;">2)家长抱着婴儿站在磅秤上称体重,减去大人的体重,即为婴儿体重。</div>
<div style="font-size: 28rpx; font-weight: 300; color: #000000;">3)测量前最好空腹,排去大小便,或两小时内没有进食,尽量脱去衣裤、鞋帽、尿布等,仅穿单衣裤;所测得的数据应减去婴儿所穿的衣物及尿布的重量。</div>
</div>
`)
// 确认按钮事件
const handleOkTouchStart = () => {
isOkPressed.value = true
}
const handleOkTouchEnd = () => {
isOkPressed.value = false
closePopup()
}
const closePopup = () => {
emit('update:visible', false)
}
</script>
<style lang="less" scoped>
.popup-overlay {
position: fixed;
top: 0;
left: 0;
right: 0;
bottom: 0;
background-color: rgba(0, 0, 0, 0.7);
z-index: 9999;
.popup-content {
position: absolute;
width: 661rpx;
height: 883rpx;
background-color: #ffffff;
overflow: hidden;
border-radius: 52rpx;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
display: flex;
flex-direction: column;
.question-icon {
display: flex;
justify-content: center;
align-items: center;
margin-top: 40rpx;
.icon {
width: 80rpx;
height: 80rpx;
}
}
.tips-content {
margin-top: 20rpx;
flex: 1;
padding-left: 30rpx;
padding-right: 30rpx;
overflow-y: auto;
.rich-content {
width: 100%;
height: 100%;
/deep/ div {
margin-bottom: 20rpx;
}
/deep/ br {
display: block;
margin: 10rpx 0;
}
}
}
.bottom-buttons {
display: flex;
justify-content: center;
align-items: center;
padding: 0 40rpx 40rpx;
margin-top: 30rpx;
.ok-btn {
width: 500rpx;
height: 97rpx;
transition: transform 0.1s ease-out;
&.ok-btn-active {
transform: scale(0.95);
}
}
}
}
}
</style>
\ No newline at end of file
This diff is collapsed.
{
"pages": [
// 产检提醒
{
"path" : "pages/postnatalCheckUp/postnatalCheckUp",
"style" :
......@@ -98,7 +97,6 @@
"enablePullDownRefresh" : false
}
},
// 我的报告单
{
"path" : "pages/myReportCard/myReportCard",
"style" :
......@@ -108,7 +106,6 @@
"navigationStyle": "custom"
}
},
// 产检日历
{
"path" : "pages/productionCalendar/productionCalendar",
"style" :
......@@ -118,7 +115,6 @@
"navigationStyle": "custom"
}
},
// 产检详情
{
"path" : "pages/productionDetails/productionDetails",
"style" :
......@@ -136,6 +132,18 @@
"navigationBarBackgroundColor":"#ffffff",
"enablePullDownRefresh" : false
}
},
{
"path": "pages/shengzhangTools/shengzhangTools",
"style": {
"navigationStyle": "custom"
}
},
{
"path": "pages/shengzhangTestResult/shengzhangTestResult",
"style": {
"navigationStyle": "custom"
}
}
],
"globalStyle": {
......
This diff is collapsed.
This diff is collapsed.
import { defineStore } from "pinia";
import {
assessmentSave,
getGrowthCurveData
} from "../api/shengzhangTools.js";
export const useShengzhangStore = defineStore("shengzhangInfo", {
state: () => {
return {
shengzhangInfo: null,
getGrowthCurveDataInfoHeight: null,
getGrowthCurveDataInfoWeight: null,
getGrowthCurveDataInfoHead: null,
getGrowthCurveDataInfoBmi: null,
};
},
actions: {
/**
* 设置生长测评结果
* @param {Object} userInfo
*/
setShengzhangInfo(shengzhangInfo) {
this.shengzhangInfo = shengzhangInfo;
},
async assessmentSave(submitData) {
const data = await assessmentSave(submitData);
if(data.success){
data.data.success = data.success;
this.setShengzhangInfo(data.data);
}
},
setGetGrowthCurveDataHeightInfo(getGrowthCurveDataInfo) {
this.getGrowthCurveDataInfoHeight = getGrowthCurveDataInfo;
},
setGetGrowthCurveDataWeightInfo(getGrowthCurveDataInfo) {
this.getGrowthCurveDataInfoWeight = getGrowthCurveDataInfo;
},
setGetGrowthCurveDataHeadInfo(getGrowthCurveDataInfo) {
this.getGrowthCurveDataInfoHead = getGrowthCurveDataInfo;
},
setGetGrowthCurveDataBmiInfo(getGrowthCurveDataInfo) {
this.getGrowthCurveDataInfoBmi = getGrowthCurveDataInfo;
},
async getGrowthCurveData(babyData) {
const data = await getGrowthCurveData(babyData);
if(data.success){
data.data.success = data.success;
switch(babyData.curveType){
case 'HEIGHT':
this.setGetGrowthCurveDataHeightInfo(data.data);
break;
case 'WEIGHT':
this.setGetGrowthCurveDataWeightInfo(data.data);
break;
case 'HEAD':
this.setGetGrowthCurveDataHeadInfo(data.data);
break;
case 'BMI':
this.setGetGrowthCurveDataBmiInfo(data.data);
break;
}
}
},
},
});
......@@ -21,6 +21,7 @@ export const useUserStore = defineStore("userInfo", {
babyInfo: null,
memberInfo: null,
babyNickCache: [],
cepingjieguoInfo:null,
};
},
actions: {
......
......@@ -54,6 +54,19 @@ export function jump({ type, url, extra = {} }) {
}
}
export function formatDate(timestamp){
const date = new Date(timestamp);
if (isNaN(date.getTime())) {
console.error('无效的时间戳:', timestamp);
return '';
}
const year = date.getFullYear()
const month = String(date.getMonth() + 1).padStart(2, '0')
const day = String(date.getDate()).padStart(2, '0')
return `${year}-${month}-${day}`
}
/**
* 防连点函数
* @param {Function} fn 需要防连点的函数
......
......@@ -1472,6 +1472,7 @@
//banner点击事件
const bannerHandler = (item) => {
md.sensorLogTake({
xcxClick: "积分服务页-首屏页面点击",
pageName: "积分服务页-首屏",
......
......@@ -232,6 +232,8 @@ const babyInfo = computed(() => userStore?.babyInfo || {});
const showRegisterLayer = ref(false);
const showBabySwitcher = ref(false);
const babyId = ref(0);
const handleHot = (e) => {
const type = e.currentTarget.dataset.type;
md.sensorLog(e);
......@@ -245,6 +247,7 @@ const handleHot = (e) => {
}
};
// 页面跳转
const navigateTo = (url) => {
uni.navigateTo({
......@@ -299,7 +302,13 @@ const handleToolClick = async (item) => {
},
});
} else {
jump({ type: item.link.type, url: item.link.url });
const extra = item.link.extra;
if(extra && extra.babyId){
jump({ type: item.link.type, url: item.link.url+'?babyId='+extra.babyId});
}else{
jump({ type: item.link.type, url: item.link.url});
}
}
};
......@@ -323,9 +332,8 @@ const handleEditProfile = (e) => {
md.sensorLog(e);
const type =
userStore.babyInfo?.allBabyBaseInfo?.length == 0 ? "add" : "edit";
const babyId = userStore.babyInfo?.allBabyBaseInfo.find(
const type = userStore.babyInfo?.allBabyBaseInfo?.length == 0 ? "add" : "edit";
babyId.value = userStore.babyInfo?.allBabyBaseInfo.find(
(item) => item.selected
)?.id;
......@@ -436,11 +444,32 @@ onMounted(async () => {
await pageCfgStore.fetchCfg();
initData();
hideLoading();
babyId.value = userStore.babyInfo?.allBabyBaseInfo.find(
(item) => item.selected
)?.id;
console.log('babyIdsdfsdfsdfsdfsdfsdfdsfsdf=', babyId.value);
const a = {
"bgUrl": "my/babytest.png",
"desc": "生长测评",
"link": {
"extra": {babyId: babyId.value},
"type": 1,
"url": "/pages/shengzhangTools/shengzhangTools"
},
"title": "生长测评"
}
toolList.value.push(a);
});
watch([() => userStore.userInfo, () => userStore.babyInfo], () => {
console.log("userInfo/babyInfo变化", userStore.userInfo, userStore.babyInfo);
initData();
babyId.value = userStore.babyInfo?.allBabyBaseInfo.find(
(item) => item.selected
)?.id;
});
// 定义页面配置
......
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