postJob.js 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735
  1. // pages/my/postJob/postJob.js
  2. const App = getApp()
  3. const util = require('../../utils/tool');
  4. let CityArray0 = []
  5. let CityArray1 = []
  6. let CityArray2 = []
  7. Page({
  8. /**
  9. * 页面的初始数据
  10. */
  11. data: {
  12. appAssetsUrl2: App.appAssetsUrl2,
  13. user: wx.getStorageSync('USER'),
  14. lng: null,
  15. lat: null,
  16. // 活动地址
  17. address: null,
  18. // 坐标
  19. coordinate: null,
  20. multiArray: [],
  21. multiIndex: [],
  22. // 省
  23. province: null,
  24. // 市
  25. city: null,
  26. // 区
  27. area: null,
  28. // 标题
  29. title: null,
  30. // 所属客户
  31. clientId: null,
  32. clientList: [],
  33. clientIndex: 0,
  34. // 兼职分类
  35. category: null,
  36. // 兼职类型
  37. type: null,
  38. categoryList: [],
  39. categoryIndex: 0,
  40. typeList: [],
  41. typeIndex: 0,
  42. // 工作兼职时间
  43. // worktimeStart: null,
  44. // worktimeEnd: null,
  45. workdateStart: null,
  46. workdateEnd: null,
  47. worktimeStart: null,
  48. worktimeEnd: null,
  49. // workStartTimeDate: null,
  50. // workStartTimeHS: null,
  51. // workEndTimeDate: null,
  52. // workEndTimeHS: null,
  53. // 报名截止
  54. registrationTime: null,
  55. registrationDate: null,
  56. registrationHS: null,
  57. // 集合时间
  58. meetingTime: null,
  59. // 集合日期
  60. meetingTimeDate: null,
  61. // 集合日期时间
  62. meetingTimeHS: null,
  63. // 是否推荐至首页
  64. isTop: null,
  65. arrayPrice: [],
  66. priceIndex: 0,
  67. // 工资价格
  68. price: null,
  69. // 工资单位
  70. unit: null,
  71. // 性别要求
  72. sexlimit: null,
  73. // 是否需要会员
  74. isNeedVip: 0,
  75. heightList: [],
  76. heightIndex: 0,
  77. // 身高要求
  78. heightlimit: null,
  79. // 面试时间
  80. interviewTime: null,
  81. // 培训时间
  82. trainingTime: null,
  83. // 报名人数限制
  84. willnum: null,
  85. activityjs: null,
  86. activityyq: null,
  87. activitysx: null,
  88. // 兼职banner图
  89. indexImg: null,
  90. // 联系二维码
  91. qrCodePicture: null,
  92. contactInstructions: null,
  93. // 注意事项
  94. attention: null
  95. },
  96. /**
  97. * 生命周期函数--监听页面加载
  98. */
  99. onLoad(options) {
  100. this.getProvince()
  101. this.getCoord()
  102. this.getWorkCategory()
  103. this.getType()
  104. this.getUnit()
  105. this.getHeightList()
  106. this.getclient()
  107. },
  108. /**
  109. * 生命周期函数--监听页面初次渲染完成
  110. */
  111. onReady() {
  112. },
  113. /**
  114. * 生命周期函数--监听页面显示
  115. */
  116. onShow() {
  117. },
  118. // 获取兼职分类
  119. getWorkCategory() {
  120. App._post_form('work/category', '', {}, res => {
  121. if (res.code === 0) {
  122. this.setData({
  123. categoryList: res.data
  124. })
  125. }
  126. })
  127. },
  128. // 获取兼职类型
  129. getType() {
  130. App._post_form('bizlibrary/infoList/workType', '', {}, res => {
  131. if (res.code === 0) {
  132. this.setData({
  133. typeList: res.dictList
  134. })
  135. }
  136. })
  137. },
  138. getUnit() {
  139. App._post_form('bizlibrary/infoList/workUnit', '', {}, res => {
  140. if (res.code === 0) {
  141. this.setData({
  142. arrayPrice: res.dictList
  143. })
  144. }
  145. })
  146. },
  147. getHeightList() {
  148. App._post_form('bizlibrary/infoList/workHeightLimit', '', {}, res => {
  149. if (res.code === 0) {
  150. this.setData({
  151. heightList: res.dictList
  152. })
  153. }
  154. })
  155. },
  156. getclient() {
  157. App._post_form('wgclientinfo/selectCiList', '', {}, res => {
  158. if (res.code === 0) {
  159. this.setData({
  160. clientList: res.list
  161. })
  162. }
  163. })
  164. },
  165. // 获取经纬度
  166. getCoord() {
  167. wx.getLocation({
  168. type: 'gcj02',
  169. success: (res) => {
  170. const latitude = res.latitude
  171. const longitude = res.longitude
  172. this.setData({
  173. lng: Number(longitude),
  174. lat: Number(latitude)
  175. })
  176. },
  177. fail: (e) => {}
  178. })
  179. },
  180. // 获取省
  181. getProvince() {
  182. App._get('region/provinceList', {}, res => {
  183. let pId = ''
  184. let prov = ''
  185. if (res.code === 0) {
  186. let provice = res.data
  187. this.data.multiArray[0] = provice
  188. CityArray0 = provice
  189. if (CityArray0.length) {
  190. for (let i = 0; i < CityArray0.length; i++) {
  191. if (CityArray0[i].id == this.data.province) {
  192. this.data.multiIndex[0] = i
  193. break;
  194. } else {
  195. this.data.multiIndex[0] = 0
  196. // break;
  197. }
  198. }
  199. }
  200. if (this.data.province) {
  201. pId = this.data.province
  202. } else {
  203. //根据默认省,获取默认市
  204. if (this.data.multiArray[0].length) {
  205. pId = this.data.multiArray[0][0].id;
  206. }
  207. }
  208. this.getCity(pId)
  209. }
  210. })
  211. },
  212. getCity(pId) {
  213. App._get(`region/urbanDistrictList?id=${pId}`, {}, res => {
  214. // App._get(`region/urbanDistrictList?id=420000`, {}, res => {
  215. if (res.code === 0) {
  216. let city = res.data;
  217. this.data.multiArray[1] = city;
  218. CityArray1 = city;
  219. if (CityArray1.length) {
  220. for (let i = 0; i < CityArray1.length; i++) {
  221. // console.log(CityArray1[i].id, pId, 222)
  222. if (CityArray1[i].pid === pId) {
  223. this.data.multiIndex[1] = i;
  224. break;
  225. }
  226. }
  227. }
  228. let cityId = '';
  229. if (this.data.city) {
  230. cityId = this.data.city
  231. } else {
  232. if (this.data.multiArray[1].length) {
  233. cityId = this.data.multiArray[1][0].id
  234. }
  235. }
  236. this.getArea(cityId)
  237. this.setData({
  238. multiArray: this.data.multiArray,
  239. multiIndex: this.data.multiIndex
  240. })
  241. }
  242. })
  243. },
  244. // 获取区
  245. getArea(cityId) {
  246. for (let i = 0; i < this.data.multiArray[1].length; i++) {
  247. console.log(this.data.multiArray[1], cityId, 'area')
  248. if (this.data.multiArray[1][i].id === cityId) {
  249. CityArray2 = this.data.multiArray[1][i].childRegionList
  250. this.data.multiArray[2] = this.data.multiArray[1][i].childRegionList
  251. this.data.multiIndex[2] = i
  252. break;
  253. }
  254. }
  255. if (this.data.area) {
  256. for (let j = 0; j < this.data.multiArray[2].length; j++) {
  257. if (this.data.multiArray[2][j].id === this.data.area) {
  258. this.data.multiIndex[2] = j
  259. break;
  260. }
  261. }
  262. }
  263. this.setData({
  264. multiArray: this.data.multiArray,
  265. multiIndex: this.data.multiIndex
  266. })
  267. console.log(this.data.multiArray, this.data.multiIndex, 1111)
  268. },
  269. // 兼职分类
  270. categoryChange(e) {
  271. console.log(e)
  272. let category = this.data.categoryList[e.detail.value].itemcode
  273. this.setData({
  274. category: category,
  275. categoryIndex: e.detail.value
  276. })
  277. },
  278. // 兼职类型
  279. typeChange(e) {
  280. let type = this.data.typeList[e.detail.value].itemcode
  281. this.setData({
  282. type: type,
  283. typeIndex: e.detail.value
  284. })
  285. },
  286. // 工资选择
  287. priceChange(e) {
  288. console.log(e, 111)
  289. let unit = this.data.arrayPrice[e.detail.value].itemcode
  290. this.setData({
  291. unit: unit,
  292. priceIndex: e.detail.value
  293. })
  294. },
  295. heightChange(e) {
  296. let heightlimit = this.data.heightList[e.detail.value].itemcode
  297. this.setData({
  298. heightlimit: heightlimit,
  299. heightIndex: e.detail.value
  300. })
  301. },
  302. clientChange(e) {
  303. let clientId = this.data.clientList[e.detail.value].id
  304. this.setData({
  305. clientId: clientId,
  306. clientIndex: e.detail.value
  307. })
  308. },
  309. areaChange(e) {
  310. this.data.multiIndex[0] = e.detail.value[0]
  311. this.data.multiIndex[1] = e.detail.value[1]
  312. this.data.multiIndex[2] = e.detail.value[2]
  313. let province = CityArray0[e.detail.value[0]].id
  314. let city = CityArray1[e.detail.value[1]].id
  315. let area = CityArray2[e.detail.value[2]].id
  316. this.setData({
  317. multiIndex: this.data.multiIndex,
  318. province: province,
  319. city: city,
  320. area: area
  321. })
  322. },
  323. MultiPickerAreaChange(e) {
  324. if (e.detail.column == 0) {
  325. let pid = CityArray0[e.detail.value].id
  326. this.data.multiIndex[0] = e.detail.value
  327. this.getCity(pid)
  328. } else if (e.detail.column == 1) {
  329. let pid = CityArray1[e.detail.value].id
  330. this.data.multiIndex[1] = e.detail.value
  331. this.getArea(pid)
  332. } else {
  333. this.data.multiIndex[2] = e.detail.value
  334. }
  335. this.setData({
  336. multiIndex: this.data.multiIndex
  337. })
  338. },
  339. // 工作日期
  340. workStartTimeBindDateChange(e) {
  341. this.setData({
  342. workdateStart: e.detail.value
  343. })
  344. },
  345. workStartTimeBindTimeChange(e) {
  346. this.setData({
  347. worktimeStart: e.detail.value
  348. })
  349. },
  350. workEndTimeBindDateChange(e) {
  351. this.setData({
  352. workdateEnd: e.detail.value
  353. })
  354. },
  355. workEndTimeBindTimeChange(e) {
  356. this.setData({
  357. worktimeEnd: e.detail.value
  358. })
  359. },
  360. // 报名截止
  361. registrationBindDateChange(e) {
  362. this.setData({
  363. registrationDate: e.detail.value
  364. })
  365. },
  366. registrationBindTimeChange(e) {
  367. this.setData({
  368. registrationHS: e.detail.value
  369. })
  370. },
  371. // 集合时间
  372. meetingBindDateChange(e) {
  373. this.setData({
  374. meetingTimeDate: e.detail.value
  375. })
  376. },
  377. meetingBindTimeChange(e) {
  378. this.setData({
  379. meetingTimeHS: e.detail.value
  380. })
  381. },
  382. // 是否需要会员
  383. freeRadioChange(e) {
  384. this.setData({
  385. isNeedVip: e.detail.value,
  386. })
  387. },
  388. // 推荐首页
  389. recommendRadioChange(e) {
  390. this.setData({
  391. isTop: e.detail.value
  392. })
  393. },
  394. // 性别要求
  395. sexRadioChange(e) {
  396. this.setData({
  397. sexlimit: e.detail.value
  398. })
  399. },
  400. changeAddress() {
  401. wx.chooseLocation({
  402. success: (res) => {
  403. console.log(res, 1111)
  404. wx.showLoading({
  405. title: '获取位置中...',
  406. })
  407. App._get('store/getDetailsAddress', {
  408. lon: res.longitude,
  409. lat: res.latitude
  410. }, res => {
  411. if (res.code === 0) {
  412. wx.hideLoading()
  413. this.setData({
  414. address: res.data.street_number,
  415. coordinate: res.longitude + ',' + res.latitude
  416. })
  417. }
  418. })
  419. },
  420. })
  421. // wx.navigateTo({
  422. // url: `/activity/map/map?lng=${this.data.lng}&lat=${this.data.lat}`,
  423. // })
  424. },
  425. uploadHandle(e) {
  426. let currentIndex = e.currentTarget.dataset.index
  427. // if (this.data.list.length == 3) {
  428. // return false
  429. // }
  430. let _this = this;
  431. var tempFile;
  432. wx.showActionSheet({
  433. itemList: ['拍照上传', '从相册中选择'],
  434. success(res) {
  435. if (res.tapIndex === 0) {
  436. wx.chooseImage({
  437. count: 1,
  438. sizeType: ['original', 'compressed'],
  439. sourceType: ['camera'],
  440. success(res) {
  441. wx.showLoading({
  442. title: '上传中...',
  443. })
  444. const tempFilePaths = res.tempFilePaths
  445. wx.uploadFile({
  446. url: App.apiRoot + 'file/upload',
  447. filePath: tempFilePaths[0],
  448. name: 'file',
  449. success: function (res) {
  450. if (res.errMsg === "uploadFile:ok") {
  451. wx.hideLoading()
  452. wx.showToast({
  453. title: '上传成功',
  454. image: '',
  455. duration: 1500,
  456. mask: false
  457. });
  458. let data = JSON.parse(res.data)
  459. if (currentIndex == 1) {
  460. _this.data.indexImg = data.data
  461. _this.setData({
  462. indexImg: _this.data.indexImg,
  463. })
  464. } else {
  465. _this.data.qrCodePicture = data.data
  466. _this.setData({
  467. qrCodePicture: _this.data.qrCodePicture,
  468. })
  469. }
  470. }
  471. },
  472. function () {
  473. wx.hideLoading()
  474. wx.showToast({
  475. title: '上传失败',
  476. icon: 'none',
  477. image: '',
  478. duration: 1500,
  479. mask: false,
  480. });
  481. }
  482. })
  483. }
  484. })
  485. } else if (res.tapIndex === 1) {
  486. wx.chooseImage({
  487. count: 1,
  488. sizeType: ['original', 'compressed'],
  489. sourceType: ['album'],
  490. success(res) {
  491. wx.showLoading({
  492. title: '上传中...',
  493. })
  494. const tempFilePaths = res.tempFilePaths
  495. wx.uploadFile({
  496. url: App.apiRoot + 'file/upload',
  497. filePath: tempFilePaths[0],
  498. name: 'file',
  499. success: function (res) {
  500. if (res.errMsg === "uploadFile:ok") {
  501. wx.hideLoading()
  502. wx.showToast({
  503. title: '上传成功',
  504. image: '',
  505. duration: 1500,
  506. mask: false
  507. });
  508. let data = JSON.parse(res.data)
  509. if (currentIndex == 1) {
  510. _this.data.indexImg = data.data
  511. _this.setData({
  512. indexImg: _this.data.indexImg,
  513. })
  514. } else {
  515. _this.data.qrCodePicture = data.data
  516. _this.setData({
  517. qrCodePicture: _this.data.qrCodePicture,
  518. })
  519. }
  520. }
  521. },
  522. function () {
  523. wx.hideLoading()
  524. wx.showToast({
  525. title: '上传失败',
  526. icon: 'none',
  527. image: '',
  528. duration: 1500,
  529. mask: false,
  530. success: (result) => {},
  531. fail: () => {},
  532. complete: () => {}
  533. });
  534. }
  535. })
  536. }
  537. })
  538. }
  539. },
  540. fail(res) {}
  541. })
  542. },
  543. submit() {
  544. if (!this.data.title) {
  545. return util.alert('请先填写兼职标题');
  546. }
  547. if (!this.data.category) {
  548. return util.alert('请先选择兼职分类');
  549. }
  550. if (!this.data.type) {
  551. return util.alert('请先选择兼职类型');
  552. }
  553. if (!this.data.city || !this.data.area) {
  554. return util.alert('请先选择所属区域');
  555. }
  556. if (!this.data.address) {
  557. return util.alert('请先选择兼职地址');
  558. }
  559. if (!this.data.workdateStart || !this.data.workdateEnd) {
  560. return util.alert('请先选择工作日期');
  561. }
  562. if (!this.data.worktimeStart || !this.data.worktimeEnd) {
  563. return util.alert('请先选择工作时间');
  564. }
  565. if (!this.data.registrationDate || !this.data.registrationHS) {
  566. return util.alert('请先选择报名截止时间');
  567. }
  568. if (!this.data.meetingTimeDate || !this.data.meetingTimeHS) {
  569. return util.alert('请先选择集合时间');
  570. }
  571. if (!this.data.price) {
  572. return util.alert('请先填写工资价格');
  573. }
  574. if (!this.data.unit) {
  575. return util.alert('请先选择工资单位');
  576. }
  577. if (!this.data.heightlimit) {
  578. return util.alert('请先选择身高要求');
  579. }
  580. if (!this.data.willnum) {
  581. return util.alert('请先填写报名人数限制');
  582. }
  583. if (!this.data.indexImg) {
  584. return util.alert('请先上传兼职详情banner图');
  585. }
  586. if (!this.data.activityjs) {
  587. return util.alert('请先填写兼职介绍');
  588. }
  589. if (!this.data.activityyq) {
  590. return util.alert('请先填写兼职要求');
  591. }
  592. if (!this.data.activitysx) {
  593. return util.alert('请先填写注意事项');
  594. }
  595. if (!this.data.attention) {
  596. return util.alert('请先填写注意事项');
  597. }
  598. if (!this.data.qrCodePicture) {
  599. return util.alert('请先上传联系二维码图');
  600. }
  601. if (!this.data.contactInstructions) {
  602. return util.alert('请先填写联系说明');
  603. }
  604. wx.showLoading({
  605. title: '提交中,请稍后',
  606. })
  607. let list = [this.data.activityjs, this.data.activityyq, this.data.activitysx]
  608. let obj = {
  609. category: this.data.category,
  610. type: this.data.type,
  611. address: this.data.address,
  612. area: this.data.area,
  613. indexImg: this.data.indexImg,
  614. city: this.data.city,
  615. workAppletsDetailsList: list,
  616. coordinate: this.data.coordinate,
  617. workdateEnd: this.data.workdateEnd,
  618. worktimeEnd: this.data.worktimeEnd,
  619. isNeedVip: this.data.isNeedVip == 1 ? true : false,
  620. isTop: this.data.isTop,
  621. meetingTime: this.data.meetingTimeDate + ' ' + this.data.meetingTimeHS,
  622. price: this.data.price,
  623. unit: this.data.unit,
  624. sexlimit: this.data.sexlimit,
  625. province: this.data.province,
  626. registrationTime: this.data.registrationDate + ' ' + this.data.registrationHS,
  627. clientId: this.data.clientId,
  628. heightlimit: this.data.heightlimit,
  629. interviewTime: this.data.interviewTime,
  630. trainingTime: this.data.trainingTime,
  631. workdateStart: this.data.workdateStart,
  632. worktimeStart: this.data.worktimeStart,
  633. qrCodePicture: this.data.qrCodePicture,
  634. contactInstructions: this.data.contactInstructions,
  635. title: this.data.title,
  636. willnum: this.data.willnum,
  637. attention: this.data.attention,
  638. memberId: this.data.user.id,
  639. // is_applets_release 是否是小程序发布 1是 0否
  640. isAppletsRelease: 1
  641. }
  642. wx.setStorageSync('workDetail', obj)
  643. wx.navigateTo({
  644. url: '/job/postJob/detail',
  645. })
  646. return false
  647. // App._post_form('work/saveWork', '', obj, res => {
  648. // if (res.code === 0) {
  649. // wx.showToast({
  650. // title: '添加成功',
  651. // })
  652. // wx.removeStorageSync('workDetail')
  653. // }
  654. // }, err => {}, complete => {
  655. // setTimeout(() => {
  656. // wx.hideLoading()
  657. // }, 300)
  658. // })
  659. },
  660. /**
  661. * 生命周期函数--监听页面隐藏
  662. */
  663. onHide() {
  664. },
  665. /**
  666. * 生命周期函数--监听页面卸载
  667. */
  668. onUnload() {
  669. },
  670. /**
  671. * 页面相关事件处理函数--监听用户下拉动作
  672. */
  673. onPullDownRefresh() {
  674. },
  675. /**
  676. * 页面上拉触底事件的处理函数
  677. */
  678. onReachBottom() {
  679. },
  680. /**
  681. * 用户点击右上角分享
  682. */
  683. onShareAppMessage() {
  684. }
  685. })