<template>
  <view class="system-settimg">
    <view>
      <uni-nav-bar left-icon="back" @clickLeft="back" statusBar fixed title="">
        <view class="system-settimg-title">系统设置</view>
        <view slot="left"></view>
        <view slot="right"></view>
      </uni-nav-bar>
    </view>
    <view class="list-main" v-for="(item, index) in name" :key="index">
      <view class="list-flex" :class="index + 1 === name.length ? '' : 'list-border'" @click="checkList(index)">
        <view class="list-text">
          <text>{{ item }}</text>
        </view>
        <view class="">
          <text><uni-icons type="right" color="#000000" size="18"></uni-icons></text>
        </view>
      </view>
    </view>
    <qn-footer fixed height="120">
      <view class="flex-row-center-center">
        <view class="button flex-row-center-center" @click="exit(true)">
          <text class="text">退出登录</text>
        </view>
      </view>
    </qn-footer>
  </view>
</template>

<script>
import { back, go2, uploadFile, exit } from '@/utils/hook.js'
export default {
  data() {
    return {
      name: ['用户名', '账号管理', '用户协议', '系统权限', '关于纸掌柜']
    }
  },
  methods: {
    back,
    exit,
    // 校验是否有企业
    checkCompany(msg = '请完善企业信息') {
      let company = this.$store.state.supplierInfo
      if (!company || !company.id) {
        uni.showToast({
          title: msg,
          icon: 'none'
        })
        return false
      }
      return true
    },
    checkList(item) {
      switch (item) {
        case 0:
          if (!this.checkCompany()) {
            return
          }
          go2('user-info')
          break
        case 1:
          if (!this.checkCompany()) {
            return
          }
          go2('account-management')
          break
        case 2:
          go2('agreement')
          break
        case 3:
          let main = plus.android.runtimeMainActivity()
          let Intent = plus.android.importClass('android.content.Intent')
          let mIntent = new Intent('android.settings.WIRELESS_SETTINGS')
          main.startActivity(mIntent)
          break
        case 4:
          go2('about')
          break
        default:
          break
      }
    }
  }
}
</script>

<style lang="scss">
.system-settimg {
  .system-settimg-title {
    width: 100%;
    font-size: 36rpx;
    color: #000000;
    letter-spacing: 0;
    text-align: center;
    font-weight: 500;
  }
  .list-main {
    background-color: #ffffff;
  }
  .list-border {
    border-bottom: 2rpx solid #d8d8d8;
  }
  .list-flex {
    display: flex;
    justify-content: space-between;

    margin: 0rpx 32rpx;
    height: 100rpx;
    align-items: center;
  }
  .list-text {
    font-size: 28rpx;
    color: #000000;
    letter-spacing: 0;
    font-weight: 400;
  }
}
.button {
  width: 608rpx;
  height: 86rpx;
  background: #007aff;
  border-radius: 42rpx;
  .text {
    font-size: 32rpx;
    color: #ffffff;
  }
}
</style>
