zgt_branch
guotao_Z 1 year ago
parent 318fe82897
commit 2e74396251

Binary file not shown.

After

Width:  |  Height:  |  Size: 262 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 54 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 46 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 116 KiB

@ -0,0 +1,48 @@
// index.js
// 获取应用实例
const app = getApp()
Page({
data: {
motto: 'Hello World',
userInfo: {},
hasUserInfo: false,
canIUse: wx.canIUse('button.open-type.getUserInfo'),
canIUseGetUserProfile: false,
canIUseOpenData: wx.canIUse('open-data.type.userAvatarUrl') && wx.canIUse('open-data.type.userNickName') // 如需尝试获取用户信息可改为false
},
// 事件处理函数
bindViewTap() {
wx.navigateTo({
url: '../logs/logs'
})
},
onLoad() {
if (wx.getUserProfile) {
this.setData({
canIUseGetUserProfile: true
})
}
},
getUserProfile(e) {
// 推荐使用wx.getUserProfile获取用户信息开发者每次通过该接口获取用户个人信息均需用户确认开发者妥善保管用户快速填写的头像昵称避免重复弹窗
wx.getUserProfile({
desc: '展示用户信息', // 声明获取用户个人信息后的用途,后续会展示在弹窗中,请谨慎填写
success: (res) => {
console.log(res)
this.setData({
userInfo: res.userInfo,
hasUserInfo: true
})
}
})
},
getUserInfo(e) {
// 不推荐使用getUserInfo获取用户信息预计自2021年4月13日起getUserInfo将不再弹出弹窗并直接返回匿名的用户个人信息
console.log(e)
this.setData({
userInfo: e.detail.userInfo,
hasUserInfo: true
})
}
})

@ -0,0 +1,3 @@
{
"usingComponents": {}
}

@ -0,0 +1,23 @@
<!--index.wxml-->
<view class="container">
<view class="userinfo">
<block wx:if="{{canIUseOpenData}}">
<view class="userinfo-avatar" bindtap="bindViewTap">
<open-data type="userAvatarUrl"></open-data>
</view>
<open-data type="userNickName"></open-data>
</block>
<block wx:elif="{{!hasUserInfo}}">
<button wx:if="{{canIUseGetUserProfile}}" bindtap="getUserProfile"> 获取头像昵称 </button>
<button wx:elif="{{canIUse}}" open-type="getUserInfo" bindgetuserinfo="getUserInfo"> 获取头像昵称 </button>
<view wx:else> 请使用1.4.4及以上版本基础库 </view>
</block>
<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>
</view>

@ -0,0 +1,19 @@
/**index.wxss**/
.userinfo {
display: flex;
flex-direction: column;
align-items: center;
color: #aaa;
}
.userinfo-avatar {
overflow: hidden;
width: 128rpx;
height: 128rpx;
margin: 20rpx;
border-radius: 50%;
}
.usermotto {
margin-top: 200px;
}

@ -0,0 +1,45 @@
// pages/login/index.js
Page({
/**
* 页面的初始数据
*/
data: {
stuId: '', //学号
password: '' //密码
},
/**
* 生命周期函数--监听页面加载
*/
onLoad(options) {
},
login(){
const postData = {
stuId: this.data.stuId,
password: this.data.password
}
wx.request({
url: 'http://localhost:3000/login',
data:postData,
method: 'POST',
success(res){
console.log(res)
if (res.data.code == -1){
wx.showToast({
title: res.data.msg,
icon: 'none'
})
return
}
wx.setStorageSync('token',res.data.data.cookie)
wx.showToast({
title: '登录成功',
icon: 'success'
})
}
})
}
})

@ -0,0 +1,4 @@
{
"usingComponents": {},
"navigationBartitleText": "登录"
}

@ -0,0 +1,16 @@
<view class="container">
<view class="header">
<image src="/asset/imgs/登录界面1.jpg" mode="aspectFill"></image>
</view>
<view class="login">
<view class="form-item">
<image src="/asset/imgs/登录1.jpg" mode="aspectFill"></image>
<input type="text" model:value="{{stuId}}" placeholder="请输入学号" />
</view>
<view class="form-item">
<image src="/asset/imgs/登录2.jpg" mode="aspectFill"></image>
<input type="password" model:value="{{password}}" placeholder="请输入密码"/>
</view>
<button bindtap="login">登录</button>
</view>
</view>

@ -0,0 +1,53 @@
page{
background: rgba(250,250,250,1)
}
.login {
padding:30rpx;
margin-top:60rpx;
}
.form-item input {
}
.form-item image {
width: 32rpx;
height: 32rpx;
margin-right: 32rpx;
}
.login button{
width: 100%;
border-radius: 60rpx;
background: linear-gradient(
90deg,
rgba(193,239,245,0.9) 0%,
rgba(10,232,240,1) 1%,
rgba(136,242,223,1) 100%
);
box-shadow: 0rpx 0rpx 12rpx 0rpx rgba(0,0,0,0.1);
color: #fff;
margin-top: 100rpx;
}
.header {
display: flex;
justify-content: center;
margin-top: 106rpx;
}
.header image {
width: 600rpx;
height: 300rpx;
}
.form-item {
height: 98rpx;
border-radius: 60rpx;
background: rgba(255,255,255,1);
border: 1rpx solid rgba(232,232,232,0.86);
box-shadow: 0rpx 0rpx 2rpx -4rpx rgba(0,0,0,0.1);
display: flex;
align-items: center;
padding: 0 30rpx;
margin-bottom: 40rpx;
}

@ -0,0 +1,18 @@
// logs.js
const util = require('../../utils/util.js')
Page({
data: {
logs: []
},
onLoad() {
this.setData({
logs: (wx.getStorageSync('logs') || []).map(log => {
return {
date: util.formatTime(new Date(log)),
timeStamp: log
}
})
})
}
})

@ -0,0 +1,4 @@
{
"navigationBarTitleText": "查看启动日志",
"usingComponents": {}
}

@ -0,0 +1,6 @@
<!--logs.wxml-->
<view class="container log-list">
<block wx:for="{{logs}}" wx:key="timeStamp" wx:for-item="log">
<text class="log-item">{{index + 1}}. {{log.date}}</text>
</block>
</view>

@ -0,0 +1,8 @@
.log-list {
display: flex;
flex-direction: column;
padding: 40rpx;
}
.log-item {
margin: 10rpx;
}

@ -0,0 +1,19 @@
const formatTime = date => {
const year = date.getFullYear()
const month = date.getMonth() + 1
const day = date.getDate()
const hour = date.getHours()
const minute = date.getMinutes()
const second = date.getSeconds()
return `${[year, month, day].map(formatNumber).join('/')} ${[hour, minute, second].map(formatNumber).join(':')}`
}
const formatNumber = n => {
n = n.toString()
return n[1] ? n : `0${n}`
}
module.exports = {
formatTime
}
Loading…
Cancel
Save