fix: update page
This commit is contained in:
@@ -24,8 +24,8 @@ export const updateUserInfo = async (body) => {
|
||||
};
|
||||
|
||||
export const reportPrivacy = async () => {
|
||||
return request({
|
||||
url: "/api/common/privacy/report",
|
||||
method: "POST",
|
||||
});
|
||||
// return request({
|
||||
// url: "/api/common/privacy/report",
|
||||
// method: "POST",
|
||||
// });
|
||||
};
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<template>
|
||||
<view>
|
||||
<uni-popup ref="popupRef" type="bottom" :safe-area="false">
|
||||
<view class="popup-container">
|
||||
<view class="popup-header">
|
||||
@@ -27,6 +28,10 @@
|
||||
</button>
|
||||
</view>
|
||||
</uni-popup>
|
||||
|
||||
<!-- 隐私协议弹窗 -->
|
||||
<PrivacyPopup ref="privacyRef" @agree="onPrivacyAgree" />
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
@@ -36,8 +41,10 @@ import { getPlatformProvider } from "@/utils/system";
|
||||
import { uploadImage } from "@/utils/common";
|
||||
import { apiLogin } from "@/api/auth.js";
|
||||
import { wxLogin } from "@/utils/login.js";
|
||||
import PrivacyPopup from "@/components/PrivacyPopup/PrivacyPopup.vue";
|
||||
|
||||
const popupRef = ref(null);
|
||||
const privacyRef = ref(null);
|
||||
const avatarUrl = ref("");
|
||||
const nickname = ref("");
|
||||
|
||||
@@ -46,19 +53,65 @@ const userStore = useUserStore();
|
||||
const emit = defineEmits(["logind"]);
|
||||
|
||||
const festivalNames = [
|
||||
'春意','福星','小福','新禧','瑞雪','花灯','喜乐','元宝','春芽','年年',
|
||||
'花灯','月圆','灯影','小灯','星灯','彩灯',
|
||||
'清风','微风','小晴','碧波','流泉',
|
||||
'月光','玉轮','桂香','秋叶','星河','小月','露华','秋水',
|
||||
'雪落','冰晶','暖阳','小雪','冬影','雪花','松影'
|
||||
"春意",
|
||||
"福星",
|
||||
"小福",
|
||||
"新禧",
|
||||
"瑞雪",
|
||||
"花灯",
|
||||
"喜乐",
|
||||
"元宝",
|
||||
"春芽",
|
||||
"年年",
|
||||
"花灯",
|
||||
"月圆",
|
||||
"灯影",
|
||||
"小灯",
|
||||
"星灯",
|
||||
"彩灯",
|
||||
"清风",
|
||||
"微风",
|
||||
"小晴",
|
||||
"碧波",
|
||||
"流泉",
|
||||
"月光",
|
||||
"玉轮",
|
||||
"桂香",
|
||||
"秋叶",
|
||||
"星河",
|
||||
"小月",
|
||||
"露华",
|
||||
"秋水",
|
||||
"雪落",
|
||||
"冰晶",
|
||||
"暖阳",
|
||||
"小雪",
|
||||
"冬影",
|
||||
"雪花",
|
||||
"松影",
|
||||
];
|
||||
|
||||
const getFestivalName = () => {
|
||||
const idx = Math.floor(Math.random() * festivalNames.length);
|
||||
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();
|
||||
};
|
||||
|
||||
@@ -75,7 +128,9 @@ const confirmLogin = async () => {
|
||||
const platform = getPlatformProvider();
|
||||
if (platform === "mp-weixin") {
|
||||
const code = await wxLogin();
|
||||
const imageUrl = avatarUrl.value ? await uploadImage(avatarUrl.value) : "";
|
||||
const imageUrl = avatarUrl.value
|
||||
? await uploadImage(avatarUrl.value)
|
||||
: "";
|
||||
|
||||
const loginRes = await apiLogin({
|
||||
code,
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
id="agree-btn"
|
||||
class="btn agree"
|
||||
open-type="agreePrivacyAuthorization"
|
||||
@agreePrivacyAuthorization="handleAgree"
|
||||
@agreeprivacyauthorization="handleAgree"
|
||||
>
|
||||
同意
|
||||
</button>
|
||||
@@ -32,28 +32,41 @@ import { reportPrivacy } from "@/api/auth.js";
|
||||
const show = ref(false);
|
||||
const privacyContractName = ref("《用户隐私保护指引》");
|
||||
|
||||
// Only for WeChat Mini Program
|
||||
const emit = defineEmits(["agree"]);
|
||||
let resolveCheck = null;
|
||||
|
||||
// #ifdef MP-WEIXIN
|
||||
onMounted(() => {
|
||||
const check = () => {
|
||||
return new Promise((resolve) => {
|
||||
if (uni.getPrivacySetting) {
|
||||
uni.getPrivacySetting({
|
||||
success: (res) => {
|
||||
console.log("getPrivacySetting", res);
|
||||
if (res.needAuthorization) {
|
||||
privacyContractName.value = res.privacyContractName;
|
||||
privacyContractName.value =
|
||||
res.privacyContractName || "《用户隐私保护指引》";
|
||||
show.value = true;
|
||||
resolveCheck = resolve;
|
||||
} else {
|
||||
// Check local storage just in case
|
||||
const hasAgreed = uni.getStorageSync("hasAgreedPrivacy");
|
||||
if (!hasAgreed) {
|
||||
uni.setStorageSync("hasAgreedPrivacy", true);
|
||||
}
|
||||
resolve(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
|
||||
|
||||
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
|
||||
uni.setStorageSync("hasAgreedPrivacy", true);
|
||||
|
||||
// 2. Hide popup
|
||||
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 {
|
||||
await reportPrivacy();
|
||||
} catch (e) {
|
||||
@@ -90,6 +113,10 @@ const handleDisagree = () => {
|
||||
});
|
||||
// #endif
|
||||
};
|
||||
|
||||
defineExpose({
|
||||
check,
|
||||
});
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
|
||||
@@ -51,6 +51,7 @@
|
||||
/* 小程序特有相关 */
|
||||
"mp-weixin": {
|
||||
"appid": "wx3fcc07a061af049a",
|
||||
"__usePrivacyCheck__": true,
|
||||
"setting": {
|
||||
"urlCheck": false
|
||||
},
|
||||
|
||||
@@ -1,8 +1,5 @@
|
||||
<template>
|
||||
<view class="spring-page" :style="{ paddingTop: getBavBarHeight() + 'px' }">
|
||||
<!-- Privacy Popup -->
|
||||
<PrivacyPopup />
|
||||
|
||||
<!-- 顶部 Banner -->
|
||||
<view class="hero">
|
||||
<view class="hero-badge">
|
||||
@@ -111,7 +108,6 @@ import {
|
||||
} from "@dcloudio/uni-app";
|
||||
import { getBavBarHeight } from "@/utils/system";
|
||||
import { getRecommendList } from "@/api/system";
|
||||
import PrivacyPopup from "@/components/PrivacyPopup/PrivacyPopup.vue";
|
||||
|
||||
const countdownText = ref("");
|
||||
|
||||
|
||||
@@ -63,11 +63,11 @@
|
||||
<!-- My Creations -->
|
||||
<view class="section-title">我的创作</view>
|
||||
<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>
|
||||
<text class="menu-text">我的新春祝福</text>
|
||||
<text class="arrow">›</text>
|
||||
</view>
|
||||
</view> -->
|
||||
<view class="menu-item" @tap="navTo('fortune-record')">
|
||||
<view class="icon-box orange-bg"><text>📹</text></view>
|
||||
<text class="menu-text">我的新年运势</text>
|
||||
@@ -136,9 +136,7 @@
|
||||
<script setup>
|
||||
import { ref, computed, onMounted } from "vue";
|
||||
import { useUserStore } from "@/stores/user";
|
||||
import {
|
||||
onShareAppMessage,
|
||||
} from "@dcloudio/uni-app";
|
||||
import { onShareAppMessage } from "@dcloudio/uni-app";
|
||||
import LoginPopup from "@/components/LoginPopup/LoginPopup.vue";
|
||||
|
||||
const userStore = useUserStore();
|
||||
|
||||
Reference in New Issue
Block a user