| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223 |
- <template>
- <view class="switch-roles">
- <nav-bar title="选择公司规模" color="#000"></nav-bar>
- <view class="roles-content">
- <view class="content">
- <view class="title">公司规模</view>
- <view class="desc">“{{ companyName || '当前公司' }}”的人员规模</view>
- <view class="check-box">
- <view
- class="check-item"
- :class="{ 'is-check': check == index }"
- v-for="(item, index) in peopleList"
- :key="index"
- @click="checkPeople(index)"
- >{{ item }}</view>
- </view>
- </view>
- </view>
- <view class="submit-btn" @click="submitCompany">确定</view>
- </view>
- </template>
- <script>
- import navBar from "@/components/nav-bar/index.vue";
- export default {
- data() {
- return {
- peopleList: [
- "0-20人",
- "20-99人",
- "100-499人",
- "500-999人",
- "1000-9999人",
- "10000人以上",
- ],
- check: 0, // 默认选中第一个选项
- companyName: '' ,// 接收上个页面传递的公司名称
- companyId:""
- };
- },
- components: {
- navBar,
- },
- onLoad(options) {
- // 接收上个页面传递的公司名称参数
- if (options.companyName) {
- this.companyName = decodeURIComponent(options.companyName);
- console.log('接收的公司名称:', this.companyName);
- }
- if (options.companyId) {
- this.companyId = decodeURIComponent(options.companyId);
- console.log('接收的公司ID:', this.companyId);
- }
-
- },
- methods: {
- // 选择公司规模
- checkPeople(index) {
- this.check = index;
- },
- // 提交企业数据
- submitCompany() {
- // 表单验证
- if (!this.companyName) {
- uni.showToast({
- title: '请先填写公司名称',
- icon: 'none'
- });
- // 可跳回上一页重新填写
- setTimeout(() => {
- uni.navigateBack();
- }, 1500);
- return;
- }
- // 获取选中的公司规模
- //const selectedPeople = this.peopleList[this.check];
- const selectedPeople = this.check
-
- // 显示加载中
- uni.showLoading({
- title: '提交中...'
- });
- // 准备提交的数据
- const data = {
- companyAllName: this.companyName,
- companyPeople: selectedPeople, // 选中的公司规模
- // 可根据接口需求添加其他字段
- };
- // 发送请求
- this.$Request.postJson("/app/company/insertCompany", data)
- .then((res) => {
- uni.hideLoading();
-
- if (res.code === 0) {
- uni.showToast({
- title: '提交成功',
- icon: 'success'
- });
- // 提交成功后跳转到职位发布页面
- setTimeout(() => {
- this.goJobPosting(res.data);
- }, 1500);
- } else {
- uni.showToast({
- title: res.msg || '提交失败,请重试',
- icon: 'none'
- });
- }
- })
- .catch((err) => {
- uni.hideLoading();
- console.error('请求失败:', err);
- uni.showToast({
- title: '网络异常,请稍后重试',
- icon: 'none'
- });
- });
- },
- // 跳转到职位发布页面
- goJobPosting(companyId) {
- uni.navigateTo({
- url: '/pages/my/jobPosting?companyName='+this.companyName+'&companyId='+companyId
- });
- }
- },
- };
- </script>
- <style lang="scss" scoped>
- /* 原有样式保持不变 */
- .switch-roles {
- background-color: #fff;
- position: absolute;
- left: 0;
- right: 0;
- top: 0;
- bottom: 0;
- display: flex;
- flex-direction: column;
- .roles-content {
- width: 100%;
- flex: 1;
- overflow: hidden;
- overflow-y: auto;
- .content {
- padding: 40rpx;
- box-sizing: border-box;
- display: flex;
- flex-direction: column;
- align-items: center;
- justify-content: center;
- .title {
- color: #333;
- width: 100%;
- font-family: DM Sans;
- font-size: 40rpx;
- font-weight: 600;
- }
- .desc {
- color: rgba(102, 102, 102, 1);
- width: 100%;
- font-family: DM Sans;
- font-size: 24rpx;
- font-weight: 400;
- line-height: 32rpx;
- letter-spacing: 0.5%;
- text-align: left;
- padding: 20rpx 0;
- box-sizing: border-box;
- }
- .check-box {
- width: 100%;
- display: grid;
- grid-template-columns: repeat(2, 1fr);
- gap: 24rpx;
- .check-item {
- border-radius: 16rpx;
- background: rgba(245, 248, 254, 1);
- color: rgba(153, 153, 153, 1);
- font-family: DM Sans;
- font-size: 28rpx;
- font-weight: 400;
- line-height: 44rpx;
- text-align: center;
- padding: 12rpx 48rpx;
- box-sizing: border-box;
- transition: all 0.3s ease;
- }
- .is-check {
- box-sizing: border-box;
- border: 1rpx solid #016bf6;
- border-radius: 16rpx;
- background: rgba(252, 233, 220, 1);
- color: #016bf6;
- }
- }
- }
- }
- .submit-btn {
- flex-shrink: 0;
- border-radius: 999px;
- box-shadow: 0px 2px 4px 0px rgba(9, 196, 116, 0.3);
- background: linear-gradient(90deg, rgba(13, 39, 247, 1), rgba(19, 193, 234, 1) 100%);
- color: rgba(255, 255, 255, 1);
- font-family: DM Sans;
- font-size: 32rpx;
- font-weight: 400;
- line-height: 48rpx;
- display: flex;
- justify-content: center;
- align-items: center;
- padding: 16rpx 32rpx;
- box-sizing: border-box;
- margin: 60rpx 20rpx;
- cursor: pointer;
- }
- }
- </style>
|