preferenceSetting.vue 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286
  1. <template>
  2. <view class="preference-setting">
  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">跨境职业标签</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. <view class="preference-section">
  18. <view class="section-title">请选择你的从事偏好</view>
  19. <!-- 偏好标签网格 -->
  20. <view class="preference-grid">
  21. <view v-for="(parent, pIndex) in preferenceOptions" :key="pIndex" class="preference-group">
  22. <!-- 一级标题 -->
  23. <view class="preference-title">
  24. <text>{{ parent.postSkillName }}</text>
  25. </view>
  26. <!-- 二级可选项 -->
  27. <view class="preference-children">
  28. <view v-for="(child, cIndex) in parent.childrenList" :key="cIndex" class="preference-tag"
  29. :class="{ active: selectedPreferences.includes(child.postSkillName) }"
  30. @click="togglePreference(child.postSkillName)">
  31. <text>{{ child.postSkillName }}</text>
  32. </view>
  33. </view>
  34. </view>
  35. </view>
  36. </view>
  37. </view>
  38. <!-- 底部确定按钮 -->
  39. <view class="bottom-btn-container">
  40. <view class="confirm-btn" @click="confirmSelection">
  41. <text>确定</text>
  42. </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. if (index === -1) {
  90. if (this.selectedPreferences.length > 4) {
  91. uni.showToast({
  92. title: '最多选择5个偏好!',
  93. icon: 'none'
  94. })
  95. return;
  96. }
  97. this.selectedPreferences.push(name);
  98. } else {
  99. this.selectedPreferences.splice(index, 1);
  100. }
  101. },
  102. confirmSelection() {
  103. // 返回选中的偏好设置
  104. uni.navigateBack({
  105. delta: 1
  106. })
  107. // 通知父页面更新偏好设置
  108. uni.$emit('preferenceUpdated', {
  109. jobTitle: this.jobTitle,
  110. preferences: this.selectedPreferences,
  111. set
  112. })
  113. }
  114. }
  115. }
  116. </script>
  117. <style lang="scss" scoped>
  118. .preference-setting {
  119. height: 100vh;
  120. background: #fff;
  121. display: flex;
  122. flex-direction: column;
  123. padding: 0 40rpx 40rpx 40rpx;
  124. }
  125. .navbar-content {
  126. display: flex;
  127. align-items: center;
  128. justify-content: space-between;
  129. height: 88rpx;
  130. }
  131. .nav-left,
  132. .nav-right {
  133. width: 60rpx;
  134. height: 60rpx;
  135. display: flex;
  136. align-items: center;
  137. justify-content: center;
  138. }
  139. .nav-title {
  140. color: rgba(51, 51, 51, 1);
  141. font-family: DM Sans;
  142. font-size: 36rpx;
  143. font-weight: 700;
  144. line-height: 26px;
  145. letter-spacing: 0px;
  146. text-align: center;
  147. }
  148. .main-content {
  149. margin-top: 20rpx;
  150. flex: 1;
  151. overflow: auto;
  152. }
  153. .job-title {
  154. color: rgba(51, 51, 51, 1);
  155. font-family: DM Sans;
  156. font-size: 52rpx;
  157. font-weight: 700;
  158. line-height: 30px;
  159. letter-spacing: 0px;
  160. text-align: left;
  161. }
  162. .description {
  163. margin: 20rpx 0;
  164. color: rgba(102, 102, 102, 1);
  165. font-family: DM Sans;
  166. font-size: 28rpx;
  167. font-weight: 400;
  168. letter-spacing: 0px;
  169. text-align: left;
  170. }
  171. .preference-section {
  172. margin-bottom: 40rpx;
  173. }
  174. .section-title {
  175. color: rgba(34, 37, 42, 1);
  176. font-family: DM Sans;
  177. font-size: 36rpx;
  178. font-weight: 400;
  179. line-height: 24px;
  180. letter-spacing: 0px;
  181. text-align: left;
  182. margin-bottom: 20rpx;
  183. }
  184. .preference-grid {
  185. display: flex;
  186. // flex-wrap: wrap;
  187. flex-direction: column;
  188. gap: 12rpx;
  189. .preference-group {}
  190. .preference-children {
  191. margin-top: 20rpx;
  192. // display: grid;
  193. // grid-template-columns: repeat(4, 1fr);
  194. // gap: 16rpx 10rpx;
  195. display: flex;
  196. flex-wrap: wrap;
  197. gap: 20rpx;
  198. }
  199. }
  200. .preference-tag {
  201. // width: calc((100% - 72rpx) / 7);
  202. padding: 14rpx 20rpx;
  203. background: #F7F8FA;
  204. border: 1rpx solid #F7F8FA;
  205. border-radius: 12rpx;
  206. transition: all 0.3s ease;
  207. display: flex;
  208. align-items: center;
  209. justify-content: center;
  210. word-break: break-all;
  211. text {
  212. font-size: 24rpx;
  213. color: rgba(102, 102, 102, 1);
  214. font-weight: 400;
  215. text-align: center;
  216. line-height: 1.2;
  217. }
  218. &.active {
  219. background: rgba(153, 196, 250, 0.4);
  220. border: 0.5px solid rgba(1, 107, 246, 1);
  221. text {
  222. color: rgba(1, 107, 246, 1);
  223. font-weight: 400;
  224. }
  225. }
  226. &:active {
  227. transform: scale(0.95);
  228. }
  229. }
  230. .bottom-btn-container {
  231. // position: fixed;
  232. // bottom: 0;
  233. // left: 0;
  234. // right: 0;
  235. padding: 32rpx;
  236. background: #fff;
  237. border-top: 1px solid #f0f0f0;
  238. }
  239. .confirm-btn {
  240. width: 100%;
  241. height: 88rpx;
  242. background: #007AFF;
  243. border-radius: 44rpx;
  244. display: flex;
  245. align-items: center;
  246. justify-content: center;
  247. text {
  248. font-size: 32rpx;
  249. font-weight: 600;
  250. color: #fff;
  251. }
  252. &:active {
  253. background: #0056CC;
  254. }
  255. }
  256. </style>