|
@@ -0,0 +1,283 @@
|
|
|
+// pages/post/post.js
|
|
|
+const app = getApp()
|
|
|
+const host = app.globalData.host;
|
|
|
+Page({
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 页面的初始数据
|
|
|
+ */
|
|
|
+ data: {
|
|
|
+ sexArray: ["男","女"], //性别
|
|
|
+ recordArray: ["小学", "初中", "高中", "大专", "本科","硕士","博士"], //学历
|
|
|
+ categoryArray: [{ label: '电工', id: 0 }, { label: '水工', id: 1 }], //作业类别
|
|
|
+ subjectArray: [{name:'请选择'}], //准操项目
|
|
|
+ trainArray: [{ name: '新办', intro: '第一次取证;或者以前取证了没有按规定的时间复审、换证' },
|
|
|
+ { name: '复审', intro: '已取证;复审日期一天都不超最好提前3个月' },
|
|
|
+ { name: '换证', intro: '有效期满提前三个月' }], //培训类型
|
|
|
+ receiveArray: ['自取','邮寄(将产生邮寄费用)'], //领取类型
|
|
|
+ sex:0,
|
|
|
+ record:0,
|
|
|
+ category:-1,
|
|
|
+ subject:-1,
|
|
|
+ train:-1,
|
|
|
+ receive:0,
|
|
|
+ area: ['四川省', '成都市', '锦江区'],
|
|
|
+ time:'2020-01-01',
|
|
|
+ price:'0.00',
|
|
|
+ classList:[],
|
|
|
+ class_:-1,
|
|
|
+ class_id:0
|
|
|
+ },
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 生命周期函数--监听页面加载
|
|
|
+ */
|
|
|
+ onLoad: function (options) {
|
|
|
+ if(options.id){
|
|
|
+ wx.request({
|
|
|
+ url: host+'/api/wx/signup',
|
|
|
+ method:'GET',
|
|
|
+ data:{id:options.id},
|
|
|
+ success:res=>{
|
|
|
+ console.log(res.data)
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+ if(options.class_id){
|
|
|
+ this.setData({
|
|
|
+ class_id: options.class_id,
|
|
|
+ price: options.price
|
|
|
+ })
|
|
|
+ }else{
|
|
|
+ wx.request({
|
|
|
+ url: host + '/api/wx/sujectitem',
|
|
|
+ success: res => {
|
|
|
+ let list = res.data.data.filter(item => item.name == options.id)
|
|
|
+ this.setData({
|
|
|
+ categoryArray: list[0].children,
|
|
|
+ z_type: options.id
|
|
|
+ })
|
|
|
+ }
|
|
|
+ })
|
|
|
+ wx.request({
|
|
|
+ url: host + '/api/wx/class/list',
|
|
|
+ method: 'GET',
|
|
|
+ success: res => {
|
|
|
+ let list = res.data.data.filter(item => item.type == options.id)
|
|
|
+ this.setData({
|
|
|
+ classList: list[0].classes
|
|
|
+ })
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ },
|
|
|
+ pickerChange:function(e){
|
|
|
+ if(e.target.dataset.name == 'sex'){
|
|
|
+ this.setData({
|
|
|
+ sex: e.detail.value
|
|
|
+ })
|
|
|
+ };
|
|
|
+ if (e.target.dataset.name == 'record') {
|
|
|
+ this.setData({
|
|
|
+ record: e.detail.value
|
|
|
+ })
|
|
|
+ };
|
|
|
+ if (e.target.dataset.name == 'category') {
|
|
|
+ let list = this.data.categoryArray[e.detail.value].children
|
|
|
+ this.setData({
|
|
|
+ category: e.detail.value,
|
|
|
+ subjectArray: list,
|
|
|
+ subject:-1,
|
|
|
+ train:-1
|
|
|
+ })
|
|
|
+ };
|
|
|
+ if (e.target.dataset.name == 'subject') {
|
|
|
+ this.setData({
|
|
|
+ subject: e.detail.value,
|
|
|
+ train: -1
|
|
|
+ })
|
|
|
+ };
|
|
|
+ if (e.target.dataset.name == 'time') {
|
|
|
+ this.setData({
|
|
|
+ time: e.detail.value
|
|
|
+ })
|
|
|
+ };
|
|
|
+ if (e.target.dataset.name == 'train') {
|
|
|
+ var price=this.data.price
|
|
|
+ if(!this.data.class_id && this.data.category>=0 && this.data.subject>=0){
|
|
|
+ if (e.detail.value == 0){
|
|
|
+ price = this.data.categoryArray[this.data.category].price_new
|
|
|
+ }
|
|
|
+ if (e.detail.value == 1) {
|
|
|
+ price = this.data.categoryArray[this.data.category].price_re
|
|
|
+ }
|
|
|
+ if (e.detail.value == 2) {
|
|
|
+ price = this.data.categoryArray[this.data.category].price_change
|
|
|
+ }
|
|
|
+ }
|
|
|
+ this.setData({
|
|
|
+ train: e.detail.value,
|
|
|
+ price: price
|
|
|
+ })
|
|
|
+ };
|
|
|
+ if (e.target.dataset.name == 'area') {
|
|
|
+ this.setData({
|
|
|
+ area: e.detail.value
|
|
|
+ })
|
|
|
+ };
|
|
|
+ if (e.target.dataset.name == 'receive') {
|
|
|
+ this.setData({
|
|
|
+ receive: e.detail.value
|
|
|
+ })
|
|
|
+ };
|
|
|
+ if (e.target.dataset.name == 'class_') {
|
|
|
+ this.setData({
|
|
|
+ class_: e.detail.value
|
|
|
+ })
|
|
|
+ };
|
|
|
+
|
|
|
+ },
|
|
|
+ next:function(e){
|
|
|
+ var formData = e.detail.value,data=this.data
|
|
|
+ if (formData.name == '') {
|
|
|
+ wx.showToast({
|
|
|
+ title: '姓名不能为空!',
|
|
|
+ icon: 'none',
|
|
|
+ duration: 2000
|
|
|
+ })
|
|
|
+ return false
|
|
|
+ }
|
|
|
+ if (formData.idno == '') {
|
|
|
+ wx.showToast({
|
|
|
+ title: '身份证不能为空!',
|
|
|
+ icon: 'none',
|
|
|
+ duration: 2000
|
|
|
+ })
|
|
|
+ return false
|
|
|
+ }
|
|
|
+ if (formData.phone == '') {
|
|
|
+ wx.showToast({
|
|
|
+ title: '手机号不能为空!',
|
|
|
+ icon: 'none',
|
|
|
+ duration: 2000
|
|
|
+ })
|
|
|
+ return false
|
|
|
+ }
|
|
|
+ if(!this.data.class_id){
|
|
|
+ if (this.data.category == -1) {
|
|
|
+ wx.showToast({
|
|
|
+ title: '请选择作业类别',
|
|
|
+ icon: 'none',
|
|
|
+ duration: 2000
|
|
|
+ })
|
|
|
+ return false
|
|
|
+ }
|
|
|
+ if (this.data.subject == -1) {
|
|
|
+ wx.showToast({
|
|
|
+ title: '请选择准操项目或资格类型',
|
|
|
+ icon: 'none',
|
|
|
+ duration: 2000
|
|
|
+ })
|
|
|
+ return false
|
|
|
+ }
|
|
|
+ if (this.data.train == -1) {
|
|
|
+ wx.showToast({
|
|
|
+ title: '请选择培训类型',
|
|
|
+ icon: 'none',
|
|
|
+ duration: 2000
|
|
|
+ })
|
|
|
+ return false
|
|
|
+ }
|
|
|
+ if (this.data.class_ == -1) {
|
|
|
+ wx.showToast({
|
|
|
+ title: '请选择班级',
|
|
|
+ icon: 'none',
|
|
|
+ duration: 2000
|
|
|
+ })
|
|
|
+ return false
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (!this.data.class_id) {
|
|
|
+ formData.subject_item = data.z_type+"|"+data.categoryArray[data.category].name+"|"+data.subjectArray[data.subject].name
|
|
|
+ formData.subject_id = data.subjectArray[data.subject].id
|
|
|
+ formData.sex=data.sexArray[data.sex]
|
|
|
+ formData.education = data.recordArray[data.record]
|
|
|
+ formData.receive_card = data.receiveArray[data.receive]
|
|
|
+ formData.class_id = data.classList[data.class_].id
|
|
|
+ }else{
|
|
|
+ formData.class_id = this.data.class_id
|
|
|
+ }
|
|
|
+ formData.train_type = data.trainArray[data.train].name
|
|
|
+ formData.price=this.data.price
|
|
|
+ formData.area=this.data.area.join('')
|
|
|
+ wx.showLoading({
|
|
|
+ title: '',
|
|
|
+ })
|
|
|
+ wx.request({
|
|
|
+ url: host + '/api/wx/signup',
|
|
|
+ method: 'POST',
|
|
|
+ header: {
|
|
|
+ openid: this.data.openid
|
|
|
+ },
|
|
|
+ data: formData,
|
|
|
+ success: res => {
|
|
|
+ wx.hideLoading()
|
|
|
+ wx.navigateTo({
|
|
|
+ url: '../upload/upload?id='+res.data.data.id,
|
|
|
+ })
|
|
|
+ }
|
|
|
+ })
|
|
|
+
|
|
|
+ },
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 生命周期函数--监听页面初次渲染完成
|
|
|
+ */
|
|
|
+ onReady: function () {
|
|
|
+
|
|
|
+ },
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 生命周期函数--监听页面显示
|
|
|
+ */
|
|
|
+ onShow: function () {
|
|
|
+
|
|
|
+ },
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 生命周期函数--监听页面隐藏
|
|
|
+ */
|
|
|
+ onHide: function () {
|
|
|
+
|
|
|
+ },
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 生命周期函数--监听页面卸载
|
|
|
+ */
|
|
|
+ onUnload: function () {
|
|
|
+
|
|
|
+ },
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 页面相关事件处理函数--监听用户下拉动作
|
|
|
+ */
|
|
|
+ onPullDownRefresh: function () {
|
|
|
+
|
|
|
+ },
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 页面上拉触底事件的处理函数
|
|
|
+ */
|
|
|
+ onReachBottom: function () {
|
|
|
+
|
|
|
+ },
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 用户点击右上角分享
|
|
|
+ */
|
|
|
+ onShareAppMessage: function () {
|
|
|
+
|
|
|
+ }
|
|
|
+})
|