addExpectation.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599
  1. <template>
  2. <view class="add-expectation">
  3. <!-- 顶部导航 -->
  4. <view class="nav-bar" :style="{ paddingTop: (12 + statusBarHeight) + 'px' }">
  5. <view class="nav-left" @click="goBack">
  6. <u-icon name="arrow-leftward" color="rgba(51, 51, 51, 1)" style="font-size: 38rpx;"></u-icon>
  7. </view>
  8. <view class="nav-title">{{id==""||id==0?'添加':'编辑'}}求职期望</view>
  9. <view class="nav-right"></view>
  10. </view>
  11. <!-- 表单内容 -->
  12. <view class="form-container">
  13. <!-- 工作职位 -->
  14. <view class="form-item">
  15. <text class="form-label">工作职位</text>
  16. <view class="form-input" @click="selectJob">
  17. <text class="input-text">{{ jobTitle || '请选择' }}</text>
  18. <u-icon name="arrow-right" color="#999" size="24"></u-icon>
  19. </view>
  20. </view>
  21. <!-- 工作城市 -->
  22. <view class="form-item">
  23. <text class="form-label">工作城市</text>
  24. <view class="form-input" @click="selectCity">
  25. <text class="input-text">{{ city || '请选择' }}</text>
  26. <u-icon name="arrow-right" color="#999" size="24"></u-icon>
  27. </view>
  28. </view>
  29. <!-- 期望薪酬 -->
  30. <view class="form-item">
  31. <text class="form-label">期望薪酬</text>
  32. <view class="salary-container">
  33. <view class="salary-inputs">
  34. <view class="salary-input">
  35. <text class="currency">¥</text>
  36. <input v-model="minSalary" type="number" placeholder="8000" class="salary-field" />
  37. </view>
  38. <view class="salary-input">
  39. <text class="currency">¥</text>
  40. <input v-model="maxSalary" type="number" placeholder="10000" class="salary-field" />
  41. </view>
  42. </view>
  43. <!-- 范围滑块 -->
  44. <!-- <view class="range-slider-container">
  45. <view class="range-slider-track" @click="onTrackClick">
  46. <view class="range-slider-progress" :style="progressStyle"></view>
  47. <view
  48. class="range-slider-thumb range-slider-thumb-left"
  49. :style="leftThumbStyle"
  50. @touchstart="onLeftThumbStart"
  51. @touchmove="onLeftThumbMove"
  52. @touchend="onLeftThumbEnd"
  53. ></view>
  54. <view
  55. class="range-slider-thumb range-slider-thumb-right"
  56. :style="rightThumbStyle"
  57. @touchstart="onRightThumbStart"
  58. @touchmove="onRightThumbMove"
  59. @touchend="onRightThumbEnd"
  60. ></view>
  61. </view>
  62. </view> -->
  63. </view>
  64. </view>
  65. <!-- 工作类型 -->
  66. <!-- view class="form-item">
  67. <text class="form-label">工作类型</text>
  68. <view class="job-type-container">
  69. <view
  70. class="job-type-btn"
  71. :class="{ active: jobType === 'fulltime' }"
  72. @click="selectJobType('fulltime')"
  73. >
  74. <text>全职</text>
  75. </view>
  76. <view
  77. class="job-type-btn"
  78. :class="{ active: jobType === 'parttime' }"
  79. @click="selectJobType('parttime')"
  80. >
  81. <text>兼职</text>
  82. </view>
  83. </view>
  84. </view> -->
  85. <!-- 从事方向 -->
  86. <view class="form-item">
  87. <text class="form-label">跨境标签</text>
  88. <view class="form-input" @click="selectIndustry">
  89. <text class="input-text">{{ industry || '请选择' }}</text>
  90. <u-icon name="arrow-right" color="#999" size="24"></u-icon>
  91. </view>
  92. </view>
  93. </view>
  94. <view class="fixed-section">
  95. <u-button type="primary" class="submit-btn" @click="saveWorkExperience">保存</u-button>
  96. </view>
  97. </view>
  98. </template>
  99. <script>
  100. export default {
  101. data() {
  102. return {
  103. statusBarHeight: 0, // 状态栏高度
  104. id:0,
  105. jobId:0,
  106. jobTitle: '',
  107. city: '',
  108. minSalary: '8000',
  109. maxSalary: '10000',
  110. jobType: 'fulltime',
  111. industry: '',
  112. // 范围滑块相关数据
  113. minValue: 8000,
  114. maxValue: 10000,
  115. sliderMin: 5000,
  116. sliderMax: 50000,
  117. step: 1000,
  118. trackWidth: 0,
  119. draggingThumb: null, // 'left' 或 'right' 或 null
  120. startX: 0,
  121. startValue: 0,
  122. isWork:false
  123. }
  124. },
  125. computed: {
  126. // 左侧滑块位置百分比
  127. leftPercent() {
  128. return ((this.minValue - this.sliderMin) / (this.sliderMax - this.sliderMin)) * 100
  129. },
  130. // 右侧滑块位置百分比
  131. rightPercent() {
  132. return ((this.maxValue - this.sliderMin) / (this.sliderMax - this.sliderMin)) * 100
  133. },
  134. // // 进度条样式
  135. // progressStyle() {
  136. // return {
  137. // left: this.leftPercent + '%',
  138. // width: (this.rightPercent - this.leftPercent) + '%'
  139. // }
  140. // },
  141. // // 左侧滑块样式
  142. // leftThumbStyle() {
  143. // return {
  144. // left: this.leftPercent + '%'
  145. // }
  146. // },
  147. // // 右侧滑块样式
  148. // rightThumbStyle() {
  149. // return {
  150. // left: this.rightPercent + '%'
  151. // }
  152. // }
  153. },
  154. methods: {
  155. getData(){
  156. var that=this
  157. this.$Request.getT("/app/intention/getIntentionInfo", {intentionId:this.id}).then((res) => {
  158. if (res.code == 0) {
  159. res=res.data
  160. that.jobId=res.ruleClassifyId
  161. that.jobTitle=res.ruleClassifyName
  162. that.jobType=res.postType=='全职'?'fulltime':'parttime'
  163. that.city=res.citys
  164. that.industry=res.industry
  165. var salaryRange=res.salaryRange.split('-')
  166. that.minValue=salaryRange[0]?parseInt(salaryRange[0]):0
  167. that.maxValue=salaryRange[1]?parseInt(salaryRange[1]):0
  168. that.minSalary=salaryRange[0]?salaryRange[0]:0
  169. that.maxSalary=salaryRange[1]?salaryRange[1]:0
  170. } else {
  171. uni.showToast({
  172. title: res.msg,
  173. icon: "none",
  174. });
  175. }
  176. });
  177. },
  178. goBack() {
  179. uni.navigateBack()
  180. },
  181. selectJob() {
  182. uni.navigateTo({
  183. url: '/package/jobIntention/jobList'
  184. })
  185. },
  186. selectCity() {
  187. uni.navigateTo({
  188. url: '/package/jobIntention/city'
  189. })
  190. },
  191. selectIndustry() {
  192. if(this.jobId==''||this.jobId==0)
  193. return this.$queue.showToast('请先选择岗位')
  194. uni.navigateTo({
  195. url: '/package/jobIntention/preferenceSetting?jobId='+this.jobId+'&jobTitle='+this.jobTitle+'&selectedPreferences='+encodeURIComponent(JSON.stringify(this.industry==''||this.industry==null?[]:this.industry.split('/')))
  196. })
  197. },
  198. // selectJobType(type) {
  199. // this.jobType = type
  200. // },
  201. // // 获取滑块轨道宽度
  202. // getTrackWidth() {
  203. // uni.createSelectorQuery().in(this).select('.range-slider-track').boundingClientRect(data => {
  204. // this.trackWidth = data.width
  205. // }).exec()
  206. // },
  207. // // 将像素位置转换为数值
  208. // pixelToValue(pixel) {
  209. // const percent = (pixel / this.trackWidth) * 100
  210. // const value = this.sliderMin + (percent / 100) * (this.sliderMax - this.sliderMin)
  211. // return Math.round(value / this.step) * this.step
  212. // },
  213. // // 左侧滑块开始拖拽
  214. // onLeftThumbStart(e) {
  215. // this.draggingThumb = 'left'
  216. // this.startX = e.touches[0].clientX
  217. // this.startValue = this.minValue
  218. // e.preventDefault()
  219. // },
  220. // // 左侧滑块拖拽中
  221. // onLeftThumbMove(e) {
  222. // if (this.draggingThumb !== 'left') return
  223. // const deltaX = e.touches[0].clientX - this.startX
  224. // const deltaPercent = (deltaX / this.trackWidth) * 100
  225. // const deltaValue = (deltaPercent / 100) * (this.sliderMax - this.sliderMin)
  226. // let newValue = this.startValue + deltaValue
  227. // // 限制范围
  228. // newValue = Math.max(this.sliderMin, Math.min(newValue, this.maxValue - this.step))
  229. // newValue = Math.round(newValue / this.step) * this.step
  230. // this.minValue = newValue
  231. // this.minSalary = newValue.toString()
  232. // e.preventDefault()
  233. // },
  234. // // 左侧滑块结束拖拽
  235. // onLeftThumbEnd(e) {
  236. // this.draggingThumb = null
  237. // e.preventDefault()
  238. // },
  239. // // 右侧滑块开始拖拽
  240. // onRightThumbStart(e) {
  241. // this.draggingThumb = 'right'
  242. // this.startX = e.touches[0].clientX
  243. // this.startValue = this.maxValue
  244. // e.preventDefault()
  245. // },
  246. // // 右侧滑块拖拽中
  247. // onRightThumbMove(e) {
  248. // if (this.draggingThumb !== 'right') return
  249. // const deltaX = e.touches[0].clientX - this.startX
  250. // const deltaPercent = (deltaX / this.trackWidth) * 100
  251. // const deltaValue = (deltaPercent / 100) * (this.sliderMax - this.sliderMin)
  252. // let newValue = this.startValue + deltaValue
  253. // // 限制范围
  254. // newValue = Math.max(this.minValue + this.step, Math.min(newValue, this.sliderMax))
  255. // newValue = Math.round(newValue / this.step) * this.step
  256. // this.maxValue = newValue
  257. // this.maxSalary = newValue.toString()
  258. // e.preventDefault()
  259. // },
  260. // // 右侧滑块结束拖拽
  261. // onRightThumbEnd(e) {
  262. // this.draggingThumb = null
  263. // e.preventDefault()
  264. // },
  265. // // 点击轨道
  266. // onTrackClick(e) {
  267. // if (this.draggingThumb) return
  268. // const rect = e.currentTarget.getBoundingClientRect()
  269. // const clickX = e.detail.x - rect.left
  270. // const clickPercent = (clickX / rect.width) * 100
  271. // const clickValue = this.sliderMin + (clickPercent / 100) * (this.sliderMax - this.sliderMin)
  272. // // 判断点击位置更靠近哪个滑块
  273. // const distanceToLeft = Math.abs(clickValue - this.minValue)
  274. // const distanceToRight = Math.abs(clickValue - this.maxValue)
  275. // if (distanceToLeft < distanceToRight) {
  276. // // 更靠近左侧滑块
  277. // let newValue = Math.round(clickValue / this.step) * this.step
  278. // newValue = Math.max(this.sliderMin, Math.min(newValue, this.maxValue - this.step))
  279. // this.minValue = newValue
  280. // this.minSalary = newValue.toString()
  281. // } else {
  282. // // 更靠近右侧滑块
  283. // let newValue = Math.round(clickValue / this.step) * this.step
  284. // newValue = Math.max(this.minValue + this.step, Math.min(newValue, this.sliderMax))
  285. // this.maxValue = newValue
  286. // this.maxSalary = newValue.toString()
  287. // }
  288. // },
  289. saveWorkExperience() {
  290. if (!this.jobId) {
  291. uni.showToast({ title: "请选择工作职位", icon: "none" });
  292. return;
  293. }
  294. if (!this.city) {
  295. uni.showToast({ title: "请选择城市", icon: "none" });
  296. return;
  297. }
  298. // 限制最低工资不能高于最高工资
  299. const minSalary = Number(this.minSalary) || 0
  300. const maxSalary = Number(this.maxSalary) || 0
  301. if (minSalary > maxSalary) {
  302. uni.showToast({ title: "最低薪酬不能大于最高薪酬", icon: "none" });
  303. return;
  304. }
  305. if (!this.industry) {
  306. uni.showToast({ title: "请选择跨境标签", icon: "none" });
  307. return;
  308. }
  309. if(this.isWork)
  310. return
  311. this.isWork=true
  312. let data={
  313. intentionId:this.id,
  314. ruleClassifyId:this.jobId,
  315. ruleClassifyName:this.jobTitle,
  316. citys:this.city,
  317. salaryRange:this.minSalary+'-'+this.maxSalary,
  318. postType:this.jobType === 'fulltime'?'全职':'兼职',
  319. industry:this.industry,
  320. "createTime": "",
  321. "industryId": 201,
  322. "industryOneId": 200,
  323. "classifyOneId": 0,
  324. "classifyTwoId": 0,
  325. "isDefault": 1
  326. }
  327. uni.showLoading({ title: "提交中..." });
  328. this.$Request.postJson("/app/intention/saveUpdate", data).then((res) => {
  329. this.isWork=false
  330. this.industry=''
  331. uni.hideLoading();
  332. if (res.code == 0) {
  333. uni.showToast({ title: "保存成功", icon: "none" });
  334. // 实际开发中可以在这里添加跳转逻辑
  335. uni.$emit('updateResume')
  336. uni.$emit('updateIndexType')
  337. setTimeout(() => {
  338. uni.navigateBack()
  339. }, 1000);
  340. } else {
  341. uni.showToast({
  342. title: res.msg,
  343. icon: "none",
  344. });
  345. }
  346. });
  347. },
  348. },
  349. mounted() {
  350. // // 初始化滑块轨道宽度
  351. // this.$nextTick(() => {
  352. // this.getTrackWidth()
  353. // })
  354. },
  355. onLoad(options) {
  356. // 获取状态栏高度
  357. let systemInfo = uni.getSystemInfoSync();
  358. this.statusBarHeight = systemInfo.statusBarHeight || 0;
  359. this.id=options&&options.id?options.id:""
  360. // 监听选择结果
  361. uni.$on('jobs', (data) => {
  362. this.jobTitle = data.ruleClassifyName
  363. this.jobId = data.ruleClassifyId
  364. })
  365. uni.$on('city', (data) => {
  366. console.log(data)
  367. this.city = data.city
  368. })
  369. /* uni.$on('industry', (data) => {
  370. this.industry = data.industry
  371. }) */
  372. // 监听技能设置更新
  373. uni.$on('preferenceUpdated', (data) => {
  374. this.industry=data.preferences.join('/')
  375. })
  376. if(this.id!=0&&this.id!='')
  377. this.getData()
  378. },
  379. onUnload() {
  380. // 移除监听
  381. uni.$off('jobs')
  382. uni.$off('city')
  383. /* uni.$off('industry') */
  384. uni.$off('preferenceUpdated')
  385. }
  386. }
  387. </script>
  388. <style lang="scss" scoped>
  389. @import '../../common.scss';
  390. .add-expectation {
  391. min-height: 100vh;
  392. }
  393. .nav-bar {
  394. display: flex;
  395. align-items: center;
  396. justify-content: space-between;
  397. margin-bottom: 30rpx;
  398. padding: 0 40rpx;
  399. .nav-left {
  400. display: flex;
  401. align-items: center;
  402. justify-content: center;
  403. }
  404. .nav-title {
  405. color: rgba(51, 51, 51, 1);
  406. font-family: DM Sans;
  407. font-size: 32rpx;
  408. font-weight: 700;
  409. line-height: 26px;
  410. text-align: center;
  411. }
  412. }
  413. .form-container {
  414. background: #ffffff;
  415. border-radius: 20rpx;
  416. margin-top: 30rpx;
  417. padding: 0 40rpx;
  418. }
  419. .form-item {
  420. margin-bottom: 40rpx;
  421. &:last-child {
  422. margin-bottom: 0;
  423. }
  424. .form-label {
  425. color: rgba(58, 57, 67, 1);
  426. font-family: DM Sans;
  427. font-size: 36rpx;
  428. font-weight: 500;
  429. line-height: 24px;
  430. letter-spacing: 0px;
  431. text-align: left;
  432. }
  433. .form-input {
  434. height: 100rpx;
  435. display: flex;
  436. justify-content: space-between;
  437. align-items: center;
  438. padding: 24rpx 20rpx;
  439. border-radius: 12rpx;
  440. box-shadow: 0px 8px 150px 0px rgba(0, 0, 0, 0.06);
  441. background: rgba(255, 255, 255, 1);
  442. margin-top: 20rpx;
  443. .input-text {
  444. color: rgba(97, 110, 124, 1);
  445. font-family: DM Sans;
  446. font-weight: 400;
  447. line-height: 20px;
  448. letter-spacing: 0px;
  449. text-align: left;
  450. font-size: 28rpx;
  451. }
  452. }
  453. }
  454. .salary-container {
  455. .salary-inputs {
  456. display: flex;
  457. align-items: center;
  458. margin: 20rpx 0 30rpx 0;
  459. .salary-input {
  460. display: flex;
  461. align-items: center;
  462. flex: 1;
  463. padding: 30rpx 20rpx;
  464. border-radius: 12rpx;
  465. box-shadow: 0px 8px 150px 0px rgba(0, 0, 0, 0.06);
  466. background: rgba(255, 255, 255, 1);
  467. .currency, .salary-field {
  468. color: rgba(97, 110, 124, 1);
  469. font-family: DM Sans;
  470. font-weight: 400;
  471. line-height: 20px;
  472. letter-spacing: 0px;
  473. text-align: left;
  474. font-size: 28rpx;
  475. }
  476. }
  477. .salary-input:first-child {
  478. margin-right: 50rpx;
  479. }
  480. .salary-separator {
  481. margin: 0 20rpx;
  482. color: rgba(153, 153, 153, 1);
  483. font-size: 28rpx;
  484. }
  485. }
  486. // .range-slider-container {
  487. // padding: 20rpx 10rpx;
  488. // }
  489. // .range-slider-track {
  490. // position: relative;
  491. // height: 6rpx;
  492. // background-color: #E5E5EA;
  493. // border-radius: 3rpx;
  494. // cursor: pointer;
  495. // }
  496. // .range-slider-progress {
  497. // position: absolute;
  498. // top: 0;
  499. // height: 100%;
  500. // background-color: #007AFF;
  501. // border-radius: 3rpx;
  502. // transition: all 0.1s ease;
  503. // }
  504. // .range-slider-thumb {
  505. // position: absolute;
  506. // top: 50%;
  507. // width: 40rpx;
  508. // height: 40rpx;
  509. // background-color: #007AFF;
  510. // border-radius: 50%;
  511. // border: 4rpx solid #ffffff;
  512. // box-shadow: 0 2rpx 8rpx rgba(0, 122, 255, 0.3);
  513. // transform: translate(-50%, -50%);
  514. // cursor: pointer;
  515. // transition: all 0.1s ease;
  516. // }
  517. // .range-slider-thumb:active {
  518. // transform: translate(-50%, -50%) scale(1.1);
  519. // box-shadow: 0 4rpx 12rpx rgba(0, 122, 255, 0.4);
  520. // }
  521. }
  522. // .job-type-container {
  523. // display: flex;
  524. // gap: 50rpx;
  525. // margin-top: 20rpx;
  526. // .job-type-btn {
  527. // flex: 1;
  528. // padding: 24rpx 20rpx;
  529. // border: 1rpx solid #E5E5EA;
  530. // border-radius: 42rpx;
  531. // text-align: center;
  532. // text {
  533. // color: rgba(97, 110, 124, 1);
  534. // font-size: 28rpx;
  535. // }
  536. // &.active {
  537. // background: #016BF6;
  538. // text {
  539. // color: #FFFFFF;
  540. // font-weight: 400;
  541. // }
  542. // }
  543. // }
  544. // }
  545. // .footer {
  546. // position: fixed;
  547. // left: 0;
  548. // right: 0;
  549. // bottom: 0;
  550. // padding: 0 40rpx;
  551. // box-shadow: 0px -4px 16px 0px rgba(0, 0, 0, 0.04);
  552. // background-color: #fff;
  553. // .submit-btn {
  554. // background: linear-gradient(90.00deg, rgba(13, 39, 247, 1),rgba(19, 193, 234, 1));
  555. // }
  556. // }
  557. </style>