index.vue 4.04 KB
<template>
  <div class="client-index-page">
    <div class="cloud-bg"></div>
    <!-- TAG: animate 动画 -->
    <!-- <transition name="fade" enter-active-class="animated animate__swing" leave-active-class="animated animate__swing">
      <van-icon v-if="show" :name="icon_subscribed" size="5rem" style="position: absolute; top: 50%;" />
    </transition> -->
  </div>
  <div class="entry-wrapper">
    <!-- TEMP:临时取消授权,正式需要删除 -->
    <!-- <div @click="cancelAuth">取消授权</div> -->
    <!-- <p class="text">请选择您的身份</p> -->
    <div class="control">
      <div class="plain">
        <my-button type="custom" :custom-style="styleObject1" @on-click="goVisit">访客</my-button>
      </div>
      <div class="primary">
        <my-button type="custom" :custom-style="styleObject2" @on-click="goSchool">选择我的幼儿园</my-button>
      </div>
    </div>
  </div>
</template>

<script setup>
import { mainStore } from '@/store'

import Cookies from 'js-cookie'
import 'animate.css';
import icon_subscribed from '@images/icon-dingyue01@2x.png'

import MyButton from '@/components/MyButton/index.vue'

import $ from 'jquery';
import { useRoute, useRouter, onBeforeRouteLeave } from 'vue-router'
import { Toast } from 'vant';
import { nextTick, onMounted, reactive, ref, watch } from 'vue'
import axios from '@/utils/axios';


// 滚动条判断
function hasScrollbar() {
  return document.body.scrollHeight > (window.innerHeight || document.documentElement.clientHeight);
}

onMounted(() => {
  // TODO: 临时处理位置不对问题
  // 因为微信第一次进入默认全屏,之后产生的导航栏会影响位置
  if (hasScrollbar()) {
    location.reload()
  }
})

const $route = useRoute();
const $router = useRouter();

// TAG: keepAlive 缓存页面
const store = mainStore();
store.keepThisPage($route.meta.name);

// 自定义按钮颜色样式
const styleObject1 = reactive({
  backgroundColor: '#FFFFFF',
  color: '#0B3A72',
  borderColor: '#0B3A72'
})
const styleObject2 = reactive({
  backgroundColor: '#F9D95C',
  color: '#0B3A72',
  borderColor: '#F9D95C'
})

const goVisit = () => { // 跳转爱心书籍页面
  $router.push({
    path: '/client/chooseBook'
  });
  Cookies.set('userType', 'visitor'); // 访客标识
}
const goSchool = () => { // 跳转选择幼儿园页面
  $router.push({
    path: '/client/chooseSchool'
  });
  Cookies.set('userType', 'client'); // 客户标识
}

onMounted(() => {
  // 背景颜色全屏
  $('.client-index-page').height($(document).height());
})

// TEMP:临时测试动画效果
// const show = ref(true);
// const interval = setInterval(() => { // 图标动画效果
//   show.value = !show.value
// }, 1000);
// onBeforeRouteLeave(() => {
//   clearInterval(interval); // 清除调用
// })

const cancelAuth = () => {
  axios.get('/srv/?a=cancel_wx_auth', {
    params: {
      type: 'cancel'
    }
  })
    .then(res => {
      if (res.data.code === 1) {
        Toast.success('操作成功')
      } else {
        console.warn(res);
        if (!res.data.show) return false;
        Toast({
          icon: 'close',
          message: res.data.msg
        });
      }
    })
    .catch(err => {
      console.error(err);
    })
}
</script>

<script>
import mixin from 'common/mixin'
import { mainStore } from '@/store'
import { storeToRefs } from 'pinia'
export default {
  name: 'index',
  mixins: [mixin.init],
  data() {
    return {
    }
  },
  mounted() {
  },
  methods: {

  }
}
</script>

<style lang="less" scoped>
.client-index-page {
  // 背景图 宽度100% 高度控制
  background-image: url('@images/yindao@2x.png');
  background-repeat: no-repeat;
  width: 100%;
  background-size: 100% 85%;
  position: relative;
}

.entry-wrapper {
  position: absolute;
  bottom: 1rem;
  width: 100%;

  .text {
    color: #B8B8B8;
    margin: 1rem;
    margin-bottom: 0;
  }

  .control {
    margin: 1rem;
    margin-top: 0.5rem;
    overflow: auto;

    .plain {
      width: 28%;
      float: left;
      margin-right: 3%;
    }

    .primary {
      width: 69%;
      float: left;
    }
  }
}
</style>