<template>
  <div class="container">
    <van-radio-group v-model="radio" class="nobr"  @change="handleStoreChange">
      <van-cell-group >
        <van-cell   v-for="(item,index) in list" :key="index"   >
          <div class="list">
            <div class="left">
              <img :src="item.logo" alt="" />
            </div>
            <div class="right">
              <h3>{{ item.name }}</h3>
              <p>{{ item.summaryTitle }}</p>
            </div>
          </div>
          <van-radio slot="right-icon" :name="item.oyStallCode" />
        </van-cell>
      </van-cell-group>
    </van-radio-group>
  </div>
</template>

<script>
import { getStoreList } from "@/api/sidebar/voucher"
import { log } from 'util';
export default {
  data() {
    return {
      radio: '',
      userId: '',
      list: []
    }
  },
  created() {  
    this.radio = sessionStorage.getItem('oyStallCode')    
    this.getList()  
  },
  methods: {
    getList() {    
      if(this.$route.query.userId !== '') {
        this.userId = this.$route.query.userId
      }else {
        this.userId = sessionStorage.getItem('userId')
      }      
      let params = {
        user_id: this.userId
      }
      getStoreList(params).then(res => {
        console.log(res.data)    
        this.list = res.data        
      })
    },
    handleStoreChange(val) {
      console.log(val,'修改后的oyStallCode')     
      sessionStorage.setItem('oyStallCode',val)    
        let obj = this.list.find(function (obj) {
          return obj.oyStallCode == val
        })
        console.log(obj,'obj')     
        sessionStorage.setItem("barName", obj.name)
      }
  }
}
</script>

<style scoped>
.container {
  height: auto;
  background-color: #fff;
  min-height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
}
.title {
  height: 44px;
  background: rgba(248, 248, 248, 1);
  line-height: 44px;
  padding: 0 16px;
  font-size: 12px;
  color: rgba(45, 71, 106, 1);
}
.fg {
  padding: 0 16px;
  font-size: 12px;
  color: rgba(45, 71, 106, 1);
  height: 44px;
  line-height: 44px;
}
.icon {
  font-weight: 800;
}
.active {
  background-color: #fff;
  padding: 12px 12px 0 12px;
  box-shadow: 0px 2px 4px 0px rgba(221, 221, 221, 1);
}
.list {
  height: 94px;
  width: 100%;
  background-color: #fff;
  display: flex;
  justify-content: space-between;
  border-bottom: 1px solid rgba(238, 238, 238, 1);
  margin-bottom: 14px;
}
.list3 {
  border-bottom: none;
  margin-bottom: 0;
}
.left,
.right {
  height: 80px;
}
.left {
  width: 80px;
  background: rgba(248, 248, 248, 1);
}
.left img {
  width: 100%;
  height: 80px;
}
.right {
  width: 76%;
  padding: 10px;
  background-color: #fff;
}
h3 {
  font-size: 14px;
  font-weight: bold;
  color: rgba(45, 71, 106, 1);
}
p {
  margin-top: 10px;
  font-size: 12px;
  color: rgba(45, 71, 106, 0.8);
}
.nobr >>> [class*=van-hairline]::after {
  display: none;
}
.nobr >>> .van-cell:not(:last-child)::after {
  display: none;
}
</style>