<template>
	<v-header title="我的设置" border backgroundColor="#fff">
    <view class="set-container flex">
      <view
          v-for="(item,index) in controlData"
          :key="index"
          class="step-control-item row aCenter"
          @click="trigger(item)"
      >
        <view class="flex-all-1">{{item.label}}</view>
        <text class="iconfont iconfont-more step-control-more"></text>
      </view>
      <view class="flex-all-1"></view>
      <view v-if="isLogin" class="step-control-button-container center">
        <view @click="outLogin" class="step-control-button center">退出登录</view>
      </view>
    </view>

  </v-header>
</template>

<script>
import vHeader from '@/components/v-header/main.vue';
import mixins from './mixins/index';
import controlData from './data/control';
import modal from '@/utils/tool/modal';
import notice from "@/utils/notice/index";
import toast from "../../utils/tool/toast";
export default {
  components:{
    vHeader
  },
  data(){
    return {
      controlData
    }
  },

  methods:{
    outLogin(){
      modal.confirm({
        title:'是否退出登录?',
        confirmText: '退出',
        confirmColor:'#FD3232',
        confirm:()=>{
          this.$store.commit('clearUserInfo');
        }
      })
    }
  },

  onShow(){
    if (this.storageMsg) {
      toast.success(this.storageMsg);
      this.storageMsg = null;
    }
  },

  created(){
    notice.on('set',(item)=>{
      if(item.toast) {
        this.storageMsg = item.toast;
      }
    },'setup');
  },

  beforeDestroy(){
    return notice.off('set','setup');
  },

  mixins
}
</script>

<style lang='scss' scoped src="./style.scss"></style>