sceneEntryDialog.vue 4.16 KB
<!-- 下载对账单 -->
<template>
  <d2-dialog title="场景入口"
             :is-visible="sceneEntryVisible"
             class="qRcodeDailog"
             width="750px"
             @closeDialog="handleClose"
             @confirmDialog="handleAddConfirm">
    <div class="scene-box">
      <div class="scene-item" v-for="(item, index) in sceneList" :key="index">
        <img class="scene-image" :src="`https://img02.glsx.com.cn/weapp/resource/dj-car-boutique-work-wechat/scene_type_${item.sceneType}.png`" alt="">
        <div class="item-text">
          <div class="text-name">{{ item.sceneName }}</div>
          <div class="text-tips">{{ item.sceneDesc }}</div>
        </div>
        <div class="switch-box">
          <el-switch v-model="item.isOpen"
                     active-value="Y"
                     inactive-value="N"
                     active-text="开"
                     inactive-text="关" />
          <!-- <div class="switch-text">开通此场景</div> -->
        </div>
      </div>
    </div>
  </d2-dialog>
</template>

<script>
import { getYqMerchantSceneConfigAPI, settingYqMerchantSceneAPI } from "@api/serviceManage"
export default {
  name: 'SceneEntryDialog',
  data() {
    return {
      sceneList: [{
        sceneName: '精品升级',
        sceneDesc: '太阳膜升级转化下单',
        sceneType: 1,
        isOpen: 'N'
      }, {
        sceneName: '会员权益/升级',
        sceneDesc: '新车车损下单',
        sceneType: 0,
        isOpen: 'N'
      }, {
        sceneName: '售后众筹',
        sceneDesc: '门店存量客户众筹团购下单',
        sceneType: 3,
        isOpen: 'N'
      }, {
        sceneName: '次新车转化',
        sceneDesc: '次新车用户领取套餐包转化',
        sceneType: 2,
        isOpen: 'N'
      }]
    }
  },

  props: {
    sceneEntryVisible: {
      type: Boolean,
      default: false
    },
    info: {
      type: Object,
      default: null
    }
  },

  watch: {
  },

  created() {
  },
  components: {},

  mounted() {
    // 获取当前园区店开通的场景入口
    getYqMerchantSceneConfigAPI({ yqMerchantId: this.info.yqMerchantId }).then(res => {
      res?.forEach(val => {
        this.sceneList.map(v => {
          if (v.sceneType === val.scene && val.sceneOpenFlag === 0) {
            v.isOpen = 'Y'
          }
          return v
        })
      })
    })
  },

  methods: {
    // 配置园区店场景入口
    handleAddConfirm() {
      const arr = []
      this.sceneList.forEach(v => {
        arr.push({
          merchantId: this.info.yqMerchantId,
          sceneOpenFlag: v.isOpen === 'Y' ? 0 : 1,
          scene: v.sceneType
        })
      })
      settingYqMerchantSceneAPI({ list: arr }).then(res => {
        this.notice.okTips()
        this.handleClose()
        this.$emit('keyDowmGetList')
      })
    },
    handleClose() {
      this.$emit('dialogClose', true)
    }
  }
}
</script>
<style lang="scss" scoped>
.scene-box{
  display: flex;
  flex-wrap: wrap;
  gap: 15px;
  .scene-item{
    display: flex;
    align-items: center;
    width: 343px;
    background: #F4F5FA;
    border-radius: 12px;
    padding: 16px;
    box-sizing: border-box;
    .scene-image{
      width: 64px;
      height: 64px;
      margin-right: 12px;
    }
    .item-text{
      .text-name{
        font-size: 16px;
        color: #333333;
        font-weight: 500;
      }
      .text-tips{
        margin-top: 5px;
        font-size: 12px;
        color: #9B9B9E;
        font-weight: 400;
      }
    }
    .switch-box{
      flex-grow: 1;
      text-align: right;
      .switch-text{
        margin-top: 5px;
        font-size: 12px;
        color: #2a58ad;
      }
    }
  }
}
::v-deep .el-switch__label {
  position: absolute;
  display: none;
  color: #fff;
}
/*打开时文字位置设置*/
::v-deep .el-switch__label--right {
  z-index: 1;
  right: 20px;

}
/*关闭时文字位置设置*/
::v-deep .el-switch__label--left {
  z-index: 1;
  left: 20px;
}
::v-deep .el-switch__label--left.is-active {
  display: block;
  span{
    font-size: 12px;
    color: #999999;
  }
}
::v-deep .el-switch__label--right.is-active {
  display: block;
  span{
    font-size: 12px;
    color: #FFFFFF;
  }
}
</style>