|
|
@@ -219,15 +219,18 @@
|
|
|
</div>
|
|
|
</template>
|
|
|
</view>
|
|
|
+ <login-register></login-register>
|
|
|
</view>
|
|
|
</template>
|
|
|
|
|
|
<script setup name="">
|
|
|
import CusHeader from '@/components/CusHeader/index.vue'
|
|
|
import { onLoad } from '@dcloudio/uni-app';
|
|
|
- import { ref, reactive, onMounted, getCurrentInstance ,nextTick } from 'vue'
|
|
|
+ import { ref, reactive, onMounted, getCurrentInstance ,nextTick, watch } from 'vue'
|
|
|
import { onShareAppMessage, onShareTimeline } from '@dcloudio/uni-app'
|
|
|
const { proxy } = getCurrentInstance()
|
|
|
+ import { useUserStore } from '@/common/stores/user';
|
|
|
+ const userStore = useUserStore();
|
|
|
|
|
|
const id = ref('')
|
|
|
const activityInfo = ref(null)
|
|
|
@@ -346,16 +349,16 @@
|
|
|
}
|
|
|
|
|
|
onShareAppMessage((res) => {
|
|
|
+ const sharerId = JSON.parse(uni.getStorageSync('userInfo'))?.id;
|
|
|
// 如果是点击海报菜单的“发送给朋友”按钮
|
|
|
if (res.from === 'button' && res.target.id === 'posterShareBtn') {
|
|
|
return {
|
|
|
title: posterData.title,
|
|
|
- path: `/pagesHome/activityDetail?shareADId=${id.value}`,
|
|
|
+ path: `/pagesHome/activityDetail?shareADId=${activityInfo.value?.id}&shareUserId=${sharerId}`,
|
|
|
imageUrl: posterUrl.value // 使用生成的海报作为分享图
|
|
|
};
|
|
|
}
|
|
|
// 默认页面右上角分享
|
|
|
- const sharerId = JSON.parse(uni.getStorageSync('userInfo'))?.id;
|
|
|
return {
|
|
|
title: activityInfo.value?.activityName || '发现一个好物,分享给你!',
|
|
|
path: `/pagesHome/activityDetail?shareADId=${activityInfo.value?.id}&shareUserId=${sharerId}`,
|
|
|
@@ -632,7 +635,25 @@
|
|
|
|
|
|
const getActivityDetail = (id) => {
|
|
|
proxy.$api.get(`/core/activity/${id}`).then(({data:res})=>{
|
|
|
- if(res.code!==0) return proxy.$showToast(res.msg)
|
|
|
+ if(res.code!==0){
|
|
|
+ if(options?.shareADId){
|
|
|
+ uni.showModal({
|
|
|
+ title:'温馨提示',
|
|
|
+ content:res.msg,
|
|
|
+ showCancel:false,
|
|
|
+ confirmText:'返回首页',
|
|
|
+ success: (res) => {
|
|
|
+ if(res.confirm){
|
|
|
+ uni.reLaunch({
|
|
|
+ url:'/pages/home'
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
+ return
|
|
|
+ }
|
|
|
+ return proxy.$showToast(res.msg)
|
|
|
+ }
|
|
|
activityInfo.value = res.data;
|
|
|
// 更新海报数据
|
|
|
posterData.title = activityInfo.value?.activityName || posterData.title;
|
|
|
@@ -653,8 +674,49 @@
|
|
|
})
|
|
|
}
|
|
|
|
|
|
+ watch(()=>userStore.token,(newVal,oldVal)=>{
|
|
|
+ if(oldVal!=newVal&&newVal){
|
|
|
+ setTimeout(()=>{
|
|
|
+ uni.showToast({
|
|
|
+ title: '登录成功',
|
|
|
+ icon: 'success'
|
|
|
+ });
|
|
|
+ },200)
|
|
|
+ nextTick(()=>{
|
|
|
+ getActivityDetail(id.value)
|
|
|
+ })
|
|
|
+ }
|
|
|
+ })
|
|
|
+
|
|
|
onLoad(options=>{
|
|
|
id.value = options?.id||options?.shareADId||'';
|
|
|
+ if(!uni.getStorageSync('token')||!uni.getStorageSync('expaireTime')||(Date.parse(new Date())>(uni.getStorageSync('expaireTime')||0))){
|
|
|
+ uni.showModal({
|
|
|
+ title:'温馨提示',
|
|
|
+ content:'您当前登录已失效或未登录过,是否立即登录?',
|
|
|
+ success: (res) => {
|
|
|
+ if(res.confirm){
|
|
|
+ userStore.openLoginModal()
|
|
|
+ }else if(res.cancel){
|
|
|
+ uni.showModal({
|
|
|
+ title:'温馨提示',
|
|
|
+ content:'您已取消登录,当前活动详情页面不可查看',
|
|
|
+ showCancel:false,
|
|
|
+ confirmText:'返回首页',
|
|
|
+ success: (res) => {
|
|
|
+ if(res.confirm){
|
|
|
+ uni.reLaunch({
|
|
|
+ url:'/pages/home'
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
if(id.value) {
|
|
|
getActivityDetail(id.value)
|
|
|
}
|