<template>
	<view class="page__view">

		<navbar title="成员管理" leftClick @leftClick="$utils.navigateBack" bgColor="#FFFFFF" />

		<view class="main">

      <view class="tabs">
        <uv-tabs 
          :list="tabs" 
          :current="current"
          :scrollable="false" 
          lineColor="#00A9FF"
          lineWidth="48rpx"
          lineHeight="4rpx"
          :activeStyle="{
            'font-family': 'PingFang SC',
            'font-weight': 500,
            'font-size': '32rpx',
            'line-height': 1.4,
            'color': '#00A9FF',
          }" 
          :inactiveStyle="{
            'font-family': 'PingFang SC',
            'font-weight': 400,
            'font-size': '32rpx',
            'line-height': 1.4,
            'color': '#181818',
          }" 
          @click="clickTabs"
        ></uv-tabs>
      </view>

      <view class="list">
        <template v-if="current == 0">
          <view class="list-item" v-for="item in list" :key="item.id">
            <memberApplyCard :data="item" @submitted="getData"></memberApplyCard>
          </view>
        </template>
        <template v-else>
          <view class="list-item" v-for="item in list" :key="item.id">
            <memberCard :data="item" ></memberCard>
          </view>
        </template>
      </view>

    </view>

  </view>
  
</template>

<script>
	import mixinsList from '@/mixins/list.js'

  import memberCard from './memberCard.vue'
  import memberApplyCard from './memberApplyCard.vue'

  export default {
		mixins: [mixinsList],
    components: {
      memberCard,
      memberApplyCard,
    },
    data() {
      return {
        tabs: [
          { name: '绑定申请' },
          { name: '已绑定' },
        ],
        // todo
				mixinsListApi: '',
        current: 0,
      }
    },
    onShow() {
      console.log('onShow')
    },
    onLoad(arg) {
      this.clickTabs({ index: arg.index || 0 })
    },
    methods: {
      // todo: delete
      getData() {
        this.list = [
          {
            id: '001',
            name: '周小艺',
            userId: '15558661691',
            type: 0,
            createTime: '2025-04-28 08:14',
          },
          {
            id: '002',
            name: '周小艺',
            userId: '15558661691',
            type: 0,
            createTime: '2025-04-28 08:14',
          },
          {
            id: '003',
            name: '周小艺',
            userId: '15558661691',
            type: 1,
            createTime: '2025-04-28 08:14',
          },
          {
            id: '004',
            name: '周小艺',
            userId: '15558661691',
            type: 0,
            createTime: '2025-04-28 08:14',
          },
          {
            id: '005',
            name: '周小艺',
            userId: '15558661691',
            type: 0,
            createTime: '2025-04-28 08:14',
          },
        ]

      },
			//点击tab栏
			clickTabs({ index }) {
        console.log('clickTabs')
        this.current = index

				if (index == 0) {
					delete this.queryParams.status
				} else {
					this.queryParams.status = index - 1
				}
				this.getData()
			},
    },
  }
</script>

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

    /deep/ .nav-bar__view {
      position: fixed;
      top: 0;
      left: 0;
    }
  }

  .main {
    padding: calc(var(--status-bar-height) + 244rpx) 32rpx 40rpx 32rpx;

    .tabs {
      position: fixed;
      top: calc(var(--status-bar-height) + 120rpx);
      left: 0;
      width: 100%;
      height: 84rpx;
      background: #FFFFFF;
      z-index: 1;

      /deep/ .uv-tabs__wrapper__nav__line {
        border-radius: 2rpx;
      }

    }
	}


  .list {

    &-item {

      & + & {
        margin-top: 32rpx;
      }
    }
  }
</style>