123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735 |
- // pages/my/postJob/postJob.js
- const App = getApp()
- const util = require('../../utils/tool');
- let CityArray0 = []
- let CityArray1 = []
- let CityArray2 = []
- Page({
- /**
- * 页面的初始数据
- */
- data: {
- appAssetsUrl2: App.appAssetsUrl2,
- user: wx.getStorageSync('USER'),
- lng: null,
- lat: null,
- // 活动地址
- address: null,
- // 坐标
- coordinate: null,
- multiArray: [],
- multiIndex: [],
- // 省
- province: null,
- // 市
- city: null,
- // 区
- area: null,
- // 标题
- title: null,
- // 所属客户
- clientId: null,
- clientList: [],
- clientIndex: 0,
- // 兼职分类
- category: null,
- // 兼职类型
- type: null,
- categoryList: [],
- categoryIndex: 0,
- typeList: [],
- typeIndex: 0,
- // 工作兼职时间
- // worktimeStart: null,
- // worktimeEnd: null,
- workdateStart: null,
- workdateEnd: null,
- worktimeStart: null,
- worktimeEnd: null,
- // workStartTimeDate: null,
- // workStartTimeHS: null,
- // workEndTimeDate: null,
- // workEndTimeHS: null,
- // 报名截止
- registrationTime: null,
- registrationDate: null,
- registrationHS: null,
- // 集合时间
- meetingTime: null,
- // 集合日期
- meetingTimeDate: null,
- // 集合日期时间
- meetingTimeHS: null,
- // 是否推荐至首页
- isTop: null,
- arrayPrice: [],
- priceIndex: 0,
- // 工资价格
- price: null,
- // 工资单位
- unit: null,
- // 性别要求
- sexlimit: null,
- // 是否需要会员
- isNeedVip: 0,
- heightList: [],
- heightIndex: 0,
- // 身高要求
- heightlimit: null,
- // 面试时间
- interviewTime: null,
- // 培训时间
- trainingTime: null,
- // 报名人数限制
- willnum: null,
- activityjs: null,
- activityyq: null,
- activitysx: null,
- // 兼职banner图
- indexImg: null,
- // 联系二维码
- qrCodePicture: null,
- contactInstructions: null,
- // 注意事项
- attention: null
- },
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad(options) {
- this.getProvince()
- this.getCoord()
- this.getWorkCategory()
- this.getType()
- this.getUnit()
- this.getHeightList()
- this.getclient()
- },
- /**
- * 生命周期函数--监听页面初次渲染完成
- */
- onReady() {
- },
- /**
- * 生命周期函数--监听页面显示
- */
- onShow() {
- },
- // 获取兼职分类
- getWorkCategory() {
- App._post_form('work/category', '', {}, res => {
- if (res.code === 0) {
- this.setData({
- categoryList: res.data
- })
- }
- })
- },
- // 获取兼职类型
- getType() {
- App._post_form('bizlibrary/infoList/workType', '', {}, res => {
- if (res.code === 0) {
- this.setData({
- typeList: res.dictList
- })
- }
- })
- },
- getUnit() {
- App._post_form('bizlibrary/infoList/workUnit', '', {}, res => {
- if (res.code === 0) {
- this.setData({
- arrayPrice: res.dictList
- })
- }
- })
- },
- getHeightList() {
- App._post_form('bizlibrary/infoList/workHeightLimit', '', {}, res => {
- if (res.code === 0) {
- this.setData({
- heightList: res.dictList
- })
- }
- })
- },
- getclient() {
- App._post_form('wgclientinfo/selectCiList', '', {}, res => {
- if (res.code === 0) {
- this.setData({
- clientList: res.list
- })
- }
- })
- },
- // 获取经纬度
- getCoord() {
- wx.getLocation({
- type: 'gcj02',
- success: (res) => {
- const latitude = res.latitude
- const longitude = res.longitude
- this.setData({
- lng: Number(longitude),
- lat: Number(latitude)
- })
- },
- fail: (e) => {}
- })
- },
- // 获取省
- getProvince() {
- App._get('region/provinceList', {}, res => {
- let pId = ''
- let prov = ''
- if (res.code === 0) {
- let provice = res.data
- this.data.multiArray[0] = provice
- CityArray0 = provice
- if (CityArray0.length) {
- for (let i = 0; i < CityArray0.length; i++) {
- if (CityArray0[i].id == this.data.province) {
- this.data.multiIndex[0] = i
- break;
- } else {
- this.data.multiIndex[0] = 0
- // break;
- }
- }
- }
- if (this.data.province) {
- pId = this.data.province
- } else {
- //根据默认省,获取默认市
- if (this.data.multiArray[0].length) {
- pId = this.data.multiArray[0][0].id;
- }
- }
- this.getCity(pId)
- }
- })
- },
- getCity(pId) {
- App._get(`region/urbanDistrictList?id=${pId}`, {}, res => {
- // App._get(`region/urbanDistrictList?id=420000`, {}, res => {
- if (res.code === 0) {
- let city = res.data;
- this.data.multiArray[1] = city;
- CityArray1 = city;
- if (CityArray1.length) {
- for (let i = 0; i < CityArray1.length; i++) {
- // console.log(CityArray1[i].id, pId, 222)
- if (CityArray1[i].pid === pId) {
- this.data.multiIndex[1] = i;
- break;
- }
- }
- }
- let cityId = '';
- if (this.data.city) {
- cityId = this.data.city
- } else {
- if (this.data.multiArray[1].length) {
- cityId = this.data.multiArray[1][0].id
- }
- }
- this.getArea(cityId)
- this.setData({
- multiArray: this.data.multiArray,
- multiIndex: this.data.multiIndex
- })
- }
- })
- },
- // 获取区
- getArea(cityId) {
- for (let i = 0; i < this.data.multiArray[1].length; i++) {
- console.log(this.data.multiArray[1], cityId, 'area')
- if (this.data.multiArray[1][i].id === cityId) {
- CityArray2 = this.data.multiArray[1][i].childRegionList
- this.data.multiArray[2] = this.data.multiArray[1][i].childRegionList
- this.data.multiIndex[2] = i
- break;
- }
- }
- if (this.data.area) {
- for (let j = 0; j < this.data.multiArray[2].length; j++) {
- if (this.data.multiArray[2][j].id === this.data.area) {
- this.data.multiIndex[2] = j
- break;
- }
- }
- }
- this.setData({
- multiArray: this.data.multiArray,
- multiIndex: this.data.multiIndex
- })
- console.log(this.data.multiArray, this.data.multiIndex, 1111)
- },
- // 兼职分类
- categoryChange(e) {
- console.log(e)
- let category = this.data.categoryList[e.detail.value].itemcode
- this.setData({
- category: category,
- categoryIndex: e.detail.value
- })
- },
- // 兼职类型
- typeChange(e) {
- let type = this.data.typeList[e.detail.value].itemcode
- this.setData({
- type: type,
- typeIndex: e.detail.value
- })
- },
- // 工资选择
- priceChange(e) {
- console.log(e, 111)
- let unit = this.data.arrayPrice[e.detail.value].itemcode
- this.setData({
- unit: unit,
- priceIndex: e.detail.value
- })
- },
- heightChange(e) {
- let heightlimit = this.data.heightList[e.detail.value].itemcode
- this.setData({
- heightlimit: heightlimit,
- heightIndex: e.detail.value
- })
- },
- clientChange(e) {
- let clientId = this.data.clientList[e.detail.value].id
- this.setData({
- clientId: clientId,
- clientIndex: e.detail.value
- })
- },
- areaChange(e) {
- this.data.multiIndex[0] = e.detail.value[0]
- this.data.multiIndex[1] = e.detail.value[1]
- this.data.multiIndex[2] = e.detail.value[2]
- let province = CityArray0[e.detail.value[0]].id
- let city = CityArray1[e.detail.value[1]].id
- let area = CityArray2[e.detail.value[2]].id
- this.setData({
- multiIndex: this.data.multiIndex,
- province: province,
- city: city,
- area: area
- })
- },
- MultiPickerAreaChange(e) {
- if (e.detail.column == 0) {
- let pid = CityArray0[e.detail.value].id
- this.data.multiIndex[0] = e.detail.value
- this.getCity(pid)
- } else if (e.detail.column == 1) {
- let pid = CityArray1[e.detail.value].id
- this.data.multiIndex[1] = e.detail.value
- this.getArea(pid)
- } else {
- this.data.multiIndex[2] = e.detail.value
- }
- this.setData({
- multiIndex: this.data.multiIndex
- })
- },
- // 工作日期
- workStartTimeBindDateChange(e) {
- this.setData({
- workdateStart: e.detail.value
- })
- },
- workStartTimeBindTimeChange(e) {
- this.setData({
- worktimeStart: e.detail.value
- })
- },
- workEndTimeBindDateChange(e) {
- this.setData({
- workdateEnd: e.detail.value
- })
- },
- workEndTimeBindTimeChange(e) {
- this.setData({
- worktimeEnd: e.detail.value
- })
- },
- // 报名截止
- registrationBindDateChange(e) {
- this.setData({
- registrationDate: e.detail.value
- })
- },
- registrationBindTimeChange(e) {
- this.setData({
- registrationHS: e.detail.value
- })
- },
- // 集合时间
- meetingBindDateChange(e) {
- this.setData({
- meetingTimeDate: e.detail.value
- })
- },
- meetingBindTimeChange(e) {
- this.setData({
- meetingTimeHS: e.detail.value
- })
- },
- // 是否需要会员
- freeRadioChange(e) {
- this.setData({
- isNeedVip: e.detail.value,
- })
- },
- // 推荐首页
- recommendRadioChange(e) {
- this.setData({
- isTop: e.detail.value
- })
- },
- // 性别要求
- sexRadioChange(e) {
- this.setData({
- sexlimit: e.detail.value
- })
- },
- changeAddress() {
- wx.chooseLocation({
- success: (res) => {
- console.log(res, 1111)
- wx.showLoading({
- title: '获取位置中...',
- })
- App._get('store/getDetailsAddress', {
- lon: res.longitude,
- lat: res.latitude
- }, res => {
- if (res.code === 0) {
- wx.hideLoading()
- this.setData({
- address: res.data.street_number,
- coordinate: res.longitude + ',' + res.latitude
- })
- }
- })
- },
- })
- // wx.navigateTo({
- // url: `/activity/map/map?lng=${this.data.lng}&lat=${this.data.lat}`,
- // })
- },
- uploadHandle(e) {
- let currentIndex = e.currentTarget.dataset.index
- // if (this.data.list.length == 3) {
- // return false
- // }
- let _this = this;
- var tempFile;
- wx.showActionSheet({
- itemList: ['拍照上传', '从相册中选择'],
- success(res) {
- if (res.tapIndex === 0) {
- wx.chooseImage({
- count: 1,
- sizeType: ['original', 'compressed'],
- sourceType: ['camera'],
- success(res) {
- wx.showLoading({
- title: '上传中...',
- })
- const tempFilePaths = res.tempFilePaths
- wx.uploadFile({
- url: App.apiRoot + 'file/upload',
- filePath: tempFilePaths[0],
- name: 'file',
- success: function (res) {
- if (res.errMsg === "uploadFile:ok") {
- wx.hideLoading()
- wx.showToast({
- title: '上传成功',
- image: '',
- duration: 1500,
- mask: false
- });
- let data = JSON.parse(res.data)
- if (currentIndex == 1) {
- _this.data.indexImg = data.data
- _this.setData({
- indexImg: _this.data.indexImg,
- })
- } else {
- _this.data.qrCodePicture = data.data
- _this.setData({
- qrCodePicture: _this.data.qrCodePicture,
- })
- }
- }
- },
- function () {
- wx.hideLoading()
- wx.showToast({
- title: '上传失败',
- icon: 'none',
- image: '',
- duration: 1500,
- mask: false,
- });
- }
- })
- }
- })
- } else if (res.tapIndex === 1) {
- wx.chooseImage({
- count: 1,
- sizeType: ['original', 'compressed'],
- sourceType: ['album'],
- success(res) {
- wx.showLoading({
- title: '上传中...',
- })
- const tempFilePaths = res.tempFilePaths
- wx.uploadFile({
- url: App.apiRoot + 'file/upload',
- filePath: tempFilePaths[0],
- name: 'file',
- success: function (res) {
- if (res.errMsg === "uploadFile:ok") {
- wx.hideLoading()
- wx.showToast({
- title: '上传成功',
- image: '',
- duration: 1500,
- mask: false
- });
- let data = JSON.parse(res.data)
- if (currentIndex == 1) {
- _this.data.indexImg = data.data
- _this.setData({
- indexImg: _this.data.indexImg,
- })
- } else {
- _this.data.qrCodePicture = data.data
- _this.setData({
- qrCodePicture: _this.data.qrCodePicture,
- })
- }
- }
- },
- function () {
- wx.hideLoading()
- wx.showToast({
- title: '上传失败',
- icon: 'none',
- image: '',
- duration: 1500,
- mask: false,
- success: (result) => {},
- fail: () => {},
- complete: () => {}
- });
- }
- })
- }
- })
- }
- },
- fail(res) {}
- })
- },
- submit() {
- if (!this.data.title) {
- return util.alert('请先填写兼职标题');
- }
- if (!this.data.category) {
- return util.alert('请先选择兼职分类');
- }
- if (!this.data.type) {
- return util.alert('请先选择兼职类型');
- }
- if (!this.data.city || !this.data.area) {
- return util.alert('请先选择所属区域');
- }
- if (!this.data.address) {
- return util.alert('请先选择兼职地址');
- }
- if (!this.data.workdateStart || !this.data.workdateEnd) {
- return util.alert('请先选择工作日期');
- }
- if (!this.data.worktimeStart || !this.data.worktimeEnd) {
- return util.alert('请先选择工作时间');
- }
- if (!this.data.registrationDate || !this.data.registrationHS) {
- return util.alert('请先选择报名截止时间');
- }
- if (!this.data.meetingTimeDate || !this.data.meetingTimeHS) {
- return util.alert('请先选择集合时间');
- }
- if (!this.data.price) {
- return util.alert('请先填写工资价格');
- }
- if (!this.data.unit) {
- return util.alert('请先选择工资单位');
- }
- if (!this.data.heightlimit) {
- return util.alert('请先选择身高要求');
- }
- if (!this.data.willnum) {
- return util.alert('请先填写报名人数限制');
- }
- if (!this.data.indexImg) {
- return util.alert('请先上传兼职详情banner图');
- }
- if (!this.data.activityjs) {
- return util.alert('请先填写兼职介绍');
- }
- if (!this.data.activityyq) {
- return util.alert('请先填写兼职要求');
- }
- if (!this.data.activitysx) {
- return util.alert('请先填写注意事项');
- }
- if (!this.data.attention) {
- return util.alert('请先填写注意事项');
- }
- if (!this.data.qrCodePicture) {
- return util.alert('请先上传联系二维码图');
- }
- if (!this.data.contactInstructions) {
- return util.alert('请先填写联系说明');
- }
- wx.showLoading({
- title: '提交中,请稍后',
- })
- let list = [this.data.activityjs, this.data.activityyq, this.data.activitysx]
- let obj = {
- category: this.data.category,
- type: this.data.type,
- address: this.data.address,
- area: this.data.area,
- indexImg: this.data.indexImg,
- city: this.data.city,
- workAppletsDetailsList: list,
- coordinate: this.data.coordinate,
- workdateEnd: this.data.workdateEnd,
- worktimeEnd: this.data.worktimeEnd,
- isNeedVip: this.data.isNeedVip == 1 ? true : false,
- isTop: this.data.isTop,
- meetingTime: this.data.meetingTimeDate + ' ' + this.data.meetingTimeHS,
- price: this.data.price,
- unit: this.data.unit,
- sexlimit: this.data.sexlimit,
- province: this.data.province,
- registrationTime: this.data.registrationDate + ' ' + this.data.registrationHS,
- clientId: this.data.clientId,
- heightlimit: this.data.heightlimit,
- interviewTime: this.data.interviewTime,
- trainingTime: this.data.trainingTime,
- workdateStart: this.data.workdateStart,
- worktimeStart: this.data.worktimeStart,
- qrCodePicture: this.data.qrCodePicture,
- contactInstructions: this.data.contactInstructions,
- title: this.data.title,
- willnum: this.data.willnum,
- attention: this.data.attention,
- memberId: this.data.user.id,
- // is_applets_release 是否是小程序发布 1是 0否
- isAppletsRelease: 1
- }
- wx.setStorageSync('workDetail', obj)
- wx.navigateTo({
- url: '/job/postJob/detail',
- })
- return false
- // App._post_form('work/saveWork', '', obj, res => {
- // if (res.code === 0) {
- // wx.showToast({
- // title: '添加成功',
- // })
- // wx.removeStorageSync('workDetail')
- // }
- // }, err => {}, complete => {
- // setTimeout(() => {
- // wx.hideLoading()
- // }, 300)
- // })
- },
- /**
- * 生命周期函数--监听页面隐藏
- */
- onHide() {
- },
- /**
- * 生命周期函数--监听页面卸载
- */
- onUnload() {
- },
- /**
- * 页面相关事件处理函数--监听用户下拉动作
- */
- onPullDownRefresh() {
- },
- /**
- * 页面上拉触底事件的处理函数
- */
- onReachBottom() {
- },
- /**
- * 用户点击右上角分享
- */
- onShareAppMessage() {
- }
- })
|