MerchantList.vue 4.89 KB
<template>
  <view
    class="box"
    :key="selectMerchantId"
  >
    <template v-if="flag">
      <template v-if="loginUserInfoList.length">
        <template v-for="(item,index) in loginUserInfoList">
          <view
            :key="index"
            :class="['items' ,{active:item.active}]"
            @click="chooseAccount(item)"
          >
            <view class="right">
              <view class="sprite-icon icon-store"></view>
            </view>
            <view class="left">
              <view class="text_box">
                <view class="name">{{item.merchantName}}</view>
                <view class="text_no">商户号:{{item.merchantId}}</view>
              </view>
            </view>

          </view>
        </template>
      </template>
      <template v-else>
        <view class="list-not">
          暂无内容
        </view>
      </template>
    </template>
  </view>
</template>

<script type='text/ecmascript-6'>
export default {
  name: 'MerchantList',
  data () {
    return {
      loginUserInfoList: [],
      copyLoginUserInfoList: [],
      showSelect: false,
      openSceneArr: [],
      flag: false,
      userInfo: {},
      selectMerchantId:''
    }
  },
  onLoad () {

  },
  methods: {
    init (userInfo) {
      this.userInfo = userInfo
      this.getMerchantList()
      this.getSceneArr()
    },
    getSceneArr () {
      let { userInfo } = this
      // 超管开通全部场景
      if (userInfo?.isSuper) return
      // 获取4s店关联场景数据
      uni.$api.userApi.getYqMerchantSceneConfigAPI({
        yqMerchantId: userInfo?.subLoginUser?.merchantId,
        merchantId: userInfo?.shopMerchantId
      }).then(result => {
        uni.hideLoading()
        this.openSceneArr = result.map(val => { if (val.sceneOpenFlag == 0) return val.scene }) || []
      })
    },
    getMerchantList () {
      uni.showLoading()
      let { userInfo } = this
      let params = {
        merchantId: userInfo?.isSuper ? '' : userInfo?.merchantId,
        staffUUID: userInfo?.isSuper ? '' : userInfo?.uuid
      }
      uni.$api.userApi.getSceneMerchantRefStoreList(params).then(result => {
        uni.hideLoading()
        this.loginUserInfoList = result
        this.copyLoginUserInfoList = result
        this.flag = true
      }).catch(err => {
        uni.hideLoading()
        console.log(err)
      })
    },
    chooseAccount (item) {
      uni.showLoading()
      let { loginUserInfoList } = this
      let listArr = loginUserInfoList
      listArr.map(i => {
        i.active = false
        if (i.merchantId == item?.merchantId) {
          i.active = true
        }
        return i
      })
      this.loginUserInfoList = listArr
      this.selectMerchantId = item.merchantId
      this.jumpPage(item)
    },
    async jumpPage (item) {
      let { openSceneArr } = this,
        { merchantName: shopMerchantName, merchantId: shopMerchantId } = item,
        { userInfo } = this
      if (!openSceneArr?.length && !userInfo?.isSuper) return uni.showToast({
        title: '暂无开通业务,请联系总部管理员',
        icon: 'none'
      })
      this.$emit('chooseMerchant',{
        ...userInfo,
        shopMerchantName,
        shopMerchantId,
        default4SStoreInfo: {
          merchantId: shopMerchantId,
          merchantName: shopMerchantName
        },
        default4SStoreInfo_crowdFunding: {
          merchantId: shopMerchantId,
          merchantName: shopMerchantName
        },
        default4SStoreInfo_newCarConversion: {
          merchantId: shopMerchantId,
          merchantName: shopMerchantName
        }
      })
      uni.hideLoading()
    },
    searchEvent (searchValue) {
      let { copyLoginUserInfoList, selectMerchantId } = this
      copyLoginUserInfoList.map(val => {
        val.active = false
        if (val.merchantId == selectMerchantId) val.active = true
        return val
      })
      let filterArr = copyLoginUserInfoList.filter(val => val.merchantName.includes(searchValue) || val.merchantId == searchValue) || []
      this.loginUserInfoList = filterArr

      if (!searchValue) this.loginUserInfoList = copyLoginUserInfoList
    },
  }
}
</script>

<style scoped lang='scss'>
.box {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  padding: 0 48rpx;
  gap: 48rpx;
  .items {
    width: calc(50% - 24rpx);
    height: 160rpx;
    background: #ffffff;
    border-radius: 16rpx;
    padding: 32rpx;
    display: flex;
    align-items: center;
    box-sizing: border-box;
    border: 4rpx solid transparent;
    .right {
      margin-right: 28rpx;
      flex-shrink: 0;
    }
    .left {
      flex: 1;
      .name {
        font-weight: 500;
        font-size: 32rpx;
        color: #181a1f;
        margin-bottom: 12rpx;
      }
      .text_no {
        font-size: 28rpx;
        color: #999ea8;
      }
    }
  }
  .active {
    border: 4rpx solid #347bff;
  }
  .list-not {
    font-size: 28rpx;
    color: #999999;
    margin: auto;
  }
}
</style>