index.vue 7.43 KB
<template>
  <view class="container" @click="handleTouchStart">
    <view :class="['home', { show: !id && showHome }]">
      <left-side :userInfo="userInfo" :tabIndex.sync="tabIndex" ref="leftBox" @changeTab="$emit('changeTab', $event)" @stopAudio="stopAudio" />
      <view class="right-side">
        <template v-if="tabIndex == 0">
          <view class="right-content">
            <view class="start" @click="$emit('start')">
              <image class="start-btn" src="../../assets/images/home/start.gif" alt="开始接待" />
              <image class="start-border" src="../../assets/images/home/start-border.png" />
            </view>
            <view class="module-list">
              <slot name="module" />
            </view>
          </view>
        </template>
        <template v-else>
          <component :is="componentName" :userInfo="userInfo" @showPage="handleShowPage" />
        </template>
        <view class="store-addr">
          <view class="icon-addr sprite-icon icon-addr"></view>
          <view class="addr-text">{{ userInfo.shopMerchantName }}</view>
        </view>
      </view>
    </view>
    <view :class="['detail', { show: id }]">
      <slot name="detail" />
    </view>
    <view class="point-page" v-if="!showHome">
      <component :is="pointComponentName" @backHome="backHome" @jump="jump" :transfer="transfer" />
    </view>
    <!-- 未点击开始接待,弹窗 -->
    <MessageBox ref="previewRef" @confirm="$emit('preview')" :popupW="704" content="直接点击素材可进行预览,若面向车主展示,请点击「开始接待」" confirmBtnText="预览素材" @cancel="$emit('previewCancel')" @close="$emit('previewClose')"></MessageBox>
    <!-- 停留弹框 -->
    <MessageBox ref="tipBox" @cancel="tipCancel" @confirm="tipConfirm" content="系统检测到您在当前页面停留较久,是否仍在客户接待中?" cancelBtnText="否" confirmBtnText="是"></MessageBox>
    <!-- 退出弹框 -->
    <MessageBox :popupW="704" ref="finish" :content="finishContene" :isFooter="false">
      <view class="footer">
        <view class="footer-btn confirm flex" @click="$emit('openStep')">
          <template v-if="finishDoneText">
            {{ finishDoneText }}
          </template>
          <template v-else>
            完成接待
            <text>(推荐)</text>
          </template>
        </view>
        <view class="footer-btn cancel flex" @click="$emit('backHome')">
          仍要退出
          <text>(不推荐)</text>
        </view>
      </view>
    </MessageBox>
    <!-- 升级弹框 -->
    <update-box />
    <slot name="content" />
    <web-view @message="handlerMessage" ref="webview" src="/hybrid/html/index.html"></web-view>
  </view>
