addExpectation.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603
  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.minSalary?.indexOf('.') > -1 || this.maxSalary?.indexOf('.') > -1) {
  306. uni.showToast({ title: "期望薪酬请输入整数", icon: "none" });
  307. return
  308. }
  309. if (!this.industry) {
  310. uni.showToast({ title: "请选择跨境标签", icon: "none" });
  311. return;
  312. }
  313. if(this.isWork)
  314. return
  315. this.isWork=true
  316. let data={
  317. intentionId:this.id,
  318. ruleClassifyId:this.jobId,
  319. ruleClassifyName:this.jobTitle,
  320. citys:this.city,
  321. salaryRange:this.minSalary+'-'+this.maxSalary,
  322. postType:this.jobType === 'fulltime'?'全职':'兼职',
  323. industry:this.industry,
  324. "createTime": "",
  325. "industryId": 201,
  326. "industryOneId": 200,
  327. "classifyOneId": 0,
  328. "classifyTwoId": 0,
  329. "isDefault": 1
  330. }
  331. uni.showLoading({ title: "提交中..." });
  332. this.$Request.postJson("/app/intention/saveUpdate", data).then((res) => {
  333. this.isWork=false
  334. this.industry=''
  335. uni.hideLoading();
  336. if (res.code == 0) {
  337. uni.showToast({ title: "保存成功", icon: "none" });
  338. // 实际开发中可以在这里添加跳转逻辑
  339. uni.$emit('updateResume')
  340. uni.$emit('updateIndexType')
  341. setTimeout(() => {
  342. uni.navigateBack()
  343. }, 1000);
  344. } else {
  345. uni.showToast({
  346. title: res.msg,
  347. icon: "none",
  348. });
  349. }
  350. });
  351. },
  352. },
  353. mounted() {
  354. // // 初始化滑块轨道宽度
  355. // this.$nextTick(() => {
  356. // this.getTrackWidth()
  357. // })
  358. },
  359. onLoad(options) {
  360. // 获取状态栏高度
  361. let systemInfo = uni.getSystemInfoSync();
  362. this.statusBarHeight = systemInfo.statusBarHeight || 0;
  363. this.id=options&&options.id?options.id:""
  364. // 监听选择结果
  365. uni.$on('jobs', (data) => {
  366. this.jobTitle = data.ruleClassifyName
  367. this.jobId = data.ruleClassifyId
  368. })
  369. uni.$on('city', (data) => {
  370. console.log(data)
  371. this.city = data.city
  372. })
  373. /* uni.$on('industry', (data) => {
  374. this.industry = data.industry
  375. }) */
  376. // 监听技能设置更新
  377. uni.$on('preferenceUpdated', (data) => {
  378. this.industry=data.preferences.join('/')
  379. })
  380. if(this.id!=0&&this.id!='')
  381. this.getData()
  382. },
  383. onUnload() {
  384. // 移除监听
  385. uni.$off('jobs')
  386. uni.$off('city')
  387. /* uni.$off('industry') */
  388. uni.$off('preferenceUpdated')
  389. }
  390. }
  391. </script>
  392. <style lang="scss" scoped>
  393. @import '../../common.scss';
  394. .add-expectation {
  395. min-height: 100vh;
  396. }
  397. .nav-bar {
  398. display: flex;
  399. align-items: center;
  400. justify-content: space-between;
  401. margin-bottom: 30rpx;
  402. padding: 0 40rpx;
  403. .nav-left {
  404. display: flex;
  405. align-items: center;
  406. justify-content: center;
  407. }
  408. .nav-title {
  409. color: rgba(51, 51, 51, 1);
  410. font-family: DM Sans;
  411. font-size: 32rpx;
  412. font-weight: 700;
  413. line-height: 26px;
  414. text-align: center;
  415. }
  416. }
  417. .form-container {
  418. background: #ffffff;
  419. border-radius: 20rpx;
  420. margin-top: 30rpx;
  421. padding: 0 40rpx;
  422. }
  423. .form-item {
  424. margin-bottom: 40rpx;
  425. &:last-child {
  426. margin-bottom: 0;
  427. }
  428. .form-label {
  429. color: rgba(58, 57, 67, 1);
  430. font-family: DM Sans;
  431. font-size: 36rpx;
  432. font-weight: 500;
  433. line-height: 24px;
  434. letter-spacing: 0px;
  435. text-align: left;
  436. }
  437. .form-input {
  438. height: 100rpx;
  439. display: flex;
  440. justify-content: space-between;
  441. align-items: center;
  442. padding: 24rpx 20rpx;
  443. border-radius: 12rpx;
  444. box-shadow: 0px 8px 150px 0px rgba(0, 0, 0, 0.06);
  445. background: rgba(255, 255, 255, 1);
  446. margin-top: 20rpx;
  447. .input-text {
  448. color: rgba(97, 110, 124, 1);
  449. font-family: DM Sans;
  450. font-weight: 400;
  451. line-height: 20px;
  452. letter-spacing: 0px;
  453. text-align: left;
  454. font-size: 28rpx;
  455. }
  456. }
  457. }
  458. .salary-container {
  459. .salary-inputs {
  460. display: flex;
  461. align-items: center;
  462. margin: 20rpx 0 30rpx 0;
  463. .salary-input {
  464. display: flex;
  465. align-items: center;
  466. flex: 1;
  467. padding: 30rpx 20rpx;
  468. border-radius: 12rpx;
  469. box-shadow: 0px 8px 150px 0px rgba(0, 0, 0, 0.06);
  470. background: rgba(255, 255, 255, 1);
  471. .currency, .salary-field {
  472. color: rgba(97, 110, 124, 1);
  473. font-family: DM Sans;
  474. font-weight: 400;
  475. line-height: 20px;
  476. letter-spacing: 0px;
  477. text-align: left;
  478. font-size: 28rpx;
  479. }
  480. }
  481. .salary-input:first-child {
  482. margin-right: 50rpx;
  483. }
  484. .salary-separator {
  485. margin: 0 20rpx;
  486. color: rgba(153, 153, 153, 1);
  487. font-size: 28rpx;
  488. }
  489. }
  490. // .range-slider-container {
  491. // padding: 20rpx 10rpx;
  492. // }
  493. // .range-slider-track {
  494. // position: relative;
  495. // height: 6rpx;
  496. // background-color: #E5E5EA;
  497. // border-radius: 3rpx;
  498. // cursor: pointer;
  499. // }
  500. // .range-slider-progress {
  501. // position: absolute;
  502. // top: 0;
  503. // height: 100%;
  504. // background-color: #007AFF;
  505. // border-radius: 3rpx;
  506. // transition: all 0.1s ease;
  507. // }
  508. // .range-slider-thumb {
  509. // position: absolute;
  510. // top: 50%;
  511. // width: 40rpx;
  512. // height: 40rpx;
  513. // background-color: #007AFF;
  514. // border-radius: 50%;
  515. // border: 4rpx solid #ffffff;
  516. // box-shadow: 0 2rpx 8rpx rgba(0, 122, 255, 0.3);
  517. // transform: translate(-50%, -50%);
  518. // cursor: pointer;
  519. // transition: all 0.1s ease;
  520. // }
  521. // .range-slider-thumb:active {
  522. // transform: translate(-50%, -50%) scale(1.1);
  523. // box-shadow: 0 4rpx 12rpx rgba(0, 122, 255, 0.4);
  524. // }
  525. }
  526. // .job-type-container {
  527. // display: flex;
  528. // gap: 50rpx;
  529. // margin-top: 20rpx;
  530. // .job-type-btn {
  531. // flex: 1;
  532. // padding: 24rpx 20rpx;
  533. // border: 1rpx solid #E5E5EA;
  534. // border-radius: 42rpx;
  535. // text-align: center;
  536. // text {
  537. // color: rgba(97, 110, 124, 1);
  538. // font-size: 28rpx;
  539. // }
  540. // &.active {
  541. // background: #016BF6;
  542. // text {
  543. // color: #FFFFFF;
  544. // font-weight: 400;
  545. // }
  546. // }
  547. // }
  548. // }
  549. // .footer {
  550. // position: fixed;
  551. // left: 0;
  552. // right: 0;
  553. // bottom: 0;
  554. // padding: 0 40rpx;
  555. // box-shadow: 0px -4px 16px 0px rgba(0, 0, 0, 0.04);
  556. // background-color: #fff;
  557. // .submit-btn {
  558. // background: linear-gradient(90.00deg, rgba(13, 39, 247, 1),rgba(19, 193, 234, 1));
  559. // }
  560. // }
  561. </style>