<template>
  <view class="businessInfo">
    <view class="info-continer">
      <view
        class="info-box"
        @click="navigateTo('/user_module/changeLogo/index')"
      >
        <view class="box-left">店铺LOGO</view>
        <view class="box-right">
          <image class="" :src="shopInfo.shopLogo" />
          <view class="icon">
            <tui-icon name="arrowright" color="#333333" :size="28"></tui-icon>
          </view>
        </view>
      </view>
      <view
        class="info-box top"
        v-for="(item, index) in infoData"
        :key="index"
        @click="goChangeInfo(item)"
      >
        <view class="box-left">{{ item.name }}</view>
        <view class="box-right">
          <text>{{ shopInfo[item.title] || "" }}</text>
          <view class="icon">
            <tui-icon name="arrowright" color="#333333" :size="28"></tui-icon>
          </view>
        </view>
      </view>
    </view>
    <view class="login-state">
      <!-- <view class="btn">切换账号</view> -->
      <view class="btn exit" @click="exitLogin">退出登录</view>
    </view>
    <modal
      :showModal="modal"
      :promptList="promptList"
      @closeModal="closeModal"
      :showBtn="true"
      showText="退出登录"
      @btnClick="btnClick"
    ></modal>
  </view>
</template>

<script>
export default {
  onShow() {
    //  获取本地存储的数据
    this.shopInfo = uni.getStorageSync("shopInfo");
    console.log(this.shopInfo);
  },
  data() {
    return {
      shopInfo: {},
      infoData: [
        {
          name: "店铺名称",
          title: "shopName",
        },
        // {
        //   name:'店铺负责人',
        //   title:'shopName'
        // },
        {
          name: "手机号码",
          title: "shopPhone",
        },
        {
          name: "店铺地址",
          title: "shopAdress",
        },
        {
          name: "店铺简介",
          title: "shopBrief",
        },
        {
          name: "修改密码",
          title: "changePassword",
        },
      ],
      //  弹框
      modal: false,
      promptList: ["是否退出当前账号呢？"],
    };
  },
  methods: {
    goChangeInfo(item) {
      if (item.title == "changePassword") {
        this.navigateTo(`/user_module/changePassword/index`);
        return;
      }
      //  这个方法混入在 mixin 中
      this.navigateTo(
        `/user_module/changeInfo/index?barTitle=${item.name}&title=${
          item.title
        }`
      );
    },
    //  退出登录
    exitLogin() {
      this.modal = true;
    },
    //  确认退出登录
    btnClick() {
      //  清除本地缓存
      uni.clearStorageSync();
      //  跳转回登陆页面
      uni.reLaunch({
        url: "/pages/login/index",
      });
    },
    closeModal() {
      this.modal = false;
    },
  },
};
</script>

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