用工小程序前端代码
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.

502 lines
15 KiB

10 months ago
6 months ago
10 months ago
6 months ago
10 months ago
6 months ago
7 months ago
10 months ago
7 months ago
6 months ago
7 months ago
10 months ago
7 months ago
10 months ago
7 months ago
10 months ago
7 months ago
10 months ago
7 months ago
10 months ago
7 months ago
10 months ago
7 months ago
10 months ago
7 months ago
10 months ago
7 months ago
10 months ago
7 months ago
7 months ago
7 months ago
10 months ago
6 months ago
7 months ago
10 months ago
7 months ago
7 months ago
10 months ago
7 months ago
10 months ago
7 months ago
10 months ago
6 months ago
10 months ago
6 months ago
10 months ago
6 months ago
7 months ago
10 months ago
6 months ago
10 months ago
7 months ago
10 months ago
7 months ago
7 months ago
10 months ago
7 months ago
10 months ago
7 months ago
10 months ago
6 months ago
6 months ago
6 months ago
10 months ago
7 months ago
10 months ago
7 months ago
10 months ago
7 months ago
10 months ago
7 months ago
10 months ago
7 months ago
7 months ago
6 months ago
7 months ago
7 months ago
7 months ago
6 months ago
7 months ago
6 months ago
7 months ago
10 months ago
7 months ago
10 months ago
7 months ago
10 months ago
7 months ago
10 months ago
7 months ago
10 months ago
  1. <template>
  2. <view>
  3. <u--form labelPosition="left" :model="form" :rules="rules" ref="uForm" labelWidth="80">
  4. <view class="se-p-20">
  5. <view class="se-px-20 se-bgc-white se-br-10 se-fs-20">
  6. <u-form-item labelWidth="0">
  7. <view class="se-flex se-flex-ai-c">
  8. <view class="line-orange"></view>
  9. <view class="se-ml-10 se-fs-32 se-c-black se-fw-6">
  10. 标题
  11. </view>
  12. </view>
  13. </u-form-item>
  14. <u-form-item labelWidth="0" prop="title">
  15. <u--input v-model="form.title" placeholder="请在此输入标题"></u--input>
  16. </u-form-item>
  17. <u-form-item label="工作地点" prop="area" @click="handleAreaChange()">
  18. <u--input readonly v-model="form.area" placeholder="请选择工作地点"
  19. border="none"></u--input>
  20. <u-icon slot="right" name="arrow-right"></u-icon>
  21. </u-form-item>
  22. <!-- <u-form-item label="请选择地址" class="se-b-b" prop="area" @click="handleAreaChange()">
  23. <u--input readonly v-model="form.area" placeholder="请选择地址" border="none"></u--input>
  24. <u-icon slot="right" name="arrow-right" ></u-icon>
  25. </u-form-item> -->
  26. <!-- <u-form-item label="详细地址" prop="address">
  27. <u--textarea v-model="form.address" count
  28. placeholder="请输入详细地址"></u--textarea>
  29. </u-form-item> -->
  30. <u-form-item label="所属行业" prop="industryId" @click="handleindustryChange">
  31. <u--input @click="handleindustryChange" readonly v-model="form.industryName" placeholder="请选择行业"
  32. border="none"></u--input>
  33. <u-icon @click="handleindustryChange" slot="right" name="arrow-right"></u-icon>
  34. </u-form-item>
  35. <u-form-item label="所属工种" prop="typeId" @click="handleTypeChange">
  36. <u--input @click="handleTypeChange" v-model="form.typeName" readonly placeholder="请选择工种"
  37. border="none"></u--input>
  38. <u-icon @click="handleTypeChange" slot="right" name="arrow-right"></u-icon>
  39. </u-form-item>
  40. <u-form-item label="期望月薪" prop="salary">
  41. <view class="se-flex se-flex-h-c">
  42. <u--input v-model="form.salaryMin" class="se-w-200" placeholder="最小值"></u--input>
  43. <text class="se-mx-10">~</text>
  44. <u--input v-model="form.salaryMax" class="se-w-200" placeholder="最大值"></u--input>
  45. </view>
  46. </u-form-item>
  47. <u-form-item label="试工日薪" prop="dayMoney">
  48. <u--input v-model="form.dayMoney" placeholder="试工日薪"></u--input>
  49. </u-form-item>
  50. <u-form-item label="结算方式" prop="settlement">
  51. <u-radio-group v-model="form.settlement" placement="row">
  52. <u-radio activeColor="#FF7A31" name="0" label="提前支付"></u-radio>
  53. <u-radio activeColor="#FF7A31" class="se-ml-20" name="1" label="试用以后支付"></u-radio>
  54. </u-radio-group>
  55. </u-form-item>
  56. <u-form-item label="开始时间" prop="dateMin" @click="showMinDate=true">
  57. <u--input v-model="form.dateMin" disabled placeholder="开始时间"></u--input>
  58. </u-form-item>
  59. <u-form-item label="结束时间" prop="dateMax" @click="showMaxDate=true">
  60. <u--input v-model="form.dateMax" disabled placeholder="结束时间"></u--input>
  61. </u-form-item>
  62. <u-form-item label="联系电话" prop="mobile">
  63. <u--input v-model="form.mobile" placeholder="请输入联系方式"></u--input>
  64. </u-form-item>
  65. <u-form-item label="工作内容" prop="introduce">
  66. <u--textarea v-model="form.introduce" count
  67. placeholder="请选择工作内容"></u--textarea>
  68. </u-form-item>
  69. </view>
  70. </view>
  71. <view class="se-p-20">
  72. <view class="se-px-20 se-pb-20 se-bgc-white se-br-10 se-fs-20">
  73. <u-form-item prop="fileList" labelWidth="2">
  74. <view class="se-flex se-flex-v-sa">
  75. <view class="se-py-20 se-w-p-100 se-flex">
  76. <view class="line-orange"></view>
  77. <view class="se-ml-10">
  78. 图片上传
  79. </view>
  80. </view>
  81. <view class="se-py-20 se-w-p-100">
  82. <u-upload :fileList="form.fileList" @afterRead="afterRead" @delete="deletePic" name="1"
  83. multiple :maxCount="10"></u-upload>
  84. </view>
  85. </view>
  86. </u-form-item>
  87. </view>
  88. </view>
  89. <view class="se-px-20 se-pt-20">
  90. <view class="se-px-20 se-pb-80 se-fs-20 se-flex">
  91. <view @click="submit"
  92. class="se-mx-10 se-flex-1 se-br-40 se-flex-h-c se-h-80 se-lh-80 se-ta-c se-fs-28 se-c-white se-bgc-orange">
  93. <text>发布订单</text>
  94. </view>
  95. </view>
  96. </view>
  97. </u--form>
  98. <!-- 性别 -->
  99. <u-action-sheet :show="showIndustry" :actions="indList" title="请选择行业" @close="showIndustry = false" @select="industrySelect">
  100. </u-action-sheet>
  101. <!-- 种类 -->
  102. <u-action-sheet :show="showType" :actions="typeList" title="请选择种类" @close="showType = false"
  103. @select="typeSelect">
  104. </u-action-sheet>
  105. <!-- 地址 -->
  106. <citySelect v-model="showPicker" @city-change="handleCityChange"></citySelect>
  107. <!-- 时间 Min-->
  108. <u-datetime-picker
  109. :show="showMinDate"
  110. :value="form.dateMin"
  111. :minDate="todayTimestamp"
  112. mode="datetime"
  113. closeOnClickOverlay
  114. @confirm="dateMinConfirm"
  115. @cancel="dateMinClose"
  116. @close="dateMinClose"
  117. ></u-datetime-picker>
  118. <u-datetime-picker
  119. :show="showMaxDate"
  120. :value="form.dateMax"
  121. :minDate="todayTimestamp"
  122. mode="datetime"
  123. closeOnClickOverlay
  124. @confirm="dateMaxConfirm"
  125. @cancel="dateMaxClose"
  126. @close="dateMaxClose"
  127. ></u-datetime-picker>
  128. </view>
  129. </template>
  130. <script>
  131. import QQMapWX from "@/util/qqmap-wx-jssdk.min.js"
  132. import { addTask,industryList,industryById } from "@/common/api.js"
  133. import citySelect from '@/components/cityselect/index.vue'
  134. export default {
  135. components:{
  136. citySelect
  137. },
  138. data() {
  139. return {
  140. showMinDate:false,
  141. showMaxDate:false,
  142. todayTimestamp: new Date().setHours(0, 0, 0, 0),
  143. showPicker: false,
  144. showIndustry: false,
  145. indList:[],
  146. industryList: [
  147. {
  148. name: '打铁',
  149. },
  150. {
  151. name: '打牌',
  152. }
  153. ],
  154. showType: false,
  155. typeList: [],
  156. form: {
  157. title:"",
  158. area:'',
  159. address:'',
  160. industryId:"",
  161. industryName:"",
  162. settlement:'',
  163. date:"",
  164. dateMin:"",
  165. dateMax:"",
  166. mobile: '',
  167. typeId: '',
  168. typeName:"",
  169. salary:'',
  170. dayMoney:"",
  171. salaryMin: '',
  172. salaryMax: '',
  173. introduce: '',
  174. fileList: [],
  175. latitude:'',
  176. longitude:""
  177. },
  178. rules: {
  179. title:[
  180. {
  181. type: 'string',
  182. required: true,
  183. message: '请在此输入标题',
  184. trigger: ['blur', 'change']
  185. }
  186. ],
  187. area:[
  188. {
  189. type: 'string',
  190. required: true,
  191. message: '请选择地址',
  192. trigger: ['blur', 'change']
  193. }
  194. ],
  195. address:[
  196. {
  197. type: 'string',
  198. required: true,
  199. message: '请填写详细地址',
  200. trigger: ['blur', 'change']
  201. }
  202. ],
  203. industryName:[
  204. {
  205. type: 'string',
  206. required: true,
  207. message: '请选择行业',
  208. trigger: ['blur', 'change']
  209. }
  210. ],
  211. typeId:[
  212. {
  213. type: 'string',
  214. required: true,
  215. message: '请选择工种',
  216. trigger: ['blur', 'change']
  217. }
  218. ],
  219. dayMoney:[
  220. {
  221. type: 'string',
  222. required: true,
  223. message: '试工日薪',
  224. trigger: ['blur', 'change']
  225. }
  226. ],
  227. settlement:[
  228. {
  229. type: 'string',
  230. required: true,
  231. message: '请选择结算方式',
  232. trigger: ['blur', 'change']
  233. }
  234. ],
  235. mobile: [
  236. {
  237. required: true,
  238. message: '请输入手机号',
  239. trigger: ['change','blur'],
  240. },
  241. {
  242. validator: (rule, value, callback) => {
  243. return uni.$u.test.mobile(value);
  244. },
  245. message: '手机号码不正确',
  246. trigger: ['change','blur'],
  247. },
  248. ],
  249. date: [{
  250. type: 'string',
  251. max: 1,
  252. required: true,
  253. message: '请填写时间',
  254. trigger: ['blur', 'change']
  255. }],
  256. salary: [{
  257. type: 'string',
  258. required: true,
  259. message: '请输入试用日薪',
  260. trigger: ['blur', 'change']
  261. }],
  262. introduce: [{
  263. type: 'string',
  264. required: true,
  265. message: '请输入工作内容',
  266. trigger: ['blur', 'change']
  267. }],
  268. fileList:[
  269. {
  270. validator: (rule, value, callback) => {
  271. if (value === null || value === undefined || value === '' || (Array.isArray(value) && value.length === 0)) {
  272. callback(new Error('照片不能为空'));
  273. } else {
  274. callback();
  275. }
  276. },
  277. trigger: 'blur'
  278. }
  279. ],
  280. },
  281. }
  282. },
  283. watch: {
  284. 'form.salaryMin': {
  285. handler(newVal, oldVal) {
  286. if (!uni.$u.test.isEmpty(newVal) && !uni.$u.test.isEmpty(this.form.salaryMax)) {
  287. this.form.salary = '有'
  288. } else {
  289. this.form.salary = ''
  290. }
  291. },
  292. immediate: true
  293. },
  294. 'form.salaryMax': {
  295. handler(newVal, oldVal) {
  296. if (!uni.$u.test.isEmpty(newVal) && !uni.$u.test.isEmpty(this.form.salaryMin)) {
  297. this.form.salary = '有'
  298. } else {
  299. this.form.salary = ''
  300. }
  301. },
  302. immediate: true
  303. },
  304. 'form.dateMin': {
  305. handler(newVal, oldVal) {
  306. if (!uni.$u.test.isEmpty(newVal) && !uni.$u.test.isEmpty(this.form.dateMax)) {
  307. this.form.date = '有'
  308. } else {
  309. this.form.date = ''
  310. }
  311. },
  312. immediate: true
  313. },
  314. 'form.dateMax': {
  315. handler(newVal, oldVal) {
  316. if (!uni.$u.test.isEmpty(newVal) && !uni.$u.test.isEmpty(this.form.dateMin)) {
  317. this.form.date = '有'
  318. } else {
  319. this.form.date = ''
  320. }
  321. },
  322. immediate: true
  323. },
  324. },
  325. methods: {
  326. dateMinConfirm(event){
  327. console.info(event)
  328. this.showMinDate = false
  329. this.form.dateMin = uni.$u.timeFormat(event.value, 'yyyy-mm-dd hh:MM:ss')
  330. },
  331. dateMinClose(){
  332. this.showMinDate = false
  333. },
  334. dateMaxConfirm(event){
  335. this.showMaxDate = false
  336. this.form.dateMax = uni.$u.timeFormat(event.value, 'yyyy-mm-dd hh:MM:ss')
  337. },
  338. dateMaxClose(){
  339. this.showMaxDate = false
  340. },
  341. handleAreaChange(){
  342. const that = this;
  343. wx.chooseLocation({
  344. type: 'gcj02',
  345. // type: 'wgs84',
  346. success: function (res) {
  347. that.form.latitude = res.latitude
  348. that.form.longitude = res.longitude
  349. if (!res.address && res.name) { //用户直接选择城市的逻辑
  350. return that.form.area = res.name
  351. }
  352. if (res.address || res.name) {
  353. return that.form.area = res.address + res.name
  354. }
  355. that.form.area = '' //用户啥都没选就点击勾选
  356. // const qqmapsdk = new QQMapWX({
  357. // key: 'TT7BZ-Z3LW4-KOAUB-KWHOA-SBJJ6-Y5B6R' // 必填
  358. // });
  359. // uni.showLoading({
  360. // title:"获取中...."
  361. // })
  362. // qqmapsdk.reverseGeocoder({
  363. // location: {
  364. // latitude: res.latitude,
  365. // longitude: res.longitude
  366. // },
  367. // success: function(response) {
  368. // console.log('逆地理编码结果:', response);
  369. // uni.hideLoading()
  370. // that.form.longitude = response.result.location.lng
  371. // that.form.latitude = response.result.location.lat
  372. // that.form.area = response.result.address
  373. // },
  374. // fail: function(error) {
  375. // uni.hideLoading()
  376. // console.error('逆地理编码失败:', error);
  377. // }
  378. // });
  379. }
  380. })
  381. // this.showPicker = true
  382. },
  383. handleCityChange(e) {
  384. console.info(e)
  385. this.form.area = e.province.label + '-' + e.city.label + '-' + e.area.label;
  386. },
  387. handleindustryChange() {
  388. this.showIndustry = true
  389. },
  390. industrySelect(e) {
  391. this.form.industryId=e.id
  392. this.form.industryName = e.name
  393. this.$refs.uForm.validateField('industryName')
  394. this.onIndustryById()
  395. },
  396. onIndustryById(){
  397. let that = this
  398. industryById({pid:that.form.industryId}).then(response=>{
  399. console.info("response",response);
  400. that.typeList = response.result
  401. }).catch(error=>{
  402. })
  403. },
  404. handleTypeChange() {
  405. if(!this.form.industryId){
  406. return uni.$u.toast('请选择行业')
  407. }
  408. this.showType = true
  409. },
  410. typeSelect(e) {
  411. this.form.typeId = e.id
  412. this.form.typeName = e.name
  413. this.$refs.uForm.validateField('typeId')
  414. },
  415. submit() {
  416. this.$refs.uForm.validate().then(res => {
  417. this.onaddTask()
  418. }).catch(errors => {
  419. })
  420. },
  421. onaddTask(){
  422. let that = this
  423. let params ={
  424. "phone": that.form.mobile,//招聘方联系方式
  425. "salaryDay": that.form.dayMoney,//期望日薪
  426. "endTime": that.form.dateMax,
  427. "categoryOne": that.form.industryId,
  428. "categoryTwo": that.form.typeId,
  429. "latitude": that.form.latitude,
  430. "longitude": that.form.longitude,
  431. "salaryMax": that.form.salaryMax,//期望薪资最大值
  432. "salaryMin": that.form.salaryMin,//期望薪资最小值
  433. "payType": that.form.settlement,//结算方式 0提前支付 1 试用后支付
  434. "startTime": that.form.dateMin,
  435. "title": that.form.title,//工作标题
  436. "address": that.form.area,//工作地址
  437. "details": that.form.introduce,
  438. "image": that.form.fileList.map(item => item.url).join(','),//照片
  439. }
  440. if(this.$dayjs(params.startTime).isAfter(this.$dayjs(params.endTime))){
  441. return uni.$u.toast('开始时间不能大于结束时间')
  442. } else if(this.$dayjs(params.endTime).isBefore(this.$dayjs())){
  443. return uni.$u.toast('结束时间不能小于当前时间')
  444. }else if(this.$dayjs(params.startTime).isBefore(this.$dayjs())){
  445. return uni.$u.toast('开始时间不能小于当前时间')
  446. }
  447. // let p={"bossPhone":"13189698115","dayMoney":"500","endTime":"2016-01-01 00:00:00","industryId":"1865299999310622721","industryName":"木工","latitude":28.23529,"longitude":112.93134,"moneymax":"15000","moneymin":"12000","payType":"1","startTime":"2015-01-01 00:00:00","title":"木工师傅","workAddress":"湖南省长沙市岳麓区金星北路一段517号","workDetail":"阿萨法大多数发斯蒂芬撒旦法撒旦法阿斯蒂芬撒旦法撒旦法撒旦法三大法师打","workPic":"https://tennis-oss.xzaiyp.top/2025-02-19/341d669a-ef66-4abb-8b98-ac71c08814c9.jpg"}
  448. addTask(params).then(response=>{
  449. console.info("response",response)
  450. uni.$u.toast("提交成功!")
  451. setTimeout(()=>{
  452. uni.navigateBack({
  453. delta:1
  454. })
  455. },1500)
  456. }).catch(error=>{
  457. })
  458. },
  459. deletePic(event) {
  460. this.form.fileList.splice(e.index, 1)
  461. },
  462. async afterRead(e) {
  463. let self = this
  464. e.file.forEach(file => {
  465. self.$Oss.ossUpload(file.url).then(url => {
  466. self.form.fileList.push({
  467. url
  468. })
  469. })
  470. })
  471. },
  472. onIndustryList(){
  473. industryList({}).then(response=>{
  474. console.info("industryList",response);
  475. this.indList = response.result
  476. }).catch(error=>{
  477. })
  478. },
  479. },
  480. onReady() {
  481. this.$refs.uForm.setRules(this.rules)
  482. this.onIndustryList()
  483. },
  484. }
  485. </script>
  486. <style>
  487. </style>