jobSkills.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536
  1. <template>
  2. <view class="job-skills">
  3. <!-- 自定义导航栏 -->
  4. <view class="custom-navbar" :style="{ paddingTop: (12 + statusBarHeight) + 'px' }">
  5. <view class="navbar-content">
  6. <view class="nav-left" @click="goBack">
  7. <u-icon name="close" color="#333" size="32"></u-icon>
  8. </view>
  9. <view class="nav-title">{{this.jobId==0||this.jobId==''?'我的':'岗位'}}跨境标签</view>
  10. <view class="nav-right"></view>
  11. </view>
  12. </view>
  13. <!-- 主要内容 -->
  14. <view class="main-content">
  15. <view class="job-title">{{ jobTitle }}-跨境标签</view>
  16. <view class="description">根据你的偏好设置,为你推荐更匹配的职位</view>
  17. <!-- 运营方向 -->
  18. <view class="skills-section" v-for="(it, ind) in operationOptions" :key="ind">
  19. <view class="section-title">{{it.postSkillName}}</view>
  20. <view class="skills-grid">
  21. <view v-for="(item, index) in it.childrenList" :key="index" class="skill-tag"
  22. :class="{ active: selectedOperation.includes(item.postSkillName) }"
  23. @click="toggleOperation(ind,item.postSkillName)">
  24. <text>{{ item.postSkillName }}</text>
  25. </view>
  26. </view>
  27. </view>
  28. <!-- 自定义标签 -->
  29. <view class="skills-section">
  30. <view class="section-title">自定义标签</view>
  31. <!-- 自定义标签区域 -->
  32. <view class="custom-tags">
  33. <view v-for="(item, index) in customTags" :key="index" class="custom-tag"
  34. @click="removeCustomTag(index)">
  35. <text>{{ item }}</text>
  36. <u-icon name="close" color="#007AFF" size="18"></u-icon>
  37. </view>
  38. <view class="add-tag" @click="showAddTagModal">
  39. <text>添加标签</text>
  40. <u-icon name="plus" color="#333" size="18"></u-icon>
  41. </view>
  42. </view>
  43. </view>
  44. </view>
  45. <!-- 底部确定按钮 -->
  46. <view class="bottom-btn-container">
  47. <view class="confirm-btn" @click="confirmSelection">
  48. <text>确定</text>
  49. </view>
  50. </view>
  51. <!-- 添加标签弹窗 -->
  52. <u-popup v-model="showAddTag" mode="center" border-radius="24" width="80%">
  53. <view class="add-tag-popup">
  54. <view class="popup-title">添加自定义标签</view>
  55. <view class="popup-content">
  56. <input v-model="newTagName" placeholder="请输入标签名称(不要带上, ; 这种字符)" class="tag-input" maxlength="10" />
  57. </view>
  58. <view class="popup-buttons">
  59. <view class="popup-btn cancel-btn" @click="cancelAddTag">取消</view>
  60. <view class="popup-btn confirm-btn" @click="addCustomTag">确定</view>
  61. </view>
  62. </view>
  63. </u-popup>
  64. </view>
  65. </template>
  66. <script>
  67. let set = 0
  68. export default {
  69. data() {
  70. return {
  71. statusBarHeight: 0, // 状态栏高度
  72. jobTitle: '',
  73. jobId: '',
  74. showAddTag: false,
  75. newTagName: '',
  76. selectedOperation: [],
  77. customTags: [],
  78. operationOptions: [],
  79. tagParam: '' ,// 新增:保存传入的tag参数
  80. ruleClassifyId:''
  81. }
  82. },
  83. onLoad(options) {
  84. if(options.ruleClassifyId){
  85. this.ruleClassifyId = options.ruleClassifyId;
  86. }
  87. // 保存tag参数
  88. if(options.tag){
  89. this.tagParam = decodeURIComponent(options.tag)
  90. }
  91. // 获取状态栏高度
  92. let systemInfo = uni.getSystemInfoSync();
  93. this.statusBarHeight = systemInfo.statusBarHeight || 0;
  94. if (options && options.jobTitle) {
  95. this.jobTitle = decodeURIComponent(options.jobTitle)
  96. }
  97. if (options && options.skill) {
  98. if (options && options.jobId) {
  99. this.jobId = options.jobId
  100. }
  101. if (options && options.skill)
  102. this.selectedOperation = JSON.parse(decodeURIComponent(options.skill))
  103. }
  104. this.getData()
  105. set = options && options.set ? options.set : 0
  106. },
  107. methods: {
  108. goBack() {
  109. uni.navigateBack()
  110. },
  111. getData() {
  112. let data = {
  113. ruleClassifyId: this.jobId || this.ruleClassifyId
  114. }
  115. var action = this.jobId == '' || this.jobId == 0 ? '/app/userFirst/selectSkill' :
  116. '/app/userFirst/getPostSkill'
  117. if(this.ruleClassifyId){
  118. action = '/app/userFirst/getPostSkill'
  119. }
  120. this.$Request.getT(action, data).then(res => {
  121. if (res.code == 0) {
  122. this.operationOptions = res.data
  123. // 数据加载完成后处理标签回显
  124. if (this.tagParam) {
  125. this.handleTagDisplay(this.tagParam)
  126. }
  127. }
  128. })
  129. },
  130. handleTagDisplay(tagString) {
  131. const tagArray = tagString
  132. .split(',')
  133. .map(tag => tag.trim())
  134. .filter(tag => tag && tag !== '不限');
  135. // 清空当前选中的标签
  136. this.selectedOperation = [];
  137. this.customTags = [];
  138. // 回显系统标签
  139. this.operationOptions.forEach(category => {
  140. if (category.childrenList) {
  141. category.childrenList.forEach(item => {
  142. if (tagArray.includes(item.postSkillName)) {
  143. this.selectedOperation.push(item.postSkillName);
  144. }
  145. });
  146. }
  147. });
  148. // 回显自定义标签
  149. tagArray.forEach(tag => {
  150. const isSystemTag = this.operationOptions.some(category =>
  151. category.childrenList.some(item => item.postSkillName === tag)
  152. );
  153. if (!isSystemTag && this.customTags.length < 5) {
  154. this.customTags.push(tag);
  155. }
  156. });
  157. },
  158. toggleOperation(pIndex, name) {
  159. const parent = this.operationOptions[pIndex];
  160. // 当前分类下已选中的标签(排除不限)
  161. const selectedInGroup = parent.childrenList
  162. .filter(item => item.postSkillName !== '不限' && this.selectedOperation.includes(item.postSkillName));
  163. const index = this.selectedOperation.indexOf(name);
  164. if (index === -1) {
  165. if (selectedInGroup.length >= 5) {
  166. uni.showToast({
  167. title: '每个分类最多选择5个标签',
  168. icon: 'none'
  169. });
  170. return;
  171. }
  172. this.selectedOperation.push(name);
  173. } else {
  174. this.selectedOperation.splice(index, 1);
  175. }
  176. },
  177. showAddTagModal() {
  178. this.showAddTag = true
  179. this.newTagName = ''
  180. },
  181. cancelAddTag() {
  182. this.showAddTag = false
  183. this.newTagName = ''
  184. },
  185. addCustomTag() {
  186. if (this.newTagName.trim()) {
  187. let realLength = this.customTags.filter(item => item !== '不限').length;
  188. if (realLength < 5) {
  189. this.customTags.push(this.newTagName.trim())
  190. this.showAddTag = false
  191. this.newTagName = ''
  192. } else {
  193. uni.showToast({
  194. title: '最多添加5个自定义标签',
  195. icon: 'none'
  196. })
  197. }
  198. } else {
  199. uni.showToast({
  200. title: '请输入标签名称',
  201. icon: 'none'
  202. })
  203. }
  204. },
  205. removeCustomTag(index) {
  206. this.customTags.splice(index, 1)
  207. },
  208. confirmSelection() {
  209. // 合并选择的标签和自定义标签并回传
  210. const allSelectedTags = [...this.selectedOperation, ...this.customTags]
  211. // 触发事件通知上一页面
  212. uni.$emit('skillsUpdated', {
  213. jobTitle: this.jobTitle,
  214. selectedTags: allSelectedTags, // 所有选中的标签(含系统和自定义)
  215. systemTags: this.selectedOperation, // 系统标签
  216. customTags: this.customTags, // 自定义标签
  217. set
  218. })
  219. uni.navigateBack({
  220. delta: 1
  221. })
  222. }
  223. }
  224. }
  225. </script>
  226. <style lang="scss" scoped>
  227. .job-skills {
  228. height: 100vh;
  229. background: #fff;
  230. display: flex;
  231. flex-direction: column;
  232. padding: 0 40rpx;
  233. }
  234. .navbar-content {
  235. display: flex;
  236. align-items: center;
  237. justify-content: space-between;
  238. height: 88rpx;
  239. }
  240. .nav-left,
  241. .nav-right {
  242. width: 60rpx;
  243. height: 60rpx;
  244. display: flex;
  245. align-items: center;
  246. justify-content: center;
  247. }
  248. .nav-title {
  249. color: rgba(51, 51, 51, 1);
  250. font-family: DM Sans;
  251. font-size: 36rpx;
  252. font-weight: 700;
  253. line-height: 26px;
  254. letter-spacing: 0px;
  255. text-align: center;
  256. }
  257. .main-content {
  258. margin-top: 20rpx;
  259. flex: 1;
  260. overflow: auto;
  261. }
  262. .job-title {
  263. color: rgba(51, 51, 51, 1);
  264. font-family: DM Sans;
  265. font-size: 52rpx;
  266. font-weight: 700;
  267. line-height: 30px;
  268. letter-spacing: 0px;
  269. text-align: left;
  270. margin-bottom: 30rpx;
  271. }
  272. .description {
  273. margin: 20rpx 0 40rpx 0;
  274. color: rgba(102, 102, 102, 1);
  275. font-family: DM Sans;
  276. font-size: 28rpx;
  277. font-weight: 400;
  278. letter-spacing: 0px;
  279. text-align: left;
  280. line-height: 1.5;
  281. }
  282. .skills-section {
  283. margin-bottom: 50rpx;
  284. }
  285. .section-title {
  286. color: rgba(34, 37, 42, 1);
  287. font-family: DM Sans;
  288. font-size: 36rpx;
  289. font-weight: 500;
  290. line-height: 24px;
  291. letter-spacing: 0px;
  292. text-align: left;
  293. margin-bottom: 24rpx;
  294. padding-left: 4rpx;
  295. }
  296. .skills-grid {
  297. display: flex;
  298. flex-wrap: wrap;
  299. gap: 20rpx;
  300. }
  301. .skill-tag {
  302. padding: 16rpx 24rpx;
  303. background: #F7F8FA;
  304. border: 1rpx solid #E5E5EA;
  305. border-radius: 16rpx;
  306. transition: all 0.2s ease;
  307. display: flex;
  308. align-items: center;
  309. justify-content: center;
  310. cursor: pointer;
  311. text {
  312. font-size: 26rpx;
  313. color: rgba(102, 102, 102, 1);
  314. font-weight: 400;
  315. text-align: center;
  316. line-height: 1.2;
  317. }
  318. &:hover {
  319. background: rgba(153, 196, 250, 0.2);
  320. border-color: rgba(1, 107, 246, 0.3);
  321. }
  322. &.active {
  323. background: rgba(1, 107, 246, 0.1);
  324. border: 1rpx solid rgba(1, 107, 246, 1);
  325. box-shadow: 0 4rpx 12rpx rgba(1, 107, 246, 0.15);
  326. text {
  327. color: rgba(1, 107, 246, 1);
  328. font-weight: 500;
  329. }
  330. }
  331. &:active {
  332. transform: scale(0.96);
  333. }
  334. }
  335. .custom-tags {
  336. display: flex;
  337. flex-wrap: wrap;
  338. gap: 20rpx;
  339. }
  340. .custom-tag {
  341. padding: 14rpx 20rpx;
  342. background: rgba(153, 196, 250, 0.4);
  343. border: 1rpx solid rgba(1, 107, 246, 1);
  344. border-radius: 16rpx;
  345. display: flex;
  346. align-items: center;
  347. gap: 10rpx;
  348. cursor: pointer;
  349. transition: all 0.2s ease;
  350. text {
  351. font-size: 24rpx;
  352. color: rgba(1, 107, 246, 1);
  353. font-weight: 400;
  354. }
  355. &:hover {
  356. background: rgba(153, 196, 250, 0.6);
  357. }
  358. &:active {
  359. transform: scale(0.96);
  360. }
  361. }
  362. .add-tag {
  363. padding: 14rpx 20rpx;
  364. background: #F7F8FA;
  365. border: 1rpx dashed #E5E5EA;
  366. border-radius: 16rpx;
  367. display: flex;
  368. align-items: center;
  369. gap: 10rpx;
  370. cursor: pointer;
  371. transition: all 0.2s ease;
  372. text {
  373. font-size: 24rpx;
  374. color: rgba(102, 102, 102, 1);
  375. font-weight: 400;
  376. }
  377. &:hover {
  378. background: #f0f0f0;
  379. border-color: #d9d9d9;
  380. }
  381. &:active {
  382. transform: scale(0.96);
  383. }
  384. }
  385. .bottom-btn-container {
  386. // position: fixed;
  387. // bottom: 0;
  388. // left: 0;
  389. // right: 0;
  390. padding: 32rpx;
  391. background: #fff;
  392. border-top: 1rpx solid #f0f0f0;
  393. z-index: 10;
  394. }
  395. .confirm-btn {
  396. width: 100%;
  397. height: 96rpx;
  398. background: linear-gradient(90deg, #007AFF 0%, #2DB0F0 100%);
  399. border-radius: 48rpx;
  400. display: flex;
  401. align-items: center;
  402. justify-content: center;
  403. box-shadow: 0 6rpx 16rpx rgba(0, 122, 255, 0.2);
  404. transition: all 0.2s ease;
  405. cursor: pointer;
  406. text {
  407. font-size: 34rpx;
  408. font-weight: 600;
  409. color: #fff;
  410. }
  411. &:active {
  412. background: linear-gradient(90deg, #0056CC 0%, #4A9FE7 100%);
  413. transform: scale(0.98);
  414. box-shadow: 0 4rpx 12rpx rgba(0, 122, 255, 0.15);
  415. }
  416. }
  417. // 添加标签弹窗样式
  418. .add-tag-popup {
  419. background: #fff;
  420. border-radius: 24rpx;
  421. padding: 48rpx 40rpx;
  422. width: 100%;
  423. .popup-title {
  424. color: rgba(34, 37, 42, 1);
  425. font-family: DM Sans;
  426. font-size: 36rpx;
  427. font-weight: 500;
  428. line-height: 24px;
  429. text-align: center;
  430. margin-bottom: 36rpx;
  431. }
  432. .popup-content {
  433. margin-bottom: 40rpx;
  434. .tag-input {
  435. width: 100%;
  436. height: 90rpx;
  437. padding: 0 24rpx;
  438. border: 1rpx solid #E5E5EA;
  439. border-radius: 16rpx;
  440. font-size: 28rpx;
  441. color: rgba(34, 37, 42, 1);
  442. background: #F7F8FA;
  443. box-sizing: border-box;
  444. }
  445. .tag-input::placeholder {
  446. color: #C9CDD4;
  447. }
  448. }
  449. .popup-buttons {
  450. display: flex;
  451. gap: 24rpx;
  452. .popup-btn {
  453. flex: 1;
  454. height: 88rpx;
  455. border-radius: 16rpx;
  456. display: flex;
  457. align-items: center;
  458. justify-content: center;
  459. font-size: 30rpx;
  460. font-weight: 500;
  461. transition: all 0.2s ease;
  462. cursor: pointer;
  463. }
  464. .cancel-btn {
  465. background: #F7F8FA;
  466. color: rgba(102, 102, 102, 1);
  467. &:active {
  468. background: #eaeaea;
  469. }
  470. }
  471. .confirm-btn {
  472. background: #007AFF;
  473. color: #fff;
  474. &:active {
  475. background: #0056CC;
  476. }
  477. }
  478. }
  479. }
  480. </style>