peopleNumber.vue 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235
  1. <template>
  2. <view class="switch-roles">
  3. <nav-bar title="选择公司规模" color="#000"></nav-bar>
  4. <view class="roles-content">
  5. <view class="content">
  6. <view class="title">公司规模</view>
  7. <view class="desc">“{{ companyName || '当前公司' }}”的人员规模</view>
  8. <view class="check-box">
  9. <view class="check-item" :class="{ 'is-check': check == index }" v-for="(item, index) in peopleList"
  10. :key="index" @click="checkPeople(index)">{{ item }}</view>
  11. </view>
  12. </view>
  13. </view>
  14. <view class="submit-btn" @click="submitCompany">确定</view>
  15. </view>
  16. </template>
  17. <script>
  18. import navBar from "@/components/nav-bar/index.vue";
  19. export default {
  20. data() {
  21. return {
  22. peopleList: [
  23. "0-20人",
  24. "20-99人",
  25. "100-499人",
  26. "500-999人",
  27. "1000-9999人",
  28. "10000人以上",
  29. ],
  30. check: 0, // 默认选中第一个选项
  31. companyName: '',// 接收上个页面传递的公司名称
  32. companyId: ""
  33. };
  34. },
  35. components: {
  36. navBar,
  37. },
  38. onLoad(options) {
  39. // 接收上个页面传递的公司名称参数
  40. if (options.companyName) {
  41. this.companyName = decodeURIComponent(options.companyName);
  42. console.log('接收的公司名称:', this.companyName);
  43. }
  44. if (options.companyId) {
  45. this.companyId = decodeURIComponent(options.companyId);
  46. console.log('接收的公司ID:', this.companyId);
  47. }
  48. },
  49. methods: {
  50. // 选择公司规模
  51. checkPeople(index) {
  52. this.check = index;
  53. },
  54. // 提交企业数据
  55. submitCompany() {
  56. // 表单验证
  57. if (!this.companyName) {
  58. uni.showToast({
  59. title: '请先填写公司名称',
  60. icon: 'none'
  61. });
  62. // 可跳回上一页重新填写
  63. setTimeout(() => {
  64. uni.navigateBack();
  65. }, 1500);
  66. return;
  67. }
  68. // 获取选中的公司规模
  69. //const selectedPeople = this.peopleList[this.check];
  70. const selectedPeople = this.check
  71. // 显示加载中
  72. uni.showLoading({
  73. title: '提交中...'
  74. });
  75. // 准备提交的数据
  76. const data = {
  77. companyAllName: this.companyName,
  78. companyPeople: this.peopleList[selectedPeople], // 选中的公司规模
  79. // 可根据接口需求添加其他字段
  80. };
  81. // 发送请求
  82. this.$Request.postJson("/app/company/insertCompany", data)
  83. .then((res) => {
  84. uni.hideLoading();
  85. if (res.code === 0) {
  86. uni.showToast({
  87. title: '提交成功',
  88. icon: 'success'
  89. });
  90. // 提交成功后跳转到职位发布页面
  91. setTimeout(() => {
  92. this.goJobPosting(res.data);
  93. }, 1500);
  94. } else {
  95. uni.showToast({
  96. title: res.msg || '提交失败,请重试',
  97. icon: 'none'
  98. });
  99. }
  100. })
  101. .catch((err) => {
  102. uni.hideLoading();
  103. console.error('请求失败:', err);
  104. uni.showToast({
  105. title: '网络异常,请稍后重试',
  106. icon: 'none'
  107. });
  108. });
  109. },
  110. // 跳转到职位发布页面
  111. goJobPosting(value) {
  112. let companyId = value.companyId;
  113. let status = value.status;
  114. // uni.navigateTo({
  115. // url: '/pages/my/jobPosting?companyName='+this.companyName+'&companyId='+companyId
  116. // });
  117. uni.reLaunch({
  118. url: '/pages/my/jobPosting?companyName=' + this.companyName + '&companyId=' + companyId + '&isBack=' + false + '&status=' + status
  119. });
  120. // 如果是H5,额外处理
  121. // #ifdef H5
  122. history.replaceState(null, null, window.location.href);
  123. // #endif
  124. }
  125. },
  126. };
  127. </script>
  128. <style lang="scss" scoped>
  129. /* 原有样式保持不变 */
  130. .switch-roles {
  131. background-color: #fff;
  132. position: absolute;
  133. left: 0;
  134. right: 0;
  135. top: 0;
  136. bottom: 0;
  137. display: flex;
  138. flex-direction: column;
  139. .roles-content {
  140. width: 100%;
  141. flex: 1;
  142. overflow: hidden;
  143. overflow-y: auto;
  144. .content {
  145. padding: 40rpx;
  146. box-sizing: border-box;
  147. display: flex;
  148. flex-direction: column;
  149. align-items: center;
  150. justify-content: center;
  151. .title {
  152. color: #333;
  153. width: 100%;
  154. font-family: DM Sans;
  155. font-size: 40rpx;
  156. font-weight: 600;
  157. }
  158. .desc {
  159. color: rgba(102, 102, 102, 1);
  160. width: 100%;
  161. font-family: DM Sans;
  162. font-size: 28rpx;
  163. font-weight: 400;
  164. line-height: 32rpx;
  165. letter-spacing: 0.5%;
  166. text-align: left;
  167. padding: 20rpx 0;
  168. box-sizing: border-box;
  169. }
  170. .check-box {
  171. width: 100%;
  172. display: grid;
  173. grid-template-columns: repeat(2, 1fr);
  174. gap: 24rpx;
  175. .check-item {
  176. border-radius: 16rpx;
  177. background: rgba(245, 248, 254, 1);
  178. color: rgba(153, 153, 153, 1);
  179. font-family: DM Sans;
  180. font-size: 30rpx;
  181. font-weight: 400;
  182. line-height: 44rpx;
  183. text-align: center;
  184. padding: 12rpx 48rpx;
  185. box-sizing: border-box;
  186. transition: all 0.3s ease;
  187. }
  188. .is-check {
  189. box-sizing: border-box;
  190. border: 1rpx solid #016bf6;
  191. border-radius: 16rpx;
  192. background: rgba(252, 233, 220, 1);
  193. color: #016bf6;
  194. }
  195. }
  196. }
  197. }
  198. .submit-btn {
  199. flex-shrink: 0;
  200. border-radius: 999px;
  201. box-shadow: 0px 2px 4px 0px rgba(9, 196, 116, 0.3);
  202. background: linear-gradient(90deg, rgba(13, 39, 247, 1), rgba(19, 193, 234, 1) 100%);
  203. color: rgba(255, 255, 255, 1);
  204. font-family: DM Sans;
  205. font-size: 32rpx;
  206. font-weight: 400;
  207. line-height: 48rpx;
  208. display: flex;
  209. justify-content: center;
  210. align-items: center;
  211. padding: 16rpx 32rpx;
  212. box-sizing: border-box;
  213. margin: 60rpx 20rpx;
  214. cursor: pointer;
  215. }
  216. }
  217. </style>