<template>
  <view class="client-setting">
    <page-navbar bgColor="#fff" title="设置"></page-navbar>
    <base-card marginBottom="24rpx" padding="0 24rpx">
      <u-cell-group v-for="(item, index) in LinkList1" :key="index" :border="false">
        <u-cell :title="item.title" isLink :border="index !== 1" :url="item.url" />
      </u-cell-group>
    </base-card>
    <base-card marginBottom="24rpx" padding="0 24rpx">
      <u-cell-group v-for="(item, index) in LinkList2" :key="index" :border="false">
        <u-cell :title="item.title" isLink :border="index !== 2" :url="item.url" />
      </u-cell-group>
    </base-card>
    <base-card padding="0 24rpx">
      <u-cell-group v-for="(item, index) in LinkList3" :key="index" :border="false">
        <u-cell :title="item.title" isLink :border="index !== 1" :url="item.url" />
      </u-cell-group>
    </base-card>

    <view>
      <u-button text="切换角色" :customStyle="customStyleRole" @click="handleRole"></u-button>
      <u-button text="退出登录" :customStyle="customStyleOut" @click="handleLogout"></u-button>
    </view>
  </view>
</template>

<script>
export default {
  data() {
    return {
      LinkList1: [
        {
          title: '个人信息',
          url: '/PageMine/setting/personInformation',
        },
        {
          title: '我的地址',
          url: '',
        },
      ],
      LinkList2: [
        {
          title: '用户协议',
          url: '/pages/webview/index?target=http://8.137.122.65:88/用户协议.html',
        },
        {
          title: '隐私协议',
          url: '/pages/webview/index?target=http://8.137.122.65:88/隐私政策.html',
        },
        {
          title: '注销账号',
          url: '',
        },
      ],
      LinkList3: [
        {
          title: '意见反馈',
          url: '/PageMine/feedback?channelType',
        },
        {
          title: '关于车旅程',
          url: '/PageMine/setting/aboutUs',
        },
      ],
    };
  },
  computed: {
    customStyleOut() {
      return {
        color: '#EB3636',
        marginTop: '32rpx',
        borderRadius: '16rpx',
        height: '94rpx',
        border: 'none',
        fontSize: '30rpx',
      };
    },
    customStyleRole() {
      return {
        color: '#0C1223',
        marginTop: '32rpx',
        borderRadius: '16rpx',
        height: '94rpx',
        border: 'none',
        fontSize: '30rpx',
      };
    },
  },
  methods: {
    handleRole() {
      this.$u.toast('该功能暂未开发，尽情期待！');
      // this.$store.dispatch('SwitchIdentity', 'MERCHANT');
      // uni.navigateTo({
      //   url: '/pages/merchant/mine/index',
      // });
    },
    handleLogout() {
      this.$store.dispatch('Logout').then(() => {
        uni.navigateTo({
          url: `pages/login/login`,
        });
      });
    },
  },
};
</script>

<style lang="scss" scoped>
.client-setting {
  padding: 20rpx 32rpx;

  ::v-deep .u-cell__title-text {
    line-height: 50rpx !important;
  }
}
</style>
