Refactor: UI & Feature updates (Calculator, UnitConverter, Privacy, Cleanup)

This commit is contained in:
2026-02-09 01:15:19 +08:00
parent fa1a8e083e
commit 2c5d5b7505
52 changed files with 1351 additions and 2702 deletions

View File

@@ -0,0 +1,4 @@
{
"navigationBarTitleText": "折扣计算",
"usingComponents": {}
}

View File

@@ -0,0 +1,53 @@
Page({
data: {
originalPrice: '',
discount: '',
finalPrice: '0.00',
savedMoney: '0.00'
},
bindOriginalInput(e: any) {
this.setData({
originalPrice: e.detail.value
});
this.calculate();
},
bindDiscountInput(e: any) {
this.setData({
discount: e.detail.value
});
this.calculate();
},
calculate() {
const original = parseFloat(this.data.originalPrice);
const discount = parseFloat(this.data.discount); // Assume local style 8.8折 or international %? Let's assume N折 (0-10)
if (isNaN(original) || isNaN(discount)) {
this.setData({
finalPrice: '0.00',
savedMoney: '0.00'
});
return;
}
// Logic: Input 9 = 9折 = 90% of price. Input 8.5 = 85%.
// If input > 10, maybe it means percentage? e.g. 80 = 80%?
// Let's stick to N折 standard in China.
let rate = discount;
if (rate > 10) {
rate = rate / 10.0;
}
// rate is now 0-10. e.g. 8.8
const final = original * (rate / 10.0);
const saved = original - final;
this.setData({
finalPrice: final.toFixed(2),
savedMoney: saved.toFixed(2)
});
}
});

View File

@@ -0,0 +1,28 @@
<view class="container">
<view class="card">
<view class="input-group">
<view class="label">原价 (元)</view>
<input type="digit" placeholder="请输入商品原价" bindinput="bindOriginalInput" value="{{originalPrice}}" />
</view>
<view class="divider"></view>
<view class="input-group">
<view class="label">折扣 (折)</view>
<input type="digit" placeholder="例如: 8.5" bindinput="bindDiscountInput" value="{{discount}}" />
</view>
</view>
<view class="result-card">
<view class="result-row">
<text class="result-label">折后价</text>
<text class="result-value">¥ {{finalPrice}}</text>
</view>
<view class="result-row sub-result">
<text class="result-label">为您节省</text>
<text class="result-value">¥ {{savedMoney}}</text>
</view>
</view>
<view class="tips">
<text>输入提示:输入 9 代表 9 折8.5 代表 85 折</text>
</view>
</view>

View File

@@ -0,0 +1,86 @@
page {
background-color: #EBF4F8; /* Color 03 */
padding: 30rpx;
box-sizing: border-box;
}
.card {
background-color: #fff;
border-radius: 20rpx;
padding: 0 30rpx;
margin-bottom: 30rpx;
box-shadow: 0 4rpx 12rpx rgba(17, 97, 107, 0.08);
}
.input-group {
padding: 30rpx 0;
display: flex;
align-items: center;
justify-content: space-between;
}
.label {
font-size: 32rpx;
color: #11616B; /* Color 01 */
width: 180rpx;
font-weight: 500;
}
input {
flex: 1;
text-align: right;
font-size: 36rpx;
color: #11616B; /* Color 01 */
font-weight: 500;
}
.divider {
height: 1rpx;
background-color: rgba(17, 97, 107, 0.1);
}
.result-card {
background: linear-gradient(135deg, #11616B 0%, #0D4E56 100%); /* Color 01 based gradient */
border-radius: 20rpx;
padding: 40rpx;
color: #fff;
box-shadow: 0 6rpx 16rpx rgba(17, 97, 107, 0.3);
}
.result-row {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 20rpx;
}
.result-label {
font-size: 30rpx;
opacity: 0.9;
color: #EBF4F8; /* Color 03 */
}
.result-value {
font-size: 56rpx;
font-weight: bold;
color: #ffffff;
}
.sub-result {
margin-top: 30rpx;
margin-bottom: 0;
padding-top: 20rpx;
border-top: 1rpx solid rgba(235, 244, 248, 0.2);
}
.sub-result .result-value {
font-size: 36rpx;
color: #FED9CD; /* Color 04 for highlight */
}
.tips {
margin-top: 40rpx;
text-align: center;
font-size: 24rpx;
color: #7BBDB6; /* Color 02 */
}