role-switch-component.vue 3.78 KB
Newer Older
李晓兵's avatar
李晓兵 committed
1 2 3 4 5 6 7 8 9
/**
* @Author Sean
* @Date 2019/11/27
*/
<template>
  <transition name="role">
    <div v-show="showFlag" class="role-switch-wrap">
      <div class="role-switch-content">
        <div class="content-header">
linxin's avatar
linxin committed
10
          <span>请选择要切换的内容</span>
李晓兵's avatar
李晓兵 committed
11 12 13
          <img src="@/assets/myInfo/modalClose.png" @click="roleCancle">
        </div>
        <div class="content-wrap">
linxin's avatar
linxin committed
14 15 16
          <div
            v-for="(item,index) in roleList" :key="index" :class="{'item-active':index === switchIndex}" class="role-item"
            @click="chooseRole(index)">
linxin's avatar
linxin committed
17
            <span>{{ item.bp_type_n }}</span>
李晓兵's avatar
李晓兵 committed
18
          </div>
linxin's avatar
linxin committed
19
          <div :class="{'content-btn-active':switchIndex !== ''}" class="content-btn" @click="roleConfirm"><span>确定</span></div>
李晓兵's avatar
李晓兵 committed
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
        </div>
      </div>
    </div>
  </transition>
</template>

<script>
export default {
  props: ['roleList'],
  data () {
    return {
      showFlag: false,
      switchIndex: '',
    }
  },
  created: function () {
  },
  mounted: function () {
  },
  updated: function () {
  },
  methods: {
linxin's avatar
linxin committed
42
    chooseRole (index) {
李晓兵's avatar
李晓兵 committed
43 44 45
      this.switchIndex = index
    },
    roleConfirm () {
linxin's avatar
linxin committed
46
      if (this.switchIndex === '') {
李晓兵's avatar
李晓兵 committed
47

linxin's avatar
linxin committed
48
      } else {
李晓兵's avatar
李晓兵 committed
49
        this.showFlag = false
linxin's avatar
linxin committed
50
        this.$emit('roleConfirm', this.roleList[this.switchIndex])
李晓兵's avatar
李晓兵 committed
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98
      }
    },
    show () {
      this.switchIndex = ''
      this.showFlag = true
    },
    roleCancle () {
      this.showFlag = false
      this.$emit('roleCancle')
    },
  },
}
</script>

<style scoped lang="less">
  .role-enter-active, .role-leave-active {
    transition: opacity .5s;
  }

  .role-enter, .role-leave-to /* .fade-leave-active below version 2.1.8 */ {
    opacity: 0;
  }

  .role-switch-wrap {
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    z-index: 999;
    background: rgba(56, 63, 69, 0.30);
    display: flex;
    justify-content: center;
    align-items: center;

    .role-switch-content {
      width: 80%;
      margin: 0 auto;

      .content-header {
        width: 100%;
        height: 44px;
        background-color: @headerColor;
        font-family: PingFangSC-Semibold;
        font-size: 16px;
        color: #FFFFFF;
        letter-spacing: 0;
        text-align: center;
        line-height: 44px;
李晓兵's avatar
李晓兵 committed
99 100
        border-top-left-radius: 14px;
        border-top-right-radius: 14px;
李晓兵's avatar
李晓兵 committed
101 102 103 104 105 106 107 108 109 110 111 112 113 114
        img {
          width: 26px;
          float: right;
        }
      }

      .content-wrap {
        width: 100%;
        display: flex;
        flex-direction: column;
        justify-content: center;
        align-items: center;
        background-color: #FFF;
        padding: 10px 0;
李晓兵's avatar
李晓兵 committed
115 116
        border-bottom-left-radius: 14px;
        border-bottom-right-radius: 14px;
李晓兵's avatar
李晓兵 committed
117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166
        .role-item {
          width: 90%;
          height: 44px;
          background: #FFFFFF;
          border: 1px solid #CFCFCF;
          border-radius: 4px;
          display: flex;
          justify-content: center;
          align-items: center;
          margin: 4px 0;

          span {
            font-family: PingFangSC-Regular;
            font-size: 14px;
            color: #656464;
            letter-spacing: 0;
            line-height: 18px;
          }
        }
        .item-active{
          background: rgba(29,63,255,0.10);
          border: 1px solid #1D3FFF;
          border-radius: 4px;
        }
      }

      .content-btn {
        margin-top: 10px;
        width: 84%;
        height: 40px;
        background: rgba(56, 63, 69, 0.50);
        border-radius: 4px;
        display: flex;
        justify-content: center;
        align-items: center;

        span {
          font-family: PingFangSC-Semibold;
          font-size: 15px;
          color: #FAFAFA;
          line-height: 20px;
        }
      }
      .content-btn-active{
        background: #1D3FFF;
        border-radius: 4px;
      }
    }
  }
</style>