Commit 2f99e2c5 authored by 张九刚's avatar 张九刚

feat: backuo

parent cfa344ec
......@@ -17,9 +17,9 @@ const {
// 通常可以吧 baseUrl 单独放在一个 js 文件了
// const baseUrl = "http://172.16.230.108:7777/pmall";
// const baseUrl = "https://momclub-uat.feihe.com/pmall";//测试环境
let baseUrl = "https://momclub.feihe.com/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 baseUrl = "https://feihe.m.duibatest.com.cn/pmall"
const request = (options = {}) => {
// 在这里可以对请求头进行一些设置
......
......@@ -4,68 +4,45 @@
<!-- 弹窗头部 -->
<view class="popup-header">
<text class="popup-title">切换宝宝</text>
<image
class="close-btn"
:src="`${$baseUrl}shengzhangTool/1001/changeBaby/closeBtn.png`"
mode="aspectFit"
@click="closePopup"
/>
<image class="close-btn" :src="`${$baseUrl}shengzhangTool/1001/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: selectIndex === index }"
@click="selectBaby(index)"
>
<view v-for="(baby, index) in babyList" :key="index" class="baby-item"
:class="{ selected: selectIndex === index }" @click="selectBaby(index)">
<!-- 选中背景 -->
<image
v-if="selectIndex === index"
class="baby-item-bg"
:src="`${$baseUrl}shengzhangTool/1001/changeBaby/babyItemBg.png`"
mode="aspectFit"
/>
<image v-if="selectIndex === index" class="baby-item-bg"
:src="`${$baseUrl}shengzhangTool/1001/changeBaby/babyItemBg.png`" mode="aspectFit" />
<!-- 宝宝头像 -->
<image
class="baby-avatar"
:src="baby.babyAvatar || `https://course.feihe.com/momclub-picture/common/default_avatar.png`"
mode="aspectFill"
/>
<image class="baby-avatar"
:src="baby.babyAvatar || `https://course.feihe.com/momclub-picture/common/default_avatar.png`"
mode="aspectFill" />
<!-- 宝宝信息 -->
<view class="baby-info">
<view class="baby-name-row">
<text class="baby-name">{{ baby.babyName }}</text>
<image
class="gender-icon"
:src="baby.babyGender === 'M' ? `${$baseUrl}shengzhangTool/1001/sex1.png` : `${$baseUrl}shengzhangTool/1001/sex0.png`"
mode="aspectFit"
/>
<image class="gender-icon"
:src="baby.babyGender === 'M' ? `${$baseUrl}shengzhangTool/1001/sex1.png` : `${$baseUrl}shengzhangTool/1001/sex0.png`"
mode="aspectFit" />
</view>
<text class="baby-birthday">宝宝生日: {{ baby.babyBirthday }}</text>
</view>
</view>
</view>
<image
class="ok-btn"
:class="{'ok-btn-active': isOkPressed}"
:src="`${$baseUrl}shengzhangTool/1001/changeBaby/okBtn.png`"
@touchstart="handleOkTouchStart"
@touchend="handleOkTouchEnd"
mode="aspectFit"
></image>
<image class="ok-btn" :class="{ 'ok-btn-active': isOkPressed }"
:src="`${$baseUrl}shengzhangTool/1001/changeBaby/okBtn.png`" @touchstart="handleOkTouchStart"
@touchend="handleOkTouchEnd" mode="aspectFit"></image>
</view>
</view>
</template>
<script setup>
import { ref, defineEmits, defineProps, onMounted } from 'vue'
import { ref, defineEmits, defineProps, onMounted, watch } from 'vue'
import { useUserStore } from "@/stores/user";
import md from '../md.js'
......@@ -91,12 +68,13 @@ const props = defineProps({
}
})
const userStore = useUserStore();
const emit = defineEmits(['update:visible', 'update:selectedIndex', 'change'])
const selectHandle = () => {
}
const isOkPressed = ref(false)
......@@ -145,9 +123,10 @@ const selectBaby = (index) => {
}
const babyList = ref([]);
onMounted(() => {
const initListData = () => {
babyList.value = (userStore.babyInfo?.allBabyBaseInfo || []).filter(tem => tem.babyStage === 2);
if(babyList.value === null){
if (babyList.value === null) {
babyList.value = [];
}
......@@ -159,6 +138,16 @@ onMounted(() => {
toolName: "生长曲线",
popName: "切换宝宝弹窗"
});
}
watch(() => props.visible, (val, oldVal) => {
if (val && !oldVal) {
// 打开的时候更新数据
initListData();
}
}, { immediate: true })
onMounted(() => {
initListData();
})
......@@ -192,13 +181,13 @@ onMounted(() => {
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;
......@@ -223,11 +212,11 @@ onMounted(() => {
height: 129rpx;
border-radius: 16rpx;
background-color: #fff;
&.selected {
background-color: transparent;
}
.baby-item-bg {
position: absolute;
top: 0;
......@@ -238,7 +227,7 @@ onMounted(() => {
height: 100%;
z-index: 1;
}
.baby-avatar {
position: relative;
z-index: 2;
......@@ -247,30 +236,30 @@ onMounted(() => {
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;
......@@ -285,6 +274,7 @@ onMounted(() => {
height: 98rpx;
margin-left: 35rpx;
margin-top: 0rpx;
&.ok-btn-active {
transform: scale(0.95);
}
......@@ -292,12 +282,4 @@ onMounted(() => {
}
}
</style>
\ No newline at end of file
......@@ -35,6 +35,7 @@
</template>
</view>
<view class="form-btn" @click="onAdd">
<image v-if="isType == '0' || isType == '2'" :src="`${$baseUrl}chanjianTool/1001/icon23.png`"></image>
<template v-if="type == '1'">
......@@ -43,6 +44,8 @@
<template v-if="type == '2'">
{{ isType == '0' ? '添加状态' : isType == '3' ? '我知道了' : isType == '1' ? '切换状态' : '修改状态' }}
</template>
<button v-if="isNotLogin" type="primary" class="phone-button" open-type="getPhoneNumber"
@getphonenumber="getRealtimePhoneNumber" />
</view>
</view>
</view>
......@@ -53,7 +56,8 @@ import {
ref,
onMounted,
computed,
defineEmits
defineEmits,
watch
} from 'vue'
import { useUserStore } from "@/stores/user";
// 接受父组件参数
......@@ -61,6 +65,10 @@ const props = defineProps({
type: {
type: String,
default: '1', // 1 非宝宝状态 2 非孕中状态
},
isNotLogin: {
type: Boolean,
default: false //是否未登录
}
})
// 用户信息
......@@ -68,7 +76,7 @@ const userStore = useUserStore();
const babyInfo = ref(userStore.babyInfo)
// 回调函数
const emit = defineEmits([ 'statusChange', 'close'])
const emit = defineEmits(['statusChange', 'close'])
const isType = ref('0') // 0 添加状态或者宝宝 1 切换状态 2 修改状态 3 宝宝已达上限
......@@ -77,18 +85,18 @@ const babyBaseId = ref('')
// 产检信息
const pregnancyStatus = computed(() => {
return isType.value == '0' ? '新增孕中'
: isType.value == '1' ? '切换孕中'
: isType.value == '2' ? '修改备孕'
: '';
return isType.value == '0' ? '新增孕中'
: isType.value == '1' ? '切换孕中'
: isType.value == '2' ? '修改备孕'
: '';
})
// 生长曲线和喂养记录
const babyStatus = computed(() => {
return isType.value == '0' ? '新增宝宝'
: isType.value == '1' ? '切换宝宝'
: isType.value == '2' ? (babyInfo.value.babyStage == 0 ? '修改备孕' :
babyInfo.value.babyStage == 1 ? '修改孕中' : '')
: '';
return isType.value == '0' ? '新增宝宝'
: isType.value == '1' ? '切换宝宝'
: isType.value == '2' ? (babyInfo.value.babyStage == 0 ? '修改备孕' :
babyInfo.value.babyStage == 1 ? '修改孕中' : '')
: '';
})
// 跳转新增宝宝状态页面
const navigateToFn = () => {
......@@ -98,12 +106,30 @@ const navigateToFn = () => {
url: `/pages/person/person?type=${type}`
})
}
const getRealtimePhoneNumber = async (e) => {
console.log("获取手机号码", e);
if (e.detail.errMsg !== "getPhoneNumber:ok") {
uni.showToast({
title: "请授权使用手机号",
icon: "none",
});
return;
}
await userStore.phoneCallback(e.detail, () => { }, () => {
emit('afterPhone') //如果没有宝宝信息,页面中处理宝宝注册信息
});
console.log("closeclosecloseclose");
emit('close')
emit('statusChange') //借用这个事件,刷新下页面数据
};
// 切换状态 需要对应的宝宝id 直接请求接口
const switchState = async () => {
console.log('切换状态', babyBaseId.value)
await userStore.changeBabySelected(babyBaseId.value);
// 发送事件 通知主页面
// 发送事件 通知主页面
emit('statusChange')
}
// 修改状态 需要对应备胎的id 跳转到编辑页面
......@@ -117,8 +143,12 @@ const modifyState = async () => {
url: `/pages/person/person?type=${type}&id=${babyBaseId.value}`
})
}
//这里新增一下未登录的情况,点击事件直接去拉起手机号授权
// 跳转新增产检页面
const onAdd = () => {
if (props.isNotLogin == true) {
return;
}
// 0 添加状态或者宝宝 1 切换状态 2 修改状态 3 宝宝已达上限
switch (isType.value) {
case '0':
......@@ -138,10 +168,14 @@ const onAdd = () => {
}
}
onMounted(() => {
onMounted(async () => {
if (props.isNotLogin) {
await userStore.wxAutoLogin();
}
// 宝宝生长测试和喂养记录
console.log('babyInfo-获取宝宝', babyInfo.value)
const babyBaseInfo = babyInfo.value.allBabyBaseInfo
const babyBaseInfo = babyInfo?.value?.allBabyBaseInfo
console.log("🚀 ~ babyBaseInfo:", babyBaseInfo)
// 有宝宝状态
if (babyBaseInfo) {
......@@ -168,7 +202,7 @@ onMounted(() => {
// }
babyBaseId.value = babyInfo.value.content.id;
isType.value = '2';
}
}
// 产检提醒
......@@ -205,14 +239,14 @@ onMounted(() => {
// 如果找到符合条件的 baby,取出它的 id 并赋值
babyBaseId.value = stageOneBaby.id;
} else { // 修改
console.log('没有找到符合条件的 baby', babyInfo.value);
console.log('没有找到符合条件的 baby', babyInfo.value);
// // 判断没有备孕的状态
// if (!babyBaseInfo.some(baby => baby.babyStage == 0)) {
// isType.value = '0'
// } else {
// const stageZeroBaby = babyBaseInfo.find(baby => baby.babyStage == 0);
babyBaseId.value = babyInfo.value.content.id;
isType.value = '2';
babyBaseId.value = babyInfo.value.content.id;
isType.value = '2';
// }
}
......@@ -319,11 +353,19 @@ onMounted(() => {
align-items: center;
justify-content: center;
margin-top: 55rpx;
position: relative;
image {
width: 42rpx;
height: 42rpx;
margin-right: 12rpx;
}
.phone-button {
width: 100%;
height: 100%;
position: absolute;
opacity: 0;
}
}
</style>
\ No newline at end of file
......@@ -6,7 +6,7 @@ const init = (SENSORS_URL) => {
sensors.setPara({
name: "sensors",
server_url: SENSORS_URL,
show_log: true,
show_log: false,
autoTrack: {
appLaunch: true, // 默认为 true,false 则关闭 $MPLaunch 事件采集
appShow: true, // 默认为 true,false 则关闭 $MPShow 事件采集
......
......@@ -422,7 +422,7 @@
<script setup>
import { ref, computed, onMounted, onUnmounted, getCurrentInstance } from 'vue'
import { onShow, onLoad, onHide } from '@dcloudio/uni-app'
import { onShow, onLoad, onHide,onShareAppMessage,onShareTimeline } from '@dcloudio/uni-app'
import BabySwitchPopup from '@/components/BabySwitchPopup.vue'
import popupTip from '../../components/popup-tip/popup-tip.vue'
import { fetchFeedingJSON, feedingHome, feedingRecords, feedingFoodsCustom, feedingFoodsCustomAdd, feedingFoodsCustomDelete, feedingTimerStart, feedingTimerStop, feedingVoiceUpload, feedingVoiceResult } from '@/api/feeding.js'
......@@ -2412,7 +2412,7 @@ function showAddFoodPopup(categoryName) {
pageName: "喂养工具首页",
buttonName: "辅食添加" + categoryName,
});
// 防连点检查
if (foodSelectionState.value.isAddingFood) {
console.log('防连点:添加辅食按钮被阻止')
......@@ -3747,7 +3747,22 @@ function loadDefaultFoodsData() {
}
}
onShareAppMessage(() => {
return {
title: "喂养记录:喂奶辅食轻松记录,喂养数据一目了然",
path: "/pages/feedingIndex/feedingIndex",
imageUrl: $baseUrl + "share/weiyang.png",
}
});
onShareTimeline(() => {
return {
title: "喂养记录:喂奶辅食轻松记录,喂养数据一目了然",
path: "/pages/feedingIndex/feedingIndex",
imageUrl: $baseUrl + "share/weiyang.png",
}
});
</script>
<style lang="scss" scoped>
......
......@@ -117,8 +117,7 @@
<popup-tip v-if="isTip" type="2" @statusChange="onBabyChange" @close="isTip = false"></popup-tip>
<!-- 使用封装后的日期选择器组件 -->
<DatePicker v-model:visible="visible" :default-date="time" @confirm="handleDateConfirm"
/>
<DatePicker v-model:visible="visible" :default-date="time" @confirm="handleDateConfirm" />
</view>
</view>
</template>
......@@ -133,7 +132,9 @@ import {
} from 'vue'
import {
onLoad,
onShow
onShow,
onShareAppMessage,
onShareTimeline
} from '@dcloudio/uni-app'
import {
jump,
......@@ -354,7 +355,7 @@ const close = (type) => {
});
}
showPicker.value = false;
}
// 选择提醒事件
const handleChange = (e) => {
......@@ -589,6 +590,24 @@ onMounted(() => {
pageName: "产检提醒首页"
});
})
onShareAppMessage(() => {
return {
title: "产检工具:孕检项目全掌握,产检日程不错过",
path: "/pages/postnatalCheckUp/postnatalCheckUp",
imageUrl: $baseUrl + "share/chanjian.png",
}
});
onShareTimeline(() => {
return {
title: "产检工具:孕检项目全掌握,产检日程不错过",
path: "/pages/postnatalCheckUp/postnatalCheckUp",
imageUrl: $baseUrl + "share/chanjian.png",
}
});
</script>
<style lang="less" scoped>
......
<template>
<view class="shengzhang-tools-container">
<swiper
class="banner-swiper"
:indicator-dots="swiperData?.length > 1"
:autoplay="swiperData?.length > 1"
:circular="swiperData?.length > 1"
indicator-color="#dfddd9"
indicator-active-color="#b27c1e"
:indicator-top="596"
v-if="swiperData && swiperData?.length > 0"
>
<swiper class="banner-swiper" :indicator-dots="swiperData?.length > 1" :autoplay="swiperData?.length > 1"
:circular="swiperData?.length > 1" indicator-color="#dfddd9" indicator-active-color="#b27c1e"
:indicator-top="596" v-if="swiperData && swiperData?.length > 0">
<swiper-item v-for="(item, index) in swiperData" :key="index">
<image
class="banner-img"
:src="`${$baseUrl}${item?.img}`"
mode="aspectFill"
@click="bannerHandler(item, index)"
/>
<image class="banner-img" :src="`${$baseUrl}${item?.img}`" mode="aspectFill"
@click="bannerHandler(item, index)" />
</swiper-item>
</swiper>
<!-- <image @tap="backHandler" class="btnback" :src="$baseUrl + `shengzhangTool/1001/backBtn.png`"></image>
<text class="title">生长测评</text> -->
<view class="info-container">
<!-- 顶部宝宝信息区域 -->
<view class="baby-info-section">
<view class="baby-avatar">
<image class="avatar-img" :src="babyAvatar ? babyAvatar : `https://course.feihe.com/momclub-picture/common/default_avatar.png`" mode="aspectFill"></image>
<image class="avatar-img"
:src="babyAvatar ? babyAvatar : `https://course.feihe.com/momclub-picture/common/default_avatar.png`"
mode="aspectFill"></image>
</view>
<view class="baby-details">
<view class="baby-name-row">
<text class="baby-name">{{ babyName }}</text>
<image class="change-baby-btn" @click="changeBaby" :src="`${$baseUrl}shengzhangTool/1001/changeBaby.png`" mode="aspectFit"></image>
<image class="change-baby-btn" @click="changeBaby"
:src="`${$baseUrl}shengzhangTool/1001/changeBaby.png`" mode="aspectFit"></image>
</view>
<view class="baby-info-row">
<view class="gender-age">
<image class="gender-icon" :src="babyGender == 'M' ? `${$baseUrl}shengzhangTool/1001/sex1.png` : `${$baseUrl}shengzhangTool/1001/sex0.png`" mode="aspectFit"></image>
<image class="gender-icon"
:src="babyGender == 'M' ? `${$baseUrl}shengzhangTool/1001/sex1.png` : `${$baseUrl}shengzhangTool/1001/sex0.png`"
mode="aspectFit"></image>
<text class="age-text">{{ babyAge }}</text>
</view>
<text class="birth-date">{{ formatDate(babyBirthday) }}</text>
......@@ -43,7 +37,8 @@
</view>
<view class="record-btn" @click="viewRecords">
<text class="record-text">测评记录</text>
<image class="arrow-icon" :src="`${$baseUrl}shengzhangTool/1001/close.png`" mode="aspectFit"></image>
<image class="arrow-icon" :src="`${$baseUrl}shengzhangTool/1001/close.png`" mode="aspectFit">
</image>
</view>
</view>
......@@ -56,17 +51,19 @@
<text class="label">本次测评日期</text>
<view class="date-container" @click="showDatePicker">
<text class="date-value">{{ selectedDate }}</text>
<image class="edit-icon" :src="`${$baseUrl}shengzhangTool/1001/editIcon.png`" mode="aspectFit"></image>
<image class="edit-icon" :src="`${$baseUrl}shengzhangTool/1001/editIcon.png`" mode="aspectFit">
</image>
</view>
</view>
<!-- 分割线 -->
<image class="divider-line" :src="`${$baseUrl}shengzhangTool/1001/line.png`" mode="aspectFit"></image>
<view class="feeding-row">
<text class="label">宝宝喂养方式</text>
<view class="feeding-select" @click="showFeedingPopup">
<text class="feeding-value">{{ selectedFeedText }}</text>
<image class="dropdown-icon" :src="`${$baseUrl}shengzhangTool/1001/close.png`" mode="aspectFit"></image>
<image class="dropdown-icon" :src="`${$baseUrl}shengzhangTool/1001/close.png`" mode="aspectFit">
</image>
</view>
</view>
</view>
......@@ -89,15 +86,12 @@
<view class="input-section">
<view class="input-item">
<view class="input-container">
<image class="input-bg" :src="`${$baseUrl}shengzhangTool/1001/numBg.png`" mode="aspectFit"></image>
<picker-view
class="measurement-picker"
:class="{ 'measurement-picker-disabled': isHeightTipActive }"
:value="heightPickerValue"
@change="onHeightChange"
:indicator-style="indicatorStyle"
indicator-class="date-picker"
>
<image class="input-bg" :src="`${$baseUrl}shengzhangTool/1001/numBg.png`" mode="aspectFit">
</image>
<picker-view class="measurement-picker"
:class="{ 'measurement-picker-disabled': isHeightTipActive }" :value="heightPickerValue"
@change="onHeightChange" :indicator-style="indicatorStyle"
indicator-class="date-picker">
<picker-view-column>
<view v-for="(item, index) in heightRange" :key="index" class="picker-item">
{{ item }}
......@@ -105,30 +99,20 @@
</picker-view-column>
</picker-view>
<!-- 身高输入框 -->
<input
class="measurement-input"
type="number"
:value="height"
@input="onHeightInput"
@blur="onHeightBlur"
@focus="onHeightFocus"
:disabled="isHeightTipActive"
:style="`background-image: url(${$baseUrl}shengzhangTool/1001/numBg.png); background-size: 100% 100%; background-repeat: no-repeat;`"
/>
<input class="measurement-input" type="number" :value="height" @input="onHeightInput"
@blur="onHeightBlur" @focus="onHeightFocus" :disabled="isHeightTipActive"
:style="`background-image: url(${$baseUrl}shengzhangTool/1001/numBg.png); background-size: 100% 100%; background-repeat: no-repeat;`" />
<text class="unit">cm</text>
</view>
</view>
<view class="input-item">
<view class="input-container">
<image class="input-bg" :src="`${$baseUrl}shengzhangTool/1001/numBg.png`" mode="aspectFit"></image>
<picker-view
class="measurement-picker"
:class="{ 'measurement-picker-disabled': isWeightTipActive }"
:value="weightPickerValue"
@change="onWeightChange"
:indicator-style="indicatorStyle"
indicator-class="date-picker"
>
<image class="input-bg" :src="`${$baseUrl}shengzhangTool/1001/numBg.png`" mode="aspectFit">
</image>
<picker-view class="measurement-picker"
:class="{ 'measurement-picker-disabled': isWeightTipActive }" :value="weightPickerValue"
@change="onWeightChange" :indicator-style="indicatorStyle"
indicator-class="date-picker">
<picker-view-column>
<view v-for="(item, index) in weightRange" :key="index" class="picker-item">
{{ item }}
......@@ -136,30 +120,19 @@
</picker-view-column>
</picker-view>
<!-- 体重输入框 -->
<input
class="measurement-input"
type="number"
:value="weight"
@input="onWeightInput"
@blur="onWeightBlur"
@focus="onWeightFocus"
:disabled="isWeightTipActive"
:style="`background-image: url(${$baseUrl}shengzhangTool/1001/numBg.png); background-size: 100% 100%; background-repeat: no-repeat;`"
/>
<input class="measurement-input" type="number" :value="weight" @input="onWeightInput"
@blur="onWeightBlur" @focus="onWeightFocus" :disabled="isWeightTipActive"
:style="`background-image: url(${$baseUrl}shengzhangTool/1001/numBg.png); background-size: 100% 100%; background-repeat: no-repeat;`" />
<text class="unit">kg</text>
</view>
</view>
<view class="input-item">
<view class="input-container">
<image class="input-bg" :src="`${$baseUrl}shengzhangTool/1001/numBg.png`" mode="aspectFit"></image>
<picker-view
class="measurement-picker"
:class="{ 'measurement-picker-disabled': isHeadTipActive }"
:value="headPickerValue"
@change="onHeadChange"
:indicator-style="indicatorStyle"
indicator-class="date-picker"
>
<image class="input-bg" :src="`${$baseUrl}shengzhangTool/1001/numBg.png`" mode="aspectFit">
</image>
<picker-view class="measurement-picker"
:class="{ 'measurement-picker-disabled': isHeadTipActive }" :value="headPickerValue"
@change="onHeadChange" :indicator-style="indicatorStyle" indicator-class="date-picker">
<picker-view-column>
<view v-for="(item, index) in headRange" :key="index" class="picker-item">
{{ item }}
......@@ -167,16 +140,9 @@
</picker-view-column>
</picker-view>
<!-- 头围输入框 -->
<input
class="measurement-input"
type="number"
:value="headCircumference"
@input="onHeadInput"
@blur="onHeadBlur"
@focus="onHeadFocus"
:disabled="isHeadTipActive"
:style="`background-image: url(${$baseUrl}shengzhangTool/1001/numBg.png); background-size: 100% 100%; background-repeat: no-repeat;`"
/>
<input class="measurement-input" type="number" :value="headCircumference"
@input="onHeadInput" @blur="onHeadBlur" @focus="onHeadFocus" :disabled="isHeadTipActive"
:style="`background-image: url(${$baseUrl}shengzhangTool/1001/numBg.png); background-size: 100% 100%; background-repeat: no-repeat;`" />
<text class="unit">cm</text>
</view>
</view>
......@@ -199,7 +165,8 @@
<!-- 提交按钮 -->
<view class="submit-section">
<view class="submit-btn" @click="submitData">
<image class="submit-bg" :src="`${$baseUrl}shengzhangTool/1001/submitBtn.png`" mode="aspectFit"></image>
<image class="submit-bg" :src="`${$baseUrl}shengzhangTool/1001/submitBtn.png`" mode="aspectFit">
</image>
<!-- <text class="submit-text">确认提交</text> -->
</view>
<view class="bottom-tip" @click="onClickTips">
......@@ -209,14 +176,18 @@
</view>
</view>
<view class="guide-container" v-if="guideIndex != -1" @click="guideHandler">
<image v-if="guideIndex == 0" class="guide-img0" :src="`${$baseUrl}shengzhangTool/1001/guide0.png`" mode="aspectFit"></image>
<image v-if="guideIndex == 1" class="guide-img1" :src="`${$baseUrl}shengzhangTool/1001/guide1-2.png`" mode="aspectFit"></image>
<image v-if="guideIndex == 2" class="guide-img2" :src="`${$baseUrl}shengzhangTool/1001/guide2.png`" mode="aspectFit"></image>
<image v-if="guideIndex == 0" class="guide-img0" :src="`${$baseUrl}shengzhangTool/1001/guide0.png`"
mode="aspectFit"></image>
<image v-if="guideIndex == 1" class="guide-img1" :src="`${$baseUrl}shengzhangTool/1001/guide1-2.png`"
mode="aspectFit"></image>
<image v-if="guideIndex == 2" class="guide-img2" :src="`${$baseUrl}shengzhangTool/1001/guide2.png`"
mode="aspectFit"></image>
</view>
<view class="loading-container" v-if="showLoading">
<view class="loading-content">
<view class="star-container">
<image class="loading-star" :src="`${$baseUrl}shengzhangTool/1001/loadingActImg.png`" mode="aspectFit"></image>
<image class="loading-star" :src="`${$baseUrl}shengzhangTool/1001/loadingActImg.png`"
mode="aspectFit"></image>
</view>
<view class="loading-text">
<text class="loading-title">正在计算宝宝的生长测评得分</text>
......@@ -227,49 +198,42 @@
</view>
<!-- 在页面底部添加弹窗组件 -->
<BabySwitchPopup
v-model:visible="showBabySwitchPopup"
:babyList="babyList"
v-model:selectedIndex="currentBabyIndex"
@change="onBabyChange"
/>
<BabySwitchPopup v-model:visible="showBabySwitchPopup" :babyList="babyList" v-model:selectedIndex="currentBabyIndex"
@change="onBabyChange" />
<!-- 喂养方式弹窗 -->
<BabyFeedSwitchPopup
v-model:visible="showFeedSwitchPopup"
v-model:selectedIndex="currentFeedIndex"
@change="onFeedChange"
/>
<BabyFeedSwitchPopup v-model:visible="showFeedSwitchPopup" v-model:selectedIndex="currentFeedIndex"
@change="onFeedChange" />
<!-- 日期选择弹窗 -->
<DatePickerPopup
v-model:visible="showDatePickerPopup"
v-model:selectedDate="selectedDate"
v-model:babyBirthday="babyBirthday"
@change="onDateChange"
/>
<DatePickerPopup v-model:visible="showDatePickerPopup" v-model:selectedDate="selectedDate"
v-model:babyBirthday="babyBirthday" @change="onDateChange" />
<!-- 宝宝测评提示弹窗 -->
<BabyTestTipsPopup
v-model:visible="showBabyTestTipsPopup"
/>
<popup-tip v-if="isTip" type="1" @statusChange="onBabyChange1" @close="isTip = false"></popup-tip>
<BabyTestTipsPopup v-model:visible="showBabyTestTipsPopup" />
<popup-tip v-if="isTip" type="1" @statusChange="onBabyChange1" @afterPhone="isShowRegisterLayer = true"
@close="isTip = false" :isNotLogin="isNotLogin"></popup-tip>
<RegisterLayer v-model="isShowRegisterLayer" @confirm="onRegisterConfirm" />
</template>
<script setup>
import { onMounted, ref } from 'vue'
import { onMounted, ref, getCurrentInstance,watch } from 'vue'
import BabySwitchPopup from '@/components/BabySwitchPopup.vue'
import BabyFeedSwitchPopup from '@/components/BabyFeedSwitchPopup.vue'
import DatePickerPopup from '@/components/DatePickerPopup.vue'
import BabyTestTipsPopup from '@/components/BabyTestTipsPopup.vue'
import { growthHome, guideCompleted, getGrowthCurveData,fetchShengzhangToolsJSON } from '../../api/shengzhangTools'
import { onLoad,onShow } from "@dcloudio/uni-app";
import { throttleTap,jump, JumpType, formatDate } from '../../utils/index.js';
import { growthHome, guideCompleted, getGrowthCurveData, fetchShengzhangToolsJSON } from '../../api/shengzhangTools'
import { onLoad, onShow , onShareAppMessage, onShareTimeline} from "@dcloudio/uni-app";
import { throttleTap, jump, JumpType, formatDate } from '../../utils/index.js';
import { useShengzhangStore } from '../../stores/shengzhangResult.js';
import { useUserStore } from "@/stores/user";
import md from '../../md';
import { RegisterLayer } from '@/components/RegisterLayer.vue';
import { storeToRefs } from 'pinia'
const isTip = ref(false);
const isNotLogin = ref(false);
const isShowRegisterLayer = ref(false);
const babyName = ref('宝宝名称')
const babyAge = ref('8月龄')
......@@ -282,39 +246,40 @@ const shengzhangStore = useShengzhangStore();
const guideFlag = ref(false);
const showLoading = ref(false);
const { proxy } = getCurrentInstance();
const $baseUrl = proxy.$baseUrl;
const bannerHandler = (item, index) => {
console.log(item)
let buttonName = '';
switch(index){
case 0:
buttonName = '第一张焦点图';
break;
case 1:
buttonName = '第二张焦点图';
break;
case 2:
buttonName = '第三张焦点图';
break;
case 3:
buttonName = '第四张焦点图';
break;
}
switch (index) {
case 0:
buttonName = '第一张焦点图';
break;
case 1:
buttonName = '第二张焦点图';
break;
case 2:
buttonName = '第三张焦点图';
break;
case 3:
buttonName = '第四张焦点图';
break;
}
md.sensorLogTake({
xcxClick: "生长曲线首页-banner资源位",
pageName: "生长曲线首页",
buttonName: buttonName,
});
if(item?.url != ""){
jump({
type: item.type,
url: item.url,
extra: item.extra
})
}
md.sensorLogTake({
xcxClick: "生长曲线首页-banner资源位",
pageName: "生长曲线首页",
buttonName: buttonName,
});
if (item?.url != "") {
jump({
type: item.type,
url: item.url,
extra: item.extra
})
}
}
// 首页组件逻辑
......@@ -381,10 +346,10 @@ const showDatePicker = () => {
console.log('显示日期选择器')
md.sensorPopLogTake({
xcxPopExposure: "true",
toolName: "生长曲线",
popName: "选择本次测评日期弹窗"
});
xcxPopExposure: "true",
toolName: "生长曲线",
popName: "选择本次测评日期弹窗"
});
showDatePickerPopup.value = true
}
......@@ -401,7 +366,7 @@ const showFeedingPopup = () => {
pageName: "生长曲线首页",
buttonName: "生长曲线首页-宝宝喂养方式选择-点击",
});
console.log('显示喂养方式弹窗')
showFeedSwitchPopup.value = true
currentFeedIndex.value = 1 // 默认选中"母乳+奶粉混合喂养"
......@@ -559,15 +524,15 @@ const viewRecords = () => {
}
const convertFeedingType = (type) => {
if(type == '纯母乳'){
if (type == '纯母乳') {
return 'BREAST_MILK'
}else if(type == '母乳+奶粉混合喂养'){
} else if (type == '母乳+奶粉混合喂养') {
return 'MIXED'
}else if(type == '奶粉'){
} else if (type == '奶粉') {
return 'FORMULA'
}else if(type == '母乳+辅食'){
} else if (type == '母乳+辅食') {
return 'BREAST_MILK_CF'
}else if(type == '奶粉+辅食'){
} else if (type == '奶粉+辅食') {
return 'FORMULA_CF'
}
}
......@@ -577,10 +542,10 @@ const submitData = throttleTap(async () => {
pageName: "生长曲线首页",
buttonName: "生长曲线首页-确认提交-点击",
});
showLoading.value = true;
if(headCircumference.value == 0){
if (headCircumference.value == 0) {
headCircumference.value = null;
}
const submitData = {
......@@ -595,9 +560,9 @@ const submitData = throttleTap(async () => {
await shengzhangStore.assessmentSave(submitData);
if(shengzhangStore.shengzhangInfo.success){
if (shengzhangStore.shengzhangInfo.success) {
babyId.value = shengzhangStore.shengzhangInfo.babyId;
}else{
} else {
showLoading.value = false;
return;
}
......@@ -628,8 +593,8 @@ const submitData = throttleTap(async () => {
await shengzhangStore.getGrowthCurveData(babyDataHead);
//跳转测评结果页
if(shengzhangStore.shengzhangInfo.success){
//跳转测评结果页
if (shengzhangStore.shengzhangInfo.success) {
jump({
type: JumpType.INNER,
url: "/pages/shengzhangTestResult/shengzhangTestResult"
......@@ -665,7 +630,7 @@ const onFeedChange = (feedOption, index) => {
console.log('选择了喂养方式:', feedOption, index)
selectedFeedText.value = feedOption.name
currentFeedIndex.value = index
// 这里可以更新页面上显示的喂养方式
// 比如更新 feeding-select 中的文本
}
......@@ -704,11 +669,11 @@ const toggleHeadTip = () => {
pushCount(2)
isHeadTipActive.value = !isHeadTipActive.value
if(isHeadTipActive.value){
if (isHeadTipActive.value) {
// 不改变输入框的值,只标记为暂无数据状态
tempHeadCircumference.value = headCircumference.value;
headCircumference.value = 0;
}else{
headCircumference.value = 0;
} else {
// 恢复原来的值
headCircumference.value = tempHeadCircumference.value;
}
......@@ -758,10 +723,10 @@ const guideHandler = async () => {
if (guideIndex.value > 2) {
const data = await guideCompleted();
if(data.success){
if (data.success) {
guideFlag.value = true;
guideIndex.value = -1;
}else{
} else {
//引导页完成失败,提示用户
}
}
......@@ -774,61 +739,24 @@ onLoad((options) => {
babyId.value = parseInt(options.babyId)
console.log('获取到的babyId:', babyId.value)
}
})
onShow(async () => {
await babyRefresh();
})
// 提示弹窗回调
const onBabyChange1= async ()=>{
const onRegisterConfirm = async () => {
isShowRegisterLayer.value = false;
await babyRefresh();
}
const babyRefresh = async () => {
const userStore = useUserStore();
const babyInfo = userStore.babyInfo;
if(babyInfo && babyInfo.babyStage == 2){
isTip.value = false
await refreshBabyInfo();
}else{
isTip.value = true;
}
// 提示弹窗回调
const onBabyChange1 = async () => {
await babyRefresh();
}
const shengzhangToolsData = ref({activeInfo:[
{
"img": "shengzhangTool/1001/banner1.png",
"url": "subPackages/shopMainList/topicNew/index?id=1000911",
"type": 2,
"extra": {
"appId": "wx4205ec55b793245e",
"envVersion": "release"
}
}
]
});
const swiperData = ref([]);
onMounted(async () => {
md.sensorLogTake({
xcxPage: "生长曲线首页",
pageName: "生长曲线首页"
});
const {data} = await fetchShengzhangToolsJSON();
if(data){
shengzhangToolsData.value = {...data};
}else{
shengzhangToolsData.value = {activeInfo:[]};
}
swiperData.value = shengzhangToolsData?.value?.activeInfo || [];
})
const userStore = useUserStore();
const { babyInfo } = storeToRefs(userStore)
const refreshBabyInfo = async () => {
const userStore = useUserStore();
babyId.value = userStore.babyInfo?.content?.id;
......@@ -844,11 +772,11 @@ const refreshBabyInfo = async () => {
// (item) => item.selected
// );
const {data} = await growthHome(babyId.value);
const { data } = await growthHome(babyId.value);
selectedDate.value = formatDate(new Date());
// const data = {"babyId":1234,"babyName":"小强","gender":"M","monthAge":3,"avatar":"https://momclub.feihe.com/pmall/momclub-picture/integral/1009/yuerBtn.png","birthDate":"2018-10-28 14:06:45","guideFlag":false};
babyName.value = data.babyName
babyAge.value = data.monthAge + '月龄'
babyBirthday.value = data.birthDate
......@@ -869,33 +797,110 @@ const refreshBabyInfo = async () => {
// }
}
const babyRefresh = async () => {
const userStore = useUserStore();
const babyInfo = userStore.babyInfo;
isNotLogin.value = false;
if (
userStore?.userInfo?.memberId &&
userStore?.userInfo?.memberId == "not_login" || !userStore.userInfo
) {
isNotLogin.value = true;
}
if (babyInfo && babyInfo.babyStage == 2) {
isTip.value = false
await refreshBabyInfo();
} else {
isTip.value = true;
}
}
watch(babyInfo, (newVal,oldVal) => {
if(newVal)
{
babyRefresh();
}
},{deep: true, immediate: true})
const shengzhangToolsData = ref({
activeInfo: [
{
"img": "shengzhangTool/1001/banner1.png",
"url": "subPackages/shopMainList/topicNew/index?id=1000911",
"type": 2,
"extra": {
"appId": "wx4205ec55b793245e",
"envVersion": "release"
}
}
]
});
const swiperData = ref([]);
onMounted(async () => {
md.sensorLogTake({
xcxPage: "生长曲线首页",
pageName: "生长曲线首页"
});
const { data } = await fetchShengzhangToolsJSON();
if (data) {
shengzhangToolsData.value = { ...data };
} else {
shengzhangToolsData.value = { activeInfo: [] };
}
swiperData.value = shengzhangToolsData?.value?.activeInfo || [];
})
onShareAppMessage(() => {
return {
title: "生长测评:精准评估宝宝发育水平",
path: "/pages/shengzhangTools/shengzhangTools",
imageUrl: $baseUrl + "share/shengzhang.png",
}
});
onShareTimeline(() => {
return {
title: "生长测评:精准评估宝宝发育水平",
path: "/pages/shengzhangTools/shengzhangTools",
imageUrl: $baseUrl + "share/shengzhang.png",
}
});
</script>
<style lang="less" scoped>
.shengzhang-tools-container {
width: 100%;
overflow-x: hidden;
overflow-y: auto;
background-color: #fdf6eb;
display: flex;
flex-flow: column;
width: 100%;
overflow-x: hidden;
overflow-y: auto;
background-color: #fdf6eb;
display: flex;
flex-flow: column;
.banner-swiper {
position: relative;
width: 687rpx;
margin-left: 32rpx;
height: 176rpx;
padding-bottom: 50rpx;
.banner-img {
width: 100%;
height: 100%;
border-radius: 16rpx;
}
}
.btnback {
position: absolute;
top: 119rpx;
......@@ -903,7 +908,7 @@ const refreshBabyInfo = async () => {
width: 29rpx;
height: 29rpx;
}
.title {
position: absolute;
top: 111rpx;
......@@ -913,7 +918,7 @@ const refreshBabyInfo = async () => {
color: #000;
font-weight: 600;
}
.info-container {
width: 750rpx;
height: 1210rpx;
......@@ -929,79 +934,79 @@ const refreshBabyInfo = async () => {
display: flex;
align-items: center;
padding: 0 10rpx;
.baby-avatar {
width: 80rpx;
height: 80rpx;
border-radius: 50%;
overflow: hidden;
margin-right: 20rpx;
.avatar-img {
width: 100%;
height: 100%;
}
}
.baby-details {
flex: 1;
.baby-name-row {
display: flex;
align-items: center;
margin-bottom: 8rpx;
.baby-name {
font-size: 32rpx;
font-weight: bold;
color: #333;
margin-right: 20rpx;
}
.change-baby-btn {
width: 139rpx;
height: 37rpx;
}
}
.baby-info-row {
display: flex;
align-items: center;
.gender-age {
display: flex;
align-items: center;
margin-right: 30rpx;
.gender-icon {
width: 24rpx;
height: 24rpx;
margin-right: 8rpx;
}
.age-text {
font-size: 26rpx;
color: #666;
}
}
.birth-date {
font-size: 26rpx;
color: #666;
}
}
}
.record-btn {
display: flex;
align-items: center;
.record-text {
font-size: 26rpx;
color: #666;
margin-right: 8rpx;
}
.arrow-icon {
width: 20rpx;
height: 20rpx;
......@@ -1020,50 +1025,50 @@ const refreshBabyInfo = async () => {
display: flex;
align-items: center;
justify-content: space-between;
.label {
font-size: 28rpx;
color: #333;
}
.date-container {
display: flex;
align-items: center;
.date-value {
font-size: 28rpx;
color: #666;
margin-right: 10rpx;
}
.edit-icon {
width: 24rpx;
height: 24rpx;
}
}
}
.feeding-row {
display: flex;
align-items: center;
justify-content: space-between;
margin-bottom: 25rpx;
.label {
font-size: 28rpx;
color: #333;
}
.feeding-select {
display: flex;
align-items: center;
.feeding-value {
font-size: 28rpx;
color: #666;
margin-right: 8rpx;
}
.dropdown-icon {
width: 20rpx;
height: 20rpx;
......@@ -1075,16 +1080,16 @@ const refreshBabyInfo = async () => {
.measurement-section {
margin-bottom: 40rpx;
margin-top: 80rpx;
.measurement-header {
display: flex;
margin-bottom: 25rpx;
.measurement-item {
flex: 1;
text-align: center;
.measurement-title {
font-size: 28rpx;
color: #333;
......@@ -1092,35 +1097,35 @@ const refreshBabyInfo = async () => {
}
}
}
.input-section {
display: flex;
.input-item {
flex: 1;
display: flex;
justify-content: center;
.input-container {
position: relative;
display: flex;
align-items: center;
justify-content: center;
.input-bg {
position: absolute;
width: 105rpx;
height: 44rpx;
z-index: 1;
}
.measurement-picker {
position: relative;
z-index: 2;
width: 70rpx;
height: 370rpx;
background: transparent;
:deep(.date-picker::before) {
content: none;
}
......@@ -1133,7 +1138,7 @@ const refreshBabyInfo = async () => {
opacity: 0.4;
pointer-events: none;
}
.picker-item {
display: flex;
align-items: center;
......@@ -1145,14 +1150,14 @@ const refreshBabyInfo = async () => {
line-height: 40rpx;
}
}
.measurement-input {
position: absolute;
z-index: 3;
width: 105rpx;
height: 44rpx;
margin-top: 2rpx;
margin-top: 2rpx;
// background: #ffffff;
border: none;
font-size: 28rpx;
......@@ -1160,18 +1165,18 @@ const refreshBabyInfo = async () => {
text-align: center;
font-weight: bold;
margin-left: 0rpx;
&:disabled {
opacity: 0.4;
pointer-events: none;
}
&::placeholder {
color: #999;
font-size: 20rpx;
}
}
.unit {
position: absolute;
z-index: 2;
......@@ -1186,60 +1191,60 @@ const refreshBabyInfo = async () => {
.tips-section {
display: flex;
.tip-item0 {
flex: 1;
text-align: center;
&:hover {
opacity: 0.8;
}
.tip-text {
font-size: 24rpx;
color: #1d1e26;
text-decoration: underline;
&.tip-text-active {
color: red !important;
}
}
}
.tip-item1 {
flex: 1;
text-align: center;
&:hover {
opacity: 0.8;
}
.tip-text {
font-size: 24rpx;
color: #1d1e26;
text-decoration: underline;
&.tip-text-active {
color: red !important;
}
}
}
.tip-item2 {
// flex: 1;
position: absolute;
// text-align: center;
right: 97rpx;
&:hover {
opacity: 0.8;
}
.tip-text {
font-size: 24rpx;
color: #1d1e26;
text-decoration: underline;
&.tip-text-active {
color: red !important;
}
......@@ -1248,12 +1253,12 @@ const refreshBabyInfo = async () => {
}
}
.submit-section {
.submit-section {
position: relative;
margin-top: 130rpx;
// bottom: 50rpx;
// z-index: 666;
.submit-btn {
position: relative;
width: 681rpx;
......@@ -1262,14 +1267,14 @@ const refreshBabyInfo = async () => {
align-items: center;
justify-content: center;
margin-bottom: 20rpx;
.submit-bg {
position: absolute;
width: 100%;
height: 100%;
z-index: 1;
}
.submit-text {
position: relative;
z-index: 2;
......@@ -1278,12 +1283,12 @@ const refreshBabyInfo = async () => {
font-weight: bold;
}
}
.bottom-tip {
display: flex;
align-items: center;
justify-content: center;
.tip-icon {
width: 424rpx;
height: 23rpx;
......@@ -1292,28 +1297,31 @@ const refreshBabyInfo = async () => {
}
}
.guide-container{
.guide-container {
position: absolute;
top: 0;
bottom: 0;
width: 100%;
height: 100%;
z-index: 1000;
.guide-img0{
.guide-img0 {
width: 100%;
height: 1624rpx;
position: absolute;
top: 0;
left: 0;
}
.guide-img1{
.guide-img1 {
width: 100%;
height: 1624rpx;
height: 1624rpx;
position: absolute;
top: 0;
left: 0;
}
.guide-img2{
.guide-img2 {
width: 100%;
height: 1624rpx;
position: absolute;
......@@ -1360,7 +1368,7 @@ const refreshBabyInfo = async () => {
align-items: center;
justify-content: center;
top: 850rpx;
.loading-title {
font-size: 32rpx;
color: #ffffff;
......@@ -1383,9 +1391,11 @@ const refreshBabyInfo = async () => {
0% {
opacity: 0.6;
}
50% {
opacity: 1;
}
100% {
opacity: 0.6;
}
......
......@@ -71,7 +71,7 @@ export const useUserStore = defineStore("userInfo", {
* @param {Object} data : {encryptedData, iv, code}
* @returns
*/
async phoneCallback(data, onOpenRegisterFn = () => { }) {
async phoneCallback(data, onOpenRegisterFn = () => { }, cb) {
uni.login({
provider: "weixin",
success: async (res) => {
......@@ -86,7 +86,11 @@ export const useUserStore = defineStore("userInfo", {
code: data.code,
codeLogin: res.code,
});
!babyExistence && onOpenRegisterFn && onOpenRegisterFn();
if (!babyExistence.value && cb) {
cb();
}
const homeStore = useHomeStore();
await homeStore.setBabyExistence(babyExistence);
......@@ -115,7 +119,7 @@ export const useUserStore = defineStore("userInfo", {
// 缓存用户memberId
uni.setStorageSync('memberId', data?.memberId)
}
this.userInfo = data;
this.userInfo = data;
},
setBabyNickCache(id, name) {
......
......@@ -404,6 +404,8 @@ const initData = async () => {
// 已出生或孕中显示
cfgStatus.value.showDetail = __showDetail;
if (__showDetail) {
wheelOptions.value =
babyInfo.value.babyStage == 2
......
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