fix: update page
This commit is contained in:
@@ -24,8 +24,8 @@ export const updateUserInfo = async (body) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export const reportPrivacy = async () => {
|
export const reportPrivacy = async () => {
|
||||||
return request({
|
// return request({
|
||||||
url: "/api/common/privacy/report",
|
// url: "/api/common/privacy/report",
|
||||||
method: "POST",
|
// method: "POST",
|
||||||
});
|
// });
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,32 +1,37 @@
|
|||||||
<template>
|
<template>
|
||||||
<uni-popup ref="popupRef" type="bottom" :safe-area="false">
|
<view>
|
||||||
<view class="popup-container">
|
<uni-popup ref="popupRef" type="bottom" :safe-area="false">
|
||||||
<view class="popup-header">
|
<view class="popup-container">
|
||||||
<text class="popup-title">登录授权</text>
|
<view class="popup-header">
|
||||||
</view>
|
<text class="popup-title">登录授权</text>
|
||||||
|
</view>
|
||||||
|
|
||||||
<view class="avatar-nickname">
|
<view class="avatar-nickname">
|
||||||
<button
|
<button
|
||||||
open-type="chooseAvatar"
|
open-type="chooseAvatar"
|
||||||
@chooseavatar="onChooseAvatar"
|
@chooseavatar="onChooseAvatar"
|
||||||
class="avatar-selector custom-button"
|
class="avatar-selector custom-button"
|
||||||
>
|
>
|
||||||
<image v-if="avatarUrl" :src="avatarUrl" class="avatar-preview" />
|
<image v-if="avatarUrl" :src="avatarUrl" class="avatar-preview" />
|
||||||
<text v-else>点击获取头像</text>
|
<text v-else>点击获取头像</text>
|
||||||
|
</button>
|
||||||
|
<input
|
||||||
|
class="nickname-input"
|
||||||
|
type="nickname"
|
||||||
|
v-model="nickname"
|
||||||
|
placeholder="请输入昵称"
|
||||||
|
/>
|
||||||
|
</view>
|
||||||
|
|
||||||
|
<button class="confirm-btn custom-button" @tap="confirmLogin">
|
||||||
|
确认登录
|
||||||
</button>
|
</button>
|
||||||
<input
|
|
||||||
class="nickname-input"
|
|
||||||
type="nickname"
|
|
||||||
v-model="nickname"
|
|
||||||
placeholder="请输入昵称"
|
|
||||||
/>
|
|
||||||
</view>
|
</view>
|
||||||
|
</uni-popup>
|
||||||
|
|
||||||
<button class="confirm-btn custom-button" @tap="confirmLogin">
|
<!-- 隐私协议弹窗 -->
|
||||||
确认登录
|
<PrivacyPopup ref="privacyRef" @agree="onPrivacyAgree" />
|
||||||
</button>
|
</view>
|
||||||
</view>
|
|
||||||
</uni-popup>
|
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
@@ -36,8 +41,10 @@ import { getPlatformProvider } from "@/utils/system";
|
|||||||
import { uploadImage } from "@/utils/common";
|
import { uploadImage } from "@/utils/common";
|
||||||
import { apiLogin } from "@/api/auth.js";
|
import { apiLogin } from "@/api/auth.js";
|
||||||
import { wxLogin } from "@/utils/login.js";
|
import { wxLogin } from "@/utils/login.js";
|
||||||
|
import PrivacyPopup from "@/components/PrivacyPopup/PrivacyPopup.vue";
|
||||||
|
|
||||||
const popupRef = ref(null);
|
const popupRef = ref(null);
|
||||||
|
const privacyRef = ref(null);
|
||||||
const avatarUrl = ref("");
|
const avatarUrl = ref("");
|
||||||
const nickname = ref("");
|
const nickname = ref("");
|
||||||
|
|
||||||
@@ -46,19 +53,65 @@ const userStore = useUserStore();
|
|||||||
const emit = defineEmits(["logind"]);
|
const emit = defineEmits(["logind"]);
|
||||||
|
|
||||||
const festivalNames = [
|
const festivalNames = [
|
||||||
'春意','福星','小福','新禧','瑞雪','花灯','喜乐','元宝','春芽','年年',
|
"春意",
|
||||||
'花灯','月圆','灯影','小灯','星灯','彩灯',
|
"福星",
|
||||||
'清风','微风','小晴','碧波','流泉',
|
"小福",
|
||||||
'月光','玉轮','桂香','秋叶','星河','小月','露华','秋水',
|
"新禧",
|
||||||
'雪落','冰晶','暖阳','小雪','冬影','雪花','松影'
|
"瑞雪",
|
||||||
|
"花灯",
|
||||||
|
"喜乐",
|
||||||
|
"元宝",
|
||||||
|
"春芽",
|
||||||
|
"年年",
|
||||||
|
"花灯",
|
||||||
|
"月圆",
|
||||||
|
"灯影",
|
||||||
|
"小灯",
|
||||||
|
"星灯",
|
||||||
|
"彩灯",
|
||||||
|
"清风",
|
||||||
|
"微风",
|
||||||
|
"小晴",
|
||||||
|
"碧波",
|
||||||
|
"流泉",
|
||||||
|
"月光",
|
||||||
|
"玉轮",
|
||||||
|
"桂香",
|
||||||
|
"秋叶",
|
||||||
|
"星河",
|
||||||
|
"小月",
|
||||||
|
"露华",
|
||||||
|
"秋水",
|
||||||
|
"雪落",
|
||||||
|
"冰晶",
|
||||||
|
"暖阳",
|
||||||
|
"小雪",
|
||||||
|
"冬影",
|
||||||
|
"雪花",
|
||||||
|
"松影",
|
||||||
];
|
];
|
||||||
|
|
||||||
const getFestivalName = () => {
|
const getFestivalName = () => {
|
||||||
const idx = Math.floor(Math.random() * festivalNames.length);
|
const idx = Math.floor(Math.random() * festivalNames.length);
|
||||||
return festivalNames[idx];
|
return festivalNames[idx];
|
||||||
}
|
};
|
||||||
|
|
||||||
const open = () => {
|
const open = async () => {
|
||||||
|
console.log(22223333);
|
||||||
|
// #ifdef MP-WEIXIN
|
||||||
|
const isAgreed = await privacyRef.value.check();
|
||||||
|
console.log(1111, isAgreed);
|
||||||
|
if (isAgreed) {
|
||||||
|
popupRef.value.open();
|
||||||
|
}
|
||||||
|
// #endif
|
||||||
|
|
||||||
|
// #ifndef MP-WEIXIN
|
||||||
|
popupRef.value.open();
|
||||||
|
// #endif
|
||||||
|
};
|
||||||
|
|
||||||
|
const onPrivacyAgree = () => {
|
||||||
popupRef.value.open();
|
popupRef.value.open();
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -75,7 +128,9 @@ const confirmLogin = async () => {
|
|||||||
const platform = getPlatformProvider();
|
const platform = getPlatformProvider();
|
||||||
if (platform === "mp-weixin") {
|
if (platform === "mp-weixin") {
|
||||||
const code = await wxLogin();
|
const code = await wxLogin();
|
||||||
const imageUrl = avatarUrl.value ? await uploadImage(avatarUrl.value) : "";
|
const imageUrl = avatarUrl.value
|
||||||
|
? await uploadImage(avatarUrl.value)
|
||||||
|
: "";
|
||||||
|
|
||||||
const loginRes = await apiLogin({
|
const loginRes = await apiLogin({
|
||||||
code,
|
code,
|
||||||
|
|||||||
@@ -16,7 +16,7 @@
|
|||||||
id="agree-btn"
|
id="agree-btn"
|
||||||
class="btn agree"
|
class="btn agree"
|
||||||
open-type="agreePrivacyAuthorization"
|
open-type="agreePrivacyAuthorization"
|
||||||
@agreePrivacyAuthorization="handleAgree"
|
@agreeprivacyauthorization="handleAgree"
|
||||||
>
|
>
|
||||||
同意
|
同意
|
||||||
</button>
|
</button>
|
||||||
@@ -32,28 +32,41 @@ import { reportPrivacy } from "@/api/auth.js";
|
|||||||
const show = ref(false);
|
const show = ref(false);
|
||||||
const privacyContractName = ref("《用户隐私保护指引》");
|
const privacyContractName = ref("《用户隐私保护指引》");
|
||||||
|
|
||||||
|
const emit = defineEmits(["agree"]);
|
||||||
|
let resolveCheck = null;
|
||||||
|
|
||||||
|
// #ifdef MP-WEIXIN
|
||||||
|
const check = () => {
|
||||||
|
return new Promise((resolve) => {
|
||||||
|
if (uni.getPrivacySetting) {
|
||||||
|
uni.getPrivacySetting({
|
||||||
|
success: (res) => {
|
||||||
|
if (res.needAuthorization) {
|
||||||
|
privacyContractName.value =
|
||||||
|
res.privacyContractName || "《用户隐私保护指引》";
|
||||||
|
show.value = true;
|
||||||
|
resolveCheck = resolve;
|
||||||
|
} else {
|
||||||
|
resolve(true);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
fail: (err) => {
|
||||||
|
console.error("getPrivacySetting fail:", err);
|
||||||
|
resolve(true);
|
||||||
|
},
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
resolve(true);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
// #endif
|
||||||
|
|
||||||
// Only for WeChat Mini Program
|
// Only for WeChat Mini Program
|
||||||
// #ifdef MP-WEIXIN
|
// #ifdef MP-WEIXIN
|
||||||
onMounted(() => {
|
// onMounted(() => {
|
||||||
if (uni.getPrivacySetting) {
|
// check();
|
||||||
uni.getPrivacySetting({
|
// });
|
||||||
success: (res) => {
|
|
||||||
console.log("getPrivacySetting", res);
|
|
||||||
if (res.needAuthorization) {
|
|
||||||
privacyContractName.value = res.privacyContractName;
|
|
||||||
show.value = true;
|
|
||||||
} else {
|
|
||||||
// Check local storage just in case
|
|
||||||
const hasAgreed = uni.getStorageSync("hasAgreedPrivacy");
|
|
||||||
if (!hasAgreed) {
|
|
||||||
uni.setStorageSync("hasAgreedPrivacy", true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
fail: () => {},
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
// #endif
|
// #endif
|
||||||
|
|
||||||
const openPrivacyContract = () => {
|
const openPrivacyContract = () => {
|
||||||
@@ -65,14 +78,24 @@ const openPrivacyContract = () => {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleAgree = async () => {
|
const handleAgree = async (e) => {
|
||||||
|
if (!show.value) return; // Prevent double execution
|
||||||
|
console.log("handleAgree triggered", e);
|
||||||
// 1. Save to local storage
|
// 1. Save to local storage
|
||||||
uni.setStorageSync("hasAgreedPrivacy", true);
|
uni.setStorageSync("hasAgreedPrivacy", true);
|
||||||
|
|
||||||
// 2. Hide popup
|
// 2. Hide popup
|
||||||
show.value = false;
|
show.value = false;
|
||||||
|
|
||||||
// 3. Call server API
|
emit("agree");
|
||||||
|
|
||||||
|
// 3. Resolve the check promise
|
||||||
|
if (resolveCheck) {
|
||||||
|
resolveCheck(true);
|
||||||
|
resolveCheck = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 4. Call server API
|
||||||
try {
|
try {
|
||||||
await reportPrivacy();
|
await reportPrivacy();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
@@ -90,6 +113,10 @@ const handleDisagree = () => {
|
|||||||
});
|
});
|
||||||
// #endif
|
// #endif
|
||||||
};
|
};
|
||||||
|
|
||||||
|
defineExpose({
|
||||||
|
check,
|
||||||
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
|
|||||||
@@ -51,6 +51,7 @@
|
|||||||
/* 小程序特有相关 */
|
/* 小程序特有相关 */
|
||||||
"mp-weixin": {
|
"mp-weixin": {
|
||||||
"appid": "wx3fcc07a061af049a",
|
"appid": "wx3fcc07a061af049a",
|
||||||
|
"__usePrivacyCheck__": true,
|
||||||
"setting": {
|
"setting": {
|
||||||
"urlCheck": false
|
"urlCheck": false
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -1,8 +1,5 @@
|
|||||||
<template>
|
<template>
|
||||||
<view class="spring-page" :style="{ paddingTop: getBavBarHeight() + 'px' }">
|
<view class="spring-page" :style="{ paddingTop: getBavBarHeight() + 'px' }">
|
||||||
<!-- Privacy Popup -->
|
|
||||||
<PrivacyPopup />
|
|
||||||
|
|
||||||
<!-- 顶部 Banner -->
|
<!-- 顶部 Banner -->
|
||||||
<view class="hero">
|
<view class="hero">
|
||||||
<view class="hero-badge">
|
<view class="hero-badge">
|
||||||
@@ -111,7 +108,6 @@ import {
|
|||||||
} from "@dcloudio/uni-app";
|
} from "@dcloudio/uni-app";
|
||||||
import { getBavBarHeight } from "@/utils/system";
|
import { getBavBarHeight } from "@/utils/system";
|
||||||
import { getRecommendList } from "@/api/system";
|
import { getRecommendList } from "@/api/system";
|
||||||
import PrivacyPopup from "@/components/PrivacyPopup/PrivacyPopup.vue";
|
|
||||||
|
|
||||||
const countdownText = ref("");
|
const countdownText = ref("");
|
||||||
|
|
||||||
|
|||||||
@@ -63,11 +63,11 @@
|
|||||||
<!-- My Creations -->
|
<!-- My Creations -->
|
||||||
<view class="section-title">我的创作</view>
|
<view class="section-title">我的创作</view>
|
||||||
<view class="menu-group">
|
<view class="menu-group">
|
||||||
<view class="menu-item" @tap="navTo('greetings')">
|
<!-- <view class="menu-item" @tap="navTo('greetings')">
|
||||||
<view class="icon-box red-bg"><text>🧧</text></view>
|
<view class="icon-box red-bg"><text>🧧</text></view>
|
||||||
<text class="menu-text">我的新春祝福</text>
|
<text class="menu-text">我的新春祝福</text>
|
||||||
<text class="arrow">›</text>
|
<text class="arrow">›</text>
|
||||||
</view>
|
</view> -->
|
||||||
<view class="menu-item" @tap="navTo('fortune-record')">
|
<view class="menu-item" @tap="navTo('fortune-record')">
|
||||||
<view class="icon-box orange-bg"><text>📹</text></view>
|
<view class="icon-box orange-bg"><text>📹</text></view>
|
||||||
<text class="menu-text">我的新年运势</text>
|
<text class="menu-text">我的新年运势</text>
|
||||||
@@ -136,9 +136,7 @@
|
|||||||
<script setup>
|
<script setup>
|
||||||
import { ref, computed, onMounted } from "vue";
|
import { ref, computed, onMounted } from "vue";
|
||||||
import { useUserStore } from "@/stores/user";
|
import { useUserStore } from "@/stores/user";
|
||||||
import {
|
import { onShareAppMessage } from "@dcloudio/uni-app";
|
||||||
onShareAppMessage,
|
|
||||||
} from "@dcloudio/uni-app";
|
|
||||||
import LoginPopup from "@/components/LoginPopup/LoginPopup.vue";
|
import LoginPopup from "@/components/LoginPopup/LoginPopup.vue";
|
||||||
|
|
||||||
const userStore = useUserStore();
|
const userStore = useUserStore();
|
||||||
@@ -166,11 +164,11 @@ onMounted(() => {
|
|||||||
navBarHeight.value = 44;
|
navBarHeight.value = 44;
|
||||||
});
|
});
|
||||||
|
|
||||||
onShareAppMessage( () => {
|
onShareAppMessage(() => {
|
||||||
return {
|
return {
|
||||||
title: "新年好运已送达 🎊|祝福卡·头像·壁纸",
|
title: "新年好运已送达 🎊|祝福卡·头像·壁纸",
|
||||||
path: "/pages/index/index",
|
path: "/pages/index/index",
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
const handleUserClick = () => {
|
const handleUserClick = () => {
|
||||||
|
|||||||
Reference in New Issue
Block a user