preferenceSetting.vue 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254
  1. <template>
  2. <view class="preference-setting">
  3. <!-- 自定义导航栏 -->
  4. <view class="custom-navbar">
  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
  22. v-for="(item, index) in preferenceOptions"
  23. :key="index"
  24. class="preference-tag"
  25. :class="{ active: selectedPreferences.includes(item.preferenceName) }"
  26. @click="togglePreference(item.preferenceName)"
  27. >
  28. <text>{{ item.preferenceName }}</text>
  29. </view>
  30. </view>
  31. </view>
  32. </view>
  33. <!-- 底部确定按钮 -->
  34. <view class="bottom-btn-container">
  35. <view class="confirm-btn" @click="confirmSelection">
  36. <text>确定</text>
  37. </view>
  38. </view>
  39. </view>
  40. </template>
  41. <script>
  42. var set=0
  43. export default {
  44. data() {
  45. return {
  46. jobTitle: '岗位',
  47. jobId:'',
  48. selectedPreferences: [],
  49. preferenceOptions: [
  50. ]
  51. }
  52. },
  53. onLoad(options) {
  54. if (options&&options.jobTitle) {
  55. this.jobTitle = decodeURIComponent(options.jobTitle)
  56. }
  57. if (options&&options.jobId) {
  58. this.jobId = options.jobId
  59. }
  60. if(options&&options.selectedPreferences)
  61. this.selectedPreferences = JSON.parse(decodeURIComponent(options.selectedPreferences))
  62. this.getData()
  63. set=options&&options.set?options.set:0
  64. },
  65. methods: {
  66. getData(){
  67. let data = {
  68. ruleClassifyId:this.jobId
  69. }
  70. this.$Request.getT('/app/postPreference/getPostPreference',data).then(res => {
  71. if(res.code==0){
  72. this.preferenceOptions = res.data
  73. }
  74. })
  75. },
  76. goBack() {
  77. uni.navigateBack()
  78. },
  79. togglePreference(item) {
  80. const index = this.selectedPreferences.indexOf(item)
  81. if (index > -1) {
  82. // 如果已选中,则取消选中
  83. this.selectedPreferences.splice(index, 1)
  84. } else {
  85. // 如果未选中,则添加到选中列表
  86. this.selectedPreferences.push(item)
  87. }
  88. },
  89. confirmSelection() {
  90. // 返回选中的偏好设置
  91. uni.navigateBack({
  92. delta: 1
  93. })
  94. // 通知父页面更新偏好设置
  95. uni.$emit('preferenceUpdated', {
  96. jobTitle: this.jobTitle,
  97. preferences: this.selectedPreferences,
  98. set
  99. })
  100. }
  101. }
  102. }
  103. </script>
  104. <style lang="scss" scoped>
  105. .preference-setting {
  106. min-height: 100vh;
  107. background: #fff;
  108. display: flex;
  109. flex-direction: column;
  110. padding: 88rpx 40rpx 40rpx 40rpx;
  111. }
  112. .navbar-content {
  113. display: flex;
  114. align-items: center;
  115. justify-content: space-between;
  116. height: 88rpx;
  117. }
  118. .nav-left, .nav-right {
  119. width: 60rpx;
  120. height: 60rpx;
  121. display: flex;
  122. align-items: center;
  123. justify-content: center;
  124. }
  125. .nav-title {
  126. color: rgba(51, 51, 51, 1);
  127. font-family: DM Sans;
  128. font-size: 36rpx;
  129. font-weight: 700;
  130. line-height: 26px;
  131. letter-spacing: 0px;
  132. text-align: center;
  133. }
  134. .main-content {
  135. margin-top:20rpx;
  136. }
  137. .job-title {
  138. color: rgba(51, 51, 51, 1);
  139. font-family: DM Sans;
  140. font-size: 52rpx;
  141. font-weight: 700;
  142. line-height: 30px;
  143. letter-spacing: 0px;
  144. text-align: left;
  145. }
  146. .description {
  147. margin:20rpx 0;
  148. color: rgba(102, 102, 102, 1);
  149. font-family: DM Sans;
  150. font-size: 28rpx;
  151. font-weight: 400;
  152. letter-spacing: 0px;
  153. text-align: left;
  154. }
  155. .preference-section {
  156. margin-bottom: 40rpx;
  157. }
  158. .section-title {
  159. color: rgba(34, 37, 42, 1);
  160. font-family: DM Sans;
  161. font-size: 36rpx;
  162. font-weight: 400;
  163. line-height: 24px;
  164. letter-spacing: 0px;
  165. text-align: left;
  166. margin-bottom: 20rpx;
  167. }
  168. .preference-grid {
  169. display: flex;
  170. flex-wrap: wrap;
  171. gap: 12rpx;
  172. }
  173. .preference-tag {
  174. width: calc((100% - 72rpx) / 7);
  175. padding: 8rpx 12rpx;
  176. background: #F7F8FA;
  177. border: 1rpx solid #F7F8FA;
  178. border-radius: 12rpx;
  179. transition: all 0.3s ease;
  180. display: flex;
  181. align-items: center;
  182. justify-content: center;
  183. word-break: break-all;
  184. text {
  185. font-size: 18rpx;
  186. color: rgba(102, 102, 102, 1);
  187. font-weight: 400;
  188. text-align: center;
  189. line-height: 1.2;
  190. }
  191. &.active {
  192. background: rgba(153, 196, 250, 0.4);
  193. border: 0.5px solid rgba(1, 107, 246, 1);
  194. text {
  195. color: rgba(1, 107, 246, 1);
  196. font-weight: 400;
  197. }
  198. }
  199. &:active {
  200. transform: scale(0.95);
  201. }
  202. }
  203. .bottom-btn-container {
  204. position: fixed;
  205. bottom: 0;
  206. left: 0;
  207. right: 0;
  208. padding: 32rpx;
  209. background: #fff;
  210. border-top: 1px solid #f0f0f0;
  211. }
  212. .confirm-btn {
  213. width: 100%;
  214. height: 88rpx;
  215. background: #007AFF;
  216. border-radius: 44rpx;
  217. display: flex;
  218. align-items: center;
  219. justify-content: center;
  220. text {
  221. font-size: 32rpx;
  222. font-weight: 600;
  223. color: #fff;
  224. }
  225. &:active {
  226. background: #0056CC;
  227. }
  228. }
  229. </style>