Commit 626c3149 authored by spc's avatar spc

Merge branch 'master' into dev

parents 708dd62a c60e5b6f
This diff is collapsed.
This diff is collapsed.
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -52,7 +52,9 @@ const globalStore = useGlobalStore() ...@@ -52,7 +52,9 @@ const globalStore = useGlobalStore()
// 登录获取 cuk // 登录获取 cuk
const wxAutoLogin = async () => { const wxAutoLogin = async () => {
await userStore.wxAutoLogin() await new Promise(resolve => {
userStore.syWxAutoLogin(resolve)
})
} }
// 接收webview消息 // 接收webview消息
......
...@@ -27,7 +27,7 @@ export const useUserStore = defineStore("userInfo", { ...@@ -27,7 +27,7 @@ export const useUserStore = defineStore("userInfo", {
babyInfo: null, babyInfo: null,
memberInfo: null, memberInfo: null,
babyNickCache: [], babyNickCache: [],
cepingjieguoInfo:null, cepingjieguoInfo: null,
}; };
}, },
actions: { actions: {
...@@ -71,7 +71,7 @@ export const useUserStore = defineStore("userInfo", { ...@@ -71,7 +71,7 @@ export const useUserStore = defineStore("userInfo", {
* @param {Object} data : {encryptedData, iv, code} * @param {Object} data : {encryptedData, iv, code}
* @returns * @returns
*/ */
async phoneCallback(data, onOpenRegisterFn = () => {}) { async phoneCallback(data, onOpenRegisterFn = () => { }) {
uni.login({ uni.login({
provider: "weixin", provider: "weixin",
success: async (res) => { success: async (res) => {
...@@ -155,65 +155,65 @@ export const useUserStore = defineStore("userInfo", { ...@@ -155,65 +155,65 @@ export const useUserStore = defineStore("userInfo", {
// } // }
// } // }
// }, // },
async loadBabyInfo(retryCount = 0) { async loadBabyInfo(retryCount = 0) {
const MAX_RETRIES = 3; const MAX_RETRIES = 3;
const RETRY_DELAY = 1000; // 1 second const RETRY_DELAY = 1000; // 1 second
try { try {
const { data } = await fetchBabyInfo(); const { data } = await fetchBabyInfo();
console.log("babyInfo-宝宝信息", data); console.log("babyInfo-宝宝信息", data);
if (data?.memberId !== "not_login") { if (data?.memberId !== "not_login") {
this.babyInfo = data; this.babyInfo = data;
if (data.allBabyBaseInfo) { if (data.allBabyBaseInfo) {
if (this.babyInfo.babyAge == "0月龄") { if (this.babyInfo.babyAge == "0月龄") {
this.babyInfo.babyAge = "1月龄"; this.babyInfo.babyAge = "1月龄";
} }
console.log("this.11111", this.babyNickCache, data?.content?.id); console.log("this.11111", this.babyNickCache, data?.content?.id);
const findItem = this.babyNickCache.find( const findItem = this.babyNickCache.find(
(item) => item.id == data?.content?.id (item) => item.id == data?.content?.id
); );
if (data?.content?.id && findItem) { if (data?.content?.id && findItem) {
this.babyInfo.babyName = findItem.name; this.babyInfo.babyName = findItem.name;
this.babyInfo.allBabyBaseInfo.forEach((item) => { this.babyInfo.allBabyBaseInfo.forEach((item) => {
if (item.id == data?.content?.id) { if (item.id == data?.content?.id) {
item.babyName = findItem.name; item.babyName = findItem.name;
} }
}); });
} }
return; // Success case, exit the function return; // Success case, exit the function
} else { } else {
console.log("this.babyInfo", '重新请求接口'); console.log("this.babyInfo", '重新请求接口');
if (retryCount < MAX_RETRIES - 1) { if (retryCount < MAX_RETRIES - 1) {
await new Promise(resolve => setTimeout(resolve, RETRY_DELAY)); await new Promise(resolve => setTimeout(resolve, RETRY_DELAY));
return this.loadBabyInfo(retryCount + 1); return this.loadBabyInfo(retryCount + 1);
} else { } else {
console.log("Max retries reached, giving up"); console.log("Max retries reached, giving up");
// Show user notification when max retries reached // Show user notification when max retries reached
// uni.showToast({ // uni.showToast({
// title: "系统繁忙,请稍后再试", // title: "系统繁忙,请稍后再试",
// icon: "none", // icon: "none",
// }); // });
} }
} }
} }
} catch (error) { } catch (error) {
console.log("🚀 ~ loadBabyInfo ~ error:", error); console.log("🚀 ~ loadBabyInfo ~ error:", error);
if (retryCount >= MAX_RETRIES - 1) { if (retryCount >= MAX_RETRIES - 1) {
// Show user notification when max retries reached with error // Show user notification when max retries reached with error
uni.showToast({ uni.showToast({
title: "系统繁忙,请稍后再试", title: "系统繁忙,请稍后再试",
icon: "none", icon: "none",
}); });
} }
} }
}, },
/** /**
* 获取用户积分信息 * 获取用户积分信息
*/ */
...@@ -247,7 +247,7 @@ export const useUserStore = defineStore("userInfo", { ...@@ -247,7 +247,7 @@ export const useUserStore = defineStore("userInfo", {
console.log("autoLoginByCode", data); console.log("autoLoginByCode", data);
// 如果登录成功,获取用户信息和宝宝信息,更新到state中,方便全局使用 // 如果登录成功,获取用户信息和宝宝信息,更新到state中,方便全局使用
if (data && data.cuk) { if (data && data.cuk) {
globalStore.setCuk(data.cuk,data.openId,data.unionId); globalStore.setCuk(data.cuk, data.openId, data.unionId);
await this.loadUserInfo(); await this.loadUserInfo();
await this.loadBabyInfo(); await this.loadBabyInfo();
...@@ -256,15 +256,44 @@ export const useUserStore = defineStore("userInfo", { ...@@ -256,15 +256,44 @@ export const useUserStore = defineStore("userInfo", {
}, },
/** /**
* 用户自动登录 * 用户自动登录
*/ */
async wxAutoLogin() { async wxAutoLogin(cb = null) {
uni.login({ uni.login({
provider: "weixin", provider: "weixin",
success: async (res) => { success: async (res) => {
console.log("wxAutoLogin", res); console.log("wxAutoLogin", res);
if (res.errMsg === "login:ok") { if (res.errMsg === "login:ok") {
await this.autoLoginByCode(res.code); await this.autoLoginByCode(res.code);
cb && cb();
} else {
uni.showToast({
title: res.errMsg,
icon: "error",
});
}
md.sensors.init();
},
});
},
/**
*
* @param {sy使用}
* @returns
*/
async syWxAutoLogin(cb = null) {
uni.login({
provider: "weixin",
success: async (res) => {
if (res.errMsg === "login:ok") {
const { data } = await autoLoginByCode(res.code);
// 如果登录成功,获取用户信息和宝宝信息,更新到state中,方便全局使用
if (data && data.cuk) {
globalStore.setCuk(data.cuk, data.openId, data.unionId);
cb && cb();
}
} else { } else {
uni.showToast({ uni.showToast({
title: res.errMsg, title: res.errMsg,
......
...@@ -58,7 +58,7 @@ ...@@ -58,7 +58,7 @@
<swiper-item v-for="(item, index) in toolList.tools" :key="index" <swiper-item v-for="(item, index) in toolList.tools" :key="index"
:class="['swiperItem', { 'active': currentIndex === index }]"> :class="['swiperItem', { 'active': currentIndex === index }]">
<view class="tool"> <view class="tool">
<button v-if="homeStore && !homeStore.isLogin" open-type="getPhoneNumber" <button v-if="homeStore && !homeStore.isLogin && index>0" open-type="getPhoneNumber"
@getphonenumber="onGetPhoneNumber" class="sq_btn"></button> @getphonenumber="onGetPhoneNumber" class="sq_btn"></button>
<image class="tool_bg" :src="$baseUrl + item.icon" @tap="handleToolClick(item)"> <image class="tool_bg" :src="$baseUrl + item.icon" @tap="handleToolClick(item)">
</image> </image>
...@@ -212,7 +212,7 @@ ...@@ -212,7 +212,7 @@
更多星妈会权威专家服务团 <view class="desc1"> 点击查看 > </view> 更多星妈会权威专家服务团 <view class="desc1"> 点击查看 > </view>
</view> --> </view> -->
</view> </view>
<view class="channelbox" id="thirdScreen"> <view class="channelbox" id="thirdScreen" v-if="false">
<text class="maintitle">{{ channelTabListMianTitle }}</text> <text class="maintitle">{{ channelTabListMianTitle }}</text>
<view class="subtitle_box"> <view class="subtitle_box">
<text class="subtitle">用声音传递爱与智慧,守护宝贝成长的每一步</text> <text class="subtitle">用声音传递爱与智慧,守护宝贝成长的每一步</text>
...@@ -547,6 +547,7 @@ ...@@ -547,6 +547,7 @@
this.duration = e.target.value this.duration = e.target.value
}, },
jumpBannerHandler(item, index) { jumpBannerHandler(item, index) {
console.log("item====", item)
md.sensorLogTake({ md.sensorLogTake({
xcxClick: '首页-首屏页面点击', xcxClick: '首页-首屏页面点击',
pageName: '首页-首屏', pageName: '首页-首屏',
......
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