From d97bb20ac0feb621fe4453fde38325863abb8b28 Mon Sep 17 00:00:00 2001 From: zpc Date: Fri, 11 Apr 2025 16:13:33 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- common/common.js | 17 ++++++++-- pages/infinite/bonus_house_details.vue | 11 ++++--- pages/shouye/detail_wuxian.vue | 2 +- pages/user/index.vue | 44 ++++++++++++-------------- 4 files changed, 44 insertions(+), 30 deletions(-) diff --git a/common/common.js b/common/common.js index 96b5789..f52f446 100644 --- a/common/common.js +++ b/common/common.js @@ -45,13 +45,26 @@ export default { return `${year}-${monty}-${day}` }, - + /** + * 去除多余的0 + * @param {*} numStr + * @returns + */ + removeTrailingZeros(numStr) { + if (numStr.includes('.')) { + numStr = numStr.replace(/0+$/, ''); // 移除末尾的零 + if (numStr.endsWith('.')) { + numStr = numStr.slice(0, -1); // 处理小数点后全零的情况 + } + } + return numStr; + }, detailPageTitle(obj) { if (!obj) { return '' } let goods_info = config.getGoodTypeFind(obj.type); - if(goods_info!=null){ + if (goods_info != null) { return goods_info.name; } diff --git a/pages/infinite/bonus_house_details.vue b/pages/infinite/bonus_house_details.vue index 19639e3..a6eb0a0 100644 --- a/pages/infinite/bonus_house_details.vue +++ b/pages/infinite/bonus_house_details.vue @@ -462,7 +462,7 @@ export default { // 获取当前客户端时间并加上与服务器的时间差,以获得准确的服务器当前时间 const now = new Date(); const serverNow = new Date(now.getTime() + serverClientTimeDiff); - + this.updateButtonState(); // 判断当前时间与开始时间和结束时间的关系 if (serverNow > endDate) { clearInterval(this.countdownTimer); @@ -475,9 +475,11 @@ export default { this.remainingTime = this.formatRemainingTime(endDate - serverNow, "距离开奖时间:"); return; } + + }, 1000); - this.updateButtonState(); + }, onUnload() { @@ -588,11 +590,12 @@ export default { }, updateButtonState() { - const currentDate = new Date(this.currentServerTime); + const currentDate = new Date(); const startDate = new Date(this.bonusData.start_time.replace(/-/g, '/')); const endDate = new Date(this.bonusData.end_time.replace(/-/g, '/')); const openDate = new Date(this.bonusData.open_time.replace(/-/g, '/')); - + // console.log(currentDate,startDate); + if (currentDate < startDate) { this.buttonText = "未开始"; } else if (currentDate >= startDate && currentDate <= endDate) { diff --git a/pages/shouye/detail_wuxian.vue b/pages/shouye/detail_wuxian.vue index b7419d5..33158ff 100644 --- a/pages/shouye/detail_wuxian.vue +++ b/pages/shouye/detail_wuxian.vue @@ -607,7 +607,7 @@ export default { imgurl: a.imgurl, title: a.title, // shang_title: item.shang_title, - pro: '概率:' + a.real_pro, + pro: '概率:' + this.$c.removeTrailingZeros(a.real_pro) +'%', shang_info: { title: item.shang_title, color: item.shang_color diff --git a/pages/user/index.vue b/pages/user/index.vue index 4ebb694..047be42 100644 --- a/pages/user/index.vue +++ b/pages/user/index.vue @@ -51,36 +51,18 @@ {{$config.getAppSetting('balance_name')}} - {{ userinfo.money || '0.00' }} + {{ formatNumber(userinfo.money) }} {{$config.getAppSetting('currency1_name')}} - {{ userinfo.integral || 0 }} + {{ formatNumber(userinfo.integral) }} {{$config.getAppSetting('currency2_name')}} - {{ userinfo.money2 || 0 }} + {{ formatNumber(userinfo.money2) }} - - - - - - - @@ -713,9 +695,25 @@ url: '/pages/shouye/index' }) } - + }, + /** + * 格式化数字,如果小数部分是.00则只显示整数部分 + * @param {Number|String} num - 要格式化的数字 + * @param {String} defaultVal - 默认值,当num为空时返回 + * @return {String} - 格式化后的数字字符串 + */ + formatNumber(num, defaultVal = '0') { + if (num === undefined || num === null || num === ''||num===0) { + return defaultVal; + } + + const numStr = num.toString(); + if (numStr.endsWith('.00')) { + return parseFloat(num).toFixed(0); + } + + return numStr; } - } }