注册流程

This commit is contained in:
limqhz
2022-12-16 17:32:49 +08:00
parent b746aaaa83
commit eb5c301d00
57 changed files with 1839 additions and 20 deletions

View File

@@ -62,7 +62,22 @@ Component({
}
},
checkLogin(){
let userInfo = wx.getStorageSync('userInfo');
let token = wx.getStorageSync('userToken');
console.log('userInfo===' + userInfo);
console.log('token===' + token);
if (userInfo && token){
return true;
}else {
return false;
}
},
onChange(event) {
if (!this.checkLogin()){
wx.redirectTo({url:"/pages/login/index"});
}
this.setIconData(event.detail.value);
},
}

73
pages/login/index.js Normal file
View File

@@ -0,0 +1,73 @@
import Toast from '../../components/toast/index';
Page({
data: {
body:{
userName:'',
password:'',
code:''
}
},
// 输入框输入时
inputChange(event) {
let key = event.currentTarget.dataset.type;
this.data.body[key] = event.detail.value;
},
toast(option) {
Toast({
context: this,
selector: '#t-toast',
...option,
});
},
clickRegister() {
wx.redirectTo({
url:"/pages/register/index"
})
},
longin(){
if (!this.data.body.userName) {
this.toast({
message: '用户名不能为空!',
theme: 'fail',
placement: 'bottom',
direction: 'column'
});
return;
}
if (!this.data.body.password) {
this.toast({
message: '请输入密码!',
theme: 'fail',
placement: 'bottom',
direction: 'column'
});
return;
}
if (!this.data.body.code) {
this.toast({
message: '请输入验证码!',
theme: 'fail',
placement: 'bottom',
direction: 'column'
});
return;
}
if (this.data.body.code != '1') {
this.toast({
message: '验证码不匹配!',
theme: 'fail',
placement: 'bottom',
direction: 'column'
});
return;
}
console.log('登录成功');
wx.setStorageSync('userInfo',this.data.body);
wx.setStorageSync('userToken','123456');
wx.redirectTo({url:'/pages/myself/index'});
}
});

6
pages/login/index.json Normal file
View File

@@ -0,0 +1,6 @@
{
"usingComponents": {
"t-toast": "/components/toast/toast",
"t-button": "/components/button/button"
}
}

18
pages/login/index.wxml Normal file
View File

@@ -0,0 +1,18 @@
<view class="inputClass">
<t-input label="用户名" placeholder="请输入用户名" maxlength="{{10}}" bindchange="inputChange" data-type='userName' clearable />
<t-input label="输入密码" placeholder="请输入密码" type="password" bindchange="inputChange" data-type='password' clearable />
<t-input placeholder="请输入验证码" bindchange="inputChange" data-type='code' label="验证码">
<view slot="suffix">
<image
style="width: 72px; height: 36px; display: block; margin-top: -6px; margin-bottom: -6px"
src="https://wwcdn.weixin.qq.com/node/wework/images/202010241547.ac6876be9c.png"
mode="heightFix"
/>
</view>
</t-input>
<view class="clickRegister" bind:tap="clickRegister">点击注册></view>
</view>
<view class="inputButton">
<t-button block theme="danger" bind:tap="longin">登录</t-button>
</view>
<t-toast id="t-toast" />

13
pages/login/index.wxss Normal file
View File

@@ -0,0 +1,13 @@
.inputClass {
margin-top: 200rpx;
padding: 20rpx;
}
.inputButton {
padding: 20rpx;
margin-top: 50rpx;
}
.clickRegister{
margin-top: 10rpx;
font-size: 28rpx;
float: right;
}

View File

@@ -18,5 +18,11 @@ Page({
console.log(e);
}
})
},
exitLogin(){
wx.clearStorageSync();
wx.redirectTo({url:"/pages/login/index"})
}
});

View File

@@ -1,4 +1,5 @@
{
"usingComponents": {
"t-button": "/components/button/button"
}
}

View File

@@ -10,3 +10,6 @@
</t-cell>
<t-cell title="昵称" description="{{'浙A88FU7'}}" />
<t-cell title="邮箱" description="{{'540344226@qq.com'}}" />
<view class="subButton">
<t-button block theme="danger" bind:tap="exitLogin">退出登录</t-button>
</view>

View File

@@ -4,3 +4,8 @@
border-radius: 50%;
overflow: hidden;
}
.subButton {
position: absolute;
width: 100%;
bottom:10rpx;
}

79
pages/register/index.js Normal file
View File

