Commit e07eccec authored by spc's avatar spc

master

parent 27e1aa78
...@@ -52,7 +52,9 @@ ...@@ -52,7 +52,9 @@
<button open-type="getPhoneNumber" @getphonenumber="(e) => onGetPhoneNumber(e, 'like')" <button open-type="getPhoneNumber" @getphonenumber="(e) => onGetPhoneNumber(e, 'like')"
class="auth-like-btn phone-auth-btn-cover"></button> class="auth-like-btn phone-auth-btn-cover"></button>
<!-- 分享按钮授权覆盖 - 移除这个,让分享按钮正常工作 --> <!-- 分享按钮授权覆盖 -->
<button open-type="getPhoneNumber" @getphonenumber="(e) => onGetPhoneNumber(e, 'share')"
class="auth-share-btn phone-auth-btn-cover"></button>
</div> </div>
</div> </div>
</view> </view>
...@@ -72,7 +74,7 @@ defineOptions({ ...@@ -72,7 +74,7 @@ defineOptions({
}) })
// 响应式数据 // 响应式数据
const collectionNumber = ref('123456789') const collectionNumber = ref('')
const recordId = ref('') // 添加记录ID的响应式变量 const recordId = ref('') // 添加记录ID的响应式变量
const detailData = ref({ const detailData = ref({
content: '', content: '',
...@@ -267,9 +269,9 @@ const handleGoBack = () => { ...@@ -267,9 +269,9 @@ const handleGoBack = () => {
} }
} }
// 生命周期 // 页面初始化逻辑
onMounted(async (options) => { const initPage = async () => {
md.sensorComponentLogTake({ md.sensorComponentLogTake({
xcxComponentExposure: "true", xcxComponentExposure: "true",
pageName: "星妈lab-藏品详情页", pageName: "星妈lab-藏品详情页",
...@@ -284,7 +286,6 @@ onMounted(async (options) => { ...@@ -284,7 +286,6 @@ onMounted(async (options) => {
componentContent: "分享" componentContent: "分享"
}); });
// 调用 home 接口获取登录状态 // 调用 home 接口获取登录状态
await homeStore.loadHomeInfo() await homeStore.loadHomeInfo()
...@@ -297,7 +298,6 @@ onMounted(async (options) => { ...@@ -297,7 +298,6 @@ onMounted(async (options) => {
recordId.value = id // 立即保存ID,确保分享时能获取到 recordId.value = id // 立即保存ID,确保分享时能获取到
await fetchDetailData(id) await fetchDetailData(id)
md.sensorComponentLogTake({ md.sensorComponentLogTake({
xcxComponentExposure: "true", xcxComponentExposure: "true",
pageName: "星妈lab-藏品详情页", pageName: "星妈lab-藏品详情页",
...@@ -305,7 +305,7 @@ onMounted(async (options) => { ...@@ -305,7 +305,7 @@ onMounted(async (options) => {
componentContent: "藏品详情页+" + detailData.value.content componentContent: "藏品详情页+" + detailData.value.content
}); });
} else { } else {
console.warn('⚠️ 未获取到页面参数 id', options, currentPage.options) console.warn('⚠️ 未获取到页面参数 id', currentPage.options)
// uni.showToast({ // uni.showToast({
// title: '参数错误', // title: '参数错误',
// icon: 'none' // icon: 'none'
...@@ -323,6 +323,22 @@ onMounted(async (options) => { ...@@ -323,6 +323,22 @@ onMounted(async (options) => {
withShareTicket: true, withShareTicket: true,
menus: ['shareAppMessage'] menus: ['shareAppMessage']
}) })
}
// 生命周期
onMounted(async (options) => {
console.log('星妈lab详情页面已加载')
// 先进行自动登录获取基础信息,登录成功后执行页面初始化
try {
console.log('开始执行 normalAutoLogin...')
await userStore.normalAutoLogin(initPage)
console.log('normalAutoLogin 完成')
} catch (error) {
console.error('normalAutoLogin 失败:', error)
// 即使登录失败也执行页面初始化
await initPage()
}
}) })
// 定义分享函数 // 定义分享函数
......
This diff is collapsed.
...@@ -306,6 +306,37 @@ export const useUserStore = defineStore("userInfo", { ...@@ -306,6 +306,37 @@ export const useUserStore = defineStore("userInfo", {
}); });
}, },
/**
*
* @param {sy使用}
* @returns
*/
async normalAutoLogin(cb = null) {
uni.login({
provider: "weixin",
success: async (res) => {
console.log("normalAutoLogin", res);
if (res.errMsg === "login:ok") {
const { data } = await autoLoginByCode(res.code);
console.log("normalAutoLogin", data);
// 如果登录成功,获取用户信息和宝宝信息,更新到state中,方便全局使用
if (data && data.cuk) {
globalStore.setCuk(data.cuk, data.openId, data.unionId);
cb && cb();
}
} else {
uni.showToast({
title: res.errMsg,
icon: "error",
});
}
md.sensors.init();
},
});
},
async createBabyInfo(babyInfo) { async createBabyInfo(babyInfo) {
console.log("createBabyInfo:", babyInfo); console.log("createBabyInfo:", babyInfo);
const res = await updateBabyInfo(babyInfo); const res = await updateBabyInfo(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