|
@@ -27,28 +27,21 @@ Page({
|
|
|
this.WxValidate = new WxValidate(rules, messages)
|
|
|
},
|
|
|
|
|
|
- onSubmit: function (e) {
|
|
|
+ onSubmit: async function (e) {
|
|
|
const params = e.detail.value;
|
|
|
if (!this.WxValidate.checkForm(params)) {
|
|
|
const error = this.WxValidate.errorList[0];
|
|
|
wx.showToast({ title: `${error.msg}`, icon: 'error', duration: 2000 })
|
|
|
return false
|
|
|
} else {
|
|
|
- wx.request({
|
|
|
- url: `${app.globalData.publicUrl}/courtAdmin/api/user/login`,
|
|
|
- method: 'post',
|
|
|
- data: params,
|
|
|
- success(res) {
|
|
|
- if (res.data.errcode == 0) {
|
|
|
- app.globalData.userInfo = res.data.data;
|
|
|
- wx.setStorage({ key: "token", data: res.data.data })
|
|
|
- wx.showToast({ title: `账号登录成功`, icon: 'success', duration: 2000 })
|
|
|
- wx.navigateTo({ url: '/pages/home/index' })
|
|
|
- } else {
|
|
|
- wx.showToast({ title: res.data.errmsg, icon: 'error', duration: 2000 })
|
|
|
- }
|
|
|
- }
|
|
|
- })
|
|
|
+ const arr = await app.$post(`/courtAdmin/api/user/login`, params)
|
|
|
+ if (arr.errcode == '0') {
|
|
|
+ app.globalData.userInfo = arr.data;
|
|
|
+ wx.setStorage({ key: "token", data: arr.data })
|
|
|
+ wx.showToast({ title: `账号登录成功`, icon: 'success', duration: 2000 })
|
|
|
+ wx.navigateTo({ url: '/pages/home/index' })
|
|
|
+ }
|
|
|
+ else wx.showToast({ title: `${arr.errmsg}`, icon: 'error', duration: 2000 })
|
|
|
}
|
|
|
},
|
|
|
|