preferenceSetting.vue 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305
  1. <template>
  2. <view class="preference-setting">
  3. <view class="container">
  4. <!-- 自定义导航栏 -->
  5. <view class="custom-navbar" :style="{ paddingTop: (12 + statusBarHeight) + 'px' }">
  6. <view class="navbar-content">
  7. <view class="nav-left" @click="goBack">
  8. <u-icon name="close" color="#333" size="32"></u-icon>
  9. </view>
  10. <view class="nav-title">跨境职业标签</view>
  11. <view class="nav-right"></view>
  12. </view>
  13. </view>
  14. <!-- 主要内容 -->
  15. <view class="main-content">
  16. <view class="job-title">{{ jobTitle }}-职位偏好</view>
  17. <view class="description">根据你的偏好设置,为你推荐更匹配的职位</view>
  18. <view class="preference-section">
  19. <view class="section-title">请选择你的从事偏好</view>
  20. <!-- 偏好标签网格 -->
  21. <view class="preference-grid">
  22. <view v-for="(parent, pIndex) in preferenceOptions" :key="pIndex" class="preference-group">
  23. <!-- 一级标题 -->
  24. <view class="preference-title">
  25. <text>{{ parent.postSkillName }}</text>
  26. </view>
  27. <!-- 二级可选项 -->
  28. <view class="preference-children">
  29. <view v-for="(child, cIndex) in parent.childrenList" :key="cIndex" class="preference-tag"
  30. :class="{ active: selectedPreferences.includes(child.postSkillName) }"
  31. @click="togglePreference(pIndex,child.postSkillName)">
  32. <text>{{ child.postSkillName }}</text>
  33. </view>
  34. </view>
  35. </view>
  36. </view>
  37. </view>
  38. </view>
  39. </view>
  40. <!-- 底部确定按钮 -->
  41. <view class="button-section">
  42. <view class="submit-btn" @click="confirmSelection">确定</view>
  43. </view>
  44. </view>
  45. </template>
  46. <script>
  47. var set = 0
  48. export default {
  49. data() {
  50. return {
  51. statusBarHeight: 0, // 状态栏高度
  52. jobTitle: '岗位',
  53. jobId: '',
  54. selectedPreferences: [],
  55. preferenceOptions: []
  56. }
  57. },
  58. onLoad(options) {
  59. // 获取状态栏高度
  60. let systemInfo = uni.getSystemInfoSync();
  61. this.statusBarHeight = systemInfo.statusBarHeight || 0;
  62. if (options && options.jobTitle) {
  63. this.jobTitle = decodeURIComponent(options.jobTitle)
  64. }
  65. if (options && options.jobId) {
  66. this.jobId = options.jobId
  67. }
  68. if (options && options.selectedPreferences)
  69. this.selectedPreferences = JSON.parse(decodeURIComponent(options.selectedPreferences))
  70. this.getData()
  71. set = options && options.set ? options.set : 0
  72. },
  73. methods: {
  74. getData() {
  75. let data = {
  76. ruleClassifyId: this.jobId
  77. }
  78. this.$Request.getT('/app/userFirst/getPostSkill', data).then(res => {
  79. if (res.code == 0) {
  80. this.preferenceOptions = res.data
  81. }
  82. })
  83. },
  84. goBack() {
  85. uni.navigateBack()
  86. },
  87. // togglePreference(name) {
  88. // const index = this.selectedPreferences.indexOf(name);
  89. // const realLength = this.selectedPreferences.filter(item => item !== '不限').length;
  90. // if (index === -1) {
  91. // if (realLength >= 5) {
  92. // uni.showToast({
  93. // title: '最多选择5个偏好!',
  94. // icon: 'none'
  95. // })
  96. // return;
  97. // }
  98. // this.selectedPreferences.push(name);
  99. // } else {
  100. // this.selectedPreferences.splice(index, 1);
  101. // }
  102. // },
  103. togglePreference(pIndex, name) {
  104. const parent = this.preferenceOptions[pIndex];
  105. // 当前分类下已选中的标签(排除不限)
  106. const selectedInGroup = parent.childrenList
  107. .filter(item => item.postSkillName !== '不限' && this.selectedPreferences.includes(item.postSkillName));
  108. const index = this.selectedPreferences.indexOf(name);
  109. if (index === -1) {
  110. if (selectedInGroup.length >= 5) {
  111. uni.showToast({
  112. title: '每个分类最多选择5个偏好!',
  113. icon: 'none'
  114. });
  115. return;
  116. }
  117. this.selectedPreferences.push(name);
  118. } else {
  119. this.selectedPreferences.splice(index, 1);
  120. }
  121. },
  122. confirmSelection() {
  123. // 返回选中的偏好设置
  124. uni.navigateBack({
  125. delta: 1
  126. })
  127. // 通知父页面更新偏好设置
  128. uni.$emit('preferenceUpdated', {
  129. jobTitle: this.jobTitle,
  130. preferences: this.selectedPreferences,
  131. set
  132. })
  133. }
  134. }
  135. }
  136. </script>
  137. <style lang="scss" scoped>
  138. .preference-setting {
  139. height: 100vh;
  140. background: #fff;
  141. display: flex;
  142. flex-direction: column;
  143. // padding: 0 40rpx 40rpx 40rpx;
  144. padding-bottom: 40rpx;
  145. }
  146. .container {
  147. flex: 1;
  148. padding: 0 40rpx;
  149. }
  150. .navbar-content {
  151. display: flex;
  152. align-items: center;
  153. justify-content: space-between;
  154. height: 88rpx;
  155. }
  156. .nav-left,
  157. .nav-right {
  158. width: 60rpx;
  159. height: 60rpx;
  160. display: flex;
  161. align-items: center;
  162. justify-content: center;
  163. }
  164. .nav-title {
  165. color: rgba(51, 51, 51, 1);
  166. font-family: DM Sans;
  167. font-size: 36rpx;
  168. font-weight: 700;
  169. line-height: 26px;
  170. letter-spacing: 0px;
  171. text-align: center;
  172. }
  173. .main-content {
  174. margin-top: 20rpx;
  175. flex: 1;
  176. overflow: auto;
  177. }
  178. .job-title {
  179. color: rgba(51, 51, 51, 1);
  180. font-family: DM Sans;
  181. font-size: 52rpx;
  182. font-weight: 700;
  183. line-height: 30px;
  184. letter-spacing: 0px;
  185. text-align: left;
  186. }
  187. .description {
  188. margin: 20rpx 0;
  189. color: rgba(102, 102, 102, 1);
  190. font-family: DM Sans;
  191. font-size: 28rpx;
  192. font-weight: 400;
  193. letter-spacing: 0px;
  194. text-align: left;
  195. }
  196. .preference-section {
  197. margin-bottom: 40rpx;
  198. }
  199. .section-title {
  200. color: rgba(34, 37, 42, 1);
  201. font-family: DM Sans;
  202. font-size: 36rpx;
  203. font-weight: 400;
  204. line-height: 24px;
  205. letter-spacing: 0px;
  206. text-align: left;
  207. margin-bottom: 20rpx;
  208. }
  209. .preference-grid {
  210. display: flex;
  211. // flex-wrap: wrap;
  212. flex-direction: column;
  213. gap: 12rpx;
  214. .preference-group {}
  215. .preference-children {
  216. margin-top: 20rpx;
  217. // display: grid;
  218. // grid-template-columns: repeat(4, 1fr);
  219. // gap: 16rpx 10rpx;
  220. display: flex;
  221. flex-wrap: wrap;
  222. gap: 20rpx;
  223. }
  224. }
  225. .preference-tag {
  226. // width: calc((100% - 72rpx) / 7);
  227. padding: 14rpx 20rpx;
  228. background: #F7F8FA;
  229. border: 1rpx solid #F7F8FA;
  230. border-radius: 12rpx;
  231. transition: all 0.3s ease;
  232. display: flex;
  233. align-items: center;
  234. justify-content: center;
  235. word-break: break-all;
  236. text {
  237. font-size: 24rpx;
  238. color: rgba(102, 102, 102, 1);
  239. font-weight: 400;
  240. text-align: center;
  241. line-height: 1.2;
  242. }
  243. &.active {
  244. background: rgba(153, 196, 250, 0.4);
  245. border: 0.5px solid rgba(1, 107, 246, 1);
  246. text {
  247. color: rgba(1, 107, 246, 1);
  248. font-weight: 400;
  249. }
  250. }
  251. &:active {
  252. transform: scale(0.95);
  253. }
  254. }
  255. .button-section {
  256. padding: 28rpx 40rpx;
  257. box-shadow: 0px -4px 16px 0px rgba(0, 0, 0, 0.04);
  258. }
  259. .submit-btn {
  260. flex-shrink: 0;
  261. border-radius: 999px;
  262. box-shadow: 0px -4px 16px 0px rgba(0, 0, 0, 0.04);
  263. background: linear-gradient(90deg, rgba(13, 39, 247, 1), rgba(19, 193, 234, 1) 100%);
  264. color: rgba(255, 255, 255, 1);
  265. font-family: DM Sans;
  266. font-size: 32rpx;
  267. font-weight: 400;
  268. line-height: 48rpx;
  269. display: flex;
  270. justify-content: center;
  271. align-items: center;
  272. padding: 16rpx 32rpx;
  273. box-sizing: border-box;
  274. }
  275. </style>