Skip to content

Commit

Permalink
hzuapps#2 hzuapps#174 第2次实验代码
Browse files Browse the repository at this point in the history
  • Loading branch information
wazhuroujuan committed Nov 19, 2017
1 parent 362f57f commit 0c80bcd
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 33 deletions.
60 changes: 51 additions & 9 deletions 1514080901134/pages/index/index.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,54 @@
//index.js
//获取应用实例
const app = getApp()

Page({
open: function () {
wx.showActionSheet({
itemList: ['A', 'B', 'C'],
success: function (res) {
if (!res.cancel) {
console.log(res.tapIndex)
}
data: {
motto: 'Hello World',
userInfo: {},
hasUserInfo: false,
canIUse: wx.canIUse('button.open-type.getUserInfo')
},
//事件处理函数
bindViewTap: function() {
wx.navigateTo({
url: '../logs/logs'
})
},
onLoad: function () {
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: function(e) {
console.log(e)
app.globalData.userInfo = e.detail.userInfo
this.setData({
userInfo: e.detail.userInfo,
hasUserInfo: true
})
}
});
})
26 changes: 5 additions & 21 deletions 1514080901134/pages/index/index.wxml
Original file line number Diff line number Diff line change
@@ -1,34 +1,18 @@
<view class="page">
<view class="page__hd">
<view class="page__title">HELLO</view>
<view class="page__desc">welcome to one sheep</view>
</view>
<view class="page__bd">
<view class="weui-btn-area">
<button type="default" bindtap="open">HELLO</button>
</view>
</view>
<view class="page__hd">
<view class="page__title">Button</view>
<view class="page__desc">按钮,WeUI采用小程序原生的按钮为主体,加入一些间距的样式。</view>
<view class="page__desc">欢迎使用小程序</view>
</view>
<view class="page__bd page__bd_spacing">
<button class="weui-btn" type="primary">我的文件 </button>


<button class="weui-btn" type="default">我的收藏 </button>
<button class="weui-btn" type="primary">登陆 </button>


<button class="weui-btn" type="warn">设置 </button>
<button class="weui-btn" type="warn">退出</button>


<view class="button-sp-area">
<button class="weui-btn" type="primary" plain="true">进入</button>



<button class="weui-btn" type="primary" plain="true">设置</button>

<button class="weui-btn mini-btn" type="warn" size="mini">退出</button>
</view>
</view>
</view>
</view>
3 changes: 0 additions & 3 deletions 1514080901134/pages/index/index.wxss
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
page{
background-color: #FFFFFF;
}
.button-sp-area{
margin: 0 auto;
padding-top: 15px;
Expand Down

0 comments on commit 0c80bcd

Please sign in to comment.