中医药大学课题数据库系统
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

133 lines
3.4 KiB

<!--
* @Author: wally
* @email: 18603454788@163.com
* @Date: 2021-04-19 10:23:19
* @LastEditors: aBin
* @LastEditTime: 2021-07-08 15:33:53
-->
<template>
<a-config-provider :locale="zh_CN">
<div v-if="isRouter" class="d-flex flex-row flex-nowrap" id="app">
<!-- <div class="d-flex flex-row flex-nowrap" id="app"> -->
<!-- <btn-con /> -->
<router-view class="flex-1 bg" style="padding: 6px"></router-view>
</div>
</a-config-provider>
</template>
<script>
import { mapState, mapActions, mapMutations } from 'vuex';
import zh_CN from 'ant-design-vue/lib/locale-provider/zh_CN';
// import BtnCon from 'components/BtnCom/BtnCon.vue';
import { getHId } from 'config/api';
export default {
name: 'App',
// components: { BtnCon },
data() {
return { zh_CN, isRouter: false };
},
computed: mapState('home', ['anyringToken', 'ptProps']),
watch: {
anyringToken(val) {
if (val) {
this.isRouter = true;
}
},
},
async created() {
// const userId = '1387952026067013632';
// const params = { userId };
// await this.getUserId(params);
// await this.getToken();
if (localStorage.getItem('patientId')) {
this.setPatientId(localStorage.getItem('patientId'));
}
if (localStorage.getItem('hospitalization')) {
this.setHospitalization(localStorage.getItem('hospitalization'));
}
if (localStorage.getItem('recordCode')) {
this.setRecordCode(localStorage.getItem('recordCode'));
}
await this.isMobile();
if (this.anyringToken) {
this.isRouter = true;
}
},
methods: {
...mapActions('home', ['getUserId']),
...mapMutations('home', ['setPtProps', 'setHospitalId', 'setPatientId', 'getToken', 'setHospitalization', 'setRecordCode']),
async getHospitalId(Id) {
try {
const res = await getHId(Id);
const { code, msg, data } = res.data;
if (code === 200) {
this.setHospitalId(data.id);
}
} catch (error) {}
},
isMobile() {
this.flag = device.mobile();
if (!this.flag) {
console.log('pc端');
this.getPtpropsPC();
} else {
console.log('移动端');
this.getPtpropsMove();
}
},
getPtpropsMove() {
const that = this;
window.parent.postMessage('created', '*');
window.addEventListener('message', async function(event) {
try {
const data = JSON.parse(event.data);
if (data.type !== 'data') return;
console.log('Props', data.data);
await that.setPtProps(data.data);
console.log('ptProps', that.ptProps);
const params = { userId: data.data.userId };
await that.getUserId(params);
await that.getToken();
await that.getHospitalId(data.data.projectId);
} catch (error) {
console.log('error:', error);
}
});
},
getPtpropsPC() {
const that = this;
window.TallPlugin.init(async function(props) {
console.log('props:', props);
that.setPtProps(props);
const params = { userId: props.userId };
await that.getUserId(params);
await that.getToken();
await that.getHospitalId(props.projectId);
});
},
},
};
</script>
<style>
html,
body,
#app {
min-height: 100%;
}
#app {
background: transparent;
}
body::-webkit-scrollbar {
width: 0;
}
</style>
<style lang="stylus">
@import './common/portrait.styl';
</style>