index.vue 16.7 KB
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 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 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 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 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651
<template>
  <view class="container" @click="handleTouchStart">
    <view :class="['home', { show: !activeDetailId && showHome }]">
      <left-side :userInfo="userInfo" :tabIndex.sync="tabIndex" ref="leftBox" @changeTab="changeTab" @stopAudio="stopAudio" @showReadCountTips="showReadCountTips" @closeTips="closeTips" @openChangePassword="handleOpenChangePassword" />
      <view class="tips-box" :style="tipsObject.style" @click.stop="closeTips">{{ tipsObject.text }}</view>
      <view class="right-side">
        <home-slot v-if="tabIndex == 0" :tabIndex="tabIndex" :moduleList="moduleList" @start="start" @changeType="changeType" />
        <template v-else-if="tabIndex != 99">
          <component :is="componentName" ref="pointRef" :userInfo="userInfo" @showPage="handleShowPage" :isPermissionFunction="isPermission" />
        </template>
      </view>
      <store-address v-if="footerBox" />
    </view>
    <view :class="['detail', { show: activeDetailId }]">
      <slot name="detail" />
    </view>
    <view class="point-page" v-if="!showHome && !activeDetailId">
      <component :is="pointComponentName" :transfer="transfer" @close="showHome = true" />
    </view>
    <!-- 未点击开始接待,弹窗 -->
    <MessageBox ref="previewRef" @confirm="previewHandler('preview', true)" :popupW="704" content="直接点击素材可进行预览,若面向车主展示,请点击「开始接待」" confirmBtnText="预览素材" @cancel="previewHandler('previewCancel')" @close="previewHandler('previewClose')"></MessageBox>
    <finish-reception-dialog ref="finish" @confirm="$emit('openStep')" @cancel="$emit('backHome')" />
    <!-- 恢复接待弹窗 -->
    <MessageBox ref="resumePopup" title="恢复接待" content="检测到您有上次未完成的接待,是否继续接待?" confirmBtnText="继续接待" cancelBtnText="开始新的" :showCancelBtn="true" :popupW="704" @confirm="resumeConfirm" @cancel="resumeCancel" @close="resumeCancel" />
    <!-- 升级弹框 -->
    <update-box />
    <slot name="content" />
    <!-- 隐形 Webview (声明式) -->
    <!-- 使用 webview-styles 控制原生层级位置 -->
    <!-- 
      切换上传方案:
      - 旧方案: @message="handleUploadMessage"
      - 新方案: @message="handleUploadMessageNew"(推荐)
      只需修改 @message 绑定的方法名即可无侵入切换
    -->
    <web-view ref="uploaderWebview" src="/hybrid/html/index.html" @message="handleUploadMessageNew" :webview-styles="webviewStyles"></web-view>
    <!-- 修改密码弹窗 -->
    <change-password ref="changePasswordRef" />
    <!-- <web-view
      ref="studyWebview"
      :src="jumpUrl"
      v-if="showBeisen"
    ></web-view> -->
  </view>
</template>
<script>
import ReceptionCenter from './components/ReceptionCenter/index.vue'
import FinishReceptionDialog from './components/FinishReceptionDialog.vue'
import StoreAddress from './components/StoreAddress.vue'
import timeout from '@/mixin/timeout'
import recorder from '@/mixin/record/recorder'
import versionCheck from '@/mixin/versionCheck.js'
import LeftSide from './components/LeftSide.vue'
import Material from '@/components/MaterialIndex.vue'
import HomeSlot from './components/HomeSlot.vue'
import Order from './components/Order/index.vue'
import ChangePassword from './components/ChangePassword.vue'
// import UploadService from '@/utils/recordManager/UploadService.js'
import { FileUploadManager, UploadService } from '@/utils/recordManager'

