Commit e07eccec authored by spc's avatar spc

master

parent 27e1aa78
......@@ -52,7 +52,9 @@
<button open-type="getPhoneNumber" @getphonenumber="(e) => onGetPhoneNumber(e, 'like')"
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>
</view>
......@@ -72,7 +74,7 @@ defineOptions({
})
// 响应式数据
const collectionNumber = ref('123456789')
const collectionNumber = ref('')
const recordId = ref('') // 添加记录ID的响应式变量
const detailData = ref({
content: '',
......@@ -267,9 +269,9 @@ const handleGoBack = () => {
}
}
// 生命周期
onMounted(async (options) => {
// 页面初始化逻辑
const initPage = async () => {
md.sensorComponentLogTake({
xcxComponentExposure: "true",
pageName: "星妈lab-藏品详情页",
......@@ -284,7 +286,6 @@ onMounted(async (options) => {
componentContent: "分享"
});
// 调用 home 接口获取登录状态
await homeStore.loadHomeInfo()
......@@ -297,7 +298,6 @@ onMounted(async (options) => {
recordId.value = id // 立即保存ID,确保分享时能获取到
await fetchDetailData(id)
md.sensorComponentLogTake({
xcxComponentExposure: "true",
pageName: "星妈lab-藏品详情页",
......@@ -305,7 +305,7 @@ onMounted(async (options) => {
componentContent: "藏品详情页+" + detailData.value.content
});
} else {
console.warn('⚠️ 未获取到页面参数 id', options, currentPage.options)
console.warn('⚠️ 未获取到页面参数 id', currentPage.options)
// uni.showToast({
// title: '参数错误',
// icon: 'none'
......@@ -323,6 +323,22 @@ onMounted(async (options) => {
withShareTicket: true,
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()
}
})
// 定义分享函数
......
......@@ -20,19 +20,22 @@
<view class="banner_content">
<image class="banner_img" :src="$baseUrl + `xingmaLab/1001/bannerImg0.png`" mode="aspectFill" />
</view>
<view v-for="(item, index) in cangguanList" :key="index" class="item_cangguan"
@click="handleItemClick_cangguan(item, index)">
<!-- <image class="item_cangguan_img" :src="`${item.imgUrl}`" mode="widthFix">
<image class="item_cangguan_img_up" :src="`${item.imgUrl}`" mode="widthFix"></image>
</image> -->
<view class="item_cangguan_img1"
:style="`background-image: url(${item.imgUrl}); background-size: 707rpx auto; background-repeat: no-repeat;`"
mode="widthFix">
<image class="item_cangguan_img" :src="`${item.imgUrl}`" mode="widthFix" @load="(e) => handleImageLoad(e, item, index)"></image>
<image class="item_cangguan_img_up" :src="`${item.imgUrl}`" mode="aspectFill" :style="`width: ${item.targetWidth - 30}rpx; height: ${item.targetHeight - 120}rpx;`"></image>
<view class="item_cangguan_img1"
:style="`background-image: url(${item.imgUrl}); background-size: 707rpx auto; background-repeat: no-repeat;`"
mode="widthFix">
<image class="item_cangguan_img" :src="`${item.imgUrl}`" mode="widthFix"
@load="(e) => handleImageLoad(e, item, index)"></image>
<image class="item_cangguan_img_up" :src="`${item.imgUrl}`" mode="aspectFill"
:style="`width: ${item.targetWidth - 30}rpx; height: ${item.targetHeight - 120}rpx;`">
</image>
</view>
<view class="item_cangguan_bottom">
<view class="item_cangguan_bottom_bg">
</view>
......@@ -101,29 +104,29 @@
padding="{{ [0, 12, 0, 12] }}" type="masonry">
<view v-for="(item, index) in cangpinList" :key="index" class="waterfall-item"
@click="handleItemClick_cangpin(item, index)">
<view class="item-up-content">
<image class="item-image" :src="item.imgUrl" mode="widthFix" />
<view class="item-num">
<text class="badge-num">N0.{{ item.bizNo }}</text>
</view>
<view class="item-up-content">
<image class="item-image" :src="item.imgUrl" mode="widthFix" />
<view class="item-num">
<text class="badge-num">N0.{{ item.bizNo }}</text>
</view>
<view v-if="item.state == 1" class="item-badge">
<text class="badge-text">精选推荐</text>
<text class="badge-text">精选推荐</text>
</view>
</view>
</view>
<view class="item-info">
<view class="item-info">
<view class="item-title">{{ item.content }}</view>
<view class="item-meta">
<view class="creator-info">
<view class="item-meta">
<view class="creator-info">
<image class="creator-avatar" :src="item.avatar" mode="aspectFit" />
<text class="creator-name">{{ item.nickname }}</text>
<text class="creator-name">{{ item.nickname }}</text>
</view>
</view>
</view>
</view>
</grid-view>
</scroll-view>
</view>
<!-- 我的收藏列表 -->
......@@ -156,10 +159,10 @@
<text class="badge-text">精选推荐</text>
</view>
</view>
<view class="item-info">
<view class="item-info">
<view class="item-title">{{ item.content }}</view>
<view class="item-meta">
<view class="creator-info">
<view class="item-meta">
<view class="creator-info">
<image class="creator-avatar" :src="item.avatar" mode="aspectFit" />
<text class="creator-name">{{ item.nickname }}</text>
</view>
......@@ -168,7 +171,7 @@
</view>
</grid-view>
</scroll-view>
</view>
</view>
</view>
</view>
......@@ -195,7 +198,7 @@
<!-- 无次数弹窗 - 使用 Xingmalabnotimepop 组件 -->
<Xingmalabnotimepop :visible="showNoTimePopup" title="发布次数已用完" @button-click="handleNoTimeButtonClick"
@close="showNoTimePopup = false" />
</view>
</view>
</template>
<script setup>
......@@ -233,9 +236,9 @@ const currentItemType = ref('cangguan');
// onPageScroll((e) => {
// console.log('e.scrollTop=',e);
// const newVal = e.scrollTop;
// });
const isGeting = ref(false);
......@@ -322,59 +325,59 @@ const currentItem = ref(null);
onShow(async () => {
md.sensorComponentLogTake({
xcxComponentExposure: "true",
pageName: "星妈lab首页",
componentName: "底部切换组件",
componentContent: "星妈会藏馆"
});
xcxComponentExposure: "true",
pageName: "星妈lab首页",
componentName: "底部切换组件",
componentContent: "星妈会藏馆"
});
md.sensorComponentLogTake({
xcxComponentExposure: "true",
pageName: "星妈lab首页",
componentName: "底部切换组件",
componentContent: "发布"
});
xcxComponentExposure: "true",
pageName: "星妈lab首页",
componentName: "底部切换组件",
componentContent: "发布"
});
md.sensorComponentLogTake({
xcxComponentExposure: "true",
pageName: "星妈lab首页",
componentName: "底部切换组件",
componentContent: "我的藏品"
});
xcxComponentExposure: "true",
pageName: "星妈lab首页",
componentName: "底部切换组件",
componentContent: "我的藏品"
});
md.sensorComponentLogTake({
xcxComponentExposure: "true",
pageName: "星妈lab首页",
componentName: "星妈会藏馆",
componentContent: "首页藏品"
});
xcxComponentExposure: "true",
pageName: "星妈lab首页",
componentName: "星妈会藏馆",
componentContent: "首页藏品"
});
const pages = getCurrentPages()
let currentPage = pages[pages.length - 1]
const isFavorite = currentPage?.properties?.isFavorite
const isFavorite = currentPage?.properties?.isFavorite
console.log('isFavorite=', isFavorite);
console.log('currentPage=', currentPage);
// console.log('onshow')
//1收藏,-1取消收藏,不存在刷新页面
if(!isFavorite){
if (!isFavorite) {
await xingmaLabStore.loadXingmaInfo();
await reloadCangguanList();
await reloadCangpinList();
await reloadShoucangList();
}else{
if(isFavorite == 1){
} else {
if (isFavorite == 1) {
currentItem.value.collection = true;
}else{
if(currentItemType.value == 'cangguan'){
} else {
if (currentItemType.value == 'cangguan') {
currentItem.value.collection = false;
}else{
} else {
shoucangList.value.splice(currentItem.value, 1)
}
}
}
})
const cangguanListIdx = ref(1);
......@@ -386,7 +389,7 @@ onMounted(async () => {
// await xingmaLabStore.loadXingmaInfo();
// console.log('xingmaLabStore=', xingmaLabStore.xingmaInfo);
// //获取藏馆列表
// const data1 = await fetchRecordList(cangguanListIdx.value, 4);
// cangguanList.value = cangguanList.value.concat(data1.data.list);
......@@ -477,9 +480,15 @@ const convertDobuleList = (list) => {
// 方法
const handleBack = () => {
uni.navigateBack({
delta: 1
})
if (getCurrentPages().length > 1) {
uni.navigateBack({
delta: 1
})
} else {
uni.redirectTo({
url: '/pages/index/index?pageType=my'
})
}
}
const switchTab = (tab) => {
......@@ -491,8 +500,8 @@ const switchTab = (tab) => {
//我的藏品/我的收藏tab
const switchSubTab = async (subTab) => {
if(subTab == 'collections'){
if(currentFrontNavType != 'collections'){
if (subTab == 'collections') {
if (currentFrontNavType != 'collections') {
currentFrontNavType = 'collections'
md.sensorComponentLogTake({
......@@ -506,8 +515,8 @@ const switchSubTab = async (subTab) => {
}
}else if(subTab == 'favorites'){
if(currentFrontNavType != 'favorites'){
} else if (subTab == 'favorites') {
if (currentFrontNavType != 'favorites') {
md.sensorComponentLogTake({
xcxComponentClick: "true",
pageName: "星妈lab首页",
......@@ -570,7 +579,7 @@ const handleBottomNavClick = async (navType) => {
// 点击"星妈会藏馆"时,切换到藏馆tab,展示单列列表
activeTab.value = 'cangguan'
if(currentButtomNavType != 'cangguan'){
if (currentButtomNavType != 'cangguan') {
md.sensorComponentLogTake({
xcxComponentExposure: "true",
pageName: "星妈lab首页",
......@@ -591,19 +600,19 @@ const handleBottomNavClick = async (navType) => {
});
md.sensorComponentLogTake({
xcxComponentExposure: "true",
pageName: "星妈lab-我的藏品页",
componentName: "我的藏品",
componentContent: "我的藏品-藏品标题"
});
xcxComponentExposure: "true",
pageName: "星妈lab-我的藏品页",
componentName: "我的藏品",
componentContent: "我的藏品-藏品标题"
});
// 点击"我的藏品"时,切换到我的藏馆tab,默认展示我的藏品
activeTab.value = 'wodecangguan'
if(currentButtomNavType != 'wodecangguan'){
if (currentButtomNavType != 'wodecangguan') {
currentButtomNavType = 'wodecangguan';
if(currentFrontNavType == ''){
if(!(cangpinList.value && cangpinList.value.length > 0)){
if (currentFrontNavType == '') {
if (!(cangpinList.value && cangpinList.value.length > 0)) {
md.sensorComponentLogTake({
xcxComponentExposure: "true",
pageName: "星妈lab-我的藏品页",
......@@ -611,7 +620,7 @@ const handleBottomNavClick = async (navType) => {
componentContent: "我的藏品-去发布"
});
}
// else{
// md.sensorComponentLogTake({
// xcxComponentExposure: "true",
......@@ -625,10 +634,10 @@ const handleBottomNavClick = async (navType) => {
currentFrontNavType = 'collections'
// await reloadCangpinList();
}else{
} else {
currentFrontNavType = activeSubTab.value;
if(activeSubTab.value == 'collections'){
if(!(cangpinList.value && cangpinList.value.length > 0)){
if (activeSubTab.value == 'collections') {
if (!(cangpinList.value && cangpinList.value.length > 0)) {
md.sensorComponentLogTake({
xcxComponentExposure: "true",
......@@ -637,7 +646,7 @@ const handleBottomNavClick = async (navType) => {
componentContent: "我的藏品-去发布"
});
}
// else{
// md.sensorComponentLogTake({
// xcxComponentExposure: "true",
......@@ -648,7 +657,7 @@ const handleBottomNavClick = async (navType) => {
// }
// await reloadCangpinList();
//走onshow刷新,因为去发布按钮埋点
}else{
} else {
// md.sensorComponentLogTake({
// xcxComponentExposure: "true",
// pageName: "星妈lab-我的藏品页",
......@@ -668,11 +677,11 @@ const handleItemClick_cangguan = (item, index) => {
currentItem.value = item;
currentItemType.value = 'cangguan';
md.sensorComponentLogTake({
xcxComponentClick: "true",
pageName: "星妈lab首页",
componentName: "星妈会藏馆",
componentContent: `首页藏品-藏品标题${item.content}`
});
xcxComponentClick: "true",
pageName: "星妈lab首页",
componentName: "星妈会藏馆",
componentContent: `首页藏品-藏品标题${item.content}`
});
// 这里可以添加跳转逻辑
uni.navigateTo({
......@@ -729,12 +738,12 @@ const handlePublish = () => {
const handleNoTimeButtonClick = () => {
showNoTimePopup.value = false
// // 显示更详细的发布次数信息
// const { currentMonthPublishCount, maxPublishCount, remainingPublishCount } = xingmaLabStore.xingmaInfo
// uni.showToast({
// title: `本月已发布${currentMonthPublishCount}次,剩余${remainingPublishCount}次`,
// icon: 'none',
// duration: 3000
// // 显示更详细的发布次数信息
// const { currentMonthPublishCount, maxPublishCount, remainingPublishCount } = xingmaLabStore.xingmaInfo
// uni.showToast({
// title: `本月已发布${currentMonthPublishCount}次,剩余${remainingPublishCount}次`,
// icon: 'none',
// duration: 3000
// })
}
</script>
......
......@@ -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) {
console.log("createBabyInfo:", 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