温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

vue怎么实现底部弹窗多选项功能

发布时间:2021-09-06 10:02:42 阅读:169 作者:chen 栏目:开发技术
Vue开发者专用服务器限时活动,0元免费领,库存有限,领完即止! 点击查看>>

这篇文章主要讲解了“vue怎么实现底部弹窗多选项功能”,文中的讲解内容简单清晰,易于学习与理解,下面请大家跟着小编的思路慢慢深入,一起来研究和学习“vue怎么实现底部弹窗多选项功能”吧!

本文实例为大家分享了vue实现底部弹窗多选的具体代码,供大家参考,具体内容如下

vue怎么实现底部弹窗多选项功能

vue怎么实现底部弹窗多选项功能

vue怎么实现底部弹窗多选项功能

代码:

<template>
  <div class="release-post">
    <div class="resume_main">
      <div class="resume_content">
        <van-form>
          <div class="table_list post_welfare">
            <p class="name_title">岗位福利<span class="required">*</span></p>
            <van-field
              class="calendar"
              input-align="left"
              v-model="benefits"
              placeholder="请选择岗位福利"
              @focus="onFocus"
              :class="{ borderStyle: welfareChange }"
              @click.stop="clickWelfare"
              :disabled="true"
            />
          </div>
        </van-form>
        <!-- 岗位福利 -->
        <van-popup v-model="showWelfare" position="bottom">
          <div class="welfare_top">
            <p></p>
            <p class="welfare_title">福利待遇(可多选)</p>
            <p class="welfare_btn" @click.stop="onConfirmSpeed">完成</p>
          </div>
          <div class="welfare_content">
            <div
              v-for="(item, index) in welfareList"
              :key="index"
              :class="{ active: item.active }"
              id="welfare_item"
              @click.stop="clickWelfareItem(item, index)"
            >
              <p :class="item.active ? 'welfare_text' : 'not_welfare_text'">
                {{ item.text }}
              </p>
            </div>
          </div>
        </van-popup>
      </div>
    </div>
    <div>
      <div class="mask">
        <button
          class="btn"
          @click="submit"
          :class="{ btnBg: colorChange() }"
          v-preventReClick="1000"
        >
          完成
        </button>
      </div>
    </div>
  </div>
</template>
 
<script>
import Vue from 'vue';
import { CircleDatetimePickerFormFieldToastCalendarPickerOverlayActionSheetPopup } from 'vant';
import 'vant/lib/index.less';
Vue.use(Circle).use(DatetimePicker).use(Form).use(Field).use(Toast).use(Calendar).use(Picker).use(Overlay).use(ActionSheet).use(Popup);
 
export default {
  name"PerfectPost",
  data () {
    return {
      welfareList: [
        {
          id1,
          text"包吃"
        },
        {
          id2,
          text"包住"
        },
        {
          id3,
          text"五险一金"
        },
        {
          id4,
          text"年底双薪"
        },
        {
          id5,
          text"商业险"
        },
        {
          id6,
          text"意外险"
        },
        {
          id7,
          text"团建"
        },
        {
          id8,
          text"周末双休"
        },
        {
          id9,
          text"下午茶"
        },
        {
          id10,
          text"餐补"
        },
        {
          id11,
          text"交通补助"
        },
        {
          id12,
          text"班车接送"
        },
        {
          id13,
          text"奖金"
        },
        {
          id14,
          text"公费培训"
        },
        {
          id15,
          text"公费旅游"
        },
      ],
      showWelfarefalse,//岗位福利
      onlineForm: {
        benefits"",//岗位福利
      },
      checkedList: [],
      welfareChangefalse,
    };
  },
  methods: {
    //弹出岗位福利
    clickWelfare () {
      this.showRedTips()
      this.showWelfare = true
    },
    //选择福利项
    clickWelfareItem (v) {
      if (v.active) {
        Vue.set(v, 'active'false)
      } else if (this.checkedList.length < 5) {
        Vue.set(v, 'active'true)
      }
      this.checkedList = this.welfareList.filter(function (item) {
        return item.active
      })
      if (this.checkedList.length >= 5) {
        Toast('最多只能选择5个哦')
      }
    },
    //完成福利选项
    onConfirmSpeed () {
      this.showWelfare = false
      this.welfareChange = false
      let itemList = this.checkedList.map((item) => {
        return item.text
      });
      let str = itemList.join('/')
      let str1 = itemList.join(';')
      this.benefits = str ? str : this.benefits
      this.onlineForm.benefits = str1 ? str1 : this.benefits
    },
    showRedTips () {
      this.welfareChange = false
    },
    onFocus () {
      this.showRedTips()
    },
    //下一步按钮色值
    colorChange () {
      if (this.onlineForm.benefits) {
        return true
      }
    },
    // 验证
    validateOnlineForm () {
      let valid = true;
      if (!this.onlineForm.benefits || !this.onlineForm.benefits.trim()) {
        valid = false;
        Toast('请选择岗位福利')
        this.welfareChange = true
      }
      return valid;
    },
    //提交
    submit () {
      if (this.validateOnlineForm()) {
        Toast('提交')
      }
    },
  },
};
</script>
 