@@ -0,0 +1,79 @@
Page({
data: {
nameConfirm: false,
checkedId: '',
checkedName: '',
userNameList: [
{"id":1,"userName":"浙A88123","checked":false},
{"id":2,"userName":"浙A88dae","checked":false},
{"id":3,"userName":"浙A88F32","checked":false},
{"id":4,"userName":"浙A88231","checked":false},
{"id":5,"userName":"浙A88F213","checked":false},
{"id":6,"userName":"浙A88F1U7","checked":false},
{"id":7,"userName":"浙A81237","checked":false},
{"id":8,"userName":"浙A1238FU7","checked":false},
{"id":9,"userName":"浙A88FU7","checked":false},
{"id":10,"userName":"浙A88FU7","checked":false},
{"id":11,"userName":"浙A88FU7","checked":false},
{"id":12,"userName":"浙A88FU7","checked":false},
{"id":13,"userName":"浙A88FU7","checked":false},
{"id":14,"userName":"浙A88FU7","checked":false},
{"id":15,"userName":"浙A88FU7","checked":false},
{"id":16,"userName":"浙A88FU7","checked":false},
{"id":17,"userName":"浙A88FU7","checked":false},
{"id":18,"userName":"浙A88FU7","checked":false},
{"id":19,"userName":"浙A88FU7","checked":false},
{"id":20,"userName":"浙A88FU7","checked":false},
{"id":21,"userName":"浙A88FU7","checked":false},
{"id":22,"userName":"浙A88FU7","checked":false},
{"id":23,"userName":"浙A88FU7","checked":false},
{"id":24,"userName":"浙A88FU7","checked":false},
{"id":25,"userName":"浙A88FU7","checked":false},
{"id":26,"userName":"浙A88FU7","checked":false},
{"id":27,"userName":"浙A88FU7","checked":false},
{"id":28,"userName":"浙A88FU7","checked":false},
{"id":29,"userName":"浙A88FU7","checked":false},
{"id":30,"userName":"浙A88FU7","checked":false},
{"id":31,"userName":"浙A88FU7","checked":false},
{"id":32,"userName":"浙A88FU7","checked":false},
{"id":33,"userName":"浙A88FU7","checked":false},
{"id":34,"userName":"浙A88FU7","checked":false},
{"id":35,"userName":"浙A88FU7","checked":false},
{"id":36,"userName":"浙A88FU7","checked":false},
{"id":37,"userName":"浙A88FU7","checked":false},
{"id":38,"userName":"浙A88FU7","checked":false},
{"id":39,"userName":"浙A88FU7","checked":false},
{"id":40,"userName":"浙A88FU7","checked":false}
],
},
checkName() {
this.closeDialog();
wx.navigateTo({url:"/pages/register/password/index?name=" + this.data.checkedName})
},
changeCheckEasy() {
let dataList = this.data.userNameList;
let dataCheck = dataList[this.data.checkedId];
dataCheck.checked = !dataCheck.checked;
dataList[this.data.checkedId] = dataCheck;
this.setData({
userNameList: dataList,
})
},
closeDialog() {
this.changeCheckEasy();
this.setData({ nameConfirm : false });
},
handleCheckTagChange(e){
this.setData({
checkedId : e.currentTarget.id - 1,
checkedName : e.currentTarget.dataset.name,
nameConfirm : true
})
this.changeCheckEasy();
}
});

10
pages/register/index.json Normal file
View File

@@ -0,0 +1,10 @@
{
"usingComponents": {
"t-grid": "/components/grid/grid",
"t-grid-item": "/components/grid/grid-item",
"t-tag": "/components/tag/tag",
"t-steps": "/components/steps/steps",
"t-step-item": "/components/steps/step-item",
"t-dialog": "/components/dialog/dialog"
}
}

22
pages/register/index.wxml Normal file
View File

@@ -0,0 +1,22 @@
<view>
<t-steps class="demo-steps" defaultCurrent="0" readonly>
<t-step-item title="用户名" content="选择用户名" />
<t-step-item title="密码" content="设置密码" />
<t-step-item title="成功" content="完成注册" />
</t-steps>
</view>
<t-grid class="five" column="{{4}}" align="center" border="{{border}}">
<t-grid-item wx:for="{{userNameList}}" wx:key="index" text="{{item.id}}">
<t-tag wx:if="{{item.checked}}" theme="success" bind:tap="handleCheckTagChange" id="{{item.id}}" data-name="{{item.userName}}" size="large">{{item.userName}}</t-tag>
<t-tag wx:else theme="primary" bind:tap="handleCheckTagChange" id="{{item.id}}" data-name="{{item.userName}}" size="large">{{item.userName}}</t-tag>
</t-grid-item>
</t-grid>
<t-dialog
visible="{{nameConfirm}}"
title="确定选择【{{checkedName}}】?"
t-class-confirm="custom-confirm-btn"
confirm-btn="就它了"
cancel-btn="再想想"
bind:confirm="checkName"
bind:cancel="closeDialog"
/>

