|
@@ -1,6 +1,6 @@
|
|
|
// pages/test/index.js
|
|
|
const app = getApp()
|
|
|
-import dateTimePicker from '../../utils/dateTimePicker';
|
|
|
+import WxValidate from '../../utils/wxValidate'
|
|
|
Page({
|
|
|
/**
|
|
|
* 页面的初始数据
|
|
@@ -15,6 +15,12 @@ Page({
|
|
|
dialog: { title: '弹框标题', show: false, type: '1' },
|
|
|
form: {}
|
|
|
},
|
|
|
+ initValidate() {
|
|
|
+ const rules = { start_time: { required: true } }
|
|
|
+ // 验证字段的提示信息,若不传则调用默认的信息
|
|
|
+ const messages = { start_time: { required: '开始时间' } };
|
|
|
+ this.WxValidate = new WxValidate(rules, messages)
|
|
|
+ },
|
|
|
// 跳转菜单
|
|
|
tabPath(e) {
|
|
|
let { route } = e.detail.detail;
|
|
@@ -51,27 +57,28 @@ Page({
|
|
|
// 确认选择
|
|
|
datetimeChange: function (e) {
|
|
|
const that = this;
|
|
|
- that.setData({ [`form.${e.detail.fieldValue}`]: e.detail.datetime });
|
|
|
- console.log(that.data.form);
|
|
|
+ that.setData({ [`form.${e.detail.name}`]: e.detail.datetime });
|
|
|
+ },
|
|
|
+ // 提交保存
|
|
|
+ toSubmit: function (e) {
|
|
|
+ const that = this;
|
|
|
+ const params = e.detail.value;
|
|
|
+ console.log(params);
|
|
|
+ if (!this.WxValidate.checkForm(params)) {
|
|
|
+ const error = this.WxValidate.errorList[0];
|
|
|
+ wx.showToast({ title: `${error.msg}`, icon: 'error', duration: 2000 })
|
|
|
+ return false
|
|
|
+ } else {
|
|
|
+ console.log(params);
|
|
|
+ }
|
|
|
},
|
|
|
/**
|
|
|
* 生命周期函数--监听页面加载
|
|
|
*/
|
|
|
onLoad: async function (options) {
|
|
|
- // 获取完整的年月日 时分秒,以及默认显示的数组
|
|
|
- var obj = dateTimePicker.dateTimePicker(this.data.startYear, this.data.endYear);
|
|
|
- var obj = dateTimePicker.dateTimePicker(this.data.startYear, this.data.endYear);
|
|
|
- // this.setData({ dateTimeArray: obj.dateTimeArray });
|
|
|
- // let start = moment('02').startOf('month').format('YYYY-MM-DD');
|
|
|
- // let end = moment('02').endOf('month').format('YYYY-MM-DD');
|
|
|
- // 01,03,05,07,08,10
|
|
|
- // 02
|
|
|
- // let days = moment('2001-02').daysInMonth();
|
|
|
- // console.log(start);
|
|
|
- // console.log(end);
|
|
|
- // console.log(days);
|
|
|
- const arr = await app.$get('/matchGroup', {}, 'race');
|
|
|
- console.log(arr);
|
|
|
+ const that = this;
|
|
|
+ //验证规则函数
|
|
|
+ that.initValidate();
|
|
|
|
|
|
},
|
|
|
|