index.vue 5.66 KB
<template>
  <div class="layout">
    <div class="search sticky">
      <search @search="search" />
      <tab
        :list="['全部活码','我的活码']"
        @change="change"
      ></tab>
    </div>
    <scroll-view
      class="content"
      @ReachBottom="onReachBottom"
      ref="scrollView"
    >
      <template v-if="flag">
        <template v-if="list.length">
          <template v-for="(i,index) in list">
            <div
              class="qr-box"
              :key="index"
            >
              <div class="title text-hide">{{i.codeName}}</div>
              <div class="name-list">
                <div class="label">扫码添加人员:</div>
                <div class="value">{{i.staffName}}</div>
              </div>
              <div class="remark">
                备注:{{i.codeRemark || '- -'}}
              </div>
              <div class="img-box">
                <template v-for="(item,ind) in i.imgList">
                  <div
                    :key="ind"
                    class="item"
                    v-if="ind < 9"
                  >
                    <img
                      :src="item.thumbnailUrl"
                      @click="previewImage(i.imgList,ind)"
                    >
                    <div
                      class="mask text-center"
                      v-if="ind == 8"
                    >+{{i.imgList.length - 9}}</div>
                  </div>
                </template>
              </div>
            </div>
          </template>
        </template>
        <template v-else>
          <van-empty description="暂无内容" />
        </template>
      </template>

    </scroll-view>
    <resource-popup
      v-model="showPopup"
      @close="showPopup = false"
      :data="currentItem"
    />
  </div>
</template>

<script type='text/ecmascript-6'>
import { Notify } from 'vant'
import { entmicroApi } from '@/api'
export default {
  name: '',
  data () {
    return {
      showPopup: false,
      codeNameOrStaffName: '',
      list: [],
      currentItem: {},
      flag: false,
      tabIndex: 0
    }
  },
  mounted () {
    this.getList()
  },
  methods: {
    change (e) {
      this.flag = false
      this.list = []
      this.tabIndex = e
      this.getList()
    },
    getList () {
      let { codeNameOrStaffName, tabIndex } = this
      let obj = {}
      if (codeNameOrStaffName) obj.codeNameOrStaffName = codeNameOrStaffName
      this.showLoading()
      let target = ['getAllEntmicroChannelCodeList', 'getEntmicroChannelCodeList'][tabIndex]
      entmicroApi[target](obj).then(({ code, data, message }) => {
        this.hideLoading()
        if (code == '0') {
          data.map(e => {
            let imgList = [
              {
                id: e.id,
                autoUrl: e.qrCode,
                thumbnailUrl: e.qrCode
              }
            ]
            if (e.codeInfo && e.codeInfo.length) {
              e.codeInfo.map(i => {
                imgList.push(i)
              })
            }
            e.imgList = imgList
          })

          this.list = data
        } else {
          Notify(message)
        }
        this.flag = true
      })
    },
    previewImage (list, startPosition) {
      let images = []
      list.map(e => images.push(e.autoUrl))
      this.$router.push({
        name: 'attractCustomer.detail',
        params: {
          images,
          startPosition
        }
      })
    },
    share (e) {
      this.showPopup = true
      this.currentItem = e
    },
    search (e) {
      console.log(e)
      this.codeNameOrStaffName = e
      this.flag = false
      this.getList()
    },
    onReachBottom () {
      console.log('触底')
      this.$refs.scrollView.loading = false
      this.$refs.scrollView.finished = true
    }
  }
}
</script>

<style scoped lang='scss'>
.layout {
  .search {
    top: 0;
    z-index: 2;
    background-color: #fff;
  }
  .content {
    padding: 16px;
    height: calc(100vh - 100px);
    width: 100%;
    /deep/.van-list{
      background-color: transparent !important;
    }
    .qr-box {
      background: #ffffff;
      box-shadow: 0px 4px 8px 0px rgba(224, 224, 224, 0.5);
      border-radius: 4px;
      padding: 16px 10px;
      margin-bottom: 10px;
      position: relative;
      font-size: 12px;
      .share {
        position: absolute;
        right: 10px;
        top: 16px;
        width: 63px;
        height: 24px;
        background: #3975c6;
        border-radius: 12px;
        color: #ffffff;
        .sprite-icon {
          margin-left: 5px;
        }
      }
      .title {
        width: 224px;
        color: #333333;
        font-size: 16px;
        font-weight: 500;
        margin-bottom: 8px;
      }
      .name-list {
        display: flex;
        margin-bottom: 8px;
        .label {
          color: #666666;
          width: 90px;
          flex-shrink: 0;
        }
      }
      .remark,
      .name-list {
        color: #999999;
      }
      .img-box {
        padding-top: 8px;
        // display: flex;
        // flex-wrap: wrap;
        display: grid;
        grid-template-columns: repeat(3, 102px);
        gap: 8px;
        .item {
          width: 102px;
          height: 102px;
          position: relative;
          // margin-top: 8px;
          // margin-right: 8px;
          // &:nth-of-type(3n + 3) {
          //   margin-right: 0;
          // }
          .mask {
            position: absolute;
            width: 100%;
            height: 100%;
            background-color: rgba($color: #000000, $alpha: 0.5);
            color: #fff;
            font-weight: 500;
            font-size: 16px;
            top: 0;
            left: 0;
            pointer-events: none;
          }
        }
      }
    }
  }
}
</style>