-
Notifications
You must be signed in to change notification settings - Fork 6
随便写的 #5
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
mumu-sw
wants to merge
1
commit into
iBeiKeDevHomework:master
Choose a base branch
from
mumu-sw: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
随便写的 #5
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,39 @@ | ||
| // app.js | ||
| App({ | ||
| onLaunch() { | ||
| // 展示本地存储能力 | ||
| const logs = wx.getStorageSync('logs') || [] | ||
| logs.unshift(Date.now()) | ||
| wx.setStorageSync('logs', logs) | ||
|
|
||
| // 登录 | ||
| wx.login({ | ||
| success: res => { | ||
| // 发送 res.code 到后台换取 openId, sessionKey, unionId | ||
| } | ||
| }) | ||
| // 获取用户信息 | ||
| wx.getSetting({ | ||
| success: res => { | ||
| if (res.authSetting['scope.userInfo']) { | ||
| // 已经授权,可以直接调用 getUserInfo 获取头像昵称,不会弹框 | ||
| wx.getUserInfo({ | ||
| success: res => { | ||
| // 可以将 res 发送给后台解码出 unionId | ||
| this.globalData.userInfo = res.userInfo | ||
|
|
||
| // 由于 getUserInfo 是网络请求,可能会在 Page.onLoad 之后才返回 | ||
| // 所以此处加入 callback 以防止这种情况 | ||
| if (this.userInfoReadyCallback) { | ||
| this.userInfoReadyCallback(res) | ||
| } | ||
| } | ||
| }) | ||
| } | ||
| } | ||
| }) | ||
| }, | ||
| globalData: { | ||
| userInfo: null | ||
| } | ||
| }) |
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,16 @@ | ||
| { | ||
| "pages":[ | ||
| "pages/index/index", | ||
| "pages/logs/logs", | ||
| "pages/jisuan/jisuan", | ||
| "pages/lishi/lishi" | ||
| ], | ||
| "window":{ | ||
| "backgroundTextStyle":"light", | ||
| "navigationBarBackgroundColor": "#FFB6C1", | ||
| "navigationBarTitleText": "阿锹计算器", | ||
| "navigationBarTextStyle":"white" | ||
| }, | ||
| "style": "v2", | ||
| "sitemapLocation": "sitemap.json" | ||
| } |
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,10 @@ | ||
| /**app.wxss**/ | ||
| .container { | ||
| height: 100%; | ||
| display: flex; | ||
| flex-direction: column; | ||
| align-items: center; | ||
| justify-content: space-between; | ||
| padding: 200rpx 0; | ||
| box-sizing: border-box; | ||
| } |
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,59 @@ | ||
| // index.js | ||
| // 获取应用实例 | ||
| const app = getApp() | ||
|
|
||
| Page({ | ||
| data: { | ||
| motto: 'Hello World', | ||
| userInfo: {}, | ||
| hasUserInfo: false, | ||
| canIUse: wx.canIUse('button.open-type.getUserInfo') | ||
| }, | ||
| // 事件处理函数 | ||
| bindViewTap() { | ||
| wx.navigateTo({ | ||
| url: '../logs/logs' | ||
| }) | ||
| }, | ||
| jiSuanQi:function(){ | ||
| wx.navigateTo({ | ||
| url: '../jisuan/jisuan' | ||
| }) | ||
| }, | ||
| onLoad() { | ||
| if (app.globalData.userInfo) { | ||
| this.setData({ | ||
| userInfo: app.globalData.userInfo, | ||
| hasUserInfo: true | ||
| }) | ||
| } else if (this.data.canIUse) { | ||
| // 由于 getUserInfo 是网络请求,可能会在 Page.onLoad 之后才返回 | ||
| // 所以此处加入 callback 以防止这种情况 | ||
| app.userInfoReadyCallback = res => { | ||
| this.setData({ | ||
| userInfo: res.userInfo, | ||
| hasUserInfo: true | ||
| }) | ||
| } | ||
| } else { | ||
| // 在没有 open-type=getUserInfo 版本的兼容处理 | ||
| wx.getUserInfo({ | ||
| success: res => { | ||
| app.globalData.userInfo = res.userInfo | ||
| this.setData({ | ||
| userInfo: res.userInfo, | ||
| hasUserInfo: true | ||
| }) | ||
| } | ||
| }) | ||
| } | ||
| }, | ||
| getUserInfo(e) { | ||
| console.log(e) | ||
| app.globalData.userInfo = e.detail.userInfo | ||
| this.setData({ | ||
| userInfo: e.detail.userInfo, | ||
| hasUserInfo: true | ||
| }) | ||
| } | ||
| }) |
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,3 @@ | ||
| { | ||
| "usingComponents": {} | ||
| } |
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,14 @@ | ||
| <!--index.wxml--> | ||
| <view class="container"> | ||
| <view class="userinfo"> | ||
| <button wx:if="{{!hasUserInfo && canIUse}}" open-type="getUserInfo" bindgetuserinfo="getUserInfo"> 获取头像昵称 </button> | ||
| <block wx:else> | ||
| <image bindtap="bindViewTap" class="userinfo-avatar" src="{{userInfo.avatarUrl}}" mode="cover"></image> | ||
| <text class="userinfo-nickname">{{userInfo.nickName}}</text> | ||
| </block> | ||
| </view> | ||
| <view class="usermotto"> | ||
| <button bindtap="jiSuanQi">啊锹的计算器</button> | ||
| <text class="user-motto">{{motto}}</text> | ||
| </view> | ||
| </view> |
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,21 @@ | ||
| /**index.wxss**/ | ||
| .userinfo { | ||
| display: flex; | ||
| flex-direction: column; | ||
| align-items: center; | ||
| } | ||
|
|
||
| .userinfo-avatar { | ||
| width: 128rpx; | ||
| height: 128rpx; | ||
| margin: 20rpx; | ||
| border-radius: 50%; | ||
| } | ||
|
|
||
| .userinfo-nickname { | ||
| color:rgb(253, 228, 247); | ||
| } | ||
|
|
||
| .usermotto { | ||
| margin-top: 200px; | ||
| } |
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,172 @@ | ||
| // pages/jisuan/jisuan.js | ||
| Page({ | ||
| data: { | ||
| id0:0, | ||
| id1:1, | ||
| id2:2, | ||
| id3:3, | ||
| id4:4, | ||
| id5:5, | ||
| id6:6, | ||
| id7:7, | ||
| id8:8, | ||
| id9:9, | ||
| ida:'+', | ||
| idb:'-', | ||
| idc:'*', | ||
| idd:'/', | ||
| gl:'gl', | ||
| ch:'ch', | ||
| zf:'zf', | ||
| xsd:'.', | ||
| ls:'ls', | ||
| dy:'=', | ||
| screenData:0, | ||
| isFuHao:false, | ||
| sz:[] | ||
| /** | ||
| * 页面的初始数据 | ||
| */ | ||
|
|
||
|
|
||
| }, | ||
|
|
||
| /** | ||
| * 生命周期函数--监听页面加载 | ||
| */ | ||
| onLoad: function (options) { | ||
|
|
||
| }, | ||
|
|
||
| /** | ||
| * 生命周期函数--监听页面初次渲染完成 | ||
| */ | ||
| onReady: function () { | ||
|
|
||
| }, | ||
|
|
||
| /** | ||
| * 生命周期函数--监听页面显示 | ||
| */ | ||
| onShow: function () { | ||
|
|
||
| }, | ||
|
|
||
| /** | ||
| * 生命周期函数--监听页面隐藏 | ||
| */ | ||
| onHide: function () { | ||
|
|
||
| }, | ||
| lishi:function() { | ||
| wx.navigateTo({ | ||
| url: '../lishi/lishi' | ||
| }) | ||
| }, | ||
| clickBtn:function(e) { | ||
| var code=e.currentTarget.id; | ||
| if(code==this.data.ch){ | ||
| data=this.data.screenData; | ||
| var lastWord=data[data.length-1]; | ||
| if(lastWord==this.data.ida||lastWord==this.data.idb||lastWord==this.data.idc||lastWord==this.data.idd){ | ||
| this.setData({isFuHao:false}) | ||
| } | ||
| str=data.substring(0,data.length-1); | ||
| this.setData({screenData:str}) | ||
| this.data.sz.pop; | ||
| }else if(code==this.data.gl){ | ||
| this.setData({screenData:0}) | ||
| this.setData({isFuHao:false}) | ||
| this.data.sz=[]; | ||
| }else if(code==this.data.zf){ | ||
| data =this.data.screenData; | ||
| var firstWord=data[0]; | ||
| if(isNaN(firstWord)){ | ||
| var str=data.substring(1,data.length) | ||
| }else{ | ||
| var str='-'+data; | ||
| } | ||
| this.setData({screenData:str}); | ||
| }else if(code==this.data.dy){ | ||
| var newSz=[]; | ||
| var num=''; | ||
| var sz=this.data.sz; | ||
| for(var i in sz){ | ||
| if(isNaN(sz[i])==false||sz[i]==this.data.xsd){ | ||
| num+=sz[i]; | ||
| }else{ | ||
| newSz.push(num); | ||
| newSz.push(sz[i]); | ||
| num=""; | ||
| } | ||
| } | ||
| newSz.push(num); | ||
| var result=Number(newSz[0]); | ||
| for(var i=1;i<=newSz.length;i++){ | ||
| if(newSz[i]==this.data.ida){ | ||
| result+=Number(newSz[i+1]); | ||
| }else if(newSz[i]==this.data.idb){ | ||
| result-=Number(newSz[i+1]); | ||
| }else if(newSz[i]==this.data.idc){ | ||
| result*=Number(newSz[i+1]); | ||
| }else if(newSz[i]==this.data.idd){ | ||
| result/=Number(newSz[i+1]); | ||
| } | ||
| } | ||
|
|
||
| this.setData({screenData:result}); | ||
| console.log(newSz); | ||
| console.log(result); | ||
| }else{ | ||
| var code=e.currentTarget.id; | ||
| var data=this.data.screenData; | ||
| if(code == this.data.ida || code==this.data.idb || code==this.data.idc ||code==this.data.idd){ | ||
| if(this.data.isFuHao==true){ | ||
| return''; | ||
| } | ||
| } | ||
| var str=null; | ||
| if(data==0){ | ||
| str=code; | ||
| }else{ | ||
| str=data+code; | ||
| } | ||
| this.setData({'isFuHao':false}); | ||
| if(code== this.data.ida|| code==this.data.idb|| code==this.data.idc||code==this.data.idd){ | ||
| this.setData({'isFuHao':true}); | ||
| } | ||
| this.data.sz.push(code); | ||
| this.setData({screenData:str}) | ||
| } | ||
|
|
||
| console.log(this.data.screenData); | ||
| console.log(this.data.sz); | ||
| }, | ||
| /** | ||
| * 生命周期函数--监听页面卸载 | ||
| */ | ||
| onUnload: function () { | ||
|
|
||
| }, | ||
|
|
||
| /** | ||
| * 页面相关事件处理函数--监听用户下拉动作 | ||
| */ | ||
| onPullDownRefresh: function () { | ||
|
|
||
| }, | ||
|
|
||
| /** | ||
| * 页面上拉触底事件的处理函数 | ||
| */ | ||
| onReachBottom: function () { | ||
|
|
||
| }, | ||
|
|
||
| /** | ||
| * 用户点击右上角分享 | ||
| */ | ||
| onShareAppMessage: function () { | ||
|
|
||
| } | ||
| }) |
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,3 @@ | ||
| { | ||
| "usingComponents": {} | ||
| } |
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,40 @@ | ||
| <!--pages/jisuan/jisuan.wxml--> | ||
| <view class="aaa"> | ||
| <view class="bbb"> | ||
| <view class="screen"> | ||
| {{screenData}} | ||
| </view> | ||
| </view> | ||
| <view class="ccc"> | ||
| <view class="ddd"> | ||
| <view bindtap="clickBtn" id="{{gl}}" class="eee colorc">归零</view> | ||
| <view bindtap="clickBtn" id="{{ch}}" class="eee colorc">撤回</view> | ||
| <view bindtap="clickBtn" id="{{zf}}" class="eee colorb">+/-</view> | ||
| <view bindtap="clickBtn" id="{{ida}}" class="eee colorb">+</view> | ||
| </view> | ||
| <view class="ddd"> | ||
| <view bindtap="clickBtn" id="{{id9}}" class="eee colora">9</view> | ||
| <view bindtap="clickBtn" id="{{id8}}" class="eee colora">8</view> | ||
| <view bindtap="clickBtn" id="{{id7}}" class="eee colora">7</view> | ||
| <view bindtap="clickBtn" id="{{idb}}" class="eee colorb">-</view> | ||
| </view> | ||
| <view class="ddd"> | ||
| <view bindtap="clickBtn" id="{{id6}}" class="eee colora">6</view> | ||
| <view bindtap="clickBtn" id="{{id5}}" class="eee colora">5</view> | ||
| <view bindtap="clickBtn" id="{{id4}}" class="eee colora">4</view> | ||
| <view bindtap="clickBtn" id="{{idc}}" class="eee colorb">*</view> | ||
| </view> | ||
| <view class="ddd"> | ||
| <view bindtap="clickBtn" id="{{id3}}" class="eee colora">3</view> | ||
| <view bindtap="clickBtn" id="{{id2}}" class="eee colora">2</view> | ||
| <view bindtap="clickBtn" id="{{id1}}" class="eee colora">1</view> | ||
| <view bindtap="clickBtn" id="{{idd}}" class="eee colorb">/</view> | ||
| </view> | ||
| <view class="ddd"> | ||
| <view bindtap="clickBtn" id="{{id0}}" class="eee colora">0</view> | ||
| <view bindtap="clickBtn" id="{{xsd}}" class="eee colorb">.</view> | ||
| <view bindtap="clickBtn" id="{{ls}}" class="eee colorc" bindtap="lishi">历史</view> | ||
| <view bindtap="clickBtn" id="{{dy}}" class="eee colorb">=</view> | ||
| </view> | ||
| </view> | ||
| </view> | ||
Oops, something went wrong.
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.
结果在右侧可以加一个padding,会好看点