jobSkills.vue 13 KB

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