<template>
	<view style="letter-spacing: 1rpx;">
		<tn-nav-bar :isBack="false" backTitle="" :bottomShadow="true" backgroundColor="#FFFFFF">
			<view class="custom-nav tn-flex tn-flex-col-center tn-flex-row-left">
				<view style="padding-left: 15rpx;" @click="goBack()">
					<text class="tn-icon-left" style="font-size: 40rpx;"></text>
				</view>
				<view class="tn-margin-top"
					style=";text-shadow:  1rpx 0 0 #FFF, 0 1rpx 0 #FFF, -1rpx 0 0 #FFF , 0 -1rpx 0 #FFF;">
					<tn-tabs :list="[{name:'组织架构'}]" :current="topCurrent" activeColor="#000" :bold="false"
						:fontSize="36"></tn-tabs>
				</view>
			</view>
		</tn-nav-bar>
		<view :style="{paddingTop: vuex_custom_bar_height+ 'px'}">
			<view style="padding: 30rpx;text-align: center;">
        <template  v-for="(item, index) in architecture">
          <tn-button backgroundColor="#E83A30" height="50rpx" width="250rpx" fontColor="#ffffff">{{item.position_name}}</tn-button>
          <tn-grid align="center" col="5">
            <tn-grid-item v-if="item.neirong" style="width:20%" v-for="(v,i) in item.neirong">
              <view style="padding: 30rpx;">
                <image :src="apiImgUrl+v.photo_image" style="width: 100rpx;height: 100rpx;border-radius: 50%;">
                </image>
                <view>{{v.nikename}}</view>
              </view>
            </tn-grid-item>
            <tn-grid-item v-if="!item.neirong" style="width:20%">
              <view style="padding: 30rpx;">
                <view>暂无</view>
              </view>
            </tn-grid-item>
          </tn-grid>
        </template>
			</view>

		</view>
	</view>
</template>

<script>
	import {architectureList} from "@/util/api";
  import store from "@/store";

  export default {
		data() {
			return {
				topCurrent: 0,
        architecture:[],
        apiImgUrl:this.$store.state.imgUrl,
			}
		},
    onLoad() {
      this.getArchitectureList();
    },
		methods: {
      getArchitectureList() {
        architectureList({
          association_id: store.state.Gid,
        })
            .then(res => {
              console.log(res);
              if(res.code==1){
                this.architecture=res.data;
              }
            })
            .catch(error => {
              uni.showToast({
                title: error,
                icon: 'none',
                duration: 2000
              });
            })
      },
			goBack() {
				if (getCurrentPages().length > 1) {
					uni.navigateBack()
				} else {
					uni.redirectTo({
						url: '/pages/index/index'
					})

				}
			}
		}
	}
</script>

<style>

</style>
