index.vue 2.64 KB
<template>
  <div class="setting_container">
    <NafmHeader />
    <div class="setting_list">
      <div class="li">
        <div class="menu_left">{{$t("setting.newMsgTip")}}</div>
        <van-switch v-model="msgChecked" @click="changeMsgStatus" />
      </div>
      <div class="li">
        <div class="menu_left">多语言</div>
        <div class="menu_right" @click="popZhEn">
          <div class="text">{{$t("lang")}}</div>
          <div class="iconfont iconright"></div>
        </div>

      </div>
    </div>
    <van-overlay :show="showZhEn" z-index="10" @click="showZhEn = false">
      <div class="footer">
        <!-- <div class="btn"> -->
        <div class="btn_zh item" @click="changeLang('zh')">中文</div>
        <div class="btn_en item" @click="changeLang('en')">英文</div>
        <div class="cancel item">取消</div>
        <!-- </div> -->
      </div>

    </van-overlay>
  </div>
</template>
<script>
import { setLocalStorage } from '@/utils/LocalStorage'
export default {
  name: 'Setting',
  data() {
    return {
      msgChecked: false,
      showZhEn: false
    }
  },
  mounted() {
    this.msgChecked = true
  },
  methods: {
    // 切换消息操作
    changeMsgStatus() {
      this.msgChecked = !this.msgChecked
    },
    // 弹出 设置中英文框
    popZhEn() {
      this.showZhEn = true
    },
    changeLang(val) {
      console.log('val', val)
      setLocalStorage('lang', val)
      this.$i18n.locale = val
    }
  }
}
</script>
<style lang="less" scoped>
.setting_container {
  background-color: #efefef;
  height: 100vh;
}
.setting_list {
  .li {
    padding: 0 25px;
    background-color: #fff;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #ccc;
    height: 95px;
    .menu_left {
      color: #333;
      display: flex;
      justify-content: space-between;
      align-items: center;
    }
    .menu_right {
      flex: 1;

      display: flex;
      justify-content: flex-end;
      align-items: center;
      .text {
        color: #333;
      }
      .iconfont {
        color: #ccc;
      }
    }
  }
}
.footer {
  position: fixed;
  bottom: 20px;
  display: flex;
  width: 100%;
  justify-content: center;
  flex-direction: column;
  align-items: center;
  .item {
    background-color: #fff;
    height: 80px;
    line-height: 80px;
    width: 90%;
    text-align: center;
  }
  .btn_zh {
    border-top-left-radius: 10px;
    border-top-right-radius: 10px;
    border-bottom: 1px solid #efefef;
  }
  .btn_en {
    border-bottom-left-radius: 10px;
    border-bottom-right-radius: 10px;
    margin-bottom: 10px;
  }
  .cancel {
    border-radius: 10px;
  }
}
</style>