mirror of
https://github.com/weilanwl/coloruicss.git
synced 2026-03-14 03:54:00 +08:00
v2.0.2
v2.0.2 2.0版本上线
This commit is contained in:
56
template/pages/index/index.js
Normal file
56
template/pages/index/index.js
Normal file
@@ -0,0 +1,56 @@
|
||||
//index.js
|
||||
//获取应用实例
|
||||
const app = getApp()
|
||||
|
||||
Page({
|
||||
data: {
|
||||
StatusBar: app.globalData.StatusBar,
|
||||
CustomBar: app.globalData.CustomBar,
|
||||
motto: 'Hi 开发者!',
|
||||
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
|
||||
})
|
||||
}
|
||||
})
|
||||
3
template/pages/index/index.json
Normal file
3
template/pages/index/index.json
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"usingComponents": {}
|
||||
}
|
||||
20
template/pages/index/index.wxml
Normal file
20
template/pages/index/index.wxml
Normal file
@@ -0,0 +1,20 @@
|
||||
<custom style="height:{{CustomBar}}px;">
|
||||
<bar class="fixed gradual-blue" style="height:{{CustomBar}}px;padding-top:{{StatusBar}}px;">
|
||||
<view class='content'>ColorUI 空白模板</view>
|
||||
</bar>
|
||||
</custom>
|
||||
<view class="margin-xl padding-xl bg-white radius shadow-lg">
|
||||
<view class="flex justify-center">
|
||||
<button wx:if="{{!hasUserInfo && canIUse}}" open-type="getUserInfo" bindgetuserinfo="getUserInfo" class='round bg-green shadow'> 获取头像昵称 </button>
|
||||
<block wx:else>
|
||||
<view class='text-center'>
|
||||
<avatar class="xl round solids" style="background-image:url({{userInfo.avatarUrl}})"></avatar>
|
||||
<view class="padding">{{userInfo.nickName}}</view>
|
||||
</view>
|
||||
</block>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="text-center margin-top">
|
||||
<text class="text-grey text-xl">{{motto}}</text>
|
||||
</view>
|
||||
0
template/pages/index/index.wxss
Normal file
0
template/pages/index/index.wxss
Normal file
Reference in New Issue
Block a user