优化注册提示跳转

master
liaoanqi 4 years ago
parent d42b234c02
commit 6dc9eaf66c

@ -109,6 +109,7 @@ Page({
* 注册/登录按钮 * 注册/登录按钮
*/ */
handleLoginOrRegister() { handleLoginOrRegister() {
const that = this
if (!this.data.userName.trim()) { if (!this.data.userName.trim()) {
wx.showToast({ wx.showToast({
title: '请输入用户名', title: '请输入用户名',
@ -132,9 +133,22 @@ Page({
}, },
callBack: (res) => { callBack: (res) => {
wx.setStorageSync('token', res.accessToken) wx.setStorageSync('token', res.accessToken)
wx.switchTab({ if(this.data.isRegister) {
url: '/pages/index/index', that.setData({
}) userName: '',
password: '',
isRegister: !that.data.isRegister
})
wx.showToast({
title: '注册成功,请登录',
icon: 'none'
})
}else {
wx.switchTab({
url: '/pages/index/index',
})
}
} }
}; };
http.request(params); http.request(params);

@ -5,13 +5,13 @@
<view class="item"> <view class="item">
<view class="account"> <view class="account">
<text class="input-item">用户名</text> <text class="input-item">用户名</text>
<input type="text" data-type="account" placeholder-class="inp-palcehoder" placeholder="请输入用户名" bindinput="getInputVal"></input> <input type="text" data-type="account" placeholder-class="inp-palcehoder" value="{{userName}}" placeholder="请输入用户名" bindinput="getInputVal"></input>
</view> </view>
</view> </view>
<view class="item"> <view class="item">
<view class="account"> <view class="account">
<text class="input-item">密码</text> <text class="input-item">密码</text>
<input type="password" data-type="password" placeholder-class="inp-palcehoder" placeholder="请输入密码" bindinput="getInputVal"></input> <input type="password" data-type="password" placeholder-class="inp-palcehoder" value="{{password}}" placeholder="请输入密码" bindinput="getInputVal"></input>
</view> </view>
</view> </view>
<view> <view>

Loading…
Cancel
Save