|
@@ -1,17 +1,42 @@
|
|
|
|
|
|
+import WxValidate from '../../utils/wxValidate';
|
|
|
|
|
|
const app = getApp()
|
|
|
|
|
|
Page({
|
|
|
data: {
|
|
|
+ form: {}
|
|
|
+ },
|
|
|
+ initValidate() {
|
|
|
+ const rules = {
|
|
|
+ phone: {
|
|
|
+ required: true,
|
|
|
+ tel: true
|
|
|
+ },
|
|
|
+ password: { required: true, },
|
|
|
+ }
|
|
|
+
|
|
|
+ const messages = {
|
|
|
+ phone: { required: '请输入手机号', },
|
|
|
+ password: { required: '请输入密码', },
|
|
|
+ };
|
|
|
+ this.WxValidate = new WxValidate(rules, messages)
|
|
|
},
|
|
|
formSubmit: function (e) {
|
|
|
- let form = e.detail.value;
|
|
|
- console.log(form);
|
|
|
- wx.redirectTo({
|
|
|
- url: '/pages/home/home'
|
|
|
- })
|
|
|
+ const params = e.detail.value;
|
|
|
+ if (!this.WxValidate.checkForm(params)) {
|
|
|
+ const error = this.WxValidate.errorList[0];
|
|
|
+ wx.showToast({
|
|
|
+ title: error.msg,
|
|
|
+ icon: 'none',
|
|
|
+ duration: 2000
|
|
|
+ })
|
|
|
+ return false
|
|
|
+ } else {
|
|
|
+ console.log(params);
|
|
|
+ }
|
|
|
},
|
|
|
- onLoad: function () {
|
|
|
+ onLoad: function (options) {
|
|
|
+ this.initValidate()
|
|
|
},
|
|
|
})
|