<template>
  <view class="dt-page">
    <DtMenuList
      :menuStyle="menuStyle"
      :itemData="moduleList"
      @tapitem="onTapItem"/>
    <template v-if="isLogin">
      <button @tap="exitAction" class="btn-submit" hover-class="button-hover-scale">退出系统</button>
    </template>
  </view>
</template>

<script>
import DtMenuList from '../comps/dt_menu_list.vue'
export default {
  components:{
    DtMenuList
  },
  data() {
    return {
      menuStyle: {
        spaceColor: '#f2f2f2',
        spaceHeight: 20
      },
      moduleList: [],
      isLogin: true
    }
  },
  
  methods: {
    onTapItem(item){
      switch(item.id){
        case 0:
		let url='https://community.58fo.com/appfile/protocal.htm'
          uni.navigateTo({
          	url:"/pages/webview/webview?url="+url+"&title=隐私协议"
          })
          break;
        case 1:break;
        default:break;
      }
    },
    //退出登录
    logout() {
      this.$auth.logout()
	  this.touristLogin()
	  uni.switchTab({
	  	url:"/pages/wode/wode"
	  })
    },
    //退出操作
    exitAction() {
      this.$dialog.confirm({
        content:"是否退出本次账号",
        success: res => {
          if (res.confirm) {
            this.logout()
          }
        }
      })
    },
	/**
	 * 游客登陆
	 */
	async touristLogin() {
	  // 检查是否登录
	  if (!this.$auth.isAuth) { // 就算是游客，也重新登录
	    let resp = await this.$api.touristLogin()
		console.log("Resp",resp);
	    let userType = this.$global.userType.tourist
	    this.$auth.login(userType, resp.sessionId, resp.userId, resp)
	    console.log('游客登录成功!', resp)
	  } 
	},
    onLoadPage() {
	  wx.hideShareMenu();
      // this.memberInfo = this.$auth.getMemberInfo()
      this.isLogin = this.$auth.isAuth
      this.moduleList = [
        {
          id: 0,
          title: '隐私协议',
          value: '',
          hideArrow: false,
          isMarginTop:true
        },
        {
          id: 1,
          title: '技术支持',
          value: '宁夏新邻科技有限公司',
          hideArrow: true,
          isMarginTop:true
        }
      ]
    }
  }
}
</script>

<style lang="scss" scoped>
.dt-page{
  background-color:#f2f2f2;
  min-height:100vh;

  .btn-submit {
    margin:60upx auto;
    width:690upx;
    height: 90upx;
    line-height: 90upx;
    border-radius:10upx;
    background-color:#e54d42;
  }
}

</style>