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">
  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. }
  87. },
  88. computed: {
  89. // 只展示自定义标签(userInfo个人信息、onlineResume在线简历)
  90. onlyShowCustomTag() {
  91. if (this.fromPage == 'onlineResume' || this.fromPage == 'userInfo') {
  92. return true;
  93. }
  94. return false;
  95. }
  96. },
  97. onLoad(options) {
  98. if(options.ruleClassifyId){
  99. this.ruleClassifyId = options.ruleClassifyId;
  100. }
  101. // 保存tag参数
  102. if(options.tag){
  103. this.tagParam = decodeURIComponent(options.tag)
  104. }
  105. // 获取状态栏高度
  106. let systemInfo = uni.getSystemInfoSync();
  107. this.statusBarHeight = systemInfo.statusBarHeight || 0;
  108. if (options && options.jobTitle) {
  109. this.jobTitle = decodeURIComponent(options.jobTitle)
  110. }
  111. if (options && options.skill) {
  112. if (options && options.jobId) {
  113. this.jobId = options.jobId
  114. }
  115. if (options && options.skill)
  116. this.selectedOperation = JSON.parse(decodeURIComponent(options.skill))
  117. }
  118. this.getData()
  119. set = options && options.set ? options.set : 0
  120. // 判断从哪个页面进入 onlineResume在线简历、userInfo个人信息
  121. if (options.from) {
  122. this.fromPage = options.from
  123. }
  124. },
  125. methods: {
  126. goBack() {
  127. uni.navigateBack()
  128. },
  129. getData() {
  130. let data = {
  131. ruleClassifyId: this.jobId || this.ruleClassifyId
  132. }
  133. var action = this.jobId == '' || this.jobId == 0 ? '/app/userFirst/selectSkill' :
  134. '/app/userFirst/getPostSkill'
  135. if(this.ruleClassifyId){
  136. action = '/app/userFirst/getPostSkill'
  137. }
  138. this.$Request.getT(action, data).then(res => {
  139. if (res.code == 0) {
  140. this.operationOptions = res.data
  141. if (this.onlyShowCustomTag) {
  142. const tags = res.data.map(tag => tag.skillName)
  143. this.setCustomTags(tags)
  144. } else if (this.tagParam) {
  145. // 数据加载完成后处理标签回显
  146. this.handleTagDisplay(this.tagParam)
  147. }
  148. }
  149. })
  150. },
  151. // 设置自定义回显
  152. setCustomTags(tags) {
  153. tags.forEach(tag => {
  154. this.customTags.push(tag)
  155. })
  156. },
  157. handleTagDisplay(tagString) {
  158. const tagArray = tagString
  159. .split(',')
  160. .map(tag => tag.trim())
  161. .filter(tag => tag && tag !== '不限');
  162. // 清空当前选中的标签
  163. this.selectedOperation = [];
  164. this.customTags = [];
  165. // 回显系统标签
  166. this.operationOptions.forEach(category => {
  167. if (category.childrenList) {
  168. category.childrenList.forEach(item => {
  169. if (tagArray.includes(item.postSkillName)) {
  170. this.selectedOperation.push(item.postSkillName);
  171. }
  172. });
  173. }
  174. });
  175. // 回显自定义标签
  176. tagArray.forEach(tag => {
  177. const isSystemTag = this.operationOptions.some(category =>
  178. category.childrenList.some(item => item.postSkillName === tag)
  179. );
  180. if (!isSystemTag && this.customTags.length < 5) {
  181. this.customTags.push(tag);
  182. }
  183. });
  184. },
  185. toggleOperation(pIndex, name) {
  186. const parent = this.operationOptions[pIndex];
  187. // 当前分类下已选中的标签(排除不限)
  188. const selectedInGroup = parent.childrenList
  189. .filter(item => item.postSkillName !== '不限' && this.selectedOperation.includes(item.postSkillName));
  190. const index = this.selectedOperation.indexOf(name);
  191. if (index === -1) {
  192. if (selectedInGroup.length >= 5) {
  193. uni.showToast({
  194. title: '每个分类最多选择5个标签',
  195. icon: 'none'
  196. });
  197. return;
  198. }
  199. this.selectedOperation.push(name);
  200. } else {
  201. this.selectedOperation.splice(index, 1);
  202. }
  203. },
  204. showAddTagModal() {
  205. this.showAddTag = true
  206. this.newTagName = ''
  207. },
  208. cancelAddTag() {
  209. this.showAddTag = false
  210. this.newTagName = ''
  211. },
  212. addCustomTag() {
  213. if (this.newTagName.trim()) {
  214. let realLength = this.customTags.filter(item => item !== '不限').length;
  215. if (realLength < 5) {
  216. this.customTags.push(this.newTagName.trim())
  217. this.showAddTag = false
  218. this.newTagName = ''
  219. } else {
  220. uni.showToast({
  221. title: '最多添加5个自定义标签',
  222. icon: 'none'
  223. })
  224. }
  225. } else {
  226. uni.showToast({
  227. title: '请输入标签名称',
  228. icon: 'none'
  229. })
  230. }
  231. },
  232. removeCustomTag(index) {
  233. this.customTags.splice(index, 1)
  234. },
  235. confirmSelection() {
  236. // 合并选择的标签和自定义标签并回传
  237. const allSelectedTags = this.onlyShowCustomTag ? this.customTags : [...this.selectedOperation, ...this.customTags]
  238. // 触发事件通知上一页面
  239. uni.$emit('skillsUpdated', {
  240. jobTitle: this.jobTitle,
  241. selectedTags: allSelectedTags, // 所有选中的标签(含系统和自定义)
  242. systemTags: this.selectedOperation, // 系统标签
  243. customTags: this.customTags, // 自定义标签
  244. set
  245. })
  246. uni.navigateBack({
  247. delta: 1
  248. })
  249. }
  250. }
  251. }
  252. </script>
  253. <style lang="scss" scoped>
  254. @import '@/common.scss';
  255. .job-skills {
  256. height: 100vh;
  257. background: #fff;
  258. display: flex;
  259. flex-direction: column;
  260. padding: 0 40rpx 200rpx;
  261. }
  262. .navbar-content {
  263. display: flex;
  264. align-items: center;
  265. justify-content: space-between;
  266. height: 88rpx;
  267. }
  268. .nav-left,
  269. .nav-right {
  270. width: 60rpx;
  271. height: 60rpx;
  272. display: flex;
  273. align-items: center;
  274. justify-content: center;
  275. }
  276. .nav-title {
  277. color: rgba(51, 51, 51, 1);
  278. font-family: DM Sans;
  279. font-size: 36rpx;
  280. font-weight: 700;
  281. line-height: 26px;
  282. letter-spacing: 0px;
  283. text-align: center;
  284. }
  285. .main-content {
  286. margin-top: 20rpx;
  287. flex: 1;
  288. overflow: auto;
  289. .tip {
  290. padding: 72rpx 0 32rpx;
  291. color: #666;
  292. }
  293. }
  294. .job-title {
  295. color: rgba(51, 51, 51, 1);
  296. font-family: DM Sans;
  297. font-size: 52rpx;
  298. font-weight: 700;
  299. line-height: 30px;
  300. letter-spacing: 0px;
  301. text-align: left;
  302. margin-bottom: 30rpx;
  303. }
  304. .description {
  305. margin: 20rpx 0 40rpx 0;
  306. color: rgba(102, 102, 102, 1);
  307. font-family: DM Sans;
  308. font-size: 28rpx;
  309. font-weight: 400;
  310. letter-spacing: 0px;
  311. text-align: left;
  312. line-height: 1.5;
  313. }
  314. .skills-section {
  315. margin-bottom: 50rpx;
  316. }
  317. .section-title {
  318. color: rgba(34, 37, 42, 1);
  319. font-family: DM Sans;
  320. font-size: 36rpx;
  321. font-weight: 500;
  322. line-height: 24px;
  323. letter-spacing: 0px;
  324. text-align: left;
  325. margin-bottom: 24rpx;
  326. padding-left: 4rpx;
  327. }
  328. .skills-grid {
  329. display: flex;
  330. flex-wrap: wrap;
  331. gap: 20rpx;
  332. }
  333. .skill-tag {
  334. padding: 16rpx 24rpx;
  335. background: #F7F8FA;
  336. border: 1rpx solid #E5E5EA;
  337. border-radius: 16rpx;
  338. transition: all 0.2s ease;
  339. display: flex;
  340. align-items: center;
  341. justify-content: center;
  342. cursor: pointer;
  343. text {
  344. font-size: 26rpx;
  345. color: rgba(102, 102, 102, 1);
  346. font-weight: 400;
  347. text-align: center;
  348. line-height: 1.2;
  349. }
  350. &:hover {
  351. background: rgba(153, 196, 250, 0.2);
  352. border-color: rgba(1, 107, 246, 0.3);
  353. }
  354. &.active {
  355. background: rgba(1, 107, 246, 0.1);
  356. border: 1rpx solid rgba(1, 107, 246, 1);
  357. box-shadow: 0 4rpx 12rpx rgba(1, 107, 246, 0.15);
  358. text {
  359. color: rgba(1, 107, 246, 1);
  360. font-weight: 500;
  361. }
  362. }
  363. &:active {
  364. transform: scale(0.96);
  365. }
  366. }
  367. .custom-tags {
  368. display: flex;
  369. flex-wrap: wrap;
  370. gap: 20rpx;
  371. }
  372. .custom-tag {
  373. padding: 14rpx 20rpx;
  374. background: rgba(153, 196, 250, 0.4);
  375. border: 1rpx solid rgba(1, 107, 246, 1);
  376. border-radius: 16rpx;
  377. display: flex;
  378. align-items: center;
  379. gap: 10rpx;
  380. cursor: pointer;
  381. transition: all 0.2s ease;
  382. text {
  383. font-size: 24rpx;
  384. color: rgba(1, 107, 246, 1);
  385. font-weight: 400;
  386. }
  387. &:hover {
  388. background: rgba(153, 196, 250, 0.6);
  389. }
  390. &:active {
  391. transform: scale(0.96);
  392. }
  393. }
  394. .add-tag {
  395. padding: 14rpx 20rpx;
  396. background: #F7F8FA;
  397. border: 1rpx dashed #E5E5EA;
  398. border-radius: 16rpx;
  399. display: flex;
  400. align-items: center;
  401. gap: 10rpx;
  402. cursor: pointer;
  403. transition: all 0.2s ease;
  404. text {
  405. font-size: 24rpx;
  406. color: rgba(102, 102, 102, 1);
  407. font-weight: 400;
  408. }
  409. &:hover {
  410. background: #f0f0f0;
  411. border-color: #d9d9d9;
  412. }
  413. &:active {
  414. transform: scale(0.96);
  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>