fix: update page

This commit is contained in:
zzc
2026-02-03 02:41:19 +08:00
parent 52af2aad8f
commit bd45082544
6 changed files with 149 additions and 72 deletions

View File

@@ -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",
}); // });
}; };

View File

@@ -1,4 +1,5 @@
<template> <template>
<view>
<uni-popup ref="popupRef" type="bottom" :safe-area="false"> <uni-popup ref="popupRef" type="bottom" :safe-area="false">
<view class="popup-container"> <view class="popup-container">
<view class="popup-header"> <view class="popup-header">
@@ -27,6 +28,10 @@
</button> </button>
</view> </view>
</uni-popup> </uni-popup>
<!-- 隐私协议弹窗 -->
<PrivacyPopup ref="privacyRef" @agree="onPrivacyAgree" />
</view>
</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,

View File

@@ -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("《用户隐私保护指引》");
// Only for WeChat Mini Program const emit = defineEmits(["agree"]);
let resolveCheck = null;
// #ifdef MP-WEIXIN // #ifdef MP-WEIXIN
onMounted(() => { const check = () => {
return new Promise((resolve) => {
if (uni.getPrivacySetting) { if (uni.getPrivacySetting) {
uni.getPrivacySetting({ uni.getPrivacySetting({
success: (res) => { success: (res) => {
console.log("getPrivacySetting", res);
if (res.needAuthorization) { if (res.needAuthorization) {
privacyContractName.value = res.privacyContractName; privacyContractName.value =
res.privacyContractName || "《用户隐私保护指引》";
show.value = true; show.value = true;
resolveCheck = resolve;
} else { } else {
// Check local storage just in case resolve(true);
const hasAgreed = uni.getStorageSync("hasAgreedPrivacy");
if (!hasAgreed) {
uni.setStorageSync("hasAgreedPrivacy", true);
}
} }
}, },
fail: () => {}, fail: (err) => {
console.error("getPrivacySetting fail:", err);
resolve(true);
},
}); });
} else {
resolve(true);
} }
}); });
};
// #endif
// Only for WeChat Mini Program
// #ifdef MP-WEIXIN
// onMounted(() => {
// check();
// });
// #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>

View File

@@ -51,6 +51,7 @@
/* */ /* */
"mp-weixin": { "mp-weixin": {
"appid": "wx3fcc07a061af049a", "appid": "wx3fcc07a061af049a",
"__usePrivacyCheck__": true,
"setting": { "setting": {
"urlCheck": false "urlCheck": false
}, },

View File

@@ -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("");

View File

@@ -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();