-
Notifications
You must be signed in to change notification settings - Fork 6
060143A #6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
060143A
wants to merge
1
commit into
iBeiKeDevHomework:master
Choose a base branch
from
060143A:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
060143A #6
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,61 @@ | ||
| // index.js | ||
| // 获取应用实例 | ||
| const app = getApp() | ||
|
|
||
| Page({ | ||
| data: { | ||
| num:'0', | ||
| op:'' | ||
| }, | ||
| result: null, | ||
| isClear: false, | ||
| numBtn: function(e) { | ||
| var num = e.target.dataset.val | ||
| if (this.data.num === '0' || this.isClear) { | ||
| this.setData({ num: num }) | ||
| this.isClear = false | ||
| } else { | ||
| this.setData({ num: this.data.num + num }) | ||
| } | ||
| }, | ||
| opBtn: function(e) { | ||
| var op = this.data.op | ||
| var num = Number(this.data.num) | ||
| this.setData({ op: e.target.dataset.val }) | ||
| if (this.isClear) { | ||
| return | ||
| } | ||
| this.isClear = true | ||
| if (this.result === null) { | ||
| this.result = num | ||
| return | ||
| } | ||
| if (op === '+'){ | ||
| this.result = this.result + num | ||
| } else if (op === '-') { | ||
| this.result = this.result - num | ||
| } else if (op === '*') { | ||
| this.result = this.result * num | ||
| } else if (op === '/') { | ||
| this.result = this.result / num | ||
| } else if (op === '%') { | ||
| this.result = this.result % num | ||
| } | ||
| this.setData({ num: this.result + '' }) | ||
| }, | ||
| dotBtn: function(){ | ||
| if(this.isClear){ | ||
| this.isClear=false | ||
| return | ||
| } | ||
| this.setData({num:this.data.num+'.'}) | ||
| }, | ||
| delBtn:function(){ | ||
| var num = this.data.num.substr(0,this.data.num.length-1) | ||
| this.setData({num: num==='' ?'0' :num}) | ||
| }, | ||
| resetBtn:function(){ | ||
| this.result = null | ||
| this.isClear = false | ||
| this.setData({ num:'0',op:''}) | ||
| }}) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| { | ||
| "usingComponents": {}, | ||
| "navigationBarBackgroundColor":"#fff", | ||
| "navigationBarTitleText":"计算器", | ||
| "navigationBarTextStyle":"black" | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| <!--index.wxml--> | ||
| <view class="result"></view> | ||
| <view class="btns"></view> | ||
| <view class="btns"> | ||
| <view> | ||
| <view hover-class="bg" bindtap="resetBtn">C</view> | ||
| <view hover-class="bg" bindtap="delBtn">DEL</view> | ||
| <view hover-class="bg" bindtap="opBtn" data-val="%">%</view> | ||
| <view hover-class="bg" bindtap="opBtn" data-val="/">÷</view> | ||
| </view> | ||
| <view> | ||
| <view hover-class="bg" bindtap="numBtn" data-val="7">7</view> | ||
| <view hover-class="bg" bindtap="numBtn" data-val="8">8</view> | ||
| <view hover-class="bg" bindtap="numBtn" data-val="9">9</view> | ||
| <view hover-class="bg" bindtap="opBtn" data-val="*">×</view> | ||
| </view> | ||
| <view> | ||
| <view hover-class="bg" bindtap="numBtn" data-val="4">4</view> | ||
| <view hover-class="bg" bindtap="numBtn" data-val="5">5</view> | ||
| <view hover-class="bg" bindtap="numBtn" data-val="6">6</view> | ||
| <view hover-class="bg" bindtap="opBtn" data-val="-">-</view> | ||
| </view> | ||
| <view> | ||
| <view hover-class="bg" bindtap="numBtn" data-val="1">1</view> | ||
| <view hover-class="bg" bindtap="numBtn" data-val="2">2</view> | ||
| <view hover-class="bg" bindtap="numBtn" data-val="3">3</view> | ||
| <view hover-class="bg" bindtap="opBtn" data-val="+">+</view> | ||
| </view> | ||
| <view> | ||
| <view hover-class="bg" bindtap="numBtn" data-val="0">0</view> | ||
| <view hover-class="bg" bindtap="dotBtn">.</view> | ||
| <view hover-class="bg" bindtap="opBtn" data-val="=">=</view> | ||
| </view> | ||
| </view> | ||
| <view class="result"> | ||
| <view class="result-num">{{num}}</view> | ||
| <view class="result-op">{{op}}</view> | ||
| </view> | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 这个布局还挺有意思,两个tab来把它切割两半,result用absouble定在顶上,效果还不错。不过要实现这个效果最好别这样两个tab,因为上面的tab是没有意义的,你也可以用绝对定位钉在底下或者钉在top50% |
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,61 @@ | ||
| /**index.wxss**/ | ||
| page { | ||
| display: flex; | ||
| flex-direction: column; | ||
| height: 100% | ||
| } | ||
| .result{ | ||
| flex:1; | ||
| background:#ffffff; | ||
| } | ||
| .btns{ | ||
| flex:1; | ||
| } | ||
| .bg { | ||
| background: #eee; | ||
| } | ||
| .btns { | ||
| flex: 1; | ||
| display: flex; | ||
| flex-direction: column; | ||
| font-size: 17pt; | ||
| border-top: 1rpx solid #ccc; | ||
| border-left: 1rpx solid #ccc; | ||
| } | ||
| .btns > view { | ||
| flex: 1; | ||
| display: flex; | ||
| } | ||
| .btns > view > view { | ||
| flex-basis: 187.5rpx; | ||
| border-right: 0rpx solid #ccc; | ||
| border-bottom: 0rpx solid #ccc; | ||
| box-sizing: border-box; | ||
| display: flex; | ||
| align-items: center; | ||
| justify-content: center; | ||
| } | ||
| .btns > view:last-child > view:first-child { | ||
| flex-basis: 375rpx; | ||
| } | ||
| .btns > view:first-child > view:first-child { | ||
| color: #f00; | ||
| } | ||
| .btns>view>view:last-child{ | ||
| color:#fc8e00 | ||
| } | ||
| .result{ | ||
| flex: 2; | ||
| margin: 25px; | ||
| position: absolute; | ||
| } | ||
| .result-num{ | ||
| font-size: 27pt; | ||
| bottom: 5vh; | ||
| right: 3vw; | ||
| } | ||
| .result-op{ | ||
| font-size: 15pt; | ||
| bottom: 1vh; | ||
| right: 3vw; | ||
| } |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
多个点应该是需要判断一下