1
This commit is contained in:
38
miniprogram/pages/register/index.js
Normal file
38
miniprogram/pages/register/index.js
Normal file
@@ -0,0 +1,38 @@
|
||||
const { request } = require('../../utils/request')
|
||||
|
||||
Page({
|
||||
data: {
|
||||
form: {
|
||||
username: '',
|
||||
password: '',
|
||||
nickname: '',
|
||||
company: '',
|
||||
title: '',
|
||||
phone: ''
|
||||
},
|
||||
loading: false
|
||||
},
|
||||
|
||||
onInput(e) {
|
||||
const field = e.currentTarget.dataset.field
|
||||
this.setData({ [`form.${field}`]: (e.detail.value || '').trim() })
|
||||
},
|
||||
|
||||
async submit() {
|
||||
if (this.data.loading) return
|
||||
const { username, password } = this.data.form
|
||||
if (!username || !password) {
|
||||
wx.showToast({ title: '用户名和密码必填', icon: 'none' })
|
||||
return
|
||||
}
|
||||
|
||||
this.setData({ loading: true })
|
||||
try {
|
||||
await request({ url: '/auth/register', method: 'POST', data: this.data.form })
|
||||
wx.showToast({ title: '注册成功', icon: 'success' })
|
||||
setTimeout(() => wx.navigateBack(), 350)
|
||||
} finally {
|
||||
this.setData({ loading: false })
|
||||
}
|
||||
}
|
||||
})
|
||||
Reference in New Issue
Block a user