<template>
	<view class="page__view">

		<navbar title="切换档案" leftClick @leftClick="$utils.navigateBack" color="#191919" bgColor="#FFFFFF" />

    <view class="list">
      <uv-radio-group 
        v-model="selectedId" 
        placement="column"
        shape="circle"
        size="36rpx"
        iconSize="36rpx"
        activeColor="#00A9FF"
      >
        <view class="list-item" v-for="item in list" :key="item.id">
          <memberCard 
            :data="item" 
            :showRadio="true"
          ></memberCard>
        </view>
      </uv-radio-group>
    </view>

  </view>
  
</template>

<script>
	import { mapState } from 'vuex'

	import mixinsList from '@/mixins/list.js'

  import memberCard from './memberCard.vue'

  export default {
		mixins: [mixinsList],
    components: {
      memberCard,
    },
    data() {
      return {
        queryParams: {
          pageNo: 1,
          pageSize: 10,
          status: 1, // 绑定状态(status)：0-确认中 1-已绑定 2-已拒绝
        },
				mixinsListApi: 'queryBindList',
        selectedId: null,
      }
    },
    computed: {
			...mapState(['memberInfo']),
    },
    onLoad(arg) {
      if (this.memberInfo?.id) {
        this.selectedId = this.memberInfo.id
      }

      this.getData()
    },
    onUnload() {
      if (!this.selectedId) {
        this.$store.commit('setMemberInfo', null)
        return
      }

      const target = this.list.find(item => item.id === this.selectedId)
      this.$store.commit('setMemberInfo', target)
    },
    methods: {
      onSelect(id) {
        console.log('onSelect', id)
        this.selectedId = id
      },
    },
  }
</script>

<style scoped lang="scss">
  .page__view {
		width: 100vw;
		min-height: 100vh;
		background: $uni-bg-color;
		position: relative;
  }

  .list {
    padding: 32rpx 40rpx;

    &-item {

      & + & {
        margin-top: 24rpx;
      }

    }
  }

</style>