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

feat: 宝宝昵称前端缓存

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