java怎么跳转小程序页面_「小程序JAVA实战」小程序 loading 提示框与页面跳转(37)...

登录注册都完成了,有可能会遇到一些问题,服务器繁忙的话,后台接口卡主了,也没任何提示,小程序端的用户比较暴力一直惦记怎么办。

加载提示框,隐藏加载中提示框,页面跳转https://developers.weixin.qq.com/miniprogram/dev/api/api-react.html#wxshowtoastobject

https://developers.weixin.qq.com/miniprogram/dev/api/api-react.html#wxhideloading

505303ef9e664eec9d7f8d4bb90a528f.png

518215a9cb1312d33adf365403379f49.png

跳转实例用户登录用户注册const app = getApp()

Page({

data: {

},

doLogin: function (e) {

var formObject = e.detail.value;

var username = formObject.username;

var password = formObject.password;

// 简单验证

if (username.length == 0 || password.length == 0) {

wx.showToast({

title: '用户名或密码不能为空',

icon: 'none',

duration: 3000

})

} else {

wx.showLoading({

title: '正在加载中。。。'

});

wx.request({

url: app.serverUrl + "/login",

method: "POST",

data: {

username: username,

password: password

},

header: {

'content-type': 'application/json' // 默认值

},

success: function (res) {

console.log(res.data);

var status = res.data.status;

wx.hideLoading();

if (status == 200) {

wx.showToast({

title: "用户登陆成功~!",

icon: 'none',

duration: 3000

})

app.userinfo = res.data.data;

} else if (status == 500) {

wx.showToast({

title: res.data.msg,

icon: 'none',

duration: 3000

})

}

}

})

}

},

goLoginPage: function (e) {

console.log("跳转到注册");

}

})

61b9b534d5ce2ccd88b866034ba3af4e.png用户注册const app = getApp()

Page({

data: {

},

doRegist: function(e) {

var formObject = e.detail.value;

var username = formObject.username;

var password = formObject.password;

// 简单验证

if (username.length == 0 || password.length == 0) {

wx.showToast({

title: '用户名或密码不能为空',

icon: 'none',

duration: 3000

})

}else{

wx.showLoading({

title: '正在加载中。。。'

});

wx.request({

url: app.serverUrl +"/regist",

method:"POST",

data: {

username: username,

password: password

},

header: {

'content-type': 'application/json' // 默认值

},

success: function (res) {

console.log(res.data);

var status = res.data.status;

wx.hideLoading();

if(status == 200){

wx.showToast({

title: "用户注册成功~!",

icon: 'none',

duration: 3000

})

app.userinfo = res.data.data;

}else if(status == 500){

wx.showToast({

title: res.data.msg,

icon: 'none',

duration: 3000

})

}

}

})

}

},

goLoginPage:function(e){

console.log("跳转到登录");

}

})

e236cee20ef17c06d11facc2a126f21f.png用户登录跳转const app = getApp()

Page({

data: {

},

doLogin: function (e) {

var formObject = e.detail.value;

var username = formObject.username;

var password = formObject.password;

// 简单验证

if (username.length == 0 || password.length == 0) {

wx.showToast({

title: '用户名或密码不能为空',

icon: 'none',

duration: 3000

})

} else {

wx.showLoading({

title: '正在加载中。。。'

});

wx.request({

url: app.serverUrl + "/login",

method: "POST",

data: {

username: username,

password: password

},

header: {

'content-type': 'application/json' // 默认值

},

success: function (res) {

console.log(res.data);

var status = res.data.status;

wx.hideLoading();

if (status == 200) {

wx.showToast({

title: "用户登陆成功~!",

icon: 'none',

duration: 3000

})

app.userinfo = res.data.data;

} else if (status == 500) {

wx.showToast({

title: res.data.msg,

icon: 'none',

duration: 3000

})

}

}

})

}

},

goRegisterPage: function (e) {

wx.redirectTo({

url: '../userRegister/userRegister',

})

}

})

972e631aebdcedae4f275c0679c7b86d.png用户注册跳转

userRegister.jsconst app = getApp()

Page({

data: {

},

doRegist: function(e) {

var formObject = e.detail.value;

var username = formObject.username;

var password = formObject.password;

// 简单验证

if (username.length == 0 || password.length == 0) {

wx.showToast({

title: '用户名或密码不能为空',

icon: 'none',

duration: 3000

})

}else{

wx.showLoading({

title: '正在加载中。。。'

});

wx.request({

url: app.serverUrl +"/regist",

method:"POST",

data: {

username: username,

password: password

},

header: {

'content-type': 'application/json' // 默认值

},

success: function (res) {

console.log(res.data);

var status = res.data.status;

wx.hideLoading();

if(status == 200){

wx.showToast({

title: "用户注册成功~!",

icon: 'none',

duration: 3000

})

app.userinfo = res.data.data;

}else if(status == 500){

wx.showToast({

title: res.data.msg,

icon: 'none',

duration: 3000

})

}

}

})

}

},

goLoginPage:function(e){

wx.redirectTo({

url: '../userLogin/userLogin',

})

}

})

de1009a1d108a55ef532935c2ead4c68.png

PS:这次就是我们的跳转和loading的介绍。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值