Commit 23161dc4 authored by tao.huang's avatar tao.huang

fix: 修复问题

parent c7446d4f
......@@ -195,8 +195,6 @@ const columns = computed(() => {
const defaultValue = computed(() => {
if (props.mode === "date") {
console.log("defaultValue", props.value);
// 1. value为索引数组
if (Array.isArray(props.value) && props.value.length === 3) {
return props.value;
......
export const myObj = {
toolList: [
{
bgUrl: "my/literature.png",
title: "育儿百科",
desc: "",
link: {
type: 3,
url: "https://www.baidu.com",
extra: {},
tool: [
[
{
bgUrl: "my/literature.png",
title: "育儿百科",
desc: "",
link: {
type: 1,
url: "/pages/library/ContentLibrary",
extra: {},
},
},
},
{
bgUrl: "my/suyuan.png",
title: "产品溯源",
desc: "",
link: {
type: 3,
url: "https://www.baidu.com",
extra: {},
{
bgUrl: "my/suyuan.png",
title: "产品溯源",
desc: "",
link: {
type: 3,
url: "https://wic.feihe.com",
extra: {},
},
},
},
{
bgUrl: "my/book.png",
title: "奶娃宝典",
desc: "",
link: {
type: 1,
url: "/pages/library/ContentLibrary",
extra: {},
{
bgUrl: "my/book.png",
title: "奶娃宝典",
desc: "",
link: {
type: 3,
url: "https://mom.feihe.com/babyWikipedia",
extra: {},
},
},
},
{
bgUrl: "my/doctor.png",
title: "医生问诊",
desc: "",
link: {
type: 2,
url: "/pages/partner/redirect",
extra: {},
{
bgUrl: "my/doctor.png",
title: "医生问诊",
desc: "",
link: {
type: 2,
url: "/pages/partner/redirect",
extra: {},
},
},
},
{
bgUrl: "my/babytest.png",
title: "宝宝体质测试",
desc: "",
link: {
type: 3,
url: "https://www.baidu.com",
extra: {},
{
bgUrl: "my/babytest.png",
title: "宝宝体质测试",
desc: "",
link: {
type: 3,
url: "https://www.baidu.com",
extra: {},
},
},
},
],
],
conetntCfg: {
contentCfg: {
contentLikeOptions: [
"奶粉选择",
"奶粉成分",
......
......@@ -37,6 +37,7 @@
>
<image
class="person-avatar-img"
mode="aspectFill"
:src="formData.babyAvatar || $baseUrl + 'common/default_avatar.png'"
></image>
</button>
......@@ -45,7 +46,7 @@
<image
class="avatar-edit"
:src="$baseUrl + 'person/icon_modify.png'"
mode="aspectFit|aspectFill|widthFix"
mode="widthFix"
lazy-load="false"
binderror=""
bindload=""
......@@ -126,8 +127,10 @@
<view class="form-input-box">
<view class="form-input">
{{
(formData[item.name] &&
formData[item.name].split(",").join("、")) ||
(formData[item.name] &&
(formData[item.name].split(",").join("、").length > 11
? formData[item.name].split(",").join("、").slice(0, 11) + "..."
: formData[item.name].split(",").join("、"))) ||
item.placeholder
}}
</view>
......@@ -302,7 +305,7 @@ const specialAttentionOptions = ref([]);
const channelOptions = ref([]);
// 表单项配置
const formItems = [
const formItems = [
{
label: "当前状态",
name: "babyStage",
......@@ -447,6 +450,31 @@ const getPickerIndex = (item) => {
const onPickerChange = (e, name) => {
const item = formItems.find((i) => i.name === name);
if (name === "babyStage") {
if (
pageType.value === "edit" &&
babyStageMap[e].value < formData.value[name]
) {
uni.showToast({
title: "不能选择更早的阶段",
icon: "none",
});
return;
}
// 当阶段变化时清空相关表单项
if (formData.value[name] !== babyStageMap[e].value) {
formData.value.babyBirthday = "";
formData.value.dueDate = "";
formData.value.babyType = "";
formData.value.babyGender = "";
formData.value.feedingType = "";
formData.value.contentPreference = "";
formData.value.productPreference = "";
formData.value.followInfo = "";
formData.value.purchaseChannel = "";
formData.value.gestationalWeeks = "";
}
formData.value[name] = babyStageMap[e].value;
return;
}
......@@ -577,11 +605,11 @@ const handleUploadBackground = async (e) => {
sizeType: ["original", "compressed"],
sourceType: ["album", "camera"],
success: async (res) => {
showLoading();
const tempFilePath = res.tempFilePaths[0];
const fs = uni.getFileSystemManager();
const base64 =
"data:image/jpeg;base64," + fs.readFileSync(tempFilePath, "base64");
showLoading();
const uploadRes = await uploadImage(base64);
......@@ -614,10 +642,6 @@ const getLabelByValue = (item, value) => {
}
return value;
};
const getValueByLabel = (map, label) => {
const found = map.find((i) => i.label === label);
return found ? found.value : "";
};
const multiPickerStatus = ref(false); // 控制弹窗显示
const currentMultiPickerName = ref(""); // 当前弹窗对应的item.name
......@@ -646,7 +670,6 @@ function handleMultiPickerCancel() {
const initData = () => {
const contentCfg = JSON.parse(JSON.stringify(pageCfgStore.contentCfg));
console.log("initData", Array.isArray(contentCfg.contentLikeOptions));
contentLikeOptions.value = contentCfg.contentLikeOptions;
productLikeOptions.value = contentCfg.productLikeOptions;
......@@ -654,14 +677,14 @@ const initData = () => {
channelOptions.value = contentCfg.channelOptions;
// 更新表单项的选项数据
formItems.forEach(item => {
if (item.name === 'contentPreference') {
formItems.forEach((item) => {
if (item.name === "contentPreference") {
item.range = contentLikeOptions.value;
} else if (item.name === 'productPreference') {
} else if (item.name === "productPreference") {
item.range = productLikeOptions.value;
} else if (item.name === 'followInfo') {
} else if (item.name === "followInfo") {
item.range = specialAttentionOptions.value;
} else if (item.name === 'purchaseChannel') {
} else if (item.name === "purchaseChannel") {
item.range = channelOptions.value;
}
});
......@@ -807,8 +830,8 @@ watch(
}
.person-avatar-img {
width: 126rpx;
height: 126rpx;
width: 135rpx;
height: 135rpx;
display: block;
}
}
......
......@@ -22,7 +22,7 @@ export const usePageCfgStore = defineStore("pageCfg", {
if (!data) return;
this.toolList = data.toolList;
this.toolList = data?.tool?.[0] || [];
this.contentCfg = data.contentCfg;
this.wheelOptionsYL = data.wheelOptionsYL;
this.wheelOptionsYZ = data.wheelOptionsYZ;
......
......@@ -10,8 +10,7 @@ import {
} from "../api/user.js";
import { useGlobalStore } from "./global.js";
import { showLoading, hideLoading } from "../utils/index.js";
import { useHomeStore } from './home.js';
import { useHomeStore } from "./home.js";
const globalStore = useGlobalStore();
......@@ -46,14 +45,11 @@ export const useUserStore = defineStore("userInfo", {
async changeBabySelected(babyId) {
// 更新选中状态
showLoading();
const { data } = await fetchBabyInfoById(babyId);
console.log("babyInfo", data);
if (data?.memberId !== "not_login") {
this.babyInfo = data;
}
hideLoading();
},
saveBabyInfo(babyInfo) {
......@@ -116,8 +112,8 @@ export const useUserStore = defineStore("userInfo", {
},
/**
* 获取用户积分信息
*/
* 获取用户积分信息
*/
async loadMemberInfo() {
const { data } = await fetchMemberInfo();
console.log("fetchMemberInfo=", data);
......@@ -128,8 +124,8 @@ export const useUserStore = defineStore("userInfo", {
// }
},
/**
* 获取宝宝信息
*/
* 获取宝宝信息
*/
async loadHomeInfo() {
const homeStore = useHomeStore();
await homeStore.loadHomeInfo();
......
......@@ -16,7 +16,7 @@
:src="
babyInfo?.content?.backgroundImg || $baseUrl + 'my/cover_white_bg.png'
"
mode="aspectFit"
mode="widthFix"
lazy-load="false"
binderror=""
bindload=""
......@@ -44,7 +44,7 @@
babyInfo?.content?.babyAvatar ||
$baseUrl + 'common/default_avatar.png'
"
mode="aspectFill"
mode="widthFix"
/>
</view>
<image
......@@ -322,12 +322,14 @@ const handleChangeBaby = () => {
showBabySwitcher.value = true;
};
function onSelectBaby(baby) {
async function onSelectBaby(baby) {
// 处理宝宝切换逻辑
showBabySwitcher.value = false;
userStore.changeBabySelected(baby.id);
showLoading();
await userStore.changeBabySelected(baby.id);
hideLoading();
console.log("onSelectBaby", baby);
}
......@@ -339,11 +341,10 @@ function onAddBaby() {
// 页面加载
onMounted(async () => {
console.log("onMounted");
showLoading();
await pageCfgStore.fetchCfg();
hideLoading();
initData();
hideLoading();
});
watch([() => userStore.userInfo, () => userStore.babyInfo], () => {
......
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