Compare commits

...

2 Commits

Author SHA1 Message Date
wsq fbdc88616e 123
2 years ago
wsq 149ef8ffb3 111
2 years ago

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

@ -0,0 +1,180 @@
// pages/index/index.js
import Toast from './@vant/weapp/toast/toast';
var app=getApp();
Page({
/**
* 页面的初始数据
*/
onload: function (){
},
data: {
user:"",//输入账号
pwd:"",//输入密码
default_user:"user",//默认账号
default_pwd:"123456",//默认密码
},
//登录按钮
log_on()
{
console.log("账号",this.data.user,this.data.pwd);
if(this.data.user==this.data.default_user&& this.data.pwd==this.data.default_pwd)
{
wx.reLaunch({
url: '/pages/navigation/index/index',
})
}else{
Toast.fail('账号或密码错误');
}
},
//忘记密码
forget()
{
},
//获取用户名
getName(user) {
console.log('获取输入的用户名', user.detail.value)
this.setData({
name: user.detail.value
})
},
//获取用户账号
getZhangHao(user) {
console.log('获取输入的账号', user.detail.value)
this.setData({
zhanghao: user.detail.value
})
},
// 获取密码
getMiMa(pwd) {
console.log('获取输入的密码', pwd.detail.value)
this.setData({
mima: pwd.detail.value
})
},
//注册
zhuce() {
let name = this.data.name
let zhanghao = this.data.zhanghao
let mima = this.data.mima
console.log("点击了注册")
console.log("name", name)
console.log("zhanghao", zhanghao)
console.log("mima", mima)
//校验用户名
if (name.length < 2) {
wx.showToast({
icon: 'none',
title: '用户名至少2位',
})
return
}
if (name.length > 10) {
wx.showToast({
icon: 'none',
title: '用户名最多10位',
})
return
}
//校验账号
if (zhanghao.length < 4) {
wx.showToast({
icon: 'none',
title: '账号至少4位',
})
return
}
//校验密码
if (mima.length < 4) {
wx.showToast({
icon: 'none',
title: '密码至少4位',
})
return
}
//注册功能的实现
wx.cloud.database().collection('user').add({
data: {
user:"",//账号
pwd:"",//密码
},
success(res) {
console.log('注册成功', res)
wx.showToast({
title: '注册成功',
})
wx.navigateTo({
url: '../login/login',
})
},
fail(res) {
console.log('注册失败', res)
}
})
},
/**
* 生命周期函数--监听页面加载
*/
onLoad(options) {
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady() {
},
/**
* 生命周期函数--监听页面显示
*/
onShow() {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide() {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload() {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh() {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom() {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage() {
}
})

@ -0,0 +1,5 @@
{
"usingComponents": {},
"navigationBarTitleText":""
}

@ -0,0 +1,43 @@
<!--pages/index/index.wxml
-->
<view>
<van-toast id="van-toast" />
<view style="width:100vw; height:100vh;position:relative;overflow: hidden">
<van-image width="100vw" height="100vh" fit="fill" src="/pages/img/登陆.jpg" />
<view style="display: -webkit-flex;display: flex; flex-direction:column; position:relative;top:-700rpx;left:100rpx; z-index:100;">
<view style="display: -webkit-flex;display: flex;align-content:flex-start">
<van-icon size="70rpx" name="/pages/img/手机.jpg" />
<view style="width:450rpx;border-bottom: solid #d4d4d4 calc(0.1rem);">
<van-cell-group>
<van-field clearable model:value="{{ user }}" placeholder="请输入用户名" border="{{ false }}" />
</van-cell-group>
</view>
</view>
<view style="display: -webkit-flex;display: flex;align-content:flex-start;margin-top:50rpx;">
<van-icon size="70rpx" name="/pages/img/密码.jpg" />
<view style="width:450rpx;border-bottom: solid #d4d4d4 calc(0.1rem);">
<van-cell-group>
<van-field password clearable model:value="{{ pwd }}" placeholder="请输入密码" border="{{ false }}" />
</van-cell-group>
</view>
</view>
<van-button bind:click="log_on"round custom-style="width:550rpx;background-color:#32b16c;color:white;margin-top:60rpx;">登 录</van-button>
<view style="display: -webkit-flex;display: flex;padding:20rpx;">
<view style="flex:1 1 30%;">忘记密码?</view>
<view style="flex:1 1 70%;text-align:center;">注册</view>
</view>
</view>
</view>
</view>

@ -0,0 +1 @@
/* pages/index/index.wxss */
Loading…
Cancel
Save