<template>
  <view class="page">
    <!-- #ifdef H5-->
    <uni-nav-bar v-if="!$isWxBrowser()" :fixed="true" background-color="#FFE05C" :border="false" :statusBar="false"
                 left-icon="left" title="我的角色" @clickLeft="back"/>
    <!-- #endif -->
    <view class="flex-col item" v-for="(item,index) in list" :key="index" @click="JumpRules(item)">
      <view class="flex-row">
        <text class="key">角色名称:</text>
        <view>
          <view class="phone">{{ item.name }}</view>
        </view>
      </view>
    </view>
    <!--#ifdef H5-->
    <liu-drag-button v-if="$isWxBrowser()" @clickBtn="back">返回</liu-drag-button>
    <!--#endif-->
  </view>
</template>

<script>

export default {

  data() {
    return {
      height: '',
      list: []
    }
  },
  onLoad(e) {
    this.getInfo()
    let sysInfo = uni.getSystemInfoSync()
    this.height = sysInfo.windowHeight - 120 + 'px' //除标题栏栏外的屏幕可用高度
  },
  methods: {
    back() {
      let pages = getCurrentPages()
      if (pages.length > 1) {
        uni.navigateBack({
          delta: 1,
          fail: err => {
            console.log(err)
          }
        })
      } else {
        uni.switchTab({
          url: '/pages/my/my'
        });
      }
    },
    JumpRules(item){
      uni.navigateTo({
        url: `/pages/myRules/index?id=${item.id}`
      });

    },
    getInfo() {
      this.$api.service.getRoleList().then((res) => {
        this.list = res.data.data
      })
    },
    goAddGroup() {
      uni.navigateTo({
        url: '/pages/addGroup/addGroup'
      })
    }
  }
}
</script>


<style lang="scss" scoped>
@import './index.rpx.css';
</style>
