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.
206 lines
4.4 KiB
206 lines
4.4 KiB
// pages/release/perfectCompanyInfo/index.js |
|
const util = require('../../../utils/util.js') |
|
const app = getApp() |
|
import WxValidate from '../../../utils/WxValidate.js' |
|
Page({ |
|
|
|
/** |
|
* 页面的初始数据 |
|
*/ |
|
data: { |
|
form: { |
|
enterpriseType: 1, |
|
enterpriseAddress: '', |
|
latitude: '', |
|
longitude: '', |
|
enterpriseLogo: '', |
|
enterpriseTitle: '', |
|
enterpriseLabel: '', |
|
enterpriseNet: '', |
|
enterprisePhone: '', |
|
aboutUs: '', |
|
imgPaths:[], |
|
} |
|
}, |
|
|
|
/** |
|
* 生命周期函数--监听页面加载 |
|
*/ |
|
onLoad: function (options) { |
|
this.initValidate()//验证规则函数 |
|
}, |
|
initValidate(){ |
|
const rules = { |
|
enterpriseAddress: { |
|
required: true, |
|
}, |
|
enterpriseLogo: { |
|
required: true, |
|
}, |
|
enterpriseTitle: { |
|
required: true, |
|
}, |
|
businessNature: { |
|
required: true, |
|
}, |
|
enterpriseNet: { |
|
required: true, |
|
}, |
|
enterprisePhone:{ |
|
required:true, |
|
} |
|
} |
|
const messages = { |
|
enterpriseAddress: { |
|
required: '请选择或填写地址', |
|
}, |
|
enterpriseLogo: { |
|
required: '请上传企业Logo', |
|
}, |
|
enterpriseTitle: { |
|
required: '请填写企业slogan', |
|
}, |
|
businessNature: { |
|
required: '请填写企业经营范围', |
|
}, |
|
enterpriseNet: { |
|
required: '请填写企业网站', |
|
}, |
|
enterprisePhone:{ |
|
required: '请填写客服电话', |
|
} |
|
} |
|
this.WxValidate = new WxValidate(rules, messages) |
|
}, |
|
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)=>{ |
|
that.setData({ |
|
['form.enterpriseAddress']: result.address, |
|
['form.latitude']: result.latitude, |
|
['form.longitude']: result.longitude, |
|
}) |
|
} |
|
}) |
|
} |
|
}) |
|
}, |
|
uploadImg(e){ |
|
let type = e.currentTarget.dataset.type; |
|
util.chooseImages(img => { |
|
if(type == 'logo'){ |
|
this.setData({ |
|
['form.enterpriseLogo']: img |
|
}) |
|
} |
|
}); |
|
}, |
|
upImgs(){ |
|
util.chooseImages2(img => { |
|
let imgs = this.data.form.imgPaths |
|
imgs.push(img) |
|
this.setData({ |
|
['form.imgPaths']: imgs |
|
}) |
|
}); |
|
}, |
|
submit(e){ |
|
let that = this; |
|
console.log(e.detail.value) |
|
wx.showModal({ |
|
title: '提示!', |
|
content: '是否确认提交?', |
|
success(res){ |
|
if(res.confirm){ |
|
const params = e.detail.value |
|
params.enterpriseType = 1 |
|
params.latitude = that.data.form.latitude |
|
params.longitude = that.data.form.longitude |
|
params.enterpriseLogo = that.data.form.enterpriseLogo |
|
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 () { |
|
|
|
} |
|
}) |