View File

@@ -0,0 +1,3 @@
.custom-confirm-btn {
color: #ff4646 !important;
}

View File

@@ -0,0 +1,13 @@
Page({
data: {
userName:'',
},
onLoad: function (options) {
this.setData({
userName:options.name
})
},
toLongin(){
wx.redirectTo({url:"/pages/login/index"});
}
});

View File

@@ -0,0 +1,8 @@
{
"usingComponents": {
"t-steps": "/components/steps/steps",
"t-step-item": "/components/steps/step-item",
"t-result": "/components/result/result",
"t-button": "/components/button/button"
}
}

View File

@@ -0,0 +1,13 @@
<view>
<t-steps class="demo-steps" defaultCurrent="2" readonly>
<t-step-item title="用户名" content="选择用户名" />
<t-step-item title="密码" content="设置密码" />
<t-step-item title="成功" content="完成注册" />
</t-steps>
</view>
<view class="leaveTop">
<t-result theme="success" title="成功" description="恭喜{{userName}}注册成功!" />
</view>
<view class="leaveTop">
<t-button block theme="danger" bind:tap="toLongin">去登录>>></t-button>
</view>

View File

@@ -0,0 +1,3 @@
.leaveTop{
margin-top: 88rpx;
}

View File

@@ -0,0 +1,15 @@
Page({
data: {
userName:'',
},
onLoad: function (options) {
this.setData({
userName:options.name
})
},
toRegister(){
wx.navigateTo({url:"/pages/register/ok/index?name=" + this.data.userName})
}
});

View File

@@ -0,0 +1,7 @@
{
"usingComponents": {
"t-steps": "/components/steps/steps",
"t-step-item": "/components/steps/step-item",
"t-button": "/components/button/button"
}
}

View File

@@ -0,0 +1,15 @@
<view>
<t-steps class="demo-steps" defaultCurrent="1" readonly>
<t-step-item title="用户名" content="选择用户名" />
<t-step-item title="密码" content="设置密码" />
<t-step-item title="成功" content="完成注册" />
</t-steps>
</view>
<view class="leaveTop">
<t-input label="用户名" value="{{userName}}" disabled />
<t-input label="输入密码" placeholder="请输入密码" type="password" bindchange="inputChange" data-type='password' clearable />
<t-input label="重复输入密码" placeholder="请重复输入密码" type="password" bindchange="inputChange" data-type='rePassword' clearable />
</view>
<view class="leaveTop">
<t-button block theme="danger" bind:tap="toRegister">注册</t-button>
</view>

View File

@@ -0,0 +1,3 @@
.leaveTop{
margin-top: 88rpx;
}

View File

@@ -9,7 +9,6 @@ Page({
*/
data: {
tapCheckHandle: undefined,
dateVisible: true,
aIconList: ['check-rectangle-filled', 'star', 'notification', 'info-circle'],
taskList: [{'taskId':'1','title':'标题德外旗舰店1','note':'2022-11-11'},{'taskId':'2','title':'标题德外旗舰店2','note':'2022-11-11'}],
todayList: [{'taskId':'1','title':'标题德外旗舰店1','note':'2022-11-11'},{'taskId':'2','title':'标题德外旗舰店2','note':'2022-11-11'}],
@@ -36,13 +35,9 @@ Page({
getList(type, currentPage) {
let currentCur = this.data.categoryCur;
let pageData = this.getCurrentData(currentCur);
if (pageData.end) return;
if ('more' == type && pageData.end) return;
pageData.requesting = true;
this.setCurrentData(currentCur, pageData);
wx.showLoading({
title: '请稍候...',
mask: true,
})
app.$api.taskList({}).then(res =>{
// this.setData({
// taskList:res.data.taskList,
@@ -51,8 +46,6 @@ Page({
taskList: [],
over: false
};
console.log(data)
console.log(data.over)
let listData = this.data.delayList || [];
pageData.requesting = false;
if (type === 'refresh') {

View File

@@ -3,7 +3,6 @@
"t-date-time-picker": "/components/date-time-picker/date-time-picker",
"t-picker": "/components/picker/picker",
"t-picker-item": "/components/picker/picker-item",
"t-switch": "/components/switch/switch",
"t-button": "/components/button/button"
"t-switch": "/components/switch/switch"
}
}