<style scoped lang="less" >
* {
  margin0;
  padding0;
}
::v-deep .van-picker__title {
  font-size17px;
  font-family: PingFangSC, PingFangSC-Medium;
  font-weight500;
  text-align: center;
  color#333333;
}
.release-post {
  width100%;
  padding-bottom64px;
  padding-topconstant(safe-area-inset-top);
  padding-topenv(safe-area-inset-top);
}
.post_welfare {
  ::v-deep .van-field__control:disabled {
    font-size15px;
    font-family: PingFangSC, PingFangSC-Regular;
    font-weight400;
    text-align: left;
    color#333333;
    -webkit-text-fill-color#333333;
  }
  ::v-deep input::-webkit-input-placeholder {
    font-size15px;
    font-family: PingFangSC, PingFangSC-Regular;
    font-weight400;
    text-align: left;
    color#999999;
    -webkit-text-fill-color#999999;
  }
}
::v-deep .van-field__control:disabled {
  font-size15px;
  font-family: PingFangSC, PingFangSC-Regular;
  font-weight400;
  text-align: left;
  color#333333;
  -webkit-text-fill-color#333333;
}
 
.welfare_content {
  padding-top10px;
  padding-bottom30px;
  display: flex;
  justify-content: space-around;
  align-items: center;
  flex-wrap: wrap;
  margin0 16px;
}
#welfare_item {
  width31%;
}
.welfare_top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding13px 0;
  border-bottom: solid 0.5px #e5e5e5;
}
.welfare_title {
  font-size17px;
  font-family: PingFangSC, PingFangSC-Medium;
  font-weight500;
  text-align: center;
  color#333333;
  margin-right: -16px;
}
.welfare_btn {
  font-size16px;
  font-family: PingFangSC, PingFangSC-Regular;
  font-weight400;
  text-align: right;
  color#333333;
  margin-right16px;
}
.welfare_text {
  height36px;
  background#f4f8ff;
  border1px solid #bbdcff;
  border-radius4px;
  margin-top10px;
  line-height36px;
 
  font-size14px;
  font-family: PingFangSC, PingFangSC-Medium;
  font-weight500;
  text-align: center;
  color#1283ff;
}
.not_welfare_text {
  height36px;
  background#ffffff;
  border1px solid #e5e5e5;
  border-radius4px;
  margin-top10px;
  line-height36px;
 
  font-size14px;
  font-family: PingFang, PingFang-SC;
  font-weight500;
  text-align: center;
  color#333333;
}
 
.resume_content {
  margin-left30px;
  margin-right30px;
  ::v-deep {
    .van-popup--bottom {
      border-top-left-radius12px;
      border-top-right-radius12px;
    }
  }
}
.mask {
  width100%;
  background#ffffff;
  box-shadow0px 0px 8px 0px rgba(2042042040.3);
  position: fixed;
  bottom0;
  left0;
  display: flex;
  justify-content: center;
  align-items: center;
  padding10px 0;
  padding-bottomcalc(env(safe-area-inset-bottom)+15px);
  padding-bottomcalc(env(safe-area-inset-bottom) + 15px);
}
.btn {
  font-size16px;
  font-family: PingFangSC, PingFangSC-Medium;
  font-weight500;
  text-align: left;
  color#ffffff;
  margin0 auto;
  text-align: center;
  line-height1.6rem;
  width100%;
  margin0 16px;
  height48px;
  background#d8d8d8;
}
.btnBg {
  font-size16px;
  font-family: PingFangSC, PingFangSC-Medium;
  font-weight500;
  text-align: left;
  color#ffffff;
  margin0 auto;
  text-align: center;
  line-height1.6rem;
  width100%;
  margin0 16px;
  height48px;
  background#d8d8d8;
  border: none;
  outline: none;
  backgroundlinear-gradient(90deg#50a3ff#1283ff);
  border-radius4px;
}
 
.name_title {
  font-size16px;
  font-family: PingFangSC, PingFangSC-Medium;
  font-weight500;
  color#333333;
}
 
.required {
  font-size13px;
  font-family: PingFangSC, PingFangSC-Regular;
  font-weight400;
  color#ff1d28;
  position: absolute;
}
.calendar {
  width100%;
  height49px;
  background#ffffff;
  border1px solid #e5e5e5;
  border-radius5px;
  margin-top10px;
  padding-left20px;
  backgroundurl("./images/drop-down.png") no-repeat 96% center;
  background-size10px 7px;
  padding-right25px;
  ::v-deep .van-field__control {
    font-size15px;
    font-family: PingFangSC, PingFangSC-Regular;
    font-weight400;
    text-align: left;
    color#333333;
    margin-top12px;
  }
}
::v-deep input::-webkit-input-placeholder {
  font-size15px;
  font-family: PingFangSC, PingFangSC-Regular;
  font-weight400;
  text-align: left;
  color#afadad;
  -webkit-text-fill-color#afadad;
}
.table_list {
  margin-top16px;
}
.borderStyle {
  border: solid 1px #ff1d28;
  border-radius3px;
}
input::-webkit-input-placeholder {
  font-size15px;
  font-family: PingFangSC, PingFangSC-Regular;
  font-weight400;
  text-align: left;
  color#999999;
}
.van-field__control {
  color#333333;
}
</style>

感谢各位的阅读,以上就是“vue怎么实现底部弹窗多选项功能”的内容了,经过本文的学习后,相信大家对vue怎么实现底部弹窗多选项功能这一问题有了更深刻的体会,具体使用情况还需要大家实践验证。这里是亿速云,小编将为大家推送更多相关知识点的文章,欢迎关注!

亿速云「云服务器」,即开即用、新一代英特尔至强铂金CPU、三副本存储NVMe SSD云盘,价格低至29元/月。点击查看>>

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

vue
AI

开发者交流群×