This commit is contained in:
zpc 2025-03-23 13:34:54 +08:00
parent e5b33085bd
commit 2b2c834c59

View File

@ -10,7 +10,7 @@
<!-- 内容区域 -->
<scroll-view class="notice-content" scroll-y>
<view v-html="ruleData.content"></view>
<rich-text :nodes="ruleData.content"></rich-text>
</scroll-view>
</view>
@ -24,11 +24,8 @@
<!-- 不再提示选项 -->
<view class="remember-option">
<view class="checkbox" @click="isAgree = !isAgree">
<image class="checkbox-icon" :src="isAgree ? $img1('common/check_act.png') : $img1('common/check.png')
" lazy-load></image>
<text class="checkbox-text">{{
getPurchasePopup() ? "今日不再弹出消费规则" : "不再弹出消费规则"
}}</text>
<image class="checkbox-icon" :src="isAgree ? $img1('common/check_act.png') : $img1('common/check.png')" lazy-load></image>
<text class="checkbox-text">{{ checkboxText }}</text>
</view>
</view>
</uni-popup>
@ -37,6 +34,7 @@
<script>
export default {
name: "BuyNotice",
data() {
return {
isAgree: false,
@ -46,17 +44,33 @@ export default {
},
};
},
computed: {
/**
* 根据配置返回不同的复选框文本
*/
checkboxText() {
return this.getPurchasePopup()
? "今日不再弹出消费规则"
: "不再弹出消费规则";
}
},
methods: {
/**
* 获取消费弹窗配置
* @returns {Boolean} 是否启用今日不再弹出配置
*/
getPurchasePopup() {
try {
var _purchase_popup = this.$config.getAppSetting("purchase_popup");
if (_purchase_popup != null && _purchase_popup === "1") {
return true;
}
} catch (error) { }
return false;
const purchasePopup = this.$config.getAppSetting("purchase_popup");
return purchasePopup !== null && purchasePopup === "1";
} catch (error) {
console.error("获取消费弹窗配置异常:", error);
return false;
}
},
/**
* 确认按钮点击处理
*/
@ -65,17 +79,27 @@ export default {
//
if (this.isAgree) {
if (this.getPurchasePopup()) {
uni.setStorageSync("_agree_buy_notice_time", new Date().toLocaleDateString());
uni.setStorageSync("_agree_buy_notice", 2);
} else {
uni.setStorageSync("_agree_buy_notice_time", "");
uni.setStorageSync("_agree_buy_notice", 1);
}
this.saveAgreementState();
}
//
this.$emit("confirm");
},
/**
* 保存用户协议状态
*/
saveAgreementState() {
if (this.getPurchasePopup()) {
//
uni.setStorageSync("_agree_buy_notice_time", new Date().toLocaleDateString());
uni.setStorageSync("_agree_buy_notice", 2);
} else {
//
uni.setStorageSync("_agree_buy_notice_time", "");
uni.setStorageSync("_agree_buy_notice", 1);
}
},
/**
* 关闭弹窗
@ -92,28 +116,34 @@ export default {
this.ruleData = opt;
this.$refs._buy_notice.open();
},
/**
* 检查是否需要显示弹窗
* @returns {Boolean} 是否显示弹窗
*/
getIsShow() {
var _agree_buy_notice = uni.getStorageSync("_agree_buy_notice")
if (_agree_buy_notice == null || _agree_buy_notice == "") {
const agreeBuyNotice = uni.getStorageSync("_agree_buy_notice");
//
if (!agreeBuyNotice) {
return true;
}
//
//
if (this.getPurchasePopup()) {
//
var newd = new Date().toLocaleDateString();
let _agree_buy_notice_time = uni.getStorageSync("_agree_buy_notice_time");
if (_agree_buy_notice_time == newd) {
//
//
const today = new Date().toLocaleDateString();
const agreedTime = uni.getStorageSync("_agree_buy_notice_time");
//
if (agreedTime === today) {
return false;
}
} else {
if (_agree_buy_notice == 1) {
return false;
}
} else if (agreeBuyNotice == 1) {
//
return false;
}
return true;
},