<template>
  <div class="member-setting">
    <div class="minheight">
      <v-nav :navpath="navpath"></v-nav>
      <div class="setting-con">
        <div class="setting-container">
          <el-switch v-model="value"></el-switch> 是否允许好办通过会员姓名、手机号和卡号搜索查询全品牌会员
          <div class="save-btn">
            <el-button type="primary" @click="saveSet(2)">保存</el-button>
          </div>
        </div>
      </div>
    </div>
    <div class="footer-box">
      <vue-gic-footer></vue-gic-footer>
    </div>
  </div>
</template>

<script>
import nav from '@/common/navbar/navbar.vue';
import { doFetch,doFetchqs } from "../../components/axios/api";
import {checkFalse, checkStatus, checkSuccess} from "../../../static/js/checkStatus";
import { setTimeout } from 'timers';

export default {
  components: {
    'v-nav': nav
  },
  data() {
    return {
      navpath: [
        { name: '首页', path: '' },
        { name: '微信会员', path: '/wechatmembers' },
        { name: '会员设置', path: '' }
      ],
      value: false
    };
  },
  methods: {
    saveSet(types) {
      doFetch('/api-member/members-setting',{
        optype: types,
        appStatus: !!this.value ? 1 : 0
      }).then(res => {
        if (res.data.errorCode === 0) {
          if (res.data.result.appStatus == 1) {
            this.value = true;
          }
          // 主动设置
          if (types == 2) {
            this.$message({
              message: '设置成功！',
              type: 'success'
            });
            setTimeout(() => {
              this.$router.push({path: '/wechatmembers'});
            }, 1000);
          }
        } else {
          checkFalse(res.data.message);
        }
      }).catch(err => {
        checkStatus(err);
      });
    }
  },
  created() {
    this.saveSet(1);
    this.$store.commit('mutations-slide', true);
  }
};
</script>

<style lang="stylus" scoped>
.setting-container
  padding 20px 20px 100px 20px
  margin 24px
  color #606266
  font-size 14px
  background-color #fff
  .save-btn
    margin-top 20px

.member-setting
  height 100%
  background-color #f5f7fa
  
.minheight
  min-height 100%
.footer-box
  margin-top -116px
</style>
