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

209 lines
4.4 KiB

// pages/release/perfectPersonInfo/index.js
const util = require('../../../utils/util.js')
const app = getApp()
import WxValidate from '../../../utils/WxValidate.js'
Page({
/**
* 页面的初始数据
*/
data: {
form: {
enterpriseType: 2,
enterpriseScale: '',
businessNature: '',
establishmentTime: '',
enterpriseAddress: '',
latitude: '',
longitude: '',
enterprisePhone: '',
imgPaths: [],
},
resourcesList:[]
},
showMap(){
let that = this;
wx.getLocation({
type: 'gcj02', //返回可以用于wx.openLocation的经纬度
success: function(res) {
wx.chooseLocation({
latitude: res.latitude,
longitude: res.longitude,
scale: 28,
success: (result)=>{
console.log(result)
that.setData({
['form.enterpriseAddress']: result.address,
['form.latitude']: result.latitude,
['form.longitude']: result.longitude,
})
}
})
}
})
},
timeChange(e){
this.setData({
['form.establishmentTime']: e.detail.value
})
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
this.initValidate()//验证规则函数
this.getResourcesCagetory()
},
initValidate(){
const rules = {
enterpriseScale: {
required: true,
},
industryId: {
required: true,
},
establishmentTime: {
required: true,
},
enterpriseAddress: {
required: true,
},
enterprisePhone:{
required:true,
}
}
const messages = {
enterpriseAddress: {
required: '请选择或填写地址',
},
enterpriseScale: {
required: '请填写团队规模',
},
industryId: {
required: '请填写承接类型',
},
establishmentTime: {
required: '请选择组建时间',
},
enterprisePhone:{
required: '请填写客服电话',
}
}
this.WxValidate = new WxValidate(rules, messages)
},
//获取供应、需求类型
getResourcesCagetory(){
app.http('GET','ResourcesCagetory/listResourcesCagetory').then((res)=>{
// console.log(res)
if(res.data.success){
this.setData({
resourcesList: res.data.data
})
}
})
},
resourcesChange(e){
// console.log(e)
let idx = Number(e.detail.value)
this.setData({
resourcesIdx: idx,
['form.resourceCagetoryId']: this.data.resourcesList[idx].id
})
},
upImgs(){
util.chooseImages2(img => {
let imgs = this.data.form.imgPaths
imgs.push(img)
this.setData({
['form.imgPaths']: imgs
})
});
},
submit(e){
let that = this;
wx.showModal({
title: '提示!',
content: '是否确认提交?',
success(res){
if(res.confirm){
const params = e.detail.value
params.enterpriseType = 2
params.imgPaths = that.data.form.imgPaths
if (!that.WxValidate.checkForm(params)) {
const error = that.WxValidate.errorList[0]
that.showModal(error)
return false
}
app.http('post','Enterprise/completeEnterprise',params).then((res)=>{
if(res.data.success){
wx.showToast({
title: '提交成功',
duration: 2000
})
setTimeout(()=>{
wx.navigateBack({
delta: 1,
})
},2000)
}
})
} else{
console.log('已取消')
}
}
})
},
showModal(error) {
wx.showModal({
content: error.msg,
showCancel: false,
})
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {
}
})