You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

156 lines
3.4 KiB
JavaScript

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

// subPage/components/recordWindow/index.js
const app = getApp();
import { customRequest } from '../../../utils/request.js';
Component({
/**
* 组件的属性列表
*/
properties: {
windowShow: {
type: Boolean,
value: false,
},
info: {
type: Object,
value: {},
}
},
/**
* 组件的初始数据
*/
data: {
ageArray: [],
isAgency: app.globalData.loginUserInfo.agencyStatus == 1 ? true : false,
ageIndex: -1,
userChecked: false,
sex: [
{
id: 1,
value: "男",
checked: true
},
{
id: 2,
value: "女",
checked: false
},
],
},
ready () {
let that = this;
console.log(this.data.windowShow);
console.log(this.data.info);
for (let i = 16; i < 70; i++) {
that.data.ageArray.push(i);
}
this.setData({
ageArray: that.data.ageArray
})
},
/**
* 组件的方法列表
*/
methods: {
bindPickerChangeAge (e) {
this.setData({
ageIndex: e.detail.value,
["userInfo.age"]: parseInt(e.detail.value) + 16,
});
},
modalMove () {
return false
},
closeTobe (e) {
console.log(e);
this.setData({
windowShow: false,
ageIndex: -1,
})
},
formSubmit (e) {
let that = this;
if (e.detail.value.name == "") {
wx.showToast({
icon: "none",
title: "请输入姓名",
});
return;
}
if (e.detail.value.tel == "") {
wx.showToast({
icon: "none",
title: "请输入电话",
});
return;
}
if (that.data.ageIndex == -1) {
wx.showToast({
icon: "none",
title: "请输入年龄",
});
return;
}
var reg = /^1[3|4|5|6|9|7|8][0-9]\d{8}$/;
if (reg.test(e.detail.value.tel) == false) {
wx.showToast({
icon: "none",
title: "请输入正确的电话号码",
});
return;
}
e.detail.value.age = parseInt(that.data.ageIndex) + 16;
e.detail.value.jobName = that.data.info.vocationalName;
console.log('form发生了submit事件携带数据为', e.detail.value)
customRequest('/api/edu/apply', { header: 'headers', method: 'POST', data: e.detail.value }).then((res) => {
if (res.data.status == 200) {
wx.showToast({
icon: "none",
title: "报名成功",
})
that.setData({
windowShow: false,
ageIndex: -1
})
} else {
wx.showToast({
icon: "none",
title: res.data.msg,
})
}
})
// wx.request({
// url: app.globalData.ip + '/api/edu/apply',
// data: e.detail.value,
// header: app.globalData.headers,
// method: "POST",
// success: function (res) {
// console.log(res);
// if (res.data.status == 200) {
// wx.showToast({
// icon: "none",
// title: "报名成功",
// })
// that.setData({
// windowShow: false,
// ageIndex: -1
// })
// } else {
// wx.showToast({
// icon: "none",
// title: res.data.msg,
// })
// }
// }
// })
},
}
})