const TAB_COMPONENTS = {
  1: 'ReceptionCenter',
  2: 'Order'
}
export default {
  mixins: [recorder, versionCheck],
  components: { LeftSide, Material, ReceptionCenter, FinishReceptionDialog, StoreAddress, HomeSlot, Order, ChangePassword },
  props: {
    activeDetailId: [String, Number],
    finishDoneText: String,
    finishContene: {
      type: String,
      default: '当前操作视为强制退出接待,若需正常流程完成接待请点击「完成接待」'
    },
    moduleList: {
      type: Array,
      default: () => []
    },
    bannerKey: String,
    loadComplete: Boolean,
    swiperNoDataObject: Object,
    checkRecordAudio: {
      type: Boolean,
      default: true
    },
    swiperCustom: Boolean
  },
  data() {
    return {
      studyUrl: '',
      jumpUrl: '',
      transfer: '',
      footerBox: true,
      showHome: true,
      pointComponentName: 'Point',
      userInfo: {},
      tabIndex: 0,
      showBeisen: false,
      tipsObject: {},
      autoplay: true,
      previewOff: false,
      currentType: {},
      webviewStyles: Object.freeze({
        progress: false,
        width: '10px',
        height: '10px',
        position: 'absolute',
        top: '-1000px',
        left: '-1000px'
      })
    }
  },
  mounted() {
    const userInfo = uni.$storage.get('userInfo') || {}
    this.userInfo = userInfo
    this.currentType = uni.$storage.get('typeItem')

    // 初始化新的文件上传管理器
    // 传入 webviewRef 和 vueContext,FileUploadManager 会自动监听 webview_ready 信号
    // 调用方无需关心 WebView 的就绪时机
    FileUploadManager.init({
      webviewRef: this.$refs.uploaderWebview,
      vueContext: this
    })

    // if (this.checkRecordAudio) permision.requestAndroidPermission('android.permission.RECORD_AUDIO') // 进入界面时检查权限
  },
  beforeDestroy() {
    // 清理 FileUploadManager 资源
    FileUploadManager.destroy()
  },
  provide() {
    return {
      showPage: this.handleShowPage,
      hideFooter: this.handleFooter
    }
  },
  computed: {
    finishRef() {
      return this.$refs.finish
    },
    componentName() {
      return TAB_COMPONENTS[this.tabIndex] || ''
    }
  },
  methods: {
    async changeTab({ item, index }) {
      this.previewOff = index != 0
      this.$emit('changeTab', index)
    },
    handleFooter(val) {
      this.footerBox = val
    },
    handleShowPage(name, transfer) {
      this.transfer = transfer
      this.showHome = false
      this.pointComponentName = name
    },

    showReadCountTips(res) {
      this.tipsObject = res
    },
    closeTips() {
      this.tipsObject = {
        style: '',
        text: ''
      }
    },
    previewHandler(name, off = false) {
      this.previewOff = off
      this.$emit(name)
    },
    async start() {
      this.$emit('start')
    },
    async changeType() {
      // this.$refs.bizTypeSelector.open()
      this.$emit('changeType')
    },
    chooseBusinessType(item) {
      this.currentType = item
      uni.$storage.set('typeItem', item)
      this.$emit('changeType')
    },
    handleUploadMessage(event) {
      // 接收来自 Webview 的消息
      const data = event.detail.data[0]
      if (data) {
        // 1. 处理 Webview 就绪信号 (Event-Driven 初始化)
        if (data.action === 'webview_ready') {
          uni.$logger.local.info('【上传服务】收到 Webview 就绪信号,开始注入 Context')
          // 此时 Webview 必然已存在,无需延迟
          this.$nextTick(() => {
            UploadService.setWebviewContext(this.$refs.uploaderWebview, this)
          })
          return
        }

        // 2. 处理上传回调
        UploadService.handlerMessage(event)
      }
    },
    handleUploadMessageNew(event) {
      FileUploadManager.handleWebViewMessage(event)
    },
    handleTouchStart() {
      uni.$emit('reset_timeout')
    },
    handleOpenChangePassword() {
      this.$refs.changePasswordRef.open()
    }
  }
}
</script>
<style scoped lang="scss">
.container {
  position: relative;

  .tips-box {
    position: absolute;
    color: #ffffff;
    font-size: toRpx(28);
    width: toRpx(310);
    height: toRpx(90);
    line-height: toRpx(68);
    background-image: url('@/assets/images/home/daliog.png');
    background-size: 100% 100%;
    z-index: 9;
    padding-left: toRpx(60);
    text-align: left;
    display: none;
    opacity: 0;
    will-change: opacity, display; // 优化动画性能
  }

  &::after {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    width: 100vw;
    height: 100vh;
    background-image: url('@/assets/images/common/home-bg-1.webp');
    background-size: 100% 100%;
    z-index: 1;
  }

  .home {
    position: fixed;
    width: 100%;
    height: 100%;
    z-index: -1;
    top: 0;
    left: 0;
    visibility: hidden;
    opacity: 0;
    will-change: opacity, visibility; // 提示浏览器提前优化

    // 使用3D加速,避免重绘
    transform: translateZ(0);
  }

  .detail {
    position: fixed;
    width: 100vw;
    height: 100vh;
    left: 0;
    top: 0;
    z-index: -1;
    visibility: hidden;
    transform: translateX(100%);
    transition:
      transform 0.5s cubic-bezier(0.19, 1, 0.22, 1),
      visibility 0.5s;
    will-change: transform, visibility; // 提示浏览器提前优化

    &.show {
      z-index: 2;
      visibility: visible;
      transform: translateX(0);
      will-change: transform;
    }
  }

  .point-page {
    position: fixed;
    width: 100%;
    height: 100%;
    z-index: 2;
    top: 0;
    left: 0;
  }

  .home {
    display: flex;
    height: 100vh;
    position: relative;

    .store-addr {
      position: absolute;
      left: 50%;
      bottom: toRpx(24);
      transform: translateX(-50%);
      display: flex;
      align-items: center;

      .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%);
      }
    }
  }

  .show {
    opacity: 1;
    position: absolute;
    z-index: 2;
    visibility: visible;
    animation: show-content-left 0.15s forwards;
  }
}

@keyframes show-content-left {
  0% {
    transform: translateX(100%);
  }

  100% {
    transform: translateX(0);
  }
}

.right-side {
  flex: 1;
  position: relative;
  width: calc(100vw - #{toRpx(240)});

  .right-content {
    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 {
    height: toRpx(232);
    box-sizing: border-box;
    margin-right: toRpx(64);
    position: relative;
    background: url('@/assets/images/home/start-btn.png') no-repeat;
    background-size: 100% 100%;
    padding-top: toRpx(60);
    display: flex;
    justify-content: center;

    .sprite-icon {
      zoom: 2;
    }
  }

  .right-content-box {
    width: 100%;
    // height: calc(100% - #{toRpx(232)});
    height: 100%;
    gap: toRpx(48);
    box-sizing: border-box;
    padding: toRpx(32) 0 toRpx(80);

    .box-class {
      background: #ffffff59;
      backdrop-filter: blur(toRpx(16));
      box-shadow: inset 0 0 toRpx(16) 0 #ffffff;
      border-radius: toRpx(48);
      overflow: hidden;
    }

    .content-box {
      position: relative;
      width: 100%;
      height: calc(100% - #{toRpx(160)});

      .message-box {
        height: 100%;
      }
    }

    .content-left,
    .content-right {
      height: 100%;
      flex-shrink: 0;
    }

    .content-left {
      width: calc(100% - #{toRpx(48)});

      .common-title {
        display: flex;
        align-items: center;
        /* justify-content: space-between; 不需要space-between,左对齐自然排列 */
        padding-right: toRpx(48); /* 保持右侧边距 */

        .title-text {
          flex: 1; /* 标题占据剩余空间 */
          overflow: hidden;
          text-overflow: ellipsis;
          white-space: nowrap;
        }

        .switch-btn {
          display: flex;
          align-items: center;
          background: rgba(255, 255, 255, 0.4); /* 半透明白底,融入蓝底 */
          border: 1px solid rgba(255, 255, 255, 0.6);
          border-radius: toRpx(26);
          padding: 0 toRpx(20);
          height: toRpx(52);
          box-sizing: border-box;
          margin-left: toRpx(24);
          transition: all 0.2s ease;
          cursor: pointer;

          text {
            font-size: toRpx(24);
            color: #5b6b8c; /* 蓝灰色,低调且协调 */
            font-weight: 400;
            margin-left: toRpx(8);
          }

          .icon-exchange {
            /* 复用 sprite 图标 */
            zoom: 0.7;
            opacity: 0.7;
            /* 移除去色滤镜,让图标自然的色调显露,或者保持微调 */
          }

          /* 移除之前的 SVG 图标样式 */
          &::before {
            display: none;
          }

          &:active {
            background: rgba(255, 255, 255, 0.7);
            transform: scale(0.98);
          }
        }
      }

      .module-box {
        height: calc(100% - #{toRpx(235)});
        margin-bottom: toRpx(48);
      }
      .select-type {
        position: absolute; /* 改为绝对定位,悬浮 */
        right: toRpx(48);
        top: 68%; /* 向下调整,避免顶部遮挡 */
        transform: translateY(-50%);
        width: toRpx(128); /* 加大尺寸 */
        height: toRpx(128);
        border-radius: 50%;
        background: linear-gradient(135deg, #6187e7 0%, #8a6ef5 100%);
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        box-shadow: 0 toRpx(8) toRpx(20) rgba(97, 135, 231, 0.5);
        z-index: 10;
        animation: breathe 3s infinite ease-in-out; /* 呼吸效果 */

        .text {
          font-size: toRpx(22);
          color: #fff;
          font-weight: 600;
          line-height: 1.2;
          text-align: center;
          width: toRpx(80);
          text-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
        }

        .icon-arrow {
          display: none; /* 圆形按钮不需要箭头 */
        }

        /* 流光圆环 */
        &::before {
          content: '';
          position: absolute;
          top: toRpx(-8);
          left: toRpx(-8);
          right: toRpx(-8);
          bottom: toRpx(-8);
          border-radius: 50%;
          border: toRpx(4) solid transparent;
          border-top-color: #ffffff;
          border-right-color: rgba(255, 255, 255, 0.6);
          border-bottom-color: rgba(138, 110, 245, 0.4);
          /* 光影辉光效果 */
          box-shadow:
            0 0 toRpx(16) rgba(97, 135, 231, 0.6),
            inset 0 0 toRpx(10) rgba(255, 255, 255, 0.2);
          filter: drop-shadow(0 0 toRpx(6) rgba(255, 255, 255, 0.8));
          animation: rotate-ring 4s linear infinite;
        }

        /* 内部高光 */
        &::after {
          content: '';
          position: absolute;
          top: 0;
          left: 0;
          width: 100%;
          height: 100%;
          border-radius: 50%;
          background: radial-gradient(circle at 30% 30%, rgba(255, 255, 255, 0.5) 0%, transparent 60%);
        }

        &:active {
          transform: translateY(-50%) scale(0.9);
          box-shadow: 0 toRpx(4) toRpx(10) rgba(97, 135, 231, 0.5);
        }
      }

      @keyframes breathe {
        0%,
        100% {
          transform: translateY(-50%) scale(1);
          box-shadow: 0 toRpx(8) toRpx(20) rgba(97, 135, 231, 0.5);
        }
        50% {
          transform: translateY(-50%) scale(1.05);
          box-shadow: 0 toRpx(12) toRpx(30) rgba(97, 135, 231, 0.7);
        }
      }

      @keyframes rotate-ring {
        0% {
          transform: rotate(0deg);
        }
        100% {
          transform: rotate(360deg);
        }
      }

      .tool-box {
        height: calc(100% - #{toRpx(712)});

        .content-box {
          width: calc(100% - #{toRpx(96)});
          margin: 0 toRpx(48);
        }
      }
    }

    .content-right {
      width: calc(100% - #{toRpx(1322)});
      // width: toRpx(800);
    }
  }

  .app-content-box {
    width: 100%;
    position: absolute;
    left: 0;
    top: 0;
    opacity: 0;
    z-index: -999;
  }

  .show-content-box {
    opacity: 1;
    z-index: 1;
  }
}

.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);
  }
}

.lead-page {
  height: 100vh;
  width: 100vw;
  z-index: 999999;
  position: fixed;
}
</style>