accountItems.vue 6.48 KB
<template>
  <view class="layout">
    <view class="bg"></view>
    <view class="nav-bar">
      <view
        class="back"
        @click="back"
      >
        <uni-icons
          type="left"
          :size="24"
        ></uni-icons>
      </view>
    </view>
    <view class="step-box">
      <template v-for="(i,index) in stepList">
        <view
          :class="['step-item',{'active-item':stepIndex >= index}]"
          :key="index"
          @click="setStep(index)"
        >
          <view class="num">
            <view class="border"></view>
            <view class="text">{{index + 1}}</view>
          </view>{{i}}
        </view>
      </template>
    </view>
    <view class="content-box">
      <template v-if="stepIndex != 2">
        <view class="search-box">
          <view class="search-input">
            <template v-if="!edit">
              <view
                :class="['input', `${searchValue ? '' : 'placeholder'}`]"
                @click="open"
              >
                <template v-if="searchValue">
                  {{searchValue}}
                </template>
                <template v-else>
                  请输入门店名称/商户号搜索
                  <view class="sprite-icon icon-search"></view>
                </template>
              </view>
            </template>
            <template v-else>
              <input
                type="text"
                class="input"
                v-model="searchValue"
                :focus='inputFocus'
                confirm-type="search"
                @blur="search"
                @confirm="search"
              />
            </template>
          </view>
        </view>
      </template>
      <scroll-view
        class="list"
        scroll-y
        enable-flex
      >
        <account-list
          v-show="stepIndex == 0"
          ref="account"
          @chooseAccount="chooseAccount"
        />
        <merchant-list
          v-show="stepIndex == 1"
          ref="merchant"
          @chooseMerchant="chooseMerchant"
        />
        <scene
          v-show="stepIndex == 2"
          ref="scene"
        />
      </scroll-view>
    </view>
  </view>
</template>

<script type='text/ecmascript-6'>
import AccountList from './components/AccountList.vue'
import MerchantList from './components/MerchantList.vue'
import Scene from './components/Scene.vue'
export default {
  name: 'accountItem',
  components: { AccountList, MerchantList, Scene },
  data () {
    return {
      stepList: ['选择帐号', '选择4S店', '选择场景'],
      stepIndex: 0,
      searchValue: '',
      edit: false,
    }
  },
  onLoad (options) {
    this.stepIndex = options?.stepIndex || 0
  },
  mounted () {
  },
  methods: {

    search () {
      this.edit = false
      const { stepIndex } = this
      this.$refs[{
        0: 'account',
        1: 'merchant'
      }[stepIndex]]?.searchEvent(this.searchValue)
    },
    open () {
      this.edit = true
      this.inputFocus = true
    },
    back () {
      uni.navigateBack()
    },
    chooseAccount (userInfo) {
      this.stepIndex = 1
      this.$nextTick(() => {
        this.$refs.merchant.init(userInfo)
      })
    },
    chooseMerchant (userInfo) {
      this.stepIndex = 2
      this.$refs.scene.init(userInfo)
    },
    setStep(index){
      let {stepIndex} = this
      if(index == 2) return
      if(stepIndex > index) this.stepIndex = index
      
    }
  }
}
</script>

<style scoped lang='scss'>
.layout {
  padding-top: 144rpx;
  font-size: 28rpx;
  color: #333;
  letter-spacing: 0;
  background: #f7f8fa;
  box-sizing: border-box;
  height: 100%;
  .bg {
    position: fixed;
    width: 100%;
    height: 100%;
    left: 0;
    top: 0;
    background-image: url("../../assets/images/login/account-bg.webp");
    background-size: 100% 100%;
  }
  .nav-bar {
    position: fixed;
    width: 100%;
    height: 96rpx;
    left: 0;
    top: 48rpx;
    z-index: 9;
    .back {
      height: 100%;
      aspect-ratio: 1/1;
      display: flex;
      align-items: center;
      justify-content: center;
    }
  }
  .step-box {
    position: relative;
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0 166rpx;
    .step-item {
      display: flex;
      align-items: center;
      font-weight: 500;
      font-size: 36rpx;
      color: #999999;
      .num {
        width: 56rpx;
        height: 56rpx;
        position: relative;
        padding: 4rpx;
        color: #ffffff;
        box-sizing: border-box;
        margin-right: 10rpx;
        &::after {
          position: absolute;
          top: 0;
          left: 0;
          bottom: 0;
          right: 0;
          border: 2rpx solid #b1b1b1;
          content: "";
          border-radius: 100%;
        }
        .text {
          width: 100%;
          height: 100%;
          display: flex;
          align-items: center;
          justify-content: center;
          font-weight: 700;
          font-size: 32rpx;
          background: #b1b1b1;
          border-radius: 100%;
        }
      }
    }
    .active-item {
      color: #4673ff;
      .num {
        &::after {
          border-color: #4673ff;
        }
        .text {
          background: #4673ff;
        }
      }
    }
  }
  .content-box {
    width: 81.84%;
    height: calc(100vh - 404rpx);
    position: relative;
    margin: 48rpx auto 0;
    box-sizing: border-box;
    padding-top: 48rpx;
    box-shadow: inset 0 0 16rpx 0 #ffffff;
    border-radius: 48rpx;
    background: #ffffff59;
    &::after {
      position: absolute;
      content: "";
      left: 0;
      top: 0;
      width: 100%;
      height: 100%;
      background: #ffffff59;
      box-shadow: inset 0 0 16rpx 0 #ffffff;
      border-radius: 48rpx;
      filter: blur(8rpx);
    }
  }
  .search-box {
    margin: 0 48rpx 48rpx;
    position: relative;
    z-index: 2;
    .search-input {
      width: 100%;
      height: 80rpx;
      background: #ffffff;
      border: 3rpx solid #a8c1ff;
      border-radius: 16rpx;
      box-sizing: border-box;
      color: #333;
      box-sizing: border-box;
      padding: 0 24rpx;
      font-size: 28rpx;
      .input {
        display: flex;
        align-items: center;
        height: 100%;
        width: 100%;
        justify-content: center;
        text-align: center;
        font-size: 28rpx;
      }
      .icon-search {
        margin-left: 16rpx;
      }
      .placeholder {
        font-size: 28rpx;
        color: #999999;
      }
    }
  }
  .list {
    position: relative;
    z-index: 2;
    height: calc(100% - 176rpx);
  }
}
</style>