feat: add guest mode and optimize login experience
针对微信审核要求新增游客浏览模式,用户可无需登录直接浏览应用内容,仅在使用发布、点赞、记录等需要身份的功能时才弹窗引导登录。具体修改包括: 1. 新增游客态判断工具函数与登录守卫逻辑 2. 为登录页添加游客直接进入入口 3. 为首页、酒友圈、个人页、动态页、记录页添加游客适配逻辑 4. 优化登录态失效处理逻辑,不再强制跳转登录页 5. 调整部分页面的返回逻辑适配分享直接进入场景 6. 为各页面添加游客引导UI与交互
This commit is contained in:
@@ -65,7 +65,7 @@
|
||||
import FeedCard from '../../components/FeedCard.vue'
|
||||
import CommentItem from '../../components/CommentItem.vue'
|
||||
import EmptyState from '../../components/EmptyState.vue'
|
||||
import { GetFeedComments, AddComment, LikeFeed, UnlikeFeed, DeleteFeed } from '../../common/api'
|
||||
import { GetFeedComments, AddComment, LikeFeed, UnlikeFeed, DeleteFeed, requireLogin } from '../../common/api'
|
||||
import themeMixin from '../../common/theme-mixin'
|
||||
|
||||
export default {
|
||||
@@ -93,7 +93,23 @@ export default {
|
||||
},
|
||||
methods: {
|
||||
goBack() {
|
||||
uni.navigateBack()
|
||||
// 分享落地场景:本页是页面栈中唯一页面(好友直接从分享卡片进入,未经过首页),
|
||||
// navigateBack 无页面可退,此时直接回首页
|
||||
if (getCurrentPages().length > 1) {
|
||||
uni.navigateBack({
|
||||
fail: () => {
|
||||
uni.switchTab({
|
||||
url: '/pages/index/index',
|
||||
fail: () => uni.reLaunch({ url: '/pages/index/index' })
|
||||
})
|
||||
}
|
||||
})
|
||||
} else {
|
||||
uni.switchTab({
|
||||
url: '/pages/index/index',
|
||||
fail: () => uni.reLaunch({ url: '/pages/index/index' })
|
||||
})
|
||||
}
|
||||
},
|
||||
async loadFeed() {
|
||||
// 优先从 globalData 中查找对应动态
|
||||
@@ -127,6 +143,7 @@ export default {
|
||||
}
|
||||
},
|
||||
async handleLike(feed) {
|
||||
if (!requireLogin()) return
|
||||
feed.liked = !feed.liked
|
||||
feed.likes += feed.liked ? 1 : -1
|
||||
try {
|
||||
@@ -160,7 +177,7 @@ export default {
|
||||
try {
|
||||
await DeleteFeed({ feedId: feed.id })
|
||||
uni.showToast({ title: '已删除', icon: 'none' })
|
||||
setTimeout(() => uni.navigateBack(), 600)
|
||||
setTimeout(() => this.goBack(), 600)
|
||||
} catch (e) {
|
||||
// httpRequest 已全局弹错误提示(如非本人动态后端会拒绝)
|
||||
}
|
||||
@@ -170,6 +187,7 @@ export default {
|
||||
async submitComment() {
|
||||
const text = this.commentText.trim()
|
||||
if (!text) return
|
||||
if (!requireLogin()) return
|
||||
try {
|
||||
await AddComment({ feedId: this.feedId, content: text })
|
||||
this.comments.push({
|
||||
|
||||
Reference in New Issue
Block a user