</template>
<script>
import RecordList from './components/RecordList.vue'
import myClick from '@/mixin/click'
import uploader from '@/mixin/uploader.js'
import CustomerFile from './components/CustomerFile.vue'
import LeftSide from './components/LeftSide.vue'
import Point from './components/Point.vue'
import dayPoint from './components/Point/DayPoint.vue'
import rulePoint from './components/Point/RulePoint.vue'
import LevelPoint from './components/Point/LevelPoint.vue'
import Course from './components/Point/Course.vue'
import Ranking from './components/Point/Ranking.vue'
export default {
  mixins: [myClick, uploader],
  components: { RecordList, CustomerFile, LeftSide, Point, dayPoint, rulePoint, Course, Ranking, LevelPoint },
  props: {
    id: [String, Number],
    finishDoneText: String,
    finishContene: {
      type: String,
      default: '当前操作视为强制退出接待,若需正常流程完成接待请点击「完成接待」'
    }
  },
  data() {
    return {
      transfer: '',
      showHome: true,
      pointComponentName: 'dayPoint',
      userInfo: {},
      tabIndex: 0
    }
  },
  mounted() {
    const userInfo = uni.$storage.get('userInfo') || {}
    this.userInfo = userInfo
  },

  computed: {
    previewRef() {
      return this.$refs.previewRef
    },
    finishRef() {
      return this.$refs.finish
    },
    componentName() {
      const len = this.$refs.leftBox.tabs.length
      if (this.tabIndex == 0) return 'HomeSlot'
      else if (this.tabIndex == 1) return 'RecordList'
      else if (this.tabIndex == len - 1) return 'Point'
      else return 'CustomerFile'
    }
  },
  methods: {
    backHome() {
      this.showHome = true
    },
    jump() {
      console.log(888)
      this.showHome = true
      this.$emit('start')
    },
    handleShowPage(name, transfer) {
      console.log(transfer, 'transfer')
      this.transfer = transfer
      this.showHome = false
      this.pointComponentName = name
    }
  }
}
</script>
<style scoped lang="scss">
.container {
  position: relative;
  &::after {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    width: 100vw;
    height: 100vh;
    background-image: url('@/assets/images/common/home-bg.webp');
    background-size: 100% 100%;
  }
  .home,
  .detail {
    position: fixed;
    width: 100%;
    height: 100%;
    z-index: -1;
    top: 0;
    left: 0;
    visibility: hidden;
  }
  .point-page {
    position: fixed;
    width: 100%;
    height: 100%;
    z-index: 1;
    top: 0;
    left: 0;
  }
  .home {
    display: flex;
    height: 100vh;
  }
  .show {
    position: absolute;
    z-index: 1;
    visibility: visible;
    animation: show-content-left 0.15s forwards;
  }
}
@keyframes show-content-left {
  0% {
    left: 100%;
  }
  100% {
    left: 0;
  }
}

.right-side {
  flex: 1;
  position: relative;
  .right-content {
    padding-top: toRpx(92);
    height: 100vh;
    box-sizing: border-box;
    position: relative;
    animation: show-box 0.15s forwards;
    overflow: hidden;
  }
  @keyframes show-box {
    0% {
      left: 100%;
    }
    100% {
      left: 0;
    }
  }
  .start {
    &-btn {
      width: 100%;
      height: 100%;
    }
    &-border {
      position: absolute;
      width: 100%;
      height: 100%;
      left: 0;
      top: 0;
      vertical-align: top;
    }
    height: toRpx(336);
    box-sizing: border-box;
    margin-right: toRpx(64);
    position: relative;
    padding: toRpx(32);
  }
  .module-list {
    height: calc(100% - #{toRpx(336)});
  }
  .store-addr {
    position: absolute;
    left: 50%;
    bottom: toRpx(24);
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    margin-top: toRpx(38);
    .icon-addr {
      width: toRpx(32);
      height: toRpx(32);
      flex-shrink: 0;
    }
    .addr-text {
      font-size: toRpx(24);
      color: #999999;
      word-wrap: break-word;
      white-space: normal;
      line-height: toRpx(32);
      margin-left: toRpx(4);
      flex-shrink: 0;
    }
    &::before,
    &::after {
      content: '';
      width: toRpx(600);
      height: toRpx(2);

      margin: 0 toRpx(40);
    }
    &::before {
      background-image: linear-gradient(270deg, #eeeeee 0%, #d8d8d800 100%);
    }
    &::after {
      background-image: linear-gradient(90deg, #eeeeee 0%, #d8d8d800 100%);
    }
  }
}
.footer {
  border-top: toRpx(2) solid #eff0f2;
  font-weight: 600;
  font-size: toRpx(32);
  margin-top: toRpx(48);
  .footer-btn {
    justify-content: center;
    margin: toRpx(16) auto 0;
  }
  .confirm {
    width: toRpx(608);
    height: toRpx(80);
    background: #2c66f7;
    border-radius: toRpx(40);
    color: #fff;
  }
  .cancel {
    width: toRpx(608);
    height: toRpx(80);
    background: #ffffff00;
    border-radius: toRpx(40);
    color: #2c66f7;
  }
  text {
    font-size: toRpx(24);
  }
}
</style>