104 lines
6.6 KiB
Plaintext
104 lines
6.6 KiB
Plaintext
<!--pages/calculator/calculator.wxml-->
|
||
<view class="calculator-container">
|
||
<!-- 历史记录面板 -->
|
||
<view class="history-panel {{showHistory ? 'show' : ''}}" catchtouchmove="preventTouchMove">
|
||
<view class="history-mask" bindtap="toggleHistory"></view>
|
||
<view class="history-content">
|
||
<view class="history-header">
|
||
<text class="history-title">计算历史</text>
|
||
<text class="history-clear" bindtap="clearHistory">清空</text>
|
||
</view>
|
||
<scroll-view scroll-y class="history-list" enhanced show-scrollbar="{{false}}">
|
||
<block wx:if="{{historyList.length > 0}}">
|
||
<view class="history-item" wx:for="{{historyList}}" wx:key="index"
|
||
bindtap="useHistoryResult" data-result="{{item.result}}"
|
||
hover-class="history-item-hover" hover-stay-time="100">
|
||
<text class="history-expr">{{item.expression}}</text>
|
||
<text class="history-result">= {{item.result}}</text>
|
||
</view>
|
||
</block>
|
||
<view wx:else class="history-empty">
|
||
<text class="history-empty-icon">📭</text>
|
||
<text>暂无计算记录</text>
|
||
</view>
|
||
</scroll-view>
|
||
</view>
|
||
</view>
|
||
|
||
<!-- 显示区域 -->
|
||
<view class="display-area">
|
||
<view class="display-top-bar">
|
||
<view class="mode-indicator" bindtap="toggleMode">
|
||
<text class="{{isScientific ? 'active' : ''}}">⚗️ 科学</text>
|
||
</view>
|
||
<view class="top-actions">
|
||
<view class="action-btn" bindtap="toggleHistory" hover-class="action-btn-hover" hover-stay-time="100">
|
||
<text class="action-icon">🕐</text>
|
||
</view>
|
||
<view class="action-btn" bindtap="copyResult" hover-class="action-btn-hover" hover-stay-time="100">
|
||
<text class="action-icon">📋</text>
|
||
</view>
|
||
</view>
|
||
</view>
|
||
<view class="history-text">{{history}}</view>
|
||
<view class="current-value {{displayValue.length > 9 ? 'shrink' : ''}} {{displayValue.length > 15 ? 'shrink-more' : ''}}">{{displayValue}}</view>
|
||
</view>
|
||
|
||
<!-- 键盘区域 -->
|
||
<view class="keypad-area {{isScientific ? 'scientific-pad' : ''}}">
|
||
|
||
<!-- 科学功能区 (隐藏/显示) -->
|
||
<block wx:if="{{isScientific}}">
|
||
<view class="row small-row">
|
||
<view class="btn sci-btn" hover-class="btn-hover" hover-start-time="0" hover-stay-time="100" bindtap="onMathFunc" data-func="sin">sin</view>
|
||
<view class="btn sci-btn" hover-class="btn-hover" hover-start-time="0" hover-stay-time="100" bindtap="onMathFunc" data-func="cos">cos</view>
|
||
<view class="btn sci-btn" hover-class="btn-hover" hover-start-time="0" hover-stay-time="100" bindtap="onMathFunc" data-func="tan">tan</view>
|
||
<view class="btn sci-btn" hover-class="btn-hover" hover-start-time="0" hover-stay-time="100" bindtap="onMathFunc" data-func="log">log</view>
|
||
<view class="btn sci-btn" hover-class="btn-hover" hover-start-time="0" hover-stay-time="100" bindtap="onMathFunc" data-func="ln">ln</view>
|
||
</view>
|
||
<view class="row small-row">
|
||
<view class="btn sci-btn" hover-class="btn-hover" hover-start-time="0" hover-stay-time="100" bindtap="onConstant" data-const="pi">π</view>
|
||
<view class="btn sci-btn" hover-class="btn-hover" hover-start-time="0" hover-stay-time="100" bindtap="onConstant" data-const="e">e</view>
|
||
<view class="btn sci-btn" hover-class="btn-hover" hover-start-time="0" hover-stay-time="100" bindtap="onMathFunc" data-func="pow2">x²</view>
|
||
<view class="btn sci-btn" hover-class="btn-hover" hover-start-time="0" hover-stay-time="100" bindtap="onMathFunc" data-func="sqrt">√</view>
|
||
<view class="btn sci-btn" hover-class="btn-hover" hover-start-time="0" hover-stay-time="100" bindtap="onMathFunc" data-func="percent">%</view>
|
||
</view>
|
||
</block>
|
||
|
||
<!-- 基础键盘 -->
|
||
<view class="row">
|
||
<view class="btn func" hover-class="btn-hover" hover-start-time="0" hover-stay-time="100" bindtap="onClear">AC</view>
|
||
<view class="btn func" hover-class="btn-hover" hover-start-time="0" hover-stay-time="100" bindtap="onDelete">⌫</view>
|
||
<view class="btn func" hover-class="btn-hover" hover-start-time="0" hover-stay-time="100" bindtap="onToggleSign">+/-</view>
|
||
<view class="btn operator" hover-class="btn-hover" hover-start-time="0" hover-stay-time="100" bindtap="onOperator" data-op="÷">÷</view>
|
||
</view>
|
||
|
||
<view class="row">
|
||
<view class="btn digit" hover-class="btn-hover" hover-start-time="0" hover-stay-time="100" bindtap="onDigit" data-digit="7">7</view>
|
||
<view class="btn digit" hover-class="btn-hover" hover-start-time="0" hover-stay-time="100" bindtap="onDigit" data-digit="8">8</view>
|
||
<view class="btn digit" hover-class="btn-hover" hover-start-time="0" hover-stay-time="100" bindtap="onDigit" data-digit="9">9</view>
|
||
<view class="btn operator" hover-class="btn-hover" hover-start-time="0" hover-stay-time="100" bindtap="onOperator" data-op="×">×</view>
|
||
</view>
|
||
|
||
<view class="row">
|
||
<view class="btn digit" hover-class="btn-hover" hover-start-time="0" hover-stay-time="100" bindtap="onDigit" data-digit="4">4</view>
|
||
<view class="btn digit" hover-class="btn-hover" hover-start-time="0" hover-stay-time="100" bindtap="onDigit" data-digit="5">5</view>
|
||
<view class="btn digit" hover-class="btn-hover" hover-start-time="0" hover-stay-time="100" bindtap="onDigit" data-digit="6">6</view>
|
||
<view class="btn operator" hover-class="btn-hover" hover-start-time="0" hover-stay-time="100" bindtap="onOperator" data-op="-">−</view>
|
||
</view>
|
||
|
||
<view class="row">
|
||
<view class="btn digit" hover-class="btn-hover" hover-start-time="0" hover-stay-time="100" bindtap="onDigit" data-digit="1">1</view>
|
||
<view class="btn digit" hover-class="btn-hover" hover-start-time="0" hover-stay-time="100" bindtap="onDigit" data-digit="2">2</view>
|
||
<view class="btn digit" hover-class="btn-hover" hover-start-time="0" hover-stay-time="100" bindtap="onDigit" data-digit="3">3</view>
|
||
<view class="btn operator" hover-class="btn-hover" hover-start-time="0" hover-stay-time="100" bindtap="onOperator" data-op="+">+</view>
|
||
</view>
|
||
|
||
<view class="row">
|
||
<view class="btn digit zero" hover-class="btn-hover" hover-start-time="0" hover-stay-time="100" bindtap="onDigit" data-digit="0">0</view>
|
||
<view class="btn digit" hover-class="btn-hover" hover-start-time="0" hover-stay-time="100" bindtap="onDot">.</view>
|
||
<view class="btn operator equal" hover-class="btn-hover" hover-start-time="0" hover-stay-time="100" bindtap="onEqual">=</view>
|
||
</view>
|
||
</view>
|
||
</view>
|