作者 吴孟雨

首页开头,暂存

<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="JavaScriptSettings">
<option name="languageLevel" value="ES6" />
</component>
</project>
\ No newline at end of file
... ...
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/火柴西路.iml" filepath="$PROJECT_DIR$/.idea/火柴西路.iml" />
</modules>
</component>
</project>
\ No newline at end of file
... ...
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$" vcs="Git" />
</component>
</project>
\ No newline at end of file
... ...
<?xml version="1.0" encoding="UTF-8"?>
<module type="WEB_MODULE" version="4">
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$">
<excludeFolder url="file://$MODULE_DIR$/.tmp" />
<excludeFolder url="file://$MODULE_DIR$/temp" />
<excludeFolder url="file://$MODULE_DIR$/tmp" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>
\ No newline at end of file
... ...
/**app.wxss**/
.container {
height: 100%;
display: flex;
flex-direction: column;
align-items: center;
justify-content: space-between;
padding: 200rpx 0;
box-sizing: border-box;
}
@font-face {font-family: "iconfont";
src: url('//at.alicdn.com/t/font_961048_ey8uu8eyju6.eot?t=1544523215072'); /* IE9*/
src: url('//at.alicdn.com/t/font_961048_ey8uu8eyju6.eot?t=1544523215072#iefix') format('embedded-opentype'), /* IE6-IE8 */
url('data:application/x-font-woff;charset=utf-8;base64,d09GRgABAAAAAASkAAsAAAAABvgAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAABHU1VCAAABCAAAADMAAABCsP6z7U9TLzIAAAE8AAAARAAAAFY8dkgvY21hcAAAAYAAAABUAAABhmU+0M1nbHlmAAAB1AAAANgAAADYbiAdb2hlYWQAAAKsAAAALwAAADYTiqGcaGhlYQAAAtwAAAAcAAAAJAfeA4RobXR4AAAC+AAAA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KFrdLqnGtbxCZTg6BfSVOdaVvdU+zXQ+ciFVmTqgmrOkmMyq3Z6tAFG+fyUa8XiR6EJuVYY/62xgKOcQWFJQ6MMUIYZIjK6Og7VWb0r7FDwl57Vj3N53RbFNT/c4UBAvTPXFO6stJ5Ok+BPV8bUnV0K27LnpQ0kV7NSRKyQl7WtlRC6gE2ZVeOEXpc0Yk/KGdI/wAJWm7IAAAAeJxjYGKAAC4G7ICZkYmRmZGFgSuxqCi/XDclvzyPIyc/ObEkMz+PgQEAXj4HlwAA') format('woff'),
url('//at.alicdn.com/t/font_961048_ey8uu8eyju6.ttf?t=1544523215072') format('truetype'), /* chrome, firefox, opera, Safari, Android, iOS 4.2+*/
url('//at.alicdn.com/t/font_961048_ey8uu8eyju6.svg?t=1544523215072#iconfont') format('svg'); /* iOS 4.1- */
}
.iconfont {
font-family:"iconfont" !important;
font-size:16px;
font-style:normal;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
.icon-arrow-down:before { content: "\e63d"; }
.icon-location:before { content: "\e600"; }
... ...
... ... @@ -3,52 +3,53 @@
const app = getApp()
Page({
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
data: {
slide: [{image: '../../images/banner.png'}, {image: '../../images/banner.png'}],
motto: 'Hello World',
userInfo: {},
hasUserInfo: false,
canIUse: wx.canIUse('button.open-type.getUserInfo')
},
//事件处理函数
bindViewTap: function () {
wx.navigateTo({
url: '../logs/logs'
})
}
} else {
// 在没有 open-type=getUserInfo 版本的兼容处理
wx.getUserInfo({
success: res => {
app.globalData.userInfo = res.userInfo
this.setData({
userInfo: res.userInfo,
hasUserInfo: true
})
},
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
})
}
},
getUserInfo: function(e) {
console.log(e)
app.globalData.userInfo = e.detail.userInfo
this.setData({
userInfo: e.detail.userInfo,
hasUserInfo: true
})
}
})
... ...
{
"navigationBarTitleText": "火柴西路"
}
\ No newline at end of file
... ...
<!--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">
<text class="user-motto">{{motto}}</text>
<view class="head">
<view class="position">
<view class="left">
<view class="iconfont icon-location"></view>
<text>北京</text>
<view class="iconfont icon-arrow-down"></view>
</view>
<input type="text"/>
</view>
<swiper indicator-dots="{{true}}"
autoplay="{{true}}" interval="3000" duration="1000">
<block wx:for="{{slide}}" wx:key="index">
<navigator url="{{item.url}}" hover-class="navigator-hover">
<swiper-item>
<image src="{{item.image}}" class="slide-image"/>
</swiper-item>
</navigator>
</block>
</swiper>
</view>
</view>
... ...
/**index.wxss**/
.userinfo {
.position {
width: 100%;
display: flex;
flex-direction: column;
align-items: center;
justify-content: space-between;
position: fixed;
top: 0;
left: 0;
z-index: 10;
padding: 14rpx 20rpx;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
}
.userinfo-avatar {
width: 128rpx;
height: 128rpx;
margin: 20rpx;
border-radius: 50%;
.position .left {
display: flex;
align-items: center;
}
.position .left .icon-location {
font-size: 44rpx;
color: #ffffff;
margin-right: 14rpx;
}
.position .left .icon-arrow-down {
font-size: 36rpx;
color: #ffffff;
margin-left: 18rpx;
}
.position text {
color: #ffffff;
font-size: 28rpx;
}
.position input {
width: 478rpx;
height: 52rpx;
border-radius: 10rpx;
color: #ffffff;
padding-left: 20rpx;
font-size: 28rpx;
background-color: rgba(255,255,255,0.3);
}
.userinfo-nickname {
color: #aaa;
swiper {
width: 100%;
height: 360rpx;
/*margin-top: 20rpx;*/
}
.usermotto {
margin-top: 200px;
.slide-image {
width: 100%;
height: 100%;
}
\ No newline at end of file
... ...