Commit a1d3a6a9 authored by tao.huang's avatar tao.huang

feat: 宝宝昵称前端缓存

parent c2fe95b8
......@@ -26,8 +26,8 @@ export const myObj = {
"title": "奶娃宝典",
"desc": "奶娃宝典",
"link": {
"type": 3,
"url": "https://mom.feihe.com/babyWikipedia",
"type": 1,
"url": "/pages/library/ContentLibrary",
"extra": {}
}
},
......
......@@ -367,7 +367,7 @@ const formItems = ref([
required: false,
placeholder: "未选择",
type: "picker",
range: ["纯母乳", "混合喂养", "纯奶粉"],
range: ["奶粉喂养", "母乳喂养", "母乳奶粉混合喂养"],
mode: "custom",
},
{
......@@ -566,6 +566,9 @@ const onSubmit = async (e) => {
hideLoading();
if (res.success) {
data?.id &&
userStore.setBabyNickCache(data?.id, formData.value.babyName);
uni.showToast({
title: "提交成功",
icon: "success",
......
......@@ -20,6 +20,7 @@ export const useUserStore = defineStore("userInfo", {
userInfo: null,
babyInfo: null,
memberInfo: null,
babyNickCache: [],
};
},
actions: {
......@@ -103,6 +104,16 @@ export const useUserStore = defineStore("userInfo", {
}
},
setBabyNickCache(id, name) {
const findIndex = this.babyNickCache.findIndex((item) => item.id === id);
console.log("this.babyNickCache", findIndex);
if (findIndex > -1) {
this.babyNickCache[findIndex].name = name;
} else {
this.babyNickCache.push({ id, name });
}
},
/**
* 获取宝宝信息
*/
......@@ -111,6 +122,20 @@ export const useUserStore = defineStore("userInfo", {
console.log("babyInfo", data);
if (data?.memberId !== "not_login") {
this.babyInfo = data;
console.log("this.11111", this.babyNickCache, data?.content?.id);
const findItem = this.babyNickCache.find(
(item) => item.id == data?.content?.id
);
if (data?.content?.id && findItem) {
this.babyInfo.babyName = findItem.name;
this.babyInfo.allBabyBaseInfo.forEach((item) => {
if (item.id == data?.content?.id) {
item.babyName = findItem.name;
}
});
}
}
},
......
......@@ -29,7 +29,7 @@ export function jump({ type, url, extra = {} }) {
appId: extra.appId || "",
path: url,
extraData: extra.extraData || {},
envVersion: extra.envVersion || "trial",
envVersion: extra.envVersion || "release",
success: extra.success,
fail: extra.fail,
};
......
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