jobSkills.vue 12 KB

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