Vant Vue用Popup自定义选择联系人功能

Vant 用Popup自定义选择联系人功能

<template>
  <div>
    <van-cell @click="showPopup">
      <div class="serachuser" v-if="iscell">
        <van-button icon="add" class="add"
          ><span class="btn-font">向他求助</span></van-button
        >

      </div>
      <div class="title" v-if="iscard">
        <div class="heda">
          <img
            v-if="userPortrait"
            class="imgurl"
            :src="userPortrait"
            alt="用户头像"
          />
          <span v-if="!userPortrait" class="van-icon van-icon-manager" />
        </div>
        <div class="name-part">
          <div class="h3">
            {{ name }}
            <div v-if="party" class="party">
              <span class="icons icon-dangyuan " />
            </div>
          </div>
          <div class="time">
            <div class="left-part">
              <span class="right">{{ tel }}</span>
            </div>
          </div>
        </div>
        <van-icon name="clear" class="icon-clear" />
      </div>
    </van-cell>
    <van-popup
      v-model="show"
      closeable
      position="bottom"
      :style="{ height: '100%', background: 'rgba(246,246,246,1)' }"
    >
      <div v-for="item in list" :key="item.id" @click="choose(item)">
        <div class="title">
          <div class="heda">
            <img
              v-if="item.userPortrait"
              class="imgurl"
              :src="item.userPortrait"
              alt="用户头像"
            />
            <span v-if="!item.userPortrait" class="van-icon van-icon-manager" />
          </div>
          <div class="name-part">
            <div class="h3">
              {{ item.name }}
              <div v-if="item.party" class="party">
                <span class="icons icon-dangyuan " />
              </div>
            </div>
            <div class="time">
              <div class="left-part">
                <span class="right">{{ item.tel }}</span>
              </div>
            </div>
          </div>
        </div>
      </div>
    </van-popup>
  </div>
</template>
<script>
export default {
  data() {
    return {
      show: false,
      iscell: true,
      iscard: false,
      name: String,
      tel: String,
      id: String,
      userPortrait: String,
      party: String,

      list: [
        {
          name: "张三",
          tel: "18000000000".substr(0, 3) + "****" + "18000000000".substr(7),
          id: 0,
          userPortrait: "4a2bc1e6-d554-467e-a575-c348ec47793b.png",
          party: 1
        },
        {
          name: "李四",
          tel: "15000000000".substr(0, 3) + "****" + "15000000000".substr(7),
          id: 1,
          userPortrait: "4a2bc1e6-d554-467e-a575-c348ec47793b.png",
          party: 12
        }
      ]
    };
  },

  computed: {},
  methods: {
    showPopup() {
      this.show = true;
    },
    choose(item) {
      this.name = item.name;
      this.id = item.id;
      this.party = item.party;
      this.userPortrait = item.userPortrait;
      this.tel = item.tel;
      this.iscell = false;
      this.iscard = true;
      this.show = false;
    }
  }
};
</script>
<style lang="scss" scoped>
.serachuser {
  width: 94.6vw;
  height: 57px;
  background: rgba(255, 255, 255, 1);
  border-radius: 5px;
  border: 1px dashed rgba(170, 214, 235, 1);
  margin: auto;
  margin-top: 10px;
}
.add {
  top: 1.33333vw;
  font-size: 5.33333vw;
  position: relative;
  left: 31vw;
  border: none;
  color: #6ac2f6;
  background: white;
}
.btn-font {
  color: #4aa4c3;
  font-size: 16px;
  position: relative;
  top: -2px;
}
.h3 {
  color: #232323;
  font-size: 14px;
  font-weight: normal;
  padding: 0;
  width: 65%;
  float: left;
  margin-left: 10px;
  line-height: 20px;
  text-align: left;
  display: inline-flex;
  margin-top: 3px;
}
.title {
  min-height: 19vw;
  display: flex;
  flex-flow: row nowrap;
  justify-content: start;
  align-items: center;
  width: 100%;
  background: white;
}

.name-part {
  display: flex;
  flex-flow: column nowrap;
  justify-content: center;
  align-items: flex-start;
  width: calc(100% - 120px);
  position: relative;
  top: 0.66667vw;
}
.hrs {
  background: #eee;
  width: 95%;
  height: 0.1px;
  margin: auto;
}
.state {
  position: relative;
  top: -35px;
  left: 66.26667vw;
  color: #52c486;
  font-size: 14px;
}
.time {
  font-size: 3.2vw;
  font-family: MicrosoftYaHei;
  color: #7f7f7f;
  margin-left: 2.66667vw;
  width: 100%;
}

.left-part {
  max-width: 60%;
  height: 24px;
  overflow: hidden;
  display: flex;
  flex-flow: row wrap;
  justify-content: start;
  align-items: center;

  .tag {
    padding: 2px 4px;
    margin: 2px;
    color: #07c160;
    border: #07c160 1px solid;
    border-radius: 10px;
  }
}

.heda {
  width: 45px;
  height: 45px;
  border-radius: 100%;
  float: left;
  display: block;
  margin: 0;
  position: relative;
  background: #ccc;
  text-align: center;
  margin-left: 8px;
  margin-top: 5px;
}

.img {
  height: 100%;
  width: 100%;
  border-radius: 100%;
  position: absolute;
  left: 0;
}

.columnName {
  color: #fff;
  position: absolute;
  right: 0;
  top: 50%;
  transform: translate(0, -70%);
  background: #ff8200;
  line-height: 24px;
  border-radius: 12px;
  font-size: 12px;
  padding: 0 8px;
  text-align: center;
}

.van-icon-manager {
  font-size: 34px;
  color: #999;
  position: relative;
  top: 3px;
}

.party {
  height: 17px;
  width: 17px;
  background-color: #fe4949;
  color: yellow;
  margin-left: 2px;
  display: flex;
  justify-content: center;
  align-items: center;

  .icons {
    font-size: 14px;
  }
}
.h2 {
  color: #5a5a5a;
  font-size: 16px;
  font-weight: normal;
  padding: 0;
  line-height: 22px;
  text-align: left;
}
.textOverflowHidden {
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
  overflow: hidden;
}

.zoom {
  width: 112px;
  height: 81px;
  text-align: left;
  float: left;
}
.info {
  width: 100%;
  min-height: 120px;
}
.imgurl {
  height: 100%;
  width: 100%;
  border-radius: 100%;

  left: 0;
}
.img {
  width: 31.3%;
  height: 85px;
  margin: 10px 2% 0.5%;
  border-radius: 5px;
}
.content-container {
  margin-left: 3.66667vw;
  float: left;
  width: 220px;
  min-height: 120px;
  word-wrap: break-word;
  margin-top: 10px;
}
.icon-clear {
  color: #c2c2c2;
  font-size: 29px;
  left: 5vw;
}
</style>

效果图

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

备注:想了解更多关于vant内